@@ -202,10 +202,10 @@ LLVM.Module("SomeModule", ctx) do mod
202
202
position! (builder, entry)
203
203
204
204
valueinst1 = add! (builder, parameters (fn)[1 ],
205
- ConstantInt (LLVM . Int32Type (ctx ), 1 ))
205
+ ConstantInt (Int32 ( 1 ), ctx ))
206
206
207
207
userinst = add! (builder, valueinst1,
208
- ConstantInt (LLVM . Int32Type (ctx ), 1 ))
208
+ ConstantInt (Int32 ( 1 ), ctx ))
209
209
210
210
# use iteration
211
211
let usepairs = uses (valueinst1)
@@ -224,7 +224,7 @@ LLVM.Module("SomeModule", ctx) do mod
224
224
end
225
225
226
226
valueinst2 = add! (builder, parameters (fn)[1 ],
227
- ConstantInt (LLVM . Int32Type (ctx ), 2 ))
227
+ ConstantInt (Int32 ( 2 ), ctx ))
228
228
229
229
replace_uses! (valueinst1, valueinst2)
230
230
@test user .(collect (uses (valueinst2))) == [userinst]
@@ -236,17 +236,31 @@ end
236
236
237
237
# scalar
238
238
Context () do ctx
239
- t1 = LLVM. Int32Type (ctx)
240
- c1 = ConstantInt (t1, UInt32 (1 ))
241
- @test convert (UInt, c1) == 1
242
- c2 = ConstantInt (t1, Int32 (- 1 ))
243
- @test convert (Int, c2) == - 1
244
-
245
- # construction from wider ints
246
- c3 = ConstantInt (t1, UInt (1 ))
247
- @test convert (UInt, c3) == 1
248
- c4 = ConstantInt (t1, - 1 )
249
- @test convert (Int, c4) == - 1
239
+ # # integer constants
240
+
241
+ # manual construction of small values
242
+ let
243
+ typ = LLVM. Int32Type (ctx)
244
+ constval = ConstantInt (typ, - 1 )
245
+ @test convert (Int, constval) == - 1
246
+ @test convert (UInt32, constval) == typemax (UInt32)
247
+ end
248
+
249
+ # manual construction of large values
250
+ let
251
+ typ = LLVM. Int64Type (ctx)
252
+ constval = ConstantInt (typ, BigInt (2 )^ 100 - 1 )
253
+ @test convert (Int, constval) == - 1
254
+ end
255
+
256
+ # automatic construction
257
+ let
258
+ constval = ConstantInt (UInt32 (1 ))
259
+ @test convert (UInt, constval) == 1
260
+ end
261
+
262
+
263
+ # # floating point constants
250
264
251
265
t2 = LLVM. DoubleType (ctx)
252
266
c = ConstantFP (t2, 1.1 )
@@ -295,7 +309,7 @@ LLVM.Module("SomeModule", ctx) do mod
295
309
show (DevNull, gv)
296
310
297
311
@test_throws NullException initializer (gv)
298
- init = ConstantInt (LLVM . Int32Type (), 0 )
312
+ init = ConstantInt (Int32 ( 0 ) )
299
313
initializer! (gv, init)
300
314
@test initializer (gv) == init
301
315
0 commit comments