-
Notifications
You must be signed in to change notification settings - Fork 3
/
clif-instructions.txt
201 lines (136 loc) · 4.65 KB
/
clif-instructions.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
=============================================
Cranelift Instructions
=============================================
1. icmp
====== ======== =========
Signed Unsigned Condition
====== ======== =========
eq eq Equal
ne ne Not equal
slt ult Less than
sge uge Greater than or equal
sgt ugt Greater than
sle ule Less than or equal
====== ======== =========
2. icmp_imm
3. iadd
Wrapping integer addition: `a := x + y \pmod{2^B}`.
4. isub
Wrapping integer subtraction: `a := x - y \pmod{2^B}`.
5. imul
6. udiv
Unsigned integer division: `a := \lfloor {x \over y} \rfloor`
This operation traps if the divisor is zero.
7. sdiv
Signed integer division rounded toward zero: `a := sign(xy)
\lfloor {|x| \over |y|}\rfloor`.
This operation traps if the divisor is zero, or if the result is not
representable in `B` bits two's complement. This only happens
when `x = -2^{B-1}, y = -1`.
8. urem
This operation traps if the divisor is zero.
9. srem
Signed integer remainder. The result has the sign of the dividend.
This operation traps if the divisor is zero.
10. iadd_imm
11. imul_imm
12. udiv_imm
13. irsub_imm
Immediate reverse wrapping subtraction: `a := Y - x \pmod{2^B}`.
Also works as integer negation when `Y = 0`. Use `iadd_imm`
with a negative immediate operand for the reverse immediate
subtraction.
14. iadd_cin
Adds integers with carry input.
a = x + y + c_{in} \pmod 2^B
15. iadd_cout
Adds integers with carry out.
a &= x + y \pmod 2^B \\
c_{out} &= x+y >= 2^B
16. iadd_carry
Adds integers with carry input and output.
a &= x + y + c_{in} \pmod 2^B \\
c_{out} &= x + y + c_{in} >= 2^B
17. isub_bin
subtract integers with borrow-in flag
a = x - (y + b_{in}) \pmod 2^B
18. isub_bout
a &= x - y \pmod 2^B \\
b_{out} &= x < y
19. isub_borrow
a &= x - (y + b_{in}) \pmod 2^B \\
b_{out} &= x < y + b_{in}
20. band
21. bor
22. bxor
23. bnot
24. bor_not
Computes `x | ~y`
25. bxor_not
Computes `x ^ ~y`
26. band_imm
27. bor_imm
28. bxor_imm
29. rotl
rotate left
30. rotr
31. rotl+imm
32. rotl+imm
33. ishl
Integer shift left. Shift the bits in ``x`` towards the MSB by ``y``
places. Shift in zero bits to the LSB.
The shift amount is masked to the size of ``x``.
When shifting a B-bits integer type, this instruction computes:
s &:= y \pmod B,
a &:= x \cdot 2^s \pmod{2^B}.
34.ushr
Unsigned shift right. Shift bits in ``x`` towards the LSB by ``y``
places, shifting in zero bits to the MSB. Also called a *logical
shift*.
The shift amount is masked to the size of the register.
When shifting a B-bits integer type, this instruction computes:
s &:= y \pmod B,
a &:= \lfloor x \cdot 2^{-s} \rfloor.
35. sshr
Signed shift right. Shift bits in ``x`` towards the LSB by ``y``
places, shifting in sign bits to the MSB. Also called an *arithmetic
shift*.
The shift amount is masked to the size of the register.
36. ishl_imm
37. ushr_imm
The shift amount is masked to the size of the register.
Is it right? register?
38. sshr_imm
39. bitrev
40. clz
Count leading zero bits.
Starting from the MSB in ``x``, count the number of zero bits before
reaching the first one bit. When ``x`` is zero, returns the size of x
in bits.
41. cls
Count leading sign bits.
Starting from the MSB after the sign bit in ``x``, count the number of
consecutive bits identical to the sign bit. When ``x`` is 0 or -1,
returns one less than the size of x in bits.
42. ctz
Count trailing zeros.
Starting from the LSB in ``x``, count the number of zero bits before
reaching the first one bit. When ``x`` is zero, returns the size of x
in bits.
43. popcnt
count number of one bits in X.
44. ireduce
Convert `x` to a smaller integer type by dropping high bits.
Each lane in `x` is converted to a smaller integer type by discarding
the most significant bits. This is the same as reducing modulo
`2^n`.
45. uextend
Convert `x` to a larger integer type by zero-extending.
Each lane in `x` is converted to a larger integer type by adding
zeroes. The result has the same numerical value as `x` when both are
interpreted as unsigned integers.
46. sextend
Convert `x` to a larger integer type by sign-extending.
Each lane in `x` is converted to a larger integer type by replicating
the sign bit. The result has the same numerical value as `x` when both
are interpreted as signed integers.