-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Expand file tree
/
Copy pathirbuild-int.test
More file actions
251 lines (234 loc) · 3.88 KB
/
irbuild-int.test
File metadata and controls
251 lines (234 loc) · 3.88 KB
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
[case testIntNeq]
def f(x: int, y: int) -> bool:
return x != y
[out]
def f(x, y):
x, y :: int
r0 :: bit
L0:
r0 = int_ne x, y
return r0
[case testShortIntComparisons]
def f(x: int) -> int:
if x == 3:
return 1
elif x != 4:
return 2
elif 5 == x:
return 3
elif 6 != x:
return 4
elif x < 4:
return 5
return 6
[out]
def f(x):
x :: int
r0, r1, r2, r3, r4 :: bit
L0:
r0 = int_eq x, 6
if r0 goto L1 else goto L2 :: bool
L1:
return 2
L2:
r1 = int_ne x, 8
if r1 goto L3 else goto L4 :: bool
L3:
return 4
L4:
r2 = int_eq 10, x
if r2 goto L5 else goto L6 :: bool
L5:
return 6
L6:
r3 = int_ne 12, x
if r3 goto L7 else goto L8 :: bool
L7:
return 8
L8:
r4 = int_lt x, 8
if r4 goto L9 else goto L10 :: bool
L9:
return 10
L10:
L11:
L12:
L13:
L14:
return 12
[case testIntMin]
def f(x: int, y: int) -> int:
return min(x, y)
[out]
def f(x, y):
x, y :: int
r0 :: bit
r1 :: int
L0:
r0 = int_lt y, x
if r0 goto L1 else goto L2 :: bool
L1:
r1 = y
goto L3
L2:
r1 = x
L3:
return r1
[case testIntFloorDivideByPowerOfTwo]
def divby1(x: int) -> int:
return x // 1
def divby2(x: int) -> int:
return x // 2
def divby3(x: int) -> int:
return x // 3
def divby4(x: int) -> int:
return x // 4
def divby8(x: int) -> int:
return x // 8
[out]
def divby1(x):
x, r0 :: int
L0:
r0 = CPyTagged_FloorDivide(x, 2)
return r0
def divby2(x):
x, r0 :: int
L0:
r0 = CPyTagged_Rshift(x, 2)
return r0
def divby3(x):
x, r0 :: int
L0:
r0 = CPyTagged_FloorDivide(x, 6)
return r0
def divby4(x):
x, r0 :: int
L0:
r0 = CPyTagged_Rshift(x, 4)
return r0
def divby8(x):
x, r0 :: int
L0:
r0 = CPyTagged_Rshift(x, 6)
return r0
[case testFinalConstantFolding]
from typing import Final
X: Final = -1
Y: Final = -(1 + 3*2)
Z: Final = Y + 1
class C:
A: Final = 1
B: Final = -1
def f1() -> int:
return X
def f2() -> int:
return X + Y
def f3() -> int:
return Z
def f4() -> int:
return C.A
def f5() -> int:
return C.B
[out]
def C.__mypyc_defaults_setup(__mypyc_self__):
__mypyc_self__ :: __main__.C
L0:
__mypyc_self__.A = 2
__mypyc_self__.B = -2
return 1
def f1():
L0:
return -2
def f2():
L0:
return -16
def f3():
L0:
return -12
def f4():
L0:
return 2
def f5():
L0:
return -2
[case testConvertIntegralToInt]
def bool_to_int(b: bool) -> int:
return int(b)
def int_to_int(n: int) -> int:
return int(n)
[out]
def bool_to_int(b):
b, r0 :: bool
r1 :: int
L0:
r0 = b << 1
r1 = extend r0: builtins.bool to builtins.int
return r1
def int_to_int(n):
n :: int
L0:
return n
[case testIntUnaryOps]
def unary_minus(n: int) -> int:
x = -n
return x
def unary_plus(n: int) -> int:
x = +n
return x
def unary_invert(n: int) -> int:
x = ~n
return x
[out]
def unary_minus(n):
n, r0, x :: int
L0:
r0 = CPyTagged_Negate(n)
x = r0
return x
def unary_plus(n):
n, x :: int
L0:
x = n
return x
def unary_invert(n):
n, r0, x :: int
L0:
r0 = CPyTagged_Invert(n)
x = r0
return x
[case testIntToBytes]
def f(x: int) -> bytes:
return x.to_bytes(2, "big")
def g(x: int) -> bytes:
return x.to_bytes(4, "little", signed=True)
def h(x: int, byteorder: str) -> bytes:
return x.to_bytes(8, byteorder)
[out]
def f(x):
x :: int
r0 :: bytes
L0:
r0 = CPyTagged_ToBigEndianBytes(x, 2, 0)
return r0
def g(x):
x :: int
r0 :: bytes
L0:
r0 = CPyTagged_ToLittleEndianBytes(x, 4, 1)
return r0
def h(x, byteorder):
x :: int
byteorder :: str
r0 :: bytes
L0:
r0 = CPyTagged_ToBytes(x, 8, byteorder, 0)
return r0
[case testIntBitLength]
def f(x: int) -> int:
return x.bit_length()
[out]
def f(x):
x, r0 :: int
L0:
r0 = CPyTagged_BitLength(x)
return r0