X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=docs%2FLangRef.html;h=59dacf7ef40d626c8d9ee2f84af6e0ff2e464f47;hb=c9fdfc8e9fbca9542077bec4ecdee65576752ae0;hp=ffae318b29f0e148820b5061185ad88c3c3a49df;hpb=a1a209791982cd19831fbc9cc9152b222263bcd2;p=oota-llvm.git diff --git a/docs/LangRef.html b/docs/LangRef.html index ffae318b29f..c2e1c6c4cd9 100644 --- a/docs/LangRef.html +++ b/docs/LangRef.html @@ -1,1816 +1,4618 @@ - -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. +
  10. High Level Structure +
      +
    1. Module Structure
    2. +
    3. Linkage Types
    4. +
    5. Calling Conventions
    6. +
    7. Global Variables
    8. +
    9. Functions
    10. +
    11. Parameter Attributes
    12. +
    13. Module-Level Inline Assembly
    14. +
    15. Data Layout
    16. +
    +
  11. 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. +
        13. Packed Structure Type
        14. +
        15. Vector Type
        16. +
        17. Opaque Type
        +
      -
    2. High Level Structure +
    3. +
    4. Constants +
        +
      1. Simple Constants +
      2. Aggregate Constants +
      3. Global Variable and Function Addresses +
      4. Undefined Values +
      5. Constant Expressions +
      +
    5. +
    6. Other Values
        -
      1. Module Structure -
      2. Global Variables -
      3. Function Structure +
      4. Inline Assembler Expressions
      +
    7. 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
        14. +
        15. 'unreachable' 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. 'udiv' Instruction
        14. +
        15. 'sdiv' Instruction
        16. +
        17. 'fdiv' Instruction
        18. +
        19. 'urem' Instruction
        20. +
        21. 'srem' Instruction
        22. +
        23. 'frem' Instruction
        +
      3. Bitwise Binary Operations
          -
        1. 'and' Instruction -
        2. 'or' Instruction -
        3. 'xor' Instruction -
        4. 'shl' Instruction -
        5. 'shr' Instruction +
        6. 'shl' Instruction
        7. +
        8. 'lshr' Instruction
        9. +
        10. 'ashr' Instruction
        11. +
        12. 'and' Instruction
        13. +
        14. 'or' Instruction
        15. +
        16. 'xor' Instruction
        17. +
        +
      4. +
      5. Vector Operations +
          +
        1. 'extractelement' Instruction
        2. +
        3. 'insertelement' Instruction
        4. +
        5. 'shufflevector' Instruction
        6. +
        +
      6. +
      7. Memory Access and Addressing Operations +
          +
        1. 'malloc' Instruction
        2. +
        3. 'free' Instruction
        4. +
        5. 'alloca' Instruction
        6. +
        7. 'load' Instruction
        8. +
        9. 'store' Instruction
        10. +
        11. 'getelementptr' Instruction
        -
      8. Memory Access Operations +
      9. +
      10. Conversion Operations
          -
        1. 'malloc' Instruction -
        2. 'free' Instruction -
        3. 'alloca' Instruction -
        4. 'load' Instruction -
        5. 'store' Instruction -
        6. 'getelementptr' Instruction +
        7. 'trunc .. to' Instruction
        8. +
        9. 'zext .. to' Instruction
        10. +
        11. 'sext .. to' Instruction
        12. +
        13. 'fptrunc .. to' Instruction
        14. +
        15. 'fpext .. to' Instruction
        16. +
        17. 'fptoui .. to' Instruction
        18. +
        19. 'fptosi .. to' Instruction
        20. +
        21. 'uitofp .. to' Instruction
        22. +
        23. 'sitofp .. to' Instruction
        24. +
        25. 'ptrtoint .. to' Instruction
        26. +
        27. 'inttoptr .. to' Instruction
        28. +
        29. 'bitcast .. to' Instruction
      11. Other Operations
          -
        1. 'phi' Instruction -
        2. 'cast .. to' Instruction -
        3. 'call' Instruction -
        4. 'va_arg' Instruction +
        5. 'icmp' Instruction
        6. +
        7. 'fcmp' Instruction
        8. +
        9. 'phi' Instruction
        10. +
        11. 'select' Instruction
        12. +
        13. 'call' Instruction
        14. +
        15. 'va_arg' Instruction
        +
      +
    8. 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. Accurate Garbage Collection Intrinsics +
            +
          1. 'llvm.gcroot' Intrinsic
          2. +
          3. 'llvm.gcread' Intrinsic
          4. +
          5. 'llvm.gcwrite' Intrinsic
          6. +
          +
        7. +
        8. Code Generator Intrinsics +
            +
          1. 'llvm.returnaddress' Intrinsic
          2. +
          3. 'llvm.frameaddress' Intrinsic
          4. +
          5. 'llvm.stacksave' Intrinsic
          6. +
          7. 'llvm.stackrestore' Intrinsic
          8. +
          9. 'llvm.prefetch' Intrinsic
          10. +
          11. 'llvm.pcmarker' Intrinsic
          12. +
          13. llvm.readcyclecounter' Intrinsic
          14. +
          +
        9. +
        10. Standard C Library Intrinsics +
            +
          1. 'llvm.memcpy.*' Intrinsic
          2. +
          3. 'llvm.memmove.*' Intrinsic
          4. +
          5. 'llvm.memset.*' Intrinsic
          6. +
          7. 'llvm.sqrt.*' Intrinsic
          8. +
          9. 'llvm.powi.*' Intrinsic
          10. +
          +
        11. +
        12. Bit Manipulation Intrinsics +
            +
          1. 'llvm.bswap.*' Intrinsics
          2. +
          3. 'llvm.ctpop.*' Intrinsic
          4. +
          5. 'llvm.ctlz.*' Intrinsic
          6. +
          7. 'llvm.cttz.*' Intrinsic
          8. +
          +
        13. +
        14. Debugger intrinsics
        15. +
        16. Exception Handling 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.

