X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=docs%2FLangRef.html;h=cd8b7e9f967a5e607af176bccbef90a141901e1f;hb=befc9c16fae1719cafe9f54ab2b67219db44dc11;hp=08cdccf81021b00f418d9f50254704bd4540d134;hpb=7a3ad1a401d0ede3d4365db144c4e7f04c73d2ec;p=oota-llvm.git diff --git a/docs/LangRef.html b/docs/LangRef.html index 08cdccf8102..cd8b7e9f967 100644 --- a/docs/LangRef.html +++ b/docs/LangRef.html @@ -111,6 +111,12 @@
The first class types are perhaps the most important. Values of these types are the only ones which can be produced by instructions, passed as arguments, or used as operands to -instructions. This means that all structures and arrays must be -manipulated either by pointer or by component.
+instructions. @@ -1223,17 +1242,21 @@ type "{ i32, [0 x float]}", for example.The function type can be thought of as a function signature. It consists of a return type and a list of formal parameter types. The -return type of a function type is a scalar type or a void type or a struct type. +return type of a function type is a scalar type, a void type, or a struct type. If the return type is a struct type then all struct elements must be of first -class types. Function types are usually used to build virtual function tables -(which are structures of pointers to functions), for indirect function -calls, and when defining a function.
+class types, and the struct must have at least one element.<returntype list> (<parameter list>)+ +
+ <returntype list> (<parameter list>) ++
...where '<parameter list>' is a comma-separated list of type specifiers. Optionally, the parameter list may include a type ..., which indicates that the function takes a variable number of arguments. @@ -1241,6 +1264,7 @@ Variable argument functions can access their arguments with the variable argument handling intrinsic functions. '<returntype list>' is a comma-separated list of first class type specifiers.
+<result> = and i32 4, %var ; yields {i32}:result = 4 & %var ++ <result> = and i32 4, %var ; yields {i32}:result = 4 & %var <result> = and i32 15, 40 ; yields {i32}:result = 8 <result> = and i32 4, 8 ; yields {i32}:result = 0@@ -2483,9 +2611,10 @@ identical types.The 'or' instruction returns the bitwise logical inclusive or of its two operands.
Arguments:
-The two arguments to the 'or' instruction must be integer values. Both arguments must have -identical types.
+ +The two arguments to the 'or' instruction must be +integer or vector of integer +values. Both arguments must have identical types.
Semantics:
The truth table used for the 'or' instruction is:
@@ -2538,10 +2667,12 @@ Instruction or of its two operands. The xor is used to implement the "one's complement" operation, which is the "~" operator in C.
Arguments:
-The two arguments to the 'xor' instruction must be integer values. Both arguments must have -identical types.
+The two arguments to the 'xor' instruction must be +integer or vector of integer +values. Both arguments must have identical types.
+Semantics:
+The truth table used for the 'xor' instruction is:
@@ -2656,7 +2787,7 @@ results are undefined.+ + + +Syntax:
- <result> = insertelement <n x <ty>> <val>, <ty> <elt>, i32 <idx> ; yields <n x <ty>> + <result> = insertelement <n x <ty>> <val>, <ty> <elt>, i32 <idx> ; yields <n x <ty>>Overview:
@@ -2747,6 +2878,114 @@ operand may be undef if performing a shuffle from only one vector.+ ++ + + + +LLVM supports several instructions for working with aggregate values. +
+ ++ ++ + + + + +Syntax:
+ ++ <result> = extractvalue <aggregate type> <val>, <idx>{, <idx>}* ++ +Overview:
+ ++The 'extractvalue' instruction extracts the value of a struct field +or array element from an aggregate value. +
+ + +Arguments:
+ ++The first operand of an 'extractvalue' instruction is a +value of struct or array +type. The operands are constant indices to specify which value to extract +in a similar manner as indices in a +'getelementptr' instruction. +
+ +Semantics:
+ ++The result is the value at the position in the aggregate specified by +the index operands. +
+ +Example:
+ ++ %result = extractvalue {i32, float} %agg, 0 ; yields i32 +++ ++ +Syntax:
+ ++ <result> = insertvalue <aggregate type> <val>, <ty> <val>, <idx> ; yields <n x <ty>> ++ +Overview:
+ ++The 'insertvalue' instruction inserts a value +into a struct field or array element in an aggregate. +
+ + +Arguments:
+ ++The first operand of an 'insertvalue' instruction is a +value of struct or array type. +The second operand is a first-class value to insert. +The following operands are constant indices +indicating the position at which to insert the value in a similar manner as +indices in a +'getelementptr' instruction. +The value to insert must have the same type as the value identified +by the indices. + +
Semantics:
+ ++The result is an aggregate of the same type as val. Its +value is that of val except that the value at the position +specified by the indices is that of elt. +
+ +Example:
+ ++ %result = insertvalue {i32, float} %agg, 1, 0 ; yields {i32, float} ++Memory Access and Addressing Operations @@ -2787,7 +3026,7 @@ address space (address space zero). bytes of memory from the operating system and returns a pointer of the appropriate type to the program. If "NumElements" is specified, it is the number of elements allocated, otherwise "NumElements" is defaulted to be one. -If an alignment is specified, the value result of the allocation is guaranteed to +If a constant alignment is specified, the value result of the allocation is guaranteed to be aligned to at least that boundary. If not specified, or if zero, the target can choose to align the allocation on any convenient boundary. @@ -2796,7 +3035,8 @@ choose to align the allocation on any convenient boundary.Semantics:
Memory is allocated using the system "malloc" function, and -a pointer is returned.
+a pointer is returned. The result of a zero byte allocattion is undefined. The +result is null if there is insufficient memory available.Example:
@@ -2838,7 +3078,8 @@ instruction.Semantics:
Access to the memory pointed to by the pointer is no longer defined -after this instruction executes.
+after this instruction executes. If the pointer is null, the operation +is a noop.Example:
@@ -2874,7 +3115,7 @@ space (address space zero). bytes of memory on the runtime stack, returning a pointer of the appropriate type to the program. If "NumElements" is specified, it is the number of elements allocated, otherwise "NumElements" is defaulted to be one. -If an alignment is specified, the value result of the allocation is guaranteed +If a constant alignment is specified, the value result of the allocation is guaranteed to be aligned to at least that boundary. If not specified, or if zero, the target can choose to align the allocation on any convenient boundary. @@ -2882,12 +3123,14 @@ can choose to align the allocation on any convenient boundary.Semantics:
-Memory is allocated; a pointer is returned. 'alloca'd +
Memory is allocated; a pointer is returned. The operation is undefiend if +there is insufficient stack space for the allocation. 'alloca'd memory is automatically released when the function returns. The 'alloca' instruction is commonly used to represent automatic variables that must have an address available. When the function returns (either with the ret or unwind -instructions), the memory is reclaimed.
+instructions), the memory is reclaimed. Allocating zero bytes +is legal, but the result is undefined.Example:
@@ -2916,7 +3159,7 @@ the number or order of execution of this load with other volatile load and store instructions.-The optional "align" argument specifies the alignment of the operation +The optional constant "align" argument specifies the alignment of the operation (that is, the alignment of the memory address). A value of 0 or an omitted "align" argument means that the operation has the preferential alignment for the target. It is the responsibility of the code emitter @@ -2947,13 +3190,14 @@ Instruction
Arguments:
There are two arguments to the 'store' instruction: a value to store and an address at which to store it. The type of the '<pointer>' -operand must be a pointer to the type of the '<value>' +operand must be a pointer to the first class type +of the '<value>' operand. If the store is marked as volatile, then the optimizer is not allowed to modify the number or order of execution of this store with other volatile load and store instructions.
-The optional "align" argument specifies the alignment of the operation +The optional constant "align" argument specifies the alignment of the operation (that is, the alignment of the memory address). A value of 0 or an omitted "align" argument means that the operation has the preferential alignment for the target. It is the responsibility of the code emitter @@ -2997,8 +3241,8 @@ provided depend on the type of the first pointer argument. The 'getelementptr' instruction is used to index down through the type levels of a structure or to a specific index in an array. When indexing into a structure, only i32 integer constants are allowed. When indexing -into an array or pointer, only integers of 32 or 64 bits are allowed, and will -be sign extended to 64-bit values.
+into an array or pointer, only integers of 32 or 64 bits are allowed; 32-bit +values will be sign extended to 64-bits if required.For example, let's consider a C code fragment and how it gets compiled to LLVM:
@@ -3043,8 +3287,8 @@ entry: on the pointer type that is being indexed into. Pointer and array types can use a 32-bit or 64-bit integer type but the value will always be sign extended -to 64-bits. Structure types require i32 -constants. +to 64-bits. Structure and packed +structure types require i32 constants.In the example above, the first index is indexing into the '%ST*' type, which is a pointer, yielding a '%ST' = '{ i32, double, %RT @@ -3073,7 +3317,7 @@ the LLVM code for the given testcase is equivalent to:
Note that it is undefined to access an array out of bounds: array and pointer indexes must always be within the defined bounds of the array type. -The one exception for this rules is zero length arrays. These arrays are +The one exception for this rule is zero length arrays. These arrays are defined to be accessible as variable length arrays, which requires access beyond the zero'th element.
@@ -3509,15 +3753,19 @@ nothing is done (no-op cast).
The 'bitcast' instruction converts value to type ty2 without changing any bits.
The 'bitcast' instruction takes a value to cast, which must be a first class value, and a type to cast it to, which must also be a first class type. The bit sizes of value and the destination type, ty2, must be identical. If the source -type is a pointer, the destination type must also be a pointer.
+type is a pointer, the destination type must also be a pointer. This +instruction supports bitwise conversion of vectors to integers and to vectors +of other types (as long as they have the same size).The 'bitcast' instruction converts value to type @@ -3552,7 +3800,7 @@ instructions, which defy better classification.
The 'icmp' instruction returns a boolean value based on comparison -of its two integer operands.
+of its two integer or pointer operands.The 'icmp' instruction takes three operands. The first operand is the condition code indicating the kind of comparison to perform. It is not @@ -3649,9 +3897,9 @@ a value, just a keyword. The possible condition code are: floating point typed. They must have identical types.
The 'fcmp' compares var1 and var2 according to -the condition code given as cond. The comparison performed always -yields a i1 result, as follows: +
The 'fcmp' instruction compares var1 and var2 +according to the condition code given as cond. The comparison performed +always yields a i1 result, as follows:
<result> = vicmp <cond> <ty> <var1>, <var2> ; yields {ty}:result ++
The 'vicmp' instruction returns an integer vector value based on +element-wise comparison of its two integer vector operands.
+The 'vicmp' instruction takes three operands. The first operand is +the condition code indicating the kind of comparison to perform. It is not +a value, just a keyword. The possible condition code are: +
The remaining two arguments must be vector of +integer typed. They must also be identical types.
+The 'vicmp' instruction compares var1 and var2 +according to the condition code given as cond. The comparison yields a +vector of integer result, of +identical type as the values being compared. The most significant bit in each +element is 1 if the element-wise comparison evaluates to true, and is 0 +otherwise. All other bits of the result are undefined. The condition codes +are evaluated identically to the 'icmp' +instruction. + +
+ <result> = vicmp eq <2 x i32> < i32 4, i32 0>, < i32 5, i32 0> ; yields: result=<2 x i32> < i32 0, i32 -1 > + <result> = vicmp ult <2 x i8 > < i8 1, i8 2>, < i8 2, i8 2 > ; yields: result=<2 x i8> < i8 -1, i8 0 > ++
<result> = vfcmp <cond> <ty> <var1>, <var2>+
The 'vfcmp' instruction returns an integer vector value based on +element-wise comparison of its two floating point vector operands. The output +elements have the same width as the input elements.
+The 'vfcmp' instruction takes three operands. The first operand is +the condition code indicating the kind of comparison to perform. It is not +a value, just a keyword. The possible condition code are: +
The remaining two arguments must be vector of +floating point typed. They must also be identical +types.
+The 'vfcmp' instruction compares var1 and var2 +according to the condition code given as cond. The comparison yields a +vector of integer result, with +an identical number of elements as the values being compared, and each element +having identical with to the width of the floating point elements. The most +significant bit in each element is 1 if the element-wise comparison evaluates to +true, and is 0 otherwise. All other bits of the result are undefined. The +condition codes are evaluated identically to the +'fcmp' instruction. + +
+ <result> = vfcmp oeq <2 x float> < float 4, float 0 >, < float 5, float 0 > ; yields: result=<2 x i32> < i32 0, i32 -1 > + <result> = vfcmp ult <2 x double> < double 1, double 2 >, < double 2, double 2> ; yields: result=<2 x i64> < i64 -1, i64 0 > ++
<result> = phi <ty> [ <val0>, <label0>], ...
The 'phi' instruction is used to implement the φ node in the SSA graph representing the function.
The type of the incoming values is specified with the first type field. After this, the 'phi' instruction takes a list of pairs as arguments, with one pair for each predecessor basic block of the current block. Only values of first class type may be used as the value arguments to the PHI node. Only labels may be used as the label arguments.
+There must be no non-phi instructions between the start of a basic block and the PHI instructions: i.e. PHI instructions must be first in a basic block.
+At runtime, the 'phi' instruction logically takes on the value specified by the pair corresponding to the predecessor basic block that executed just prior to the current block.
+Loop: ; Infinite loop that counts from 0 on up...+
%indvar = phi i32 [ 0, %LoopHeader ], [ %nextindvar, %Loop ]
%nextindvar = add i32 %indvar, 1
br label %Loop
+Loop: ; Infinite loop that counts from 0 on up... + %indvar = phi i32 [ 0, %LoopHeader ], [ %nextindvar, %Loop ] + %nextindvar = add i32 %indvar, 1 + br label %Loop +
-The 'select' instruction requires a boolean value indicating the condition, and two values of the same first class type. +The 'select' instruction requires an 'i1' value indicating the +condition, and two values of the same first class +type. If the val1/val2 are vectors, the entire vectors are selected, not +individual elements.
-If the boolean condition evaluates to true, the instruction returns the first +If the i1 condition evaluates is 1, the instruction returns the first value argument; otherwise, it returns the second value argument.
@@ -3917,9 +4282,10 @@ results.The 'getresult' instruction takes a call or invoke value as its -first argument. The value must have structure type. -The second argument is an unsigned index value which must be in range for -the number of values returned by the call.
+first argument, or an undef value. The value must have structure type. The second argument is a constant +unsigned index value which must be in range for the number of values returned +by the call.At runtime, a call to this intrinsics stores a null pointer into the "ptrloc" +
At runtime, a call to this intrinsic stores a null pointer into the "ptrloc" location. At compile-time, the code generator generates information to allow the runtime to find the pointer at GC safe points. The 'llvm.gcroot' intrinsic may only be used in a function which specifies a GC