diff options
author | Devang Patel <dpatel@apple.com> | 2007-05-01 20:55:38 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2007-05-01 20:55:38 +0000 |
commit | e50fb9ac174b791047ffa8648443ab94b2097cd9 (patch) | |
tree | bc346d7fa504f489a1f459862ad1c611be52091b /docs/WritingAnLLVMPass.html | |
parent | 1b201684333c501e2f47178e1a4df68cd894c49d (diff) | |
download | external_llvm-e50fb9ac174b791047ffa8648443ab94b2097cd9.zip external_llvm-e50fb9ac174b791047ffa8648443ab94b2097cd9.tar.gz external_llvm-e50fb9ac174b791047ffa8648443ab94b2097cd9.tar.bz2 |
Update doc to reflect changes I am about to install to fix PR 888.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36631 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'docs/WritingAnLLVMPass.html')
-rw-r--r-- | docs/WritingAnLLVMPass.html | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/docs/WritingAnLLVMPass.html b/docs/WritingAnLLVMPass.html index 8f2c7af..13849d0 100644 --- a/docs/WritingAnLLVMPass.html +++ b/docs/WritingAnLLVMPass.html @@ -263,6 +263,14 @@ href="#FunctionPass"><tt>FunctionPass</tt></a>'s operate a function at a time.</p> <div class="doc_code"><pre> + static const int ID; + Hello() : FunctionPass((intptr_t)&ID) {} +</pre></div><p> + +<p> This declares pass identifier used by LLVM to identify pass. This allows LLVM to +avoid using expensive C++ runtime information.</p> + +<div class="doc_code"><pre> <b>virtual bool</b> <a href="#runOnFunction">runOnFunction</a>(Function &F) { llvm::cerr << "<i>Hello: </i>" << F.getName() << "\n"; <b>return false</b>; @@ -277,6 +285,13 @@ to do our thing, so we just print out our message with the name of each function.</p> <div class="doc_code"><pre> + const int Hello::ID = 0; +</pre></div> + +<p> We initialize pass ID here. LLVM uses ID's address to identify pass so +initialization value is not important.</p> + +<div class="doc_code"><pre> RegisterPass<Hello> X("<i>hello</i>", "<i>Hello World Pass</i>"); } <i>// end of anonymous namespace</i> </pre></div> @@ -295,6 +310,10 @@ argument "<tt>hello</tt>", and a name "<tt>Hello World Pass</tt>".</p> <b>namespace</b> { <b>struct Hello</b> : <b>public</b> <a href="#FunctionPass">FunctionPass</a> { + + static const int ID; + Hello() : FunctionPass((intptr_t)&ID) {} + <b>virtual bool</b> <a href="#runOnFunction">runOnFunction</a>(Function &F) { llvm::cerr << "<i>Hello: </i>" << F.getName() << "\n"; <b>return false</b>; |