From 3669299acdb4239d1c515e1b7a16480c50473cdc Mon Sep 17 00:00:00 2001 From: Misha Brukman Date: Wed, 12 May 2004 19:52:00 +0000 Subject: [PATCH] Made document HTML-4.01 (Strict)-compliant. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13505 91177308-0d34-0410-b5e6-96231b3b80d8 --- docs/Stacker.html | 147 ++++++++++++++++++++++++---------------------- 1 file changed, 78 insertions(+), 69 deletions(-) diff --git a/docs/Stacker.html b/docs/Stacker.html index 7e885c0bded..fca4b0bc64a 100644 --- a/docs/Stacker.html +++ b/docs/Stacker.html @@ -1,12 +1,14 @@ - + - Stacker: An Example Of Using LLVM + Stacker: An Example Of Using LLVM +
Stacker: An Example Of Using LLVM
-
+
  1. Abstract
  2. Introduction
  3. @@ -19,19 +21,17 @@
  4. The Wily GetElementPtrInst
  5. Getting Linkage Types Right
  6. Constants Are Easier Than That!
  7. -
- +
  • The Stacker Lexicon
      -
    1. The Stack -
    2. Punctuation -
    3. Comments -
    4. Literals -
    5. Words -
    6. Standard Style -
    7. Built-Ins -
    -
  • +
  • The Stack
  • +
  • Punctuation
  • +
  • Comments
  • +
  • Literals
  • +
  • Words
  • +
  • Standard Style
  • +
  • Built-Ins
  • +
  • Prime: A Complete Example
  • Internal Code Details
      @@ -44,16 +44,15 @@
    1. Test Programs
    2. Exercise
    3. Things Remaining To Be Done
    4. -
    -
  • + +
    -

    Written by Reid Spencer

    -

    +

    Written by Reid Spencer

    -
    + -
    Abstract
    +
    Abstract

    This document is another way to learn about LLVM. Unlike the LLVM Reference Manual or @@ -222,11 +221,11 @@ should be constructed. In general, here's what I learned: before. This makes for some very clean compiler design.

    The foregoing is such an important principal, its worth making an idiom:

    -
    
    -BasicBlock* bb = new BasicBlock();
    +
    +BasicBlock* bb = new BasicBlock();
     bb->getInstList().push_back( new Branch( ... ) );
     new Instruction(..., bb->getTerminator() );
    -
    +

    To make this clear, consider the typical if-then-else statement (see StackerCompiler::handle_if() method). We can set this up in a single function using LLVM in the following way:

    @@ -301,20 +300,21 @@ read the Language Reference and Programmer's Manual a couple times each, I still missed a few very key points:

    This means that when you look up an element in the global variable (assuming it's a struct or array), you must deference the pointer first! For many things, this leads to the idiom:

    -
    
    -std::vector index_vector;
    +
    +std::vector<Value*> index_vector;
     index_vector.push_back( ConstantSInt::get( Type::LongTy, 0 );
     // ... push other indices ...
     GetElementPtrInst* gep = new GetElementPtrInst( ptr, index_vector );
    -
    +

    For example, suppose we have a global variable whose type is [24 x int]. The variable itself represents a pointer to that array. To subscript the array, we need two indices, not just one. The first index (0) dereferences the @@ -513,10 +513,10 @@ using the following construction:

    Definition Of Operation Of Built In Words LOGICAL OPERATIONS - Word - Name - Operation - Description + Word + Name + Operation + Description < LT @@ -576,10 +576,10 @@ using the following construction:

    BITWISE OPERATORS - Word - Name - Operation - Description + Word + Name + Operation + Description << SHL @@ -618,10 +618,10 @@ using the following construction:

    ARITHMETIC OPERATORS - Word - Name - Operation - Description + Word + Name + Operation + Description ABS ABS @@ -699,10 +699,10 @@ using the following construction:

    STACK MANIPULATION OPERATORS - Word - Name - Operation - Description + Word + Name + Operation + Description DROP DROP @@ -754,7 +754,7 @@ using the following construction:

    The top four stack items are swapped in pairs. That is, two values are popped and retained. Then, two more values are popped and retained. The values are pushed back on to the stack in the reverse order but - in pairs.

    + in pairs. OVER OVER @@ -844,10 +844,10 @@ using the following construction:

    MEMORY OPERATORS - Word - Name - Operation - Description + Word + Name + Operation + Description MALLOC MALLOC @@ -897,10 +897,10 @@ using the following construction:

    CONTROL FLOW OPERATORS - Word - Name - Operation - Description + Word + Name + Operation + Description RETURN RETURN @@ -964,10 +964,10 @@ using the following construction:

    INPUT & OUTPUT OPERATORS - Word - Name - Operation - Description + Word + Name + Operation + Description SPACE SPACE @@ -1311,32 +1311,32 @@ directory contains everything, as follows:

    The Lexer

    See projects/Stacker/lib/compiler/Lexer.l

    -

    +
    The Parser

    See projects/Stacker/lib/compiler/StackerParser.y

    -

    +
    The Compiler

    See projects/Stacker/lib/compiler/StackerCompiler.cpp

    -

    +
    The Runtime

    See projects/Stacker/lib/runtime/stacker_rt.c

    -

    +
    Compiler Driver

    See projects/Stacker/tools/stkrc/stkrc.cpp

    -

    +
    Test Programs

    See projects/Stacker/test/*.st

    -

    +
    Exercise
    @@ -1390,11 +1390,20 @@ interested, here are some things that could be implemented better:

    Lessons I Learned About LLVM section.
    - + + +
    - +
    + Valid CSS! + Valid HTML 4.01! + + Reid Spencer
    + LLVM Compiler Infrastructure
    + Last modified: $Date$ +
    +