X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=docs%2FLangRef.html;h=e8c1f01cee16ccc4b0f886d16113a3cc8daf0955;hb=10610646cbe02d5a018ddc1092f3b17e6325a94d;hp=ffae318b29f0e148820b5061185ad88c3c3a49df;hpb=a1a209791982cd19831fbc9cc9152b222263bcd2;p=oota-llvm.git diff --git a/docs/LangRef.html b/docs/LangRef.html index ffae318b29f..e8c1f01cee1 100644 --- a/docs/LangRef.html +++ b/docs/LangRef.html @@ -1,1458 +1,1429 @@ - -LLVM Assembly Language Reference Manual - - - - -
  LLVM Language Reference Manual
- + + + + LLVM Assembly Language Reference Manual + + + +
LLVM Language Reference Manual
    -
  1. Abstract -
  2. Introduction -
  3. Identifiers +
  4. Abstract
  5. +
  6. Introduction
  7. +
  8. Identifiers
  9. Type System
      -
    1. Primitive Types -
        -
      1. Type Classifications +
      2. Primitive Types +
          +
        1. Type Classifications
        +
      3. Derived Types
          -
        1. Array Type -
        2. Function Type -
        3. Pointer Type -
        4. Structure Type - +
        5. Array Type
        6. +
        7. Function Type
        8. +
        9. Pointer Type
        10. +
        11. Structure Type
        12. +
        +
      +
    2. High Level Structure
        -
      1. Module Structure -
      2. Global Variables -
      3. Function Structure +
      4. Module Structure
      5. +
      6. Global Variables
      7. +
      8. Function Structure
      +
    3. Instruction Reference
      1. Terminator Instructions
          -
        1. 'ret' Instruction -
        2. 'br' Instruction -
        3. 'switch' Instruction -
        4. 'invoke' Instruction +
        5. 'ret' Instruction
        6. +
        7. 'br' Instruction
        8. +
        9. 'switch' Instruction
        10. +
        11. 'invoke' Instruction
        12. +
        13. 'unwind' Instruction
        +
      2. Binary Operations
          -
        1. 'add' Instruction -
        2. 'sub' Instruction -
        3. 'mul' Instruction -
        4. 'div' Instruction -
        5. 'rem' Instruction -
        6. 'setcc' Instructions +
        7. 'add' Instruction
        8. +
        9. 'sub' Instruction
        10. +
        11. 'mul' Instruction
        12. +
        13. 'div' Instruction
        14. +
        15. 'rem' Instruction
        16. +
        17. 'setcc' Instructions
        +
      3. Bitwise Binary Operations
          -
        1. 'and' Instruction -
        2. 'or' Instruction -
        3. 'xor' Instruction -
        4. 'shl' Instruction -
        5. 'shr' Instruction +
        6. 'and' Instruction
        7. +
        8. 'or' Instruction
        9. +
        10. 'xor' Instruction
        11. +
        12. 'shl' Instruction
        13. +
        14. 'shr' Instruction
        +
      4. Memory Access Operations
          -
        1. 'malloc' Instruction -
        2. 'free' Instruction -
        3. 'alloca' Instruction -
        4. 'load' Instruction -
        5. 'store' Instruction -
        6. 'getelementptr' Instruction +
        7. 'malloc' Instruction
        8. +
        9. 'free' Instruction
        10. +
        11. 'alloca' Instruction
        12. +
        13. 'load' Instruction
        14. +
        15. 'store' Instruction
        16. +
        17. 'getelementptr' Instruction
        +
      5. Other Operations
          -
        1. 'phi' Instruction -
        2. 'cast .. to' Instruction -
        3. 'call' Instruction -
        4. 'va_arg' Instruction +
        5. 'phi' Instruction
        6. +
        7. 'cast .. to' Instruction
        8. +
        9. 'call' Instruction
        10. +
        11. 'vanext' Instruction
        12. +
        13. 'vaarg' Instruction
        +
      +
    4. Intrinsic Functions -
        -
      1. Variable Argument Handling Intrinsics
          -
        1. 'llvm.va_start' Intrinsic -
        2. 'llvm.va_end' Intrinsic -
        3. 'llvm.va_copy' Intrinsic +
        4. Variable Argument Handling Intrinsics +
            +
          1. 'llvm.va_start' Intrinsic
          2. +
          3. 'llvm.va_end' Intrinsic
          4. +
          5. 'llvm.va_copy' Intrinsic
          6. +
          +
        5. +
        6. Code Generator Intrinsics +
            +
          1. 'llvm.returnaddress' Intrinsic
          2. +
          3. 'llvm.frameaddress' Intrinsic
          4. +
          +
        7. +
        8. Standard C Library Intrinsics +
            +
          1. 'llvm.memcpy' Intrinsic
          2. +
          3. 'llvm.memmove' Intrinsic
          4. +
          5. 'llvm.memset' Intrinsic
          6. +
          +
        9. +
        10. Debugger intrinsics
        -
      - -

      Written by Chris Lattner and Vikram Adve

      - - +

    - - +
    +

    Written by Chris Lattner +and Vikram Adve

    +

    +
    -

    -
    -Abstract -

    -
    -Introduction -


    Well Formedness

    -
    -Identifiers -
