<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>llvm.core.Module — llvmpy tag: 0.12.0 documentation</title> <link rel="stylesheet" href="../_static/default.css" type="text/css" /> <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '../', VERSION: 'tag: 0.12.0', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true }; </script> <script type="text/javascript" src="../_static/jquery.js"></script> <script type="text/javascript" src="../_static/underscore.js"></script> <script type="text/javascript" src="../_static/doctools.js"></script> <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> <link rel="top" title="llvmpy tag: 0.12.0 documentation" href="../index.html" /> <link rel="up" title="llvm.core" href="llvmcore.html" /> <link rel="next" title="llvm.core.PointerType" href="llvm.core.PointerType.html" /> <link rel="prev" title="llvm.core.IntegerType" href="llvm.core.IntegerType.html" /> </head> <body> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../genindex.html" title="General Index" accesskey="I">index</a></li> <li class="right" > <a href="../py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="llvm.core.PointerType.html" title="llvm.core.PointerType" accesskey="N">next</a> |</li> <li class="right" > <a href="llvm.core.IntegerType.html" title="llvm.core.IntegerType" accesskey="P">previous</a> |</li> <li><a href="../index.html">llvmpy tag: 0.12.0 documentation</a> »</li> <li><a href="llvmcore.html" accesskey="U">llvm.core</a> »</li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body"> <table border="1" class="docutils"> <colgroup> <col width="100%" /> </colgroup> <tbody valign="top"> <tr class="row-odd"><td>layout: page</td> </tr> <tr class="row-even"><td>title: Module (llvm.core)</td> </tr> </tbody> </table> <div class="section" id="llvm-core-module"> <h1>llvm.core.Module<a class="headerlink" href="#llvm-core-module" title="Permalink to this headline">¶</a></h1> <p>Modules are top-level container objects. You need to create a module object first, before you can add global variables, aliases or functions. Modules are created using the static method <tt class="docutils literal"><span class="pre">Module.new</span></tt>:</p> <div class="highlight-python"><div class="highlight"><pre><span class="c">#!/usr/bin/env python</span> <span class="kn">from</span> <span class="nn">llvm</span> <span class="kn">import</span> <span class="o">*</span> <span class="kn">from</span> <span class="nn">llvm.core</span> <span class="kn">import</span> <span class="o">*</span> <span class="c"># create a module</span> <span class="n">my_module</span> <span class="o">=</span> <span class="n">Module</span><span class="o">.</span><span class="n">new</span><span class="p">(</span><span class="s">'my_module'</span><span class="p">)</span> </pre></div> </div> <div class="section" id="automatically-generated-documentation"> <h2>Automatically Generated Documentation<a class="headerlink" href="#automatically-generated-documentation" title="Permalink to this headline">¶</a></h2> <dl class="class"> <dt id="llvm.core.Module"> <em class="property">class </em><tt class="descclassname">llvm.core.</tt><tt class="descname">Module</tt><big>(</big><em>ptr</em><big>)</big><a class="headerlink" href="#llvm.core.Module" title="Permalink to this definition">¶</a></dt> <dd><p>A Module instance stores all the information related to an LLVM module.</p> <p>Modules are the top level container of all other LLVM Intermediate Representation (IR) objects. Each module directly contains a list of globals variables, a list of functions, a list of libraries (or other modules) this module depends on, a symbol table, and various data about the target’s characteristics.</p> <p>Construct a Module only using the static methods defined below, <em>NOT</em> using the constructor. A correct usage is:</p> <p>module_obj = Module.new(‘my_module’)</p> <dl class="method"> <dt id="llvm.core.Module.add_function"> <tt class="descname">add_function</tt><big>(</big><em>ty</em>, <em>name</em><big>)</big><a class="headerlink" href="#llvm.core.Module.add_function" title="Permalink to this definition">¶</a></dt> <dd><p>Add a function of given type with given name.</p> </dd></dl> <dl class="method"> <dt id="llvm.core.Module.add_global_variable"> <tt class="descname">add_global_variable</tt><big>(</big><em>ty</em>, <em>name</em>, <em>addrspace=0</em><big>)</big><a class="headerlink" href="#llvm.core.Module.add_global_variable" title="Permalink to this definition">¶</a></dt> <dd><p>Add a global variable of given type with given name.</p> </dd></dl> <dl class="method"> <dt id="llvm.core.Module.clone"> <tt class="descname">clone</tt><big>(</big><big>)</big><a class="headerlink" href="#llvm.core.Module.clone" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <dl class="attribute"> <dt id="llvm.core.Module.data_layout"> <tt class="descname">data_layout</tt><a class="headerlink" href="#llvm.core.Module.data_layout" title="Permalink to this definition">¶</a></dt> <dd><p>The data layout string for the module’s target platform.</p> <p>The data layout strings is an encoded representation of the type sizes and alignments expected by this module.</p> </dd></dl> <dl class="staticmethod"> <dt id="llvm.core.Module.from_assembly"> <em class="property">static </em><tt class="descname">from_assembly</tt><big>(</big><em>fileobj_or_str</em><big>)</big><a class="headerlink" href="#llvm.core.Module.from_assembly" title="Permalink to this definition">¶</a></dt> <dd><p>Create a Module instance from the contents of an LLVM assembly (.ll) file.</p> <p>fileobj_or_str – takes a file-like object or string that contains a module represented in llvm-ir assembly.</p> </dd></dl> <dl class="staticmethod"> <dt id="llvm.core.Module.from_bitcode"> <em class="property">static </em><tt class="descname">from_bitcode</tt><big>(</big><em>fileobj_or_str</em><big>)</big><a class="headerlink" href="#llvm.core.Module.from_bitcode" title="Permalink to this definition">¶</a></dt> <dd><p>Create a Module instance from the contents of a bitcode file.</p> <p>fileobj_or_str – takes a file-like object or string that contains a module represented in bitcode.</p> </dd></dl> <dl class="attribute"> <dt id="llvm.core.Module.functions"> <tt class="descname">functions</tt><a class="headerlink" href="#llvm.core.Module.functions" title="Permalink to this definition">¶</a></dt> <dd><p>All functions in this module.</p> </dd></dl> <dl class="method"> <dt id="llvm.core.Module.get_function_named"> <tt class="descname">get_function_named</tt><big>(</big><em>name</em><big>)</big><a class="headerlink" href="#llvm.core.Module.get_function_named" title="Permalink to this definition">¶</a></dt> <dd><p>Return a Function object representing function with given name.</p> </dd></dl> <dl class="method"> <dt id="llvm.core.Module.get_global_variable_named"> <tt class="descname">get_global_variable_named</tt><big>(</big><em>name</em><big>)</big><a class="headerlink" href="#llvm.core.Module.get_global_variable_named" title="Permalink to this definition">¶</a></dt> <dd><p>Return a GlobalVariable object for the given name.</p> </dd></dl> <dl class="method"> <dt id="llvm.core.Module.get_named_metadata"> <tt class="descname">get_named_metadata</tt><big>(</big><em>name</em><big>)</big><a class="headerlink" href="#llvm.core.Module.get_named_metadata" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <dl class="method"> <dt id="llvm.core.Module.get_or_insert_function"> <tt class="descname">get_or_insert_function</tt><big>(</big><em>ty</em>, <em>name</em><big>)</big><a class="headerlink" href="#llvm.core.Module.get_or_insert_function" title="Permalink to this definition">¶</a></dt> <dd><p>Like get_function_named(), but does add_function() first, if function is not present.</p> </dd></dl> <dl class="method"> <dt id="llvm.core.Module.get_or_insert_named_metadata"> <tt class="descname">get_or_insert_named_metadata</tt><big>(</big><em>name</em><big>)</big><a class="headerlink" href="#llvm.core.Module.get_or_insert_named_metadata" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <dl class="method"> <dt id="llvm.core.Module.get_type_named"> <tt class="descname">get_type_named</tt><big>(</big><em>name</em><big>)</big><a class="headerlink" href="#llvm.core.Module.get_type_named" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <dl class="attribute"> <dt id="llvm.core.Module.global_variables"> <tt class="descname">global_variables</tt><a class="headerlink" href="#llvm.core.Module.global_variables" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <dl class="attribute"> <dt id="llvm.core.Module.id"> <tt class="descname">id</tt><a class="headerlink" href="#llvm.core.Module.id" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <dl class="method"> <dt id="llvm.core.Module.link_in"> <tt class="descname">link_in</tt><big>(</big><em>other</em>, <em>preserve=False</em><big>)</big><a class="headerlink" href="#llvm.core.Module.link_in" title="Permalink to this definition">¶</a></dt> <dd><p>Link the <a href="#id1"><span class="problematic" id="id2">`</span></a>other’ module into this one.</p> <p>The <a href="#id3"><span class="problematic" id="id4">`</span></a>other’ module is linked into this one such that types, global variables, function, etc. are matched and resolved.</p> <p>The <a href="#id5"><span class="problematic" id="id6">`</span></a>other’ module is no longer valid after this method is invoked, all refs to it should be dropped.</p> <p>In the future, this API might be replaced with a full-fledged Linker class.</p> </dd></dl> <dl class="staticmethod"> <dt id="llvm.core.Module.new"> <em class="property">static </em><tt class="descname">new</tt><big>(</big><em>id</em><big>)</big><a class="headerlink" href="#llvm.core.Module.new" title="Permalink to this definition">¶</a></dt> <dd><p>Create a new Module instance.</p> <p>Creates an instance of Module, having the id <a href="#id7"><span class="problematic" id="id8">`</span></a>id’.</p> </dd></dl> <dl class="attribute"> <dt id="llvm.core.Module.pointer_size"> <tt class="descname">pointer_size</tt><a class="headerlink" href="#llvm.core.Module.pointer_size" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <dl class="attribute"> <dt id="llvm.core.Module.target"> <tt class="descname">target</tt><a class="headerlink" href="#llvm.core.Module.target" title="Permalink to this definition">¶</a></dt> <dd><p>The target triple string describing the target host.</p> </dd></dl> <dl class="method"> <dt id="llvm.core.Module.to_bitcode"> <tt class="descname">to_bitcode</tt><big>(</big><em>fileobj=None</em><big>)</big><a class="headerlink" href="#llvm.core.Module.to_bitcode" title="Permalink to this definition">¶</a></dt> <dd><p>Write bitcode representation of module to given file-like object.</p> <p>fileobj – A file-like object to where the bitcode is written. If it is None, the bitcode is returned.</p> <p>Return value – Returns None if fileobj is not None. Otherwise, return the bitcode as a bytestring.</p> </dd></dl> <dl class="method"> <dt id="llvm.core.Module.to_native_assembly"> <tt class="descname">to_native_assembly</tt><big>(</big><em>fileobj=None</em><big>)</big><a class="headerlink" href="#llvm.core.Module.to_native_assembly" title="Permalink to this definition">¶</a></dt> <dd><p>Outputs the byte string of the module as native assembly code</p> <p>If a fileobj is given, the output is written to it; Otherwise, the output is returned</p> </dd></dl> <dl class="method"> <dt id="llvm.core.Module.to_native_object"> <tt class="descname">to_native_object</tt><big>(</big><em>fileobj=None</em><big>)</big><a class="headerlink" href="#llvm.core.Module.to_native_object" title="Permalink to this definition">¶</a></dt> <dd><p>Outputs the byte string of the module as native object code</p> <p>If a fileobj is given, the output is written to it; Otherwise, the output is returned</p> </dd></dl> <dl class="method"> <dt id="llvm.core.Module.verify"> <tt class="descname">verify</tt><big>(</big><big>)</big><a class="headerlink" href="#llvm.core.Module.verify" title="Permalink to this definition">¶</a></dt> <dd><p>Verify module.</p> <p>Checks module for errors. Raises <a href="#id9"><span class="problematic" id="id10">`</span></a>llvm.LLVMException’ on any error.</p> </dd></dl> </dd></dl> </div> </div> </div> </div> </div> <div class="sphinxsidebar"> <div class="sphinxsidebarwrapper"> <h3><a href="../index.html">Table Of Contents</a></h3> <ul> <li><a class="reference internal" href="#">llvm.core.Module</a><ul> <li><a class="reference internal" href="#automatically-generated-documentation">Automatically Generated Documentation</a></li> </ul> </li> </ul> <h4>Previous topic</h4> <p class="topless"><a href="llvm.core.IntegerType.html" title="previous chapter">llvm.core.IntegerType</a></p> <h4>Next topic</h4> <p class="topless"><a href="llvm.core.PointerType.html" title="next chapter">llvm.core.PointerType</a></p> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="../_sources/doc/llvm.core.Module.txt" rel="nofollow">Show Source</a></li> </ul> <div id="searchbox" style="display: none"> <h3>Quick search</h3> <form class="search" action="../search.html" method="get"> <input type="text" name="q" /> <input type="submit" value="Go" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> <p class="searchtip" style="font-size: 90%"> Enter search terms or a module, class or function name. </p> </div> <script type="text/javascript">$('#searchbox').show(0);</script> </div> </div> <div class="clearer"></div> </div> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../genindex.html" title="General Index" >index</a></li> <li class="right" > <a href="../py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="llvm.core.PointerType.html" title="llvm.core.PointerType" >next</a> |</li> <li class="right" > <a href="llvm.core.IntegerType.html" title="llvm.core.IntegerType" >previous</a> |</li> <li><a href="../index.html">llvmpy tag: 0.12.0 documentation</a> »</li> <li><a href="llvmcore.html" >llvm.core</a> »</li> </ul> </div> <div class="footer"> © Copyright 2013, Mahadevan R (2008-2010), Continuum Analytics (2012-2013). Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3. </div> </body> </html>