X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=docs%2FLangRef.html;h=f92fbf4abd7db3a2301528da805e015aa6a7fa0b;hb=1fefd099cf58ac46a77b84da47877f8ba5315626;hp=e3971ffed0d45483fed7f704e4a0717a45918dee;hpb=f95acc6d0286ffe6d0aa3f20bc61bba0dcfe14ba;p=oota-llvm.git diff --git a/docs/LangRef.html b/docs/LangRef.html index e3971ffed0d..f92fbf4abd7 100644 --- a/docs/LangRef.html +++ b/docs/LangRef.html @@ -7,7 +7,7 @@ - + @@ -103,11 +103,17 @@
  • Metadata Nodes and Metadata Strings
    1. 'tbaa' Metadata
    2. -
    3. 'fpaccuracy' Metadata
    4. +
    5. 'fpmath' Metadata
    6. +
    7. 'range' Metadata
  • +
  • Module Flags Metadata +
      +
    1. Objective-C Garbage Collection Module Flags Metadata
    2. +
    +
  • Intrinsic Global Variables
    1. The 'llvm.used' Global Variable
    2. @@ -301,6 +307,8 @@ 'llvm.annotation.*' Intrinsic
    3. 'llvm.trap' Intrinsic
    4. +
    5. + 'llvm.debugger' Intrinsic
    6. 'llvm.stackprotector' Intrinsic
    7. @@ -485,43 +493,43 @@
      -

      LLVM programs are composed of "Module"s, each of which is a translation unit - of the input programs. Each module consists of functions, global variables, - and symbol table entries. Modules may be combined together with the LLVM - linker, which merges function (and global variable) definitions, resolves - forward declarations, and merges symbol table entries. Here is an example of - the "hello world" module:

      +

      LLVM programs are composed of Modules, each of which is a + translation unit of the input programs. Each module consists of functions, + global variables, and symbol table entries. Modules may be combined together + with the LLVM linker, which merges function (and global variable) + definitions, resolves forward declarations, and merges symbol table + entries. Here is an example of the "hello world" module:

       ; Declare the string constant as a global constant. 
      -@.LC0 = internal constant [13 x i8] c"hello world\0A\00"      ; [13 x i8]* 
      +@.str = private unnamed_addr constant [13 x i8] c"hello world\0A\00" 
       
       ; External declaration of the puts function 
      -declare i32 @puts(i8*)                                      ; i32 (i8*)*  
      +declare i32 @puts(i8* nocapture) nounwind 
       
       ; Definition of main function
       define i32 @main() {   ; i32()*  
         ; Convert [13 x i8]* to i8  *... 
      -  %cast210 = getelementptr [13 x i8]* @.LC0, i64 0, i64 0   ; i8* 
      +  %cast210 = getelementptr [13 x i8]* @.str, i64 0, i64 0
       
         ; Call puts function to write out the string to stdout. 
      -  call i32 @puts(i8* %cast210)           ; i32 
      +  call i32 @puts(i8* %cast210)
         ret i32 0 
       }
       
       ; Named metadata
      -!1 = metadata !{i32 41}
      +!1 = metadata !{i32 42}
       !foo = !{!1, null}
       

      This example is made up of a global variable named - ".LC0", an external declaration of the "puts" function, + ".str", an external declaration of the "puts" function, a function definition for "main" and named metadata - "foo".

      + "foo".

      -

      In general, a module is made up of a list of global values, where both - functions and global variables are global values. Global values are +

      In general, a module is made up of a list of global values (where both + functions and global variables are global values). Global values are represented by a pointer to a memory location (in this case, a pointer to an array of char, and a pointer to a function), and have one of the following linkage types.

      @@ -2994,14 +3002,16 @@ call void @llvm.dbg.value(metadata !24, i64 0, metadata !25)

      - 'fpaccuracy' Metadata + 'fpmath' Metadata

      -

      fpaccuracy metadata may be attached to any instruction of floating - point type. It expresses the maximum relative error of the result of - that instruction, in ULPs. ULP is defined as follows:

      +

      fpmath metadata may be attached to any instruction of floating point + type. It can be used to express the maximum acceptable error in the result of + that instruction, in ULPs, thus potentially allowing the compiler to use a + more efficient but less accurate method of computing it. ULP is defined as + follows:

      @@ -3013,18 +3023,253 @@ call void @llvm.dbg.value(metadata !24, i64 0, metadata !25)
      -

      The maximum relative error may be any rational number. The metadata node - shall consist of a pair of unsigned integers respectively representing - the numerator and denominator. For example, 2.5 ULP:

      +

      The metadata node shall consist of a single positive floating point number + representing the maximum relative error, for example:

      -!0 = metadata !{ i32 5, i32 2 }
      +!0 = metadata !{ float 2.5 } ; maximum acceptable inaccuracy is 2.5 ULPs
       
      + +

      + 'range' Metadata +

      + +
      +

      range metadata may be attached only to loads of integer types. It + expresses the possible ranges the loaded value is in. The ranges are + represented with a flattened list of integers. The loaded value is known to + be in the union of the ranges defined by each consecutive pair. Each pair + has the following properties:

      +
        +
      • The type must match the type loaded by the instruction.
      • +
      • The pair a,b represents the range [a,b).
      • +
      • Both a and b are constants.
      • +
      • The range is allowed to wrap.
      • +
      • The range should not represent the full or empty set. That is, + a!=b.
      • +
      + +

      Examples:

      +
      +
      +  %a = load i8* %x, align 1, !range !0 ; Can only be 0 or 1
      +  %b = load i8* %y, align 1, !range !1 ; Can only be 255 (-1), 0 or 1
      +  %c = load i8* %z, align 1, !range !2 ; Can only be 0, 1, 3, 4 or 5
      +...
      +!0 = metadata !{ i8 0, i8 2 }
      +!1 = metadata !{ i8 255, i8 2 }
      +!2 = metadata !{ i8 0, i8 2, i8 3, i8 6 }
      +
      +
      +
      +
      + + + + +

      + Module Flags Metadata +

      + + +
      + +

      Information about the module as a whole is difficult to convey to LLVM's + subsystems. The LLVM IR isn't sufficient to transmit this + information. The llvm.module.flags named metadata exists in order to + facilitate this. These flags are in the form of key / value pairs — + much like a dictionary — making it easy for any subsystem who cares + about a flag to look it up.

      + +

      The llvm.module.flags metadata contains a list of metadata + triplets. Each triplet has the following form:

      + +
        +
      • The first element is a behavior flag, which specifies the behavior + when two (or more) modules are merged together, and it encounters two (or + more) metadata with the same ID. The supported behaviors are described + below.
      • + +
      • The second element is a metadata string that is a unique ID for the + metadata. How each ID is interpreted is documented below.
      • + +
      • The third element is the value of the flag.
      • +
      + +

      When two (or more) modules are merged together, the resulting + llvm.module.flags metadata is the union of the + modules' llvm.module.flags metadata. The only exception being a flag + with the Override behavior, which may override another flag's value + (see below).

      + +

      The following behaviors are supported:

      + + + + + + + + + + + + + + + + + + + + + + + + +
      ValueBehavior
      1 +
      +
      Error
      +
      Emits an error if two values disagree. It is an error to have an ID + with both an Error and a Warning behavior.
      +
      +
      2 +
      +
      Warning
      +
      Emits a warning if two values disagree.
      +
      +
      3 +
      +
      Require
      +
      Emits an error when the specified value is not present or doesn't + have the specified value. It is an error for two (or more) + llvm.module.flags with the same ID to have the Require + behavior but different values. There may be multiple Require flags + per ID.
      +
      +
      4 +
      +
      Override
      +
      Uses the specified value if the two values disagree. It is an + error for two (or more) llvm.module.flags with the same + ID to have the Override behavior but different values.
      +
      +
      + +

      An example of module flags:

      + +
      +!0 = metadata !{ i32 1, metadata !"foo", i32 1 }
      +!1 = metadata !{ i32 4, metadata !"bar", i32 37 }
      +!2 = metadata !{ i32 2, metadata !"qux", i32 42 }
      +!3 = metadata !{ i32 3, metadata !"qux",
      +  metadata !{
      +    metadata !"foo", i32 1
      +  }
      +}
      +!llvm.module.flags = !{ !0, !1, !2, !3 }
      +
      + +
        +
      • Metadata !0 has the ID !"foo" and the value '1'. The + behavior if two or more !"foo" flags are seen is to emit an + error if their values are not equal.

      • + +
      • Metadata !1 has the ID !"bar" and the value '37'. The + behavior if two or more !"bar" flags are seen is to use the + value '37' if their values are not equal.

      • + +
      • Metadata !2 has the ID !"qux" and the value '42'. The + behavior if two or more !"qux" flags are seen is to emit a + warning if their values are not equal.

      • + +
      • Metadata !3 has the ID !"qux" and the value:

        + +
        +metadata !{ metadata !"foo", i32 1 }
        +
        + +

        The behavior is to emit an error if the llvm.module.flags does + not contain a flag with the ID !"foo" that has the value + '1'. If two or more !"qux" flags exist, then they must have + the same value or an error will be issued.

      • +
      + + + +

      +Objective-C Garbage Collection Module Flags Metadata +

      + +
      + +

      On the Mach-O platform, Objective-C stores metadata about garbage collection + in a special section called "image info". The metadata consists of a version + number and a bitmask specifying what types of garbage collection are + supported (if any) by the file. If two or more modules are linked together + their garbage collection metadata needs to be merged rather than appended + together.

      + +

      The Objective-C garbage collection module flags metadata consists of the + following key-value pairs:

      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      KeyValue
      Objective-C Version[Required] — The Objective-C ABI + version. Valid values are 1 and 2.
      Objective-C Image Info Version[Required] — The version of the image info + section. Currently always 0.
      Objective-C Image Info Section[Required] — The section to place the + metadata. Valid values are "__OBJC, __image_info, regular" for + Objective-C ABI version 1, and "__DATA,__objc_imageinfo, regular, + no_dead_strip" for Objective-C ABI version 2.
      Objective-C Garbage Collection[Required] — Specifies whether garbage + collection is supported or not. Valid values are 0, for no garbage + collection, and 2, for garbage collection supported.
      Objective-C GC Only[Optional] — Specifies that only garbage + collection is supported. If present, its value must be 6. This flag + requires that the Objective-C Garbage Collection flag have the + value 2.
      + +

      Some important flag interactions:

      + +
        +
      • If a module with Objective-C Garbage Collection set to 0 is + merged with a module with Objective-C Garbage Collection set to + 2, then the resulting module has the Objective-C Garbage + Collection flag set to 0.
      • + +
      • A module with Objective-C Garbage Collection set to 0 cannot be + merged with a module with Objective-C GC Only set to 6.
      • +
      +
      @@ -4660,7 +4905,11 @@ IfUnequal: variables that must have an address available. When the function returns (either with the ret or resume instructions), the memory is - reclaimed. Allocating zero bytes is legal, but the result is undefined.

      + reclaimed. Allocating zero bytes is legal, but the result is undefined. + The order in which memory is allocated (ie., which way the stack grows) is + not specified.

      + +

      Example:
      @@ -8151,6 +8400,30 @@ LLVM.

      + +

      + 'llvm.debugger' Intrinsic +

      + +
      + +
      Syntax:
      +
      +  declare void @llvm.debugger()
      +
      + +
      Overview:
      +

      The 'llvm.debugger' intrinsic.

      + +
      Arguments:
      +

      None.

      + +
      Semantics:
      +

      This intrinsic is lowered to code which is intended to cause an execution + trap with the intention of requesting the attention of a debugger.

      + +
      +

      'llvm.stackprotector' Intrinsic @@ -8194,8 +8467,8 @@ LLVM.

      Syntax:
      -  declare i32 @llvm.objectsize.i32(i8* <object>, i1 <type>)
      -  declare i64 @llvm.objectsize.i64(i8* <object>, i1 <type>)
      +  declare i32 @llvm.objectsize.i32(i8* <object>, i1 <min>, i32 <runtime>)
      +  declare i64 @llvm.objectsize.i64(i8* <object>, i1 <min>, i32 <runtime>)
       
      Overview:
      @@ -8206,17 +8479,21 @@ LLVM.

      an allocation of a specific class, structure, array, or other object.

      Arguments:
      -

      The llvm.objectsize intrinsic takes two arguments. The first +

      The llvm.objectsize intrinsic takes three arguments. The first argument is a pointer to or into the object. The second argument - is a boolean 0 or 1. This argument determines whether you want the - maximum (0) or minimum (1) bytes remaining. This needs to be a literal 0 or - 1, variables are not allowed.

      + is a boolean and determines whether llvm.objectsize returns 0 (if true) + or -1 (if false) when the object size is unknown. + The third argument, runtime, indicates whether the compiler is allowed + to return a non-constant value. The higher the value, the higher the potential + run-time performance impact. + The second and third arguments only accepts constants.

      Semantics:
      -

      The llvm.objectsize intrinsic is lowered to either a constant - representing the size of the object concerned, or i32/i64 -1 or 0, - depending on the type argument, if the size cannot be determined at - compile time.

      +

      The llvm.objectsize intrinsic is lowered to a constant representing + the size of the object concerned. If the size cannot be determined at compile + time, llvm.objectsize either returns i32/i64 -1 or 0 + (depending on the min argument) if runtime is 0, or a run-time + value (if runtime > 0 and an expression could be generated).