+

LLVM requires that 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.

+

Reserved words in LLVM are very similar to reserved words in other +languages. There are keywords for different opcodes +('add', + 'bitcast', + 'ret', etc...), for primitive type names ('void', 'i32', 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:

+

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

+ +

The easy way:

-The easy way:
-  %result = mul uint %X, 8
+  %result = mul i32 %X, 8
 
-After strength reduction: +

After strength reduction:

+
-  %result = shl uint %X, ubyte 3
+  %result = shl i32 %X, i8 3
 
-And the hard way: +

And the hard way:

+
-  add uint %X, %X           ; yields {uint}:%0
-  add uint %0, %0           ; yields {uint}:%1
-  %result = add uint %1, %1
+  add i32 %X, %X           ; yields {i32}:%0
+  add i32 %0, %0           ; yields {i32}:%1
+  %result = add i32 %1, %1
 
-This last way of multiplying %X by 8 illustrates several important lexical features of LLVM:

+

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 +

  • 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 shows 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.

    +text.

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


    Type Classifications

       -Derived Types -


    Array Type


    Function Type

    + + +
    Packed Structure Type +
    +
    +
    Overview:
    +

    The packed structure type is used to represent a collection of data members +together in memory. There is no padding between fields. Further, the alignment +of a packed structure is 1 byte. The elements of a packed structure may +be any type that has a size.

    +

    Structures are accessed using 'load +and 'store' by getting a pointer to a +field with the 'getelementptr' +instruction.

    +
    Syntax:
    +
      < { <type list> } > 
    +
    Examples:
    + + + + + +
    + < { i32, i32, i32 } >
    + < { float, i32 (i32) * } >
    +
    + a triple of three i32 values
    + A pair, where the first element is a float and the second element + is a pointer to a function + that takes an i32, returning an i32.
    +
    +
    + +
    Pointer Type
    +
    +
    Overview:
    +

    As in many languages, the pointer type represents a pointer or +reference to another object, which must live in memory.

    +
    Syntax:
    +
      <type> *
    +
    Examples:
    + + + + + +
    + [4x i32]*
    + i32 (i32 *) *
    +
    + A pointer to array of + four i32 values
    + A pointer to a function that takes an i32*, returning an + i32.
    +
    +
    -


    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

    - + +
    + Exception Handling Intrinsics +
    + +
    +

    The LLVM exception handling intrinsics (which all start with +llvm.eh. prefix), are described in the LLVM Exception +Handling document.

    +
    + +
    - -
    Chris Lattner
    - - -Last modified: Thu May 8 10:48:46 CDT 2003 - -
    - +
    + Valid CSS! + Valid HTML 4.01! + + Chris Lattner
    + The LLVM Compiler Infrastructure
    + Last modified: $Date$ +
    + +