| Guochun Shi | f4688a8 | 2002-07-17 23:05:56 +0000 | [diff] [blame^] | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> | 
 | 2 | <html> | 
 | 3 |   <head> | 
 | 4 |     <title>Specification for LLVM system code</title> | 
 | 5 |   </head> | 
 | 6 |  | 
 | 7 |   <body> | 
 | 8 |     <h1>Specification for LLVM system</h1> | 
 | 9 |     <h1><a name="index">Index</a></h1> | 
 | 10 |     <ul> | 
 | 11 |       <li><a href="#cvs">Checkout LLVM from CVS</a> | 
 | 12 |       <li><a href="#compilerun">Compile and Run</a> | 
 | 13 |       <li><a href="#layout">Program layout</a> | 
 | 14 | 	<ol> | 
 | 15 | 	  <li><a href="#d&d">Depend and Debug directories</a></li> | 
 | 16 | 	  <li><a href="#include">llvm/include</a> | 
 | 17 | 	  <li><a href="#lib">llvm/lib</a> | 
 | 18 | 	  <li><a href="#test">llvm/test</a> | 
 | 19 | 	  <li><a href="#tools">llvm/tools</a>   | 
 | 20 | 	</ol> | 
 | 21 |       <li> <a href="#tutorial"> simple example for using tools</li> | 
 | 22 |       <li><a href="#links">Links</a> | 
 | 23 |     </ul> | 
 | 24 |     <h2><a name="tools">Checkout LLVM from CVS</a></h2> | 
 | 25 |     <p>   | 
 | 26 |     <dl>  | 
 | 27 |       <dt>cvs root directory:<dd> /home/vadve/vadve/Research/DynOpt/CVSRepository<br> | 
 | 28 |       <dt>project name:<dd> llvm | 
 | 29 |     </dl> | 
 | 30 |      | 
 | 31 |     For those who are not familar with cvs, there are two steps you should do:<br> | 
 | 32 |     <ol> | 
 | 33 |       <li> | 
 | 34 | 	set CVSROOT. Add the following line into the .cshrc file in your home directory if you are using tcsh or csh:<br> | 
 | 35 | 	<i>setenv CVSROOT /home/vadve/vadve/Research/DynOpt/CVSRepository</i> | 
 | 36 |       </li> | 
 | 37 |       <li> | 
 | 38 | 	check out. Go to the directory you want to store LLVM, type <br> | 
 | 39 | 	<i>cvs checkout llvm</i> | 
 | 40 |       </li> | 
 | 41 |     </ol> | 
 | 42 |      | 
 | 43 |     note: the c front-end implementation is not in cvs. If you want to use it, you can use excutable in Chris Lattner's directory<br> | 
 | 44 |     <dd><i>/home/vadve/lattner/cvs/gcc_install/bin/gcc</i><br> | 
 | 45 |       a brief usage of this gcc and other tools are introduced later. To read it now, click <a href="#tutorial">here</a>. | 
 | 46 |        | 
 | 47 |       <h2><a name="compilerun">Compile and Run</a></h2> | 
 | 48 |       There is a makefile in each directory. You can simple type <i>gmake</i> in the <b>~/llvm</b> directory to compile all the files or you can type <i>gmake</i> in the certain directory to compile all files and subdirectories in that directory.<br> | 
 | 49 |       You might want to add the the following directory into your path:<br> | 
 | 50 |       <dd><i>llvm/tools/Debug</i><br> | 
 | 51 | 	so you can run tools in any directory. If you are using csh or tcsh, add <br> | 
 | 52 | 	<dd><i>setenv PATH llvm/tools/Debug:${PATH}</i><br> | 
 | 53 | 	  at the end of the file .cshrc in your home directory. | 
 | 54 | 	   | 
 | 55 | 	</dl> | 
 | 56 | 	  <h2><a name="layout">Program Layout</a></h2> | 
 | 57 | 	  Many useful infomation can be obtained from the LLVM doxygen tree available at <a href="http://llvm.cs.uiuc.edu/doxygen/"><i>http://llvm.cs.uiuc.edu/doxygen/ </i><br></a> | 
 | 58 | 	  The following is a brief introduction to code layout: | 
 | 59 | 	   | 
 | 60 | 	  <h3><a name="d&d">Depend and Debug directories</a></h3> | 
 | 61 | 	  Most directories contain these two directories. The depend directory contains dependance files which will be used during complilation. The debug directory contains object files, library files or executables after compilation. | 
 | 62 | 	  <h3><a name="include">llvm/include</a></h3> | 
 | 63 | 	  This directory contains common head files supporting the LLVM library. Specific head files which are only used by certain directory are place in that directory instead of here.  | 
 | 64 | 	  <h3><a name="lib">llvm/lib</a></h3> | 
 | 65 | 	  This directory contains most important files of LLVM system. <br> | 
 | 66 | 	  <dl compact> | 
 | 67 | 	     | 
 | 68 | 	    <dt>llvm/lib/transforms/<dd> This directory contains files and directories for transforming one representation to another representation. | 
 | 69 | 	    <dt>llvm/lib/Target/<dd> This directory contains files and directories for target machine. The files under llvm/lib/Target describe the common property for any target machine. The directory llvm/lib/Target/Sparc describe the sparc machine specification. <br> | 
 | 70 | 	       | 
 | 71 | 	    <dt>llvm/lib/Analysis/<dd> This directory contains files and directories for doing all kinds of data and control analysis. | 
 | 72 | 	    <dt>llvm/lib/AsmParser/<dd> This directory contains files and directories for parsing the llvm assemly files.  | 
 | 73 | 	    <dt>llvm/lib/ByteCode/<dd> This directory contains files and directories for reading and write LLVM bytecode. | 
 | 74 | 	    <dt>llvm/lib/CWrite/<dd> This directory contains files and directories for writing c files as output. | 
 | 75 | 	    <dt>llvm/lib/CodeGen/<dd> This directory contains files and directories for instruction selection, instruction scheduling and register allocation.  | 
 | 76 | 	    <dt>llvm/lib/Reoptimizer<dd> This directory contains files and directories for all kinds of optimizations, e.g. dead code elimination,  Loop Invariant Code Motion, etc.  | 
 | 77 | 	       | 
 | 78 | 	    <dt>llvm/lib/Support/<dd> This directory contains some files and directories supporting the library, e.g. commandline processor and statistic reporter. | 
 | 79 | 	    <dt>llvm/lib/VMCore/<dd> This directory contains files and directories for implementing the virtual machine instruction set. | 
 | 80 | 	  </dl> | 
 | 81 | 	  <h3><a name="test">llvm/test</a></h3> | 
 | 82 | 	This directory contains llvm assembly and other files to test the llvm library. | 
 | 83 | 	   | 
 | 84 | 	  <h3><a name="tools">llvm/tools</a></h3> | 
 | 85 |     <p> The <b>tools</b> directory contains many tools. You can always get help by typing <i>command_name --help </i>. The following is a brief introduction to each tool.  | 
 | 86 |     <dl compact> | 
 | 87 |       <dt><i>analyze</i><dd> ??? | 
 | 88 | 	    <dt><i>as</i><dd>llvm .ll -> .bc assembler | 
 | 89 | 	      <br>The assembler transfroms the human readable assembly to llvm bytecode. | 
 | 90 | 	    <dt><i>dis</i><dd>llvm .bc -> .ll disassembler | 
 | 91 | 	      <br>The disassembler transfroms the llvm bytecode to human readable assembly. | 
 | 92 | 	    <dt><i>extract</i><dd>  ??? | 
 | 93 | 	    <dt><i>gccas</i><dd>llvm .ll -> .bc assembler | 
 | 94 | 	      <br>The assembler transfroms the human readable assembly to llvm bytecode. | 
 | 95 | 	    <dt><i>gccld</i><dd>many llvm bytecode -> llvm bytecode + optimizations | 
 | 96 | 	      <br> gccld links many llvm bytecode files into one bytecode file and does some optimization. | 
 | 97 | 	    <dt><i>link</i><dd>many llvm bytecode -> llvm bytecode | 
 | 98 | 	      <br> <i>link</i> takes many llvm bytecode files and link them into one llvm bytecode file. | 
 | 99 | 	    <dt><i>llc</i><dd>llvm bytecode -> SPARC assembly | 
 | 100 | 	      <br> <i>llc</i> takes a llvm bytecode file and output a SPARC assembly file. | 
 | 101 | 	    <dt><i>lli</i><dd>llvm interpreter | 
 | 102 | 	      <br><i>lli</i> reads a llvm bytecode file and execute it.  | 
 | 103 | 	    <dt><i>opt</i><dd>llvm .bc -> .bc modular optimizer | 
 | 104 | 	      <br> <i>opt</i> reads llvm bytecode and do certain optimization, then output llvm bytecode . | 
 | 105 | 	  </dl> | 
 | 106 | 	   | 
 | 107 | 	  <h2><a name="tutorial">tutorial for using tools</h2> | 
 | 108 | 	  <ul> | 
 | 109 | 	    <li>create a simple c file:<br> | 
 | 110 | 	      <pre> | 
 | 111 | 	      hello.c  | 
 | 112 |  | 
 | 113 | 	           int main() { | 
 | 114 | 	           printf("hello world\n"); | 
 | 115 | 	           return 0; | 
 | 116 | 	           } | 
 | 117 | 	      </pre> | 
 | 118 | 	    </li> | 
 | 119 | 	    <li>compile the c file into a llvm bytecode file<br> | 
 | 120 | 	      <i>% alias llvmgcc /home/vadve/lattner/cvs/gcc_install/bin/gcc</i><br> | 
 | 121 | 	      <i>% llvmgcc hello.c </i><br> | 
 | 122 | 		there will be two output files: <b>a.out</b> and <b>a.out.bc</b>. The file <b>a.out</b> is a shell script and <b>a.out.bc</b> is the llvm bytecode. You can run a.out to excute or directly call the interpreter: <br> | 
 | 123 | 	      % <i>lli a.out.bc</i><br> | 
 | 124 | 	    <li> dissembler and assembler <br> | 
 | 125 | 	      read llvm bytecode and output human readable llvm assembly<br> | 
 | 126 | 	      %<i>dis a.out.bc -o hello.ll</i><br> | 
 | 127 | 	      read human readable llvm assembly code and output llvm bytecode<br> | 
 | 128 | 	      %<i>as hello.ll -o hello.bc</i> | 
 | 129 | 	    </li> | 
 | 130 | 	    <li> compile to sparc assembly<br> | 
 | 131 | 	      <i>%llc hello.bc -o hello.s</i> | 
 | 132 | 	    </li> | 
 | 133 | 	  </ul> | 
 | 134 | 	  <h2><a name="links">Links</a></h2> | 
 | 135 | 	  <ul> | 
 | 136 | 	    <li><a href="http://llvm.cs.uiuc.edu/">LLVM homepage</a></li> | 
 | 137 | 	    <li><a href="http://tank.cs.uiuc.edu/doxygen/">LLVM doxygen tree</a></li> | 
 | 138 | 	  </ul> | 
 | 139 | 	  <hr> | 
 | 140 | 	  If you have any question, please send an email to <a href="mailto:lattner@uiuc.edu">Lattner Chris Arthur</a> or <a href="mailto:gshi1@uiuc.edu">Guochun Shi</a>. <p> | 
 | 141 | 	    <!-- Created: Mon Jul  1 02:29:02 CDT 2002 --> | 
 | 142 | 	    <!-- hhmts start --> | 
 | 143 | Last modified: Wed Jul 17 17:55:16 CDT 2002 | 
 | 144 | <!-- hhmts end --> | 
 | 145 |   </body> | 
 | 146 | </html> |