From: Owen Anderson Date: Wed, 21 Jul 2010 22:58:07 +0000 (+0000) Subject: First stab at updating the documentation for INITIALIZE_PASS(). X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=commitdiff_plain;h=20813e01e76e71c0400165b7fb8b2e412d18c0a2;hp=ab695889c67fb499bd902e8a969d0ff02ce66788 First stab at updating the documentation for INITIALIZE_PASS(). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@109055 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/docs/WritingAnLLVMPass.html b/docs/WritingAnLLVMPass.html index ed985cdc98f..f6360a19c32 100644 --- a/docs/WritingAnLLVMPass.html +++ b/docs/WritingAnLLVMPass.html @@ -290,7 +290,7 @@ function.

initialization value is not important.

-  RegisterPass<Hello> X("hello", "Hello World Pass",
+  INITIALIZE_PASS(Hello, "hello", "Hello World Pass",
                         false /* Only looks at CFG */,
                         false /* Analysis Pass */);
 }  // end of anonymous namespace
@@ -299,7 +299,7 @@ initialization value is not important.

Lastly, we register our class Hello, giving it a command line argument "hello", and a name "Hello World Pass". -Last two RegisterPass arguments are optional. Their default value is false. +Last two arguments describe its behavior. If a pass walks CFG without modifying it then third argument is set to true. If a pass is an analysis pass, for example dominator tree pass, then true is supplied as fourth argument.

@@ -326,8 +326,9 @@ is supplied as fourth argument.

}; char Hello::ID = 0; - RegisterPass<Hello> X("hello", "Hello World Pass"); + INITIALIZE_PASS(Hello, "Hello", "Hello World Pass", false, false); } +

Now that it's all together, compile the file with a simple "gmake" @@ -348,7 +349,7 @@ them) to be useful.

Now that you have a brand new shiny shared object file, we can use the opt command to run an LLVM program through your pass. Because you -registered your pass with the RegisterPass template, you will be able to +registered your pass with the INITIALIZE_PASS macro, you will be able to use the opt tool to access it, once loaded.

To test it, follow the example at the end of the Function 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.

-

As we saw above, passes are registered with the RegisterPass -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 +

As we saw above, passes are registered with the INITIALIZE_PASS +macro. 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, with opt or bugpoint). The second argument is the name of the pass, which is to be used for the -help output of