9
9
FLOAT = ir .FloatType ()
10
10
INT_CAT = ir .IntType (bits = 32 )
11
11
INT = ir .IntType (bits = 32 )
12
+ LONG = ir .IntType (bits = 64 )
12
13
ZERO_V = ir .Constant (BOOL , 0 )
13
14
FLOAT_POINTER = ir .PointerType (FLOAT )
14
15
DOUBLE_PTR = ir .PointerType (DOUBLE )
@@ -18,6 +19,10 @@ def iconst(value):
18
19
return ir .Constant (INT , value )
19
20
20
21
22
+ def lconst (value ):
23
+ return ir .Constant (LONG , value )
24
+
25
+
21
26
def fconst (value ):
22
27
return ir .Constant (FLOAT , value )
23
28
@@ -168,7 +173,9 @@ def _populate_instruction_block(
168
173
169
174
# -- SETUP BLOCK
170
175
builder = ir .IRBuilder (setup_block )
171
- loop_iter = builder .alloca (INT , 1 , "loop-idx" )
176
+ start_index = builder .zext (start_index , LONG )
177
+ end_index = builder .zext (end_index , LONG )
178
+ loop_iter = builder .alloca (LONG , 1 , "loop-idx" )
172
179
builder .store (start_index , loop_iter )
173
180
condition_block = root_func .append_basic_block ("loop-condition" )
174
181
builder .branch (condition_block )
@@ -187,9 +194,9 @@ def _populate_instruction_block(
187
194
args = []
188
195
loop_iter_reg = builder .load (loop_iter )
189
196
190
- n_args = ir .Constant (INT , forest .n_args )
197
+ n_args = ir .Constant (LONG , forest .n_args )
191
198
iter_mul_nargs = builder .mul (loop_iter_reg , n_args )
192
- idx = (builder .add (iter_mul_nargs , iconst (i )) for i in range (forest .n_args ))
199
+ idx = (builder .add (iter_mul_nargs , lconst (i )) for i in range (forest .n_args ))
193
200
raw_ptrs = [builder .gep (root_func .args [0 ], (c ,)) for c in idx ]
194
201
# cast the categorical inputs to integer
195
202
for feature , ptr in zip (forest .features , raw_ptrs ):
@@ -203,9 +210,9 @@ def _populate_instruction_block(
203
210
for func in tree_funcs :
204
211
tree_res = builder .call (func .llvm_function , args )
205
212
results [func .class_id ] = builder .fadd (tree_res , results [func .class_id ])
206
- res_idx = builder .mul (iconst (forest .n_classes ), loop_iter_reg )
213
+ res_idx = builder .mul (lconst (forest .n_classes ), loop_iter_reg )
207
214
results_ptr = [
208
- builder .gep (out_arr , (builder .add (res_idx , iconst (class_idx )),))
215
+ builder .gep (out_arr , (builder .add (res_idx , lconst (class_idx )),))
209
216
for class_idx in range (forest .n_classes )
210
217
]
211
218
@@ -224,8 +231,7 @@ def _populate_instruction_block(
224
231
for result , result_ptr in zip (results , results_ptr ):
225
232
builder .store (result , result_ptr )
226
233
227
- tmpp1 = builder .add (loop_iter_reg , iconst (1 ))
228
- builder .store (tmpp1 , loop_iter )
234
+ builder .store (builder .add (loop_iter_reg , lconst (1 )), loop_iter )
229
235
builder .branch (condition_block )
230
236
# -- END CORE LOOP BLOCK
231
237
0 commit comments