From 5568e94dbf1b54e959f3f290eed9679398e5d85c Mon Sep 17 00:00:00 2001
From: Chris Lattner
There are several different binary operators:
- + +<result> = add <ty> <var1>, <var2> ; yields {ty}:result + ++ <result> = add <ty> <var1>, <var2> ; yields {ty}:result+Overview:
+The 'add' instruction returns the sum of its two operands.
+Arguments:
-The two arguments to the 'add' instruction must be either integer or floating point values. - This instruction can also take vector versions of the values. -Both arguments must have identical types.
+ +The two arguments to the 'add' instruction must be integer, floating point, or + vector values. Both arguments must have identical + types.
+Semantics:
+The value produced is the integer or floating point sum of the two operands.
+If an integer sum has unsigned overflow, the result returned is the mathematical result modulo 2n, where n is the bit width of the result.
+Because LLVM integers use a two's complement representation, this instruction is appropriate for both signed and unsigned integers.
+Example:
-<result> = add i32 4, %var ; yields {i32}:result = 4 + %var + ++ <result> = add i32 4, %var ; yields {i32}:result = 4 + %var
<result> = sub <ty> <var1>, <var2> ; yields {ty}:result + ++ <result> = sub <ty> <var1>, <var2> ; yields {ty}:result+Overview:
+The 'sub' instruction returns the difference of its two operands.
-Note that the 'sub' instruction is used to represent the 'neg' -instruction present in most other intermediate representations.
+ +Note that the 'sub' instruction is used to represent the +'neg' instruction present in most other intermediate +representations.
+Arguments:
-The two arguments to the 'sub' instruction must be either integer or floating point -values. -This instruction can also take vector versions of the values. -Both arguments must have identical types.
+ +The two arguments to the 'sub' instruction must be integer, floating point, + or vector values. Both arguments must have identical + types.
+Semantics:
+The value produced is the integer or floating point difference of the two operands.
+If an integer difference has unsigned overflow, the result returned is the mathematical result modulo 2n, where n is the bit width of the result.
+Because LLVM integers use a two's complement representation, this instruction is appropriate for both signed and unsigned integers.
+Example:
<result> = sub i32 4, %var ; yields {i32}:result = 4 - %var <result> = sub i32 0, %val ; yields {i32}:result = -%var
<result> = mul <ty> <var1>, <var2> ; yields {ty}:result
The 'mul' instruction returns the product of its two operands.
+The two arguments to the 'mul' instruction must be either integer or floating point -values. -This instruction can also take vector versions of the values. -Both arguments must have identical types.
+ +The two arguments to the 'mul' instruction must be integer, floating point, +or vector values. Both arguments must have identical +types.
+The value produced is the integer or floating point product of the two operands.
+If the result of an integer multiplication has unsigned overflow, the result returned is the mathematical result modulo 2n, where n is the bit width of the result.
@@ -2184,6 +2223,7 @@ width of the full product.<result> = mul i32 4, %var ; yields {i32}:result = 4 * %var
The 'udiv' instruction returns the quotient of its two operands.
+The two arguments to the 'udiv' instruction must be -integer values. Both arguments must have identical -types. This instruction can also take vector versions -of the values in which case the elements must be integers.
+integer or vector of integer +values. Both arguments must have identical types. +The value produced is the unsigned integer quotient of the two operands.
Note that unsigned integer division and signed integer division are distinct operations; for signed integer division, use 'sdiv'.
@@ -2213,16 +2256,21 @@ operations; for signed integer division, use 'sdiv'.<result> = sdiv <ty> <var1>, <var2> ; yields {ty}:result ++ <result> = sdiv <ty> <var1>, <var2> ; yields {ty}:result+Overview:
+The 'sdiv' instruction returns the quotient of its two operands.
+Arguments:
-The two arguments to the 'sdiv' instruction must be -integer values. Both arguments must have identical -types. This instruction can also take vector versions -of the values in which case the elements must be integers.
+ +The two arguments to the 'sdiv' instruction must be +integer or vector of integer +values. Both arguments must have identical types.
+Semantics:
The value produced is the signed integer quotient of the two operands rounded towards zero.
Note that signed integer division and unsigned integer division are distinct @@ -2239,22 +2287,31 @@ by doing a 32-bit division of -2147483648 by -1.
Instruction
<result> = fdiv <ty> <var1>, <var2> ; yields {ty}:result ++ <result> = fdiv <ty> <var1>, <var2> ; yields {ty}:resultOverview:
+The 'fdiv' instruction returns the quotient of its two operands.
+Arguments:
+The two arguments to the 'fdiv' instruction must be -floating point values. Both arguments must have -identical types. This instruction can also take vector -versions of floating point values.
+floating point or vector +of floating point values. Both arguments must have identical types. +Semantics:
+The value produced is the floating point quotient of the two operands.
+Example:
-<result> = fdiv float 4.0, %var ; yields {float}:result = 4.0 / %var + ++ <result> = fdiv float 4.0, %var ; yields {float}:result = 4.0 / %var
The 'urem' instruction returns the remainder from the unsigned division of its two arguments.
The two arguments to the 'urem' instruction must be -integer values. Both arguments must have identical -types. This instruction can also take vector versions -of the values in which case the elements must be integers.
+The two arguments to the 'urem' instruction must be +integer or vector of integer +values. Both arguments must have identical types.
This instruction returns the unsigned integer remainder of a division. This instruction always performs an unsigned division to get the remainder.
@@ -2282,23 +2338,33 @@ distinct operations; for signed integer remainder, use 'srem'. - + +<result> = srem <ty> <var1>, <var2> ; yields {ty}:result + ++ <result> = srem <ty> <var1>, <var2> ; yields {ty}:result+Overview:
+The 'srem' instruction returns the remainder from the signed division of its two operands. This instruction can also take vector versions of the values in which case the elements must be integers.
Arguments:
+The two arguments to the 'srem' instruction must be -integer values. Both arguments must have identical -types.
+integer or vector of integer +values. Both arguments must have identical types. +Semantics:
+This instruction returns the remainder of a division (where the result has the same sign as the dividend, var1), not the modulo operator (where the result has the same sign as the divisor, var2) of @@ -2321,9 +2387,11 @@ and the remainder.)
<result> = frem <ty> <var1>, <var2> ; yields {ty}:result@@ -2332,14 +2400,18 @@ Instruction
The two arguments to the 'frem' instruction must be -floating point values. Both arguments must have -identical types. This instruction can also take vector -versions of floating point values.
+floating point or vector +of floating point values. Both arguments must have identical types. +This instruction returns the remainder of a division. The remainder has the same sign as the dividend.
+<result> = frem float 4.0, %var ; yields {float}:result = 4.0 % %var + ++ <result> = frem float 4.0, %var ; yields {float}:result = 4.0 % %var@@ -2371,7 +2443,8 @@ the left a specified number of bits.Both arguments to the 'shl' instruction must be the same integer type. 'var2' is treated as an -unsigned value.
+unsigned value. This instruction does not support +vector operands.Semantics:
@@ -2401,7 +2474,8 @@ operand shifted to the right a specified number of bits with zero fill.Arguments:
Both arguments to the 'lshr' instruction must be the same integer type. 'var2' is treated as an -unsigned value.
+unsigned value. This instruction does not support +vector operands.Semantics:
@@ -2436,7 +2510,8 @@ operand shifted to the right a specified number of bits with sign extension.Arguments:
Both arguments to the 'ashr' instruction must be the same integer type. 'var2' is treated as an -unsigned value.
+unsigned value. This instruction does not support +vector operands.Semantics:
This instruction always performs an arithmetic shift right operation, @@ -2458,17 +2533,26 @@ larger than the number of bits in var1, the result is undefined.
++Syntax:
-<result> = and <ty> <var1>, <var2> ; yields {ty}:result + ++ <result> = and <ty> <var1>, <var2> ; yields {ty}:result+Overview:
+The 'and' instruction returns the bitwise logical and of its two operands.
+Arguments:
-The two arguments to the 'and' instruction must be integer values. Both arguments must have -identical types.
+ +The two arguments to the 'and' instruction must be +integer or vector of integer +values. Both arguments must have identical types.
+Semantics:
The truth table used for the 'and' instruction is:
@@ -2504,7 +2588,8 @@ identical types.
Example:
-<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@@ -2519,9 +2604,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:
@@ -2574,10 +2660,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:
@@ -3658,15 +3746,19 @@ nothing is done (no-op cast).@@ -3935,36 +4027,50 @@ condition codes are evaluated identically to theOverview:
+The 'bitcast' instruction converts value to type ty2 without changing any bits.
Arguments:
+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).Semantics:
The 'bitcast' instruction converts value to type @@ -3881,8 +3973,8 @@ instruction.
Example:
- <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> = 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 >Example:
- <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> = 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 >- + ++@@ -3991,13 +4097,16 @@ condition, without branching.Syntax:
+<result> = phi <ty> [ <val0>, <label0>], ...Overview:
The 'phi' instruction is used to implement the φ node in the SSA graph representing the function.
Arguments:
+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.
+Semantics:
+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.
+Example:
-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 +Arguments:
-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.
Semantics:
-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.