Major changes, expansions, clarifications and corrections.
authorChris Lattner <sabre@nondot.org>
Wed, 24 Jul 2002 19:51:14 +0000 (19:51 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 24 Jul 2002 19:51:14 +0000 (19:51 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3046 91177308-0d34-0410-b5e6-96231b3b80d8

docs/GettingStarted.html

index 465c006d76aee3cfc5f8009c37f3ef108f84e62c..c3c34d3bcbdb5a6ef6a258c01dac00dcb5a1b591 100644 (file)
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 <html>
   <head>
-    <title>Specification for LLVM system code</title>
+    <title>Getting Started with LLVM System</title>
   </head>
 
   <body>
-    <h1>Specification for LLVM system</h1>
-    <h1><a name="index">Index</a></h1>
+    <h1>Getting Started with the LLVM System</h1>
     <ul>
-      <li><a href="#cvs">Checkout LLVM from CVS</a>
-      <li><a href="#compilerun">Compile and Run</a>
+      <li><a href="#quickstart">Getting started with LLVM</a>
+        <ol>
+          <li><a href="#cvs">Checkout LLVM from CVS</a>
+          <li><a href="#environment">Set up your environment</a>
+          <li><a href="#compile">Compiling the Source Code</a>
+        </ol>
       <li><a href="#layout">Program layout</a>
        <ol>
-         <li><a href="#d&d">Depend and Debug directories</a></li>
+          <li><a href="#cvsdir">CVS directories</a>
+         <li><a href="#dd">Depend, Debug, &amp; Release directories</a></li>
          <li><a href="#include">llvm/include</a>
          <li><a href="#lib">llvm/lib</a>
          <li><a href="#test">llvm/test</a>
          <li><a href="#tools">llvm/tools</a>  
        </ol>
-      <li> <a href="#tutorial"> simple example for using tools</li>
+      <li><a href="#tutorial">An example using the LLVM tool chain</a>
       <li><a href="#links">Links</a>
     </ul>
-    <h2><a name="tools">Checkout LLVM from CVS</a></h2>
-    <p>  
-    <dl> 
-      <dt>cvs root directory:<dd> /home/vadve/vadve/Research/DynOpt/CVSRepository<br>
-      <dt>project name:<dd> llvm
-    </dl>
+
+
+
+    <!--=====================================================================-->
+    <h2><a name="quickstart">Getting Started with LLVM</a></h2>
+    <!--=====================================================================-->
+
+    <p>This guide is meant to get you up and running with LLVM as quickly as
+    possible.  Once you get the basic system running you can choose an area to
+    dive into and learn more about.  If you get stuck or something is missing
+    from this document, please email <a
+    href="mailto:sabre@nondot.org">Chris</a>.</p>
+    
+
+    <!------------------------------------------------------------------------->
+    <h3><a name="tools">Checkout LLVM from CVS</a></h3>
+    <!------------------------------------------------------------------------->
+
+    <p>First step is to get the actual source code.  To do this, all you need to
+    do is check it out from CVS.  From your home directory, just enter:</p>
+
+    <p><tt>cvs -d /home/vadve/vadve/Research/DynOpt/CVSRepository checkout llvm</tt></p>
+
+    <p>This will create an '<tt>llvm</tt>' directory in your home directory and fully
+    populate it with the source code for LLVM.</p>
+    
+
+    <!------------------------------------------------------------------------->
+    <h3><a name="tools">Set up your environment</a></h3>
+    <!------------------------------------------------------------------------->
     
-    For those who are not familar with cvs, there are two steps you should do:<br>
+    <p>Now that you have the source code available, you should set up your
+    environment to be able to use the LLVM tools (once compiled) with as little
+    hassle as possible.  To do this, we recommend that you add the following
+    lines to your <tt>.cshrc</tt> (or the corresponding lines to your
+    <tt>.profile</tt> if you use a bourne shell derivative):
+
+    <pre>
+       # Make the C frontend easy to use...
+       alias llvmgcc /home/vadve/lattner/cvs/gcc_install/bin/gcc
+
+       # Make the LLVM tools easy to use...
+       setenv PATH ~/llvm/tools/Debug:${PATH}
+    </pre>
+
+    <p>The C compiler is not included in the CVS tree you just checked out, so
+    we just point to the cannonical location, and access it with the
+    <tt>llvmgcc</tt> command.  The rest of the <a href="#tools">LLVM tools</a>
+    will be built into the llvm/tools/Debug directory inside of the sourcebase.
+    Adding them to your path will make it much easier to use them.</p>
+
+
+
+    <!------------------------------------------------------------------------->
+    <h3><a name="compile">Compiling the Source Code</a></h3>
+    <!------------------------------------------------------------------------->
+
+    <p>Every directory in the LLVM source tree includes a Makefile to build it,
+    and any subdirectories that it contains.  These makefiles require that you
+    use <tt>gmake</tt>, instead of <tt>make</tt> to build them, but can
+    otherwise be used freely.  To build the entire LLVM system, just enter the
+    top level <tt>llvm</tt> directory and type <tt>gmake</tt>.  A few minutes
+    later you will hopefully have a freshly compiled toolchain waiting for you
+    in <tt>llvm/tools/Debug</tt>.  If you want to look at the libraries that
+    were compiled, look in <tt>llvm/lib/Debug</tt>.</p>
+
+
+    <!--=====================================================================-->
+    <h2><a name="layout">Program Layout</a></h2>
+    <!--=====================================================================-->
+
+    <p>One useful source of infomation about the LLVM sourcebase is the LLVM
+    doxygen documentation, available at <tt><a
+    href="http://llvm.cs.uiuc.edu/doxygen/">http://llvm.cs.uiuc.edu/doxygen/</a></tt>. The
+    following is a brief introduction to code layout:</p>
+
+
+    <!------------------------------------------------------------------------->
+    <h3><a name="cvsdir">CVS directories</a></h3>
+    <!------------------------------------------------------------------------->
+
+    Every directory checked out of CVS will contain a CVS directory, for the
+    most part these can just be ignored.
+
+
+    <!------------------------------------------------------------------------->
+    <h3><a name="ddr">Depend, Debug, &amp; Release directories</a></h3>
+    <!------------------------------------------------------------------------->
+
+    Most source directories contain two directories, Depend and Debug. The
+    Depend directory contains automatically generated dependance files which are
+    used during compilation to make sure that source files get rebuilt if a
+    header file they use is modified. The Debug directory holds the object
+    files, library files and executables that are used for building a debug
+    enabled build.  The Release directory is created to hold the same files when
+    the <tt>ENABLE_OPTIMIZED=1</tt> flag is passed to <tt>gmake</tt>, causing an
+    optimized built to be performed.
+
+
+    <!------------------------------------------------------------------------->
+    <h3><a name="include">llvm/include</a></h3>
+    <!------------------------------------------------------------------------->
+
+    This directory contains public header files exported from the LLVM
+    library. The two main subdirectories of this directory are:
+
     <ol>
-      <li>
-       set CVSROOT. Add the following line into the .cshrc file in your home directory if you are using tcsh or csh:<br>
-       <i>setenv CVSROOT /home/vadve/vadve/Research/DynOpt/CVSRepository</i>
-      </li>
-      <li>
-       check out. Go to the directory you want to store LLVM, type <br>
-       <i>cvs checkout llvm</i>
-      </li>
+       <li><tt>llvm/include/llvm</tt> - This directory contains all of the LLVM
+       specific header files.  This directory also has subdirectories for
+       different portions of llvm: <tt>Analysis</tt>, <tt>CodeGen</tt>,
+       <tt>Reoptimizer</tt>, <tt>Target</tt>, <tt>Transforms</tt>, etc...
+
+       <li><tt>llvm/include/Support</tt> - This directory contains generic
+       support libraries that are independant of LLVM, but are used by LLVM.
+       For example, some C++ STL utilities and a Command Line option processing
+       library.
     </ol>
-    
-    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>
-    <dd><i>/home/vadve/lattner/cvs/gcc_install/bin/gcc</i><br>
-      a brief usage of this gcc and other tools are introduced later. To read it now, click <a href="#tutorial">here</a>.
-      
-      <h2><a name="compilerun">Compile and Run</a></h2>
-      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>
-      You might want to add the the following directory into your path:<br>
-      <dd><i>llvm/tools/Debug</i><br>
-       so you can run tools in any directory. If you are using csh or tcsh, add <br>
-       <dd><i>setenv PATH llvm/tools/Debug:${PATH}</i><br>
-         at the end of the file .cshrc in your home directory.
-         
-       </dl>
-         <h2><a name="layout">Program Layout</a></h2>
-         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>
-         The following is a brief introduction to code layout:
-         
-         <h3><a name="d&d">Depend and Debug directories</a></h3>
-         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.
-         <h3><a name="include">llvm/include</a></h3>
-         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. 
-         <h3><a name="lib">llvm/lib</a></h3>
-         This directory contains most important files of LLVM system. <br>
-         <dl compact>
-           
-           <dt>llvm/lib/transforms/<dd> This directory contains files and directories for transforming one representation to another representation.
-           <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>
+
+    <!------------------------------------------------------------------------->
+    <h3><a name="lib">llvm/lib</a></h3>
+    <!------------------------------------------------------------------------->
+
+    This directory contains most source files of LLVM system. In LLVM almost all
+    code exists in libraries, making it very easy to share code among the
+    different <a href="#tools">tools</a>.<p>
+
+     <dl compact>
+      <dt><tt>llvm/lib/VMCore/</tt><dd> This directory holds the core LLVM
+      source files that implement core classes like Instruction and BasicBlock.
+
+      <dt><tt>llvm/lib/AsmParser/</tt><dd> This directory holds the source code
+      for the LLVM assembly language parser library.
+
+      <dt><tt>llvm/lib/ByteCode/</tt><dd> This directory holds code for reading
+      and write LLVM bytecode.
+
+      <dt><tt>llvm/lib/CWrite/</tt><dd> This directory implements the LLVM to C
+      converter.
+
+      <dt><tt>llvm/lib/Analysis/</tt><dd> This directory contains a variety of
+      different program analyses, such as Dominator Information, Call Graphs,
+      Induction Variables, Interval Identification, Natural Loop Identification,
+      etc...
+
+      <dt><tt>llvm/lib/Transforms/</tt><dd> This directory contains the source
+      code for the LLVM to LLVM program transformations, such as Aggressive Dead
+      Code Elimination, Sparse Conditional Constant Propogation, Inlining, Loop
+      Invarient Code Motion, Dead Global Elimination, Pool Allocation, and many
+      others...
+
+      <dt><tt>llvm/lib/Target/</tt><dd> This directory contains files that
+      describe various target architectures for code generation.  For example,
+      the llvm/lib/Target/Sparc directory holds the Sparc machine
+      description.<br>
              
-           <dt>llvm/lib/Analysis/<dd> This directory contains files and directories for doing all kinds of data and control analysis.
-           <dt>llvm/lib/AsmParser/<dd> This directory contains files and directories for parsing the llvm assemly files. 
-           <dt>llvm/lib/ByteCode/<dd> This directory contains files and directories for reading and write LLVM bytecode.
-           <dt>llvm/lib/CWrite/<dd> This directory contains files and directories for writing c files as output.
-           <dt>llvm/lib/CodeGen/<dd> This directory contains files and directories for instruction selection, instruction scheduling and register allocation. 
-           <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. 
+      <dt><tt>llvm/lib/CodeGen/</tt><dd> This directory contains the major parts
+      of the code generator: Instruction Selector, Instruction Scheduling, and
+      Register Allocation.
+
+      <dt><tt>llvm/lib/Reoptimizer/</tt><dd> This directory holds code related
+      to the runtime reoptimizer framework that is currently under development.
              
-           <dt>llvm/lib/Support/<dd> This directory contains some files and directories supporting the library, e.g. commandline processor and statistic reporter.
-           <dt>llvm/lib/VMCore/<dd> This directory contains files and directories for implementing the virtual machine instruction set.
-         </dl>
-         <h3><a name="test">llvm/test</a></h3>
-       This directory contains llvm assembly and other files to test the llvm library.
-         
-         <h3><a name="tools">llvm/tools</a></h3>
-    <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. 
+      <dt><tt>llvm/lib/Support/</tt><dd> This directory contains the source code
+      that corresponds to the header files located in
+      <tt>llvm/include/Support/</tt>.
+    </dl>
+
+    <!------------------------------------------------------------------------->
+    <h3><a name="test">llvm/test</a></h3>
+    <!------------------------------------------------------------------------->
+
+    <p>This directory contains regression tests and source code that is used to
+    test the LLVM infrastructure...</p>
+
+    <!------------------------------------------------------------------------->
+    <h3><a name="tools">llvm/tools</a></h3>
+    <!------------------------------------------------------------------------->
+
+    <p>The <b>tools</b> directory contains the executables built out of the
+    libraries above, which form the main part of the user interface.  You can
+    always get help for a tool by typing <tt>tool_name --help</tt>.  The
+    following is a brief introduction to the most important tools.</p>
+
     <dl compact>
-      <dt><i>analyze</i><dd> ???
-           <dt><i>as</i><dd>llvm .ll -> .bc assembler
-             <br>The assembler transfroms the human readable assembly to llvm bytecode.
-           <dt><i>dis</i><dd>llvm .bc -> .ll disassembler
-             <br>The disassembler transfroms the llvm bytecode to human readable assembly.
-           <dt><i>extract</i><dd>  ???
-           <dt><i>gccas</i><dd>llvm .ll -> .bc assembler
-             <br>The assembler transfroms the human readable assembly to llvm bytecode.
-           <dt><i>gccld</i><dd>many llvm bytecode -> llvm bytecode + optimizations
-             <br> gccld links many llvm bytecode files into one bytecode file and does some optimization.
-           <dt><i>link</i><dd>many llvm bytecode -> llvm bytecode
-             <br> <i>link</i> takes many llvm bytecode files and link them into one llvm bytecode file.
-           <dt><i>llc</i><dd>llvm bytecode -> SPARC assembly
-             <br> <i>llc</i> takes a llvm bytecode file and output a SPARC assembly file.
-           <dt><i>lli</i><dd>llvm interpreter
-             <br><i>lli</i> reads a llvm bytecode file and execute it. 
-           <dt><i>opt</i><dd>llvm .bc -> .bc modular optimizer
-             <br> <i>opt</i> reads llvm bytecode and do certain optimization, then output llvm bytecode .
-         </dl>
+      <dt><tt><b>as</b></tt><dd>The assembler transforms the human readable
+      llvm assembly to llvm bytecode.<p>
+
+      <dt><tt><b>dis</b></tt><dd>The disassembler transforms the llvm bytecode
+      to human readable llvm assembly.  Additionally it can convert LLVM
+      bytecode to C, which is enabled with the <tt>-c</tt> option.<p>
+
+      <dt><tt><b>lli</b></tt><dd> <tt>lli</tt> is the LLVM interpreter, which
+      can directly execute LLVM bytecode (although very slowly...). In addition
+      to a simple intepreter, <tt>lli</tt> is also has debugger and tracing
+      modes (entered by specifying <tt>-debug</tt> or <tt>-trace</tt> on the
+      command line, respectively).<p>
+
+      <dt><tt><b>llc</b></tt><dd> <tt>llc</tt> is the LLVM backend compiler,
+      which translates LLVM bytecode to a SPARC assembly file.<p>
+
+      <dt><tt><b>llvmgcc</b></tt><dd> <tt>llvmgcc</tt> is a GCC based C frontend
+      that has been retargeted to emit LLVM code as the machine code output.  It
+      works just like any other GCC compiler, taking the typical <tt>-c, -S, -E,
+      -o</tt> options that are typically used.  The source code for the
+      <tt>llvmgcc</tt> tool is currently not included in the LLVM cvs tree
+      because it is quite large and not very interesting.<p>
+
+      <ol>
+        <dt><tt><b>gccas</b></tt><dd> This took is invoked by the
+        <tt>llvmgcc</tt> frontend as the "assembler" part of the compiler.  This
+        tool actually assembles its input, performs a variety of optimizations,
+        and outputs LLVM bytecode.  Thus when you invoke <tt>llvmgcc -c x.c -o
+        x.o</tt>, you are causing <tt>gccas</tt> to be run, which writes the
+        <tt>x.o</tt> file (which is an LLVM bytecode file that can be
+        disassembled or manipulated just like any other bytecode file).  The
+        command line interface to <tt>gccas</tt> is designed to be as close as
+        possible to the <b>system</b> <tt>as</tt> utility so that the gcc
+        frontend itself did not have to be modified to interface to a "wierd"
+        assembler.<p>
+
+        <dt><tt><b>gccld</b></tt><dd> <tt>gccld</tt> links together several llvm
+        bytecode files into one bytecode file and does some optimization.  It is
+        the linker invoked by the gcc frontend when multiple .o files need to be
+        linked together.  Like <tt>gccas</tt> the command line interface of
+        <tt>gccld</tt> is designed to match the system linker, to aid
+        interfacing with the GCC frontend.<p>
+      </ol>
+
+      <dt><tt><b>opt</b></tt><dd> <tt>opt</tt> reads llvm bytecode, applies a
+      series of LLVM to LLVM transformations (which are specified on the command
+      line), and then outputs the resultant bytecode.  The '<tt>opt --help</tt>'
+      command is a good way to get a list of the program transformations
+      available in LLVM.<p>
+
+      <dt><tt><b>analyze</b></tt><dd> <tt>analyze</tt> is used to run a specific
+      analysis on an input LLVM bytecode file and print out the results.  It is
+      primarily useful for debugging analyses, or familiarizing yourself with
+      what an analysis does.<p>
+
+    </dl>
          
-         <h2><a name="tutorial">tutorial for using tools</h2>
-         <ul>
-           <li>create a simple c file:<br>
-             <pre>
-             hello.c 
-
-                  int main() {
-                  printf("hello world\n");
-                  return 0;
-                  }
-             </pre>
-           </li>
-           <li>compile the c file into a llvm bytecode file<br>
-             <i>% alias llvmgcc /home/vadve/lattner/cvs/gcc_install/bin/gcc</i><br>
-             <i>% llvmgcc hello.c </i><br>
-               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>
-             % <i>lli a.out.bc</i><br>
-           <li> dissembler and assembler <br>
-             read llvm bytecode and output human readable llvm assembly<br>
-             %<i>dis a.out.bc -o hello.ll</i><br>
-             read human readable llvm assembly code and output llvm bytecode<br>
-             %<i>as hello.ll -o hello.bc</i>
-           </li>
-           <li> compile to sparc assembly<br>
-             <i>%llc hello.bc -o hello.s</i>
-           </li>
-         </ul>
-         <h2><a name="links">Links</a></h2>
-         <ul>
-           <li><a href="http://llvm.cs.uiuc.edu/">LLVM homepage</a></li>
-           <li><a href="http://tank.cs.uiuc.edu/doxygen/">LLVM doxygen tree</a></li>
-         </ul>
-         <hr>
-         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>
+    <!--=====================================================================-->
+    <h2><a name="tutorial">An example using the LLVM tool chain</h2>
+    <!--=====================================================================-->
+
+    <ol>
+    <li>First, create a simple C file, name it 'hello.c':
+       <pre>
+   #include &lt;stdio.h&gt;
+   int main() {
+     printf("hello world\n");
+     return 0;
+   }
+       </pre>
+
+    <li>Next, compile the C file into a LLVM bytecode file:<p>
+
+      <tt>% llvmgcc hello.c -o hello</tt><p>
+
+      This will create two result files: <tt>hello</tt> and
+      <tt>hello.bc</tt>. The <tt>hello.bc</tt> is the LLVM bytecode that
+      corresponds the the compiled program and the library facilities that it
+      required.  <tt>hello</tt> is a simple shell script that runs the bytecode
+      file with <tt>lli</tt>, making the result directly executable.<p>
+
+    <li>Run the program. To make sure the program ran, execute one of the
+    following commands:<p>
+      
+      <tt>% ./hello</tt><p>
+      or<p>
+
+      <tt>% lli hello.bc</tt><p>
+
+    <li>Use the <tt>dis</tt> utility to take a look at the LLVM assembly
+    code:<p>
+
+      <tt>% dis < hello.bc | less</tt><p>
+
+    <li>Compile the program to native Sparc assembly using the code
+    generator:<p>
+
+      <tt>% llc hello.bc -o hello.s</tt><p>
+
+    <li>Assemble the native sparc assemble file into a program:<p>
+
+      <tt>% /opt/SUNWspro/bin/cc -xarch=v9 hello.s -o hello.sparc</tt><p>
+
+    <li>Execute the native sparc program:<p>
+
+      <tt>% ./hello.sparc</tt><p>
+
+    </ol>
+
+
+    <!--=====================================================================-->
+    <h2><a name="links">Links</a></h2>
+    <!--=====================================================================-->
+
+    <p>This document is just an <b>introduction</b> to how to use LLVM to do
+    some simple things... there are many more interesting and complicated things
+    that you can do that aren't documented here (but we'll gladly accept a patch
+    if you want to write something up!).  For more information about LLVM, check
+    out:</p>
+
+    <ul>
+    <li><a href="http://llvm.cs.uiuc.edu/">LLVM homepage</a></li>
+    <li><a href="http://tank.cs.uiuc.edu/doxygen/">LLVM doxygen tree</a></li>
+    </ul>
+
+    <hr>
+
+    If you have any questions or run into any snags (or you have any
+    additions...), please send an email to <a
+    href="mailto:sabre@nondot.org">Chris Lattner</a> or <a
+    href="mailto:gshi1@uiuc.edu">Guochun Shi</a>. <p>
+
            <!-- Created: Mon Jul  1 02:29:02 CDT 2002 -->
            <!-- hhmts start -->
-Last modified: Wed Jul 17 17:55:16 CDT 2002
+Last modified: Wed Jul 24 14:43:12 CDT 2002
 <!-- hhmts end -->
   </body>
 </html>