+

LLVM requires the values start with a '%' sign for two reasons: +Compilers don't need to worry about name clashes with reserved words, +and the set of reserved words may be expanded in the future without +penalty. Additionally, unnamed identifiers allow a compiler to quickly +come up with a temporary variable without having to avoid symbol table +conflicts.

+

Reserved words in LLVM are very similar to reserved words in other +languages. There are keywords for different opcodes ('add', 'cast', 'ret', etc...), for primitive type names ('void', 'uint', +etc...), and others. These reserved words cannot conflict with +variable names, because none of them start with a '%' character.

+

Here is an example of LLVM code to multiply the integer variable '%X' +by 8:

+

The easy way:

+
  %result = mul uint %X, 8
+

After strength reduction:

+
  %result = shl uint %X, ubyte 3
+

And the hard way:

+
  add uint %X, %X           ; yields {uint}:%0
+  add uint %0, %0           ; yields {uint}:%1
+  %result = add uint %1, %1
+

This last way of multiplying %X by 8 illustrates several +important lexical features of LLVM:

    -
  1. Comments are delimited with a ';' and go until the end of line. -
  2. Unnamed temporaries are created when the result of a computation is not - assigned to a named value. -
  3. Unnamed temporaries are numbered sequentially -

- -...and it also show a convention that we follow in this document. When -demonstrating instructions, we will follow an instruction with a comment that -defines the type and name of value produced. Comments are shown in italic -text.

- -The one non-intuitive notation for constants is the optional hexidecimal form of -floating point constants. For example, the form 'double +

  • Comments are delimited with a ';' and go until the end +of line.
  • +
  • Unnamed temporaries are created when the result of a computation +is not assigned to a named value.
  • +
  • Unnamed temporaries are numbered sequentially
  • + +

    ...and it also show a convention that we follow in this document. +When demonstrating instructions, we will follow an instruction with a +comment that defines the type and name of value produced. Comments are +shown in italic text.

    +

    The one non-intuitive notation for constants is the optional +hexidecimal form of floating point constants. For example, the form 'double 0x432ff973cafa8000' is equivalent to (but harder to read than) 'double -4.5e+15' which is also supported by the parser. The only time hexadecimal -floating point constants are useful (and the only time that they are generated -by the disassembler) is when an FP constant has to be emitted that is not -representable as a decimal floating point number exactly. For example, NaN's, -infinities, and other special cases are represented in their IEEE hexadecimal -format so that assembly and disassembly do not cause any bits to change in the -constants.

    - - +4.5e+15' which is also supported by the parser. The only time +hexadecimal floating point constants are useful (and the only time that +they are generated by the disassembler) is when an FP constant has to +be emitted that is not representable as a decimal floating point number +exactly. For example, NaN's, infinities, and other special cases are +represented in their IEEE hexadecimal format so that assembly and +disassembly do not cause any bits to change in the constants.

    + - -
    -Type System -
    -
       -Primitive Types -


    Type Classifications

       -Derived Types -


    Array Type


    Function Type


    Structure Type


    Pointer Type

    -
    -High Level Structure -
    -
       -Module Structure -
    -
       -Global Variables -
    -
       -Function Structure -
    -
    -Instruction Reference -
    -
       -Terminator Instructions -


    'ret' Instruction


    'br' Instruction


    'switch' Instruction


    'invoke' Instruction

       -Binary Operations -


    'add' Instruction


    'sub' Instruction


    'mul' Instruction


    'div' Instruction


    'rem' Instruction


    'setcc' Instructions

    -
       -Bitwise Binary Operations -


    'and' Instruction


    'or' Instruction


    'xor' Instruction


    'shl' Instruction


    'shr' Instruction

    -
       -Memory Access Operations -


    'malloc' Instruction


    'free' Instruction


    'alloca' Instruction


    'load' Instruction


    'store' Instruction


    'getelementptr' Instruction

    -
       -Other Operations -


    'phi' Instruction


    'cast .. to' Instruction


    'call' Instruction


    'va_arg' Instruction

    -
    -Intrinsic Functions -
    -
       -Variable Argument Handling Intrinsics -


    'llvm.va_start' Intrinsic


    'llvm.va_end' Intrinsic


    'llvm.va_copy' Intrinsic

    - + +
    + Debugger Intrinsics +
    + +
    +

    +The LLVM debugger intrinsics (which all start with llvm.dbg. prefix), +are described in the LLVM Source Level +Debugging document. +

    +
    +
    - + + +