update doc: analyze is gone and passes should just use RegisterPass

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29928 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2006-08-27 23:18:52 +00:00
parent d52e1b0dbe
commit c8603c2444

View File

@ -18,8 +18,7 @@
<ul>
<li><a href="#makefile">Setting up the build environment</a></li>
<li><a href="#basiccode">Basic code required</a></li>
<li><a href="#running">Running a pass with <tt>opt</tt>
or <tt>analyze</tt></a></li>
<li><a href="#running">Running a pass with <tt>opt</tt></a></li>
</ul></li>
<li><a href="#passtype">Pass classes and requirements</a>
<ul>
@ -194,7 +193,7 @@ include $(LEVEL)/Makefile.common
<p>This makefile specifies that all of the <tt>.cpp</tt> files in the current
directory are to be compiled and linked together into a
<tt>Debug/lib/Hello.so</tt> shared object that can be dynamically loaded by
the <tt>opt</tt> or <tt>analyze</tt> tools via their <tt>-load</tt> options.
the <tt>opt</tt> or <tt>bugpoint</tt> tools via their <tt>-load</tt> options.
If your operating system uses a suffix other than .so (such as windows or
Mac OS/X), the appropriate extension will be used.</p>
@ -271,15 +270,13 @@ to do our thing, so we just print out our message with the name of each
function.</p>
<div class="doc_code"><pre>
RegisterOpt&lt;Hello&gt; X("<i>hello</i>", "<i>Hello World Pass</i>");
RegisterPass&lt;Hello&gt; X("<i>hello</i>", "<i>Hello World Pass</i>");
} <i>// end of anonymous namespace</i>
</pre></div>
<p>Lastly, we register our class <tt>Hello</tt>, giving it a command line
argument "<tt>hello</tt>", and a name "<tt>Hello World Pass</tt>". There are
several different ways of <a href="#registration">registering your pass</a>,
depending on what it is to be used for. For "optimizations" we use the
<tt>RegisterOpt</tt> template.</p>
<p>Lastly, we <a href="#registration">register our class</a> <tt>Hello</tt>,
giving it a command line
argument "<tt>hello</tt>", and a name "<tt>Hello World Pass</tt>".</p>
<p>As a whole, the <tt>.cpp</tt> file looks like:</p>
@ -297,7 +294,7 @@ depending on what it is to be used for. For "optimizations" we use the
}
};
RegisterOpt&lt;Hello&gt; X("<i>hello</i>", "<i>Hello World Pass</i>");
RegisterPass&lt;Hello&gt; X("<i>hello</i>", "<i>Hello World Pass</i>");
}
</pre></div>
@ -312,14 +309,14 @@ them) to be useful.</p>
<!-- ======================================================================= -->
<div class="doc_subsection">
<a name="running">Running a pass with <tt>opt</tt> or <tt>analyze</tt></a>
<a name="running">Running a pass with <tt>opt</tt></a>
</div>
<div class="doc_text">
<p>Now that you have a brand new shiny shared object file, we can use the
<tt>opt</tt> command to run an LLVM program through your pass. Because you
registered your pass with the <tt>RegisterOpt</tt> template, you will be able to
registered your pass with the <tt>RegisterPass</tt> template, you will be able to
use the <tt>opt</tt> tool to access it, once loaded.</p>
<p>To test it, follow the example at the end of the <a
@ -844,37 +841,17 @@ remember, you may not modify the LLVM <tt>Function</tt> or its contents from a
pass registration works, and discussed some of the reasons that it is used and
what it does. Here we discuss how and why passes are registered.</p>
<p>Passes can be registered in several different ways. Depending on the general
classification of the pass, you should use one of the following templates to
register the pass:</p>
<ul>
<li><b><tt>RegisterOpt</tt></b> - This template should be used when you are
registering a pass that logically should be available for use in the
'<tt>opt</tt>' utility.</li>
<li><b><tt>RegisterAnalysis</tt></b> - This template should be used when you are
registering a pass that logically should be available for use in the
'<tt>analyze</tt>' utility.</li>
<li><b><tt>RegisterPass</tt></b> - This is the generic form of the
<tt>Register*</tt> templates that should be used if you want your pass listed by
multiple or no utilities. This template takes an extra third argument that
specifies which tools it should be listed in. See the <a
href="http://llvm.org/doxygen/PassSupport_8h-source.html">PassSupport.h</a>
file for more information.</li>
</ul>
<p>Regardless of how you register your pass, you must specify at least two
<p>As we saw above, passes are registered with the <b><tt>RegisterPass</tt></b>
template, which requires you to pass at least two
parameters. The first parameter is the name of the pass that is to be used on
the command line to specify that the pass should be added to a program (for
example <tt>opt</tt> or <tt>analyze</tt>). The second argument is the name of
the pass, which is to be used for the <tt>--help</tt> output of programs, as
example, with <tt>opt</tt> or <tt>bugpoint</tt>). The second argument is the
name of the pass, which is to be used for the <tt>--help</tt> output of
programs, as
well as for debug output generated by the <tt>--debug-pass</tt> option.</p>
<p>If a pass is registered to be used by the <tt>analyze</tt> utility, you
should implement the virtual <tt>print</tt> method:</p>
<p>If you want your pass to be easily dumpable, you should
implement the virtual <tt>print</tt> method:</p>
</div>
@ -892,7 +869,7 @@ should implement the virtual <tt>print</tt> method:</p>
<p>The <tt>print</tt> method must be implemented by "analyses" in order to print
a human readable version of the analysis results. This is useful for debugging
an analysis itself, as well as for other people to figure out how an analysis
works. The <tt>analyze</tt> tool uses this method to generate its output.</p>
works. Use the <tt>opt -analyze</tt> argument to invoke this method.</p>
<p>The <tt>ostream</tt> parameter specifies the stream to write the results on,
and the <tt>Module</tt> parameter gives a pointer to the top level module of the
@ -1181,7 +1158,7 @@ implementations of the interface by using the following code:</p>
<div class="doc_code"><pre>
<b>namespace</b> {
//<i> Analysis Group implementations <b>must</b> be registered normally...</i>
RegisterOpt&lt;FancyAA&gt;
RegisterPass&lt;FancyAA&gt;
B("<i>somefancyaa</i>", "<i>A more complex alias analysis implementation</i>");
//<i> Declare that we implement the AliasAnalysis interface</i>
@ -1199,7 +1176,7 @@ no problem.</p>
<div class="doc_code"><pre>
<b>namespace</b> {
//<i> Analysis Group implementations <b>must</b> be registered normally...</i>
RegisterOpt&lt;<a href="http://llvm.org/doxygen/structBasicAliasAnalysis.html">BasicAliasAnalysis</a>&gt;
RegisterPass&lt;<a href="http://llvm.org/doxygen/structBasicAliasAnalysis.html">BasicAliasAnalysis</a>&gt;
D("<i>basicaa</i>", "<i>Basic Alias Analysis (default AA impl)</i>");
//<i> Declare that we implement the AliasAnalysis interface</i>