diff --git a/docs/LangRef.html b/docs/LangRef.html index a3a0285a48f..7b8c6c7e7b8 100644 --- a/docs/LangRef.html +++ b/docs/LangRef.html @@ -748,40 +748,61 @@ control flows to the 'iffalse' label argument.

href="#i_ret">ret int 1
IfUnequal:
ret int 0
-
'switch' -Instruction
+
+ 'switch' Instruction +
+
Syntax:
-
  switch uint <value>, label <defaultdest> [ int <val>, label <dest>, ... ]
+ +
+  switch <intty> <value>, label <defaultdest> [ <intty> <val>, label <dest> ... ]
+
+
Overview:
-

The 'switch' instruction is used to transfer control flow -to one of several different places. It is a generalization of the 'br' + +

The 'switch' instruction is used to transfer control flow to one of +several different places. It is a generalization of the 'br' instruction, allowing a branch to occur to one of many possible destinations.

+ +
Arguments:
-

The 'switch' instruction uses three parameters: a 'uint' -comparison value 'value', a default 'label' -destination, and an array of pairs of comparison value constants and 'label's.

+ +

The 'switch' instruction uses three parameters: an integer +comparison value 'value', a default 'label' destination, and +an array of pairs of comparison value constants and 'label's. The +table is not allowed to contain duplicate constant entries.

+
Semantics:
+

The switch instruction specifies a table of values and destinations. When the 'switch' instruction is executed, this table is searched for the given value. If the value is found, the corresponding destination is branched to, otherwise the default value it transfered to.

-
Implementation:
-

Depending on properties of the target machine and the particular switch -instruction, this instruction may be code generated as a series of -chained conditional branches, or with a lookup table.

-
Example:
-
  ; Emulate a conditional br instruction
-  %Val = cast bool %value to uint
switch uint %Val, label %truedest [int 0, label %falsedest ]

; Emulate an unconditional br instruction - switch uint 0, label %dest [ ] - ; Implement a jump table: - switch uint %val, label %otherwise [ int 0, label %onzero, - int 1, label %onone, - int 2, label %ontwo ] +
Implementation:
+ +

Depending on properties of the target machine and the particular +switch instruction, this instruction may be code generated in different +ways, for example as a series of chained conditional branches, or with a lookup +table.

+ +
Example:
+ +
+ ; Emulate a conditional br instruction
+ %Val = cast bool %value to int
+ switch int %Val, label %truedest [int 0, label %falsedest ]
+
+ ; Emulate an unconditional br instruction
+ switch uint 0, label %dest [ ]
+
+ ; Implement a jump table:
+ switch uint %val, label %otherwise [ uint 0, label %onzero 
+                                      uint 1, label %onone 
+                                      uint 2, label %ontwo ]