|
4 | 4 | ft = LLVM.FunctionType(LLVM.VoidType(ctx), [LLVM.Int32Type(ctx), LLVM.Int32Type(ctx),
|
5 | 5 | LLVM.FloatType(ctx), LLVM.FloatType(ctx),
|
6 | 6 | LLVM.PointerType(LLVM.Int32Type(ctx)),
|
7 |
| - LLVM.PointerType(LLVM.Int32Type(ctx))]) |
| 7 | + LLVM.PointerType(LLVM.Int32Type(ctx)), |
| 8 | + LLVM.PointerType(LLVM.Int8Type(ctx))]) |
8 | 9 | fn = LLVM.Function(mod, "SomeFunction", ft)
|
9 | 10 |
|
10 | 11 | entrybb = BasicBlock(fn, "entry"; ctx)
|
|
16 | 17 | debuglocation!(builder, loc)
|
17 | 18 | @test debuglocation(builder) == loc
|
18 | 19 | debuglocation!(builder)
|
19 |
| - @test debuglocation(builder) == nothing |
| 20 | + @test debuglocation(builder) === nothing |
20 | 21 |
|
21 | 22 | retinst1 = ret!(builder)
|
22 | 23 | @check_ir retinst1 "ret void"
|
|
134 | 135 | array_allocainst = array_alloca!(builder, LLVM.Int32Type(ctx), int1)
|
135 | 136 | @check_ir array_allocainst "alloca i32, i32 %0"
|
136 | 137 |
|
137 |
| - # mallocinst = malloc!(builder, LLVM.Int32Type(ctx)) |
138 |
| - # @check_ir mallocinst "bitcast i8* %malloccall to i32*" |
| 138 | + mallocinst = malloc!(builder, LLVM.Int32Type(ctx)) |
| 139 | + @check_ir mallocinst r"bitcast i8\* %.+ to i32\*" |
| 140 | + @check_ir operands(mallocinst)[1] r"call i8\* @malloc\(.+\)" |
| 141 | + |
| 142 | + i8ptr = parameters(fn)[6] |
| 143 | + |
| 144 | + array_mallocinst = array_malloc!(builder, LLVM.Int8Type(ctx), ConstantInt(Int32(42); ctx)) |
| 145 | + @check_ir array_mallocinst r"call i8\* @malloc\(.+, i32 42\)" |
| 146 | + |
| 147 | + memsetisnt = memset!(builder, i8ptr, ConstantInt(Int8(1); ctx), ConstantInt(Int32(2); ctx), 4) |
| 148 | + @check_ir memsetisnt r"call void @llvm.memset.p0i8.i32\(i8\* align 4 %.+, i8 1, i32 2, i1 false\)" |
| 149 | + |
| 150 | + memcpyinst = memcpy!(builder, allocainst, 4, i8ptr, 8, ConstantInt(Int32(32); ctx)) |
| 151 | + @check_ir memcpyinst r"call void @llvm.memcpy.p0i8.p0i8.i32\(i8\* align 4 %.+, i8\* align 8 %.+, i32 32, i1 false\)" |
| 152 | + |
| 153 | + memmoveinst = memmove!(builder, allocainst, 4, i8ptr, 8, ConstantInt(Int32(32); ctx)) |
| 154 | + @check_ir memmoveinst r"call void @llvm.memmove.p0i8.p0i8.i32\(i8\* align 4 %.+, i8\* align 8 %.+, i32 32, i1 false\)" |
139 | 155 |
|
140 |
| - ptr1 = parameters(fn)[5] |
| 156 | + i32ptr1 = parameters(fn)[5] |
141 | 157 |
|
142 |
| - freeinst = free!(builder, ptr1) |
| 158 | + freeinst = free!(builder, i32ptr1) |
143 | 159 | @check_ir freeinst "tail call void @free"
|
144 | 160 |
|
145 |
| - loadinst = load!(builder, ptr1) |
| 161 | + loadinst = load!(builder, i32ptr1) |
146 | 162 | @check_ir loadinst "load i32, i32* %4"
|
147 | 163 | alignment!(loadinst, 4)
|
148 | 164 | @test alignment(loadinst) == 4
|
|
151 | 167 | @check_ir loadinst "load atomic i32, i32* %4 seq_cst"
|
152 | 168 | @test ordering(loadinst) == LLVM.API.LLVMAtomicOrderingSequentiallyConsistent
|
153 | 169 |
|
154 |
| - storeinst = store!(builder, int1, ptr1) |
| 170 | + storeinst = store!(builder, int1, i32ptr1) |
155 | 171 | @check_ir storeinst "store i32 %0, i32* %4"
|
156 | 172 |
|
157 | 173 | fenceinst = fence!(builder, LLVM.API.LLVMAtomicOrderingNotAtomic)
|
158 | 174 | @check_ir fenceinst "fence"
|
159 | 175 |
|
160 |
| - gepinst = gep!(builder, ptr1, [int1]) |
| 176 | + gepinst = gep!(builder, i32ptr1, [int1]) |
161 | 177 | @check_ir gepinst "getelementptr i32, i32* %4, i32 %0"
|
162 | 178 |
|
163 |
| - gepinst1 = inbounds_gep!(builder, ptr1, [int1]) |
| 179 | + gepinst1 = inbounds_gep!(builder, i32ptr1, [int1]) |
164 | 180 | @check_ir gepinst1 "getelementptr inbounds i32, i32* %4, i32 %0"
|
165 | 181 |
|
166 | 182 | truncinst = trunc!(builder, int1, LLVM.Int16Type(ctx))
|
|
190 | 206 | fpextinst = fpext!(builder, float1, LLVM.DoubleType(ctx))
|
191 | 207 | @check_ir fpextinst "fpext float %2 to double"
|
192 | 208 |
|
193 |
| - ptrtointinst = ptrtoint!(builder, ptr1, LLVM.Int32Type(ctx)) |
| 209 | + ptrtointinst = ptrtoint!(builder, i32ptr1, LLVM.Int32Type(ctx)) |
194 | 210 | @check_ir ptrtointinst "ptrtoint i32* %4 to i32"
|
195 | 211 |
|
196 | 212 | inttoptrinst = inttoptr!(builder, int1, LLVM.PointerType(LLVM.Int32Type(ctx)))
|
|
199 | 215 | bitcastinst = bitcast!(builder, int1, LLVM.FloatType(ctx))
|
200 | 216 | @check_ir bitcastinst "bitcast i32 %0 to float"
|
201 | 217 |
|
202 |
| - ptr1typ = llvmtype(ptr1) |
203 |
| - ptr2typ = LLVM.PointerType(ptr1typ, 2) |
| 218 | + i32ptr1typ = llvmtype(i32ptr1) |
| 219 | + i32ptr1typ2 = LLVM.PointerType(eltype(i32ptr1typ), 2) |
204 | 220 |
|
205 |
| - addrspacecastinst = addrspacecast!(builder, ptr1, ptr2typ) |
206 |
| - @check_ir addrspacecastinst "addrspacecast i32* %4 to i32* addrspace(2)*" |
| 221 | + addrspacecastinst = addrspacecast!(builder, i32ptr1, i32ptr1typ2) |
| 222 | + @check_ir addrspacecastinst "addrspacecast i32* %4 to i32 addrspace(2)*" |
207 | 223 |
|
208 | 224 | zextorbitcastinst = zextorbitcast!(builder, int1, LLVM.FloatType(ctx))
|
209 | 225 | @check_ir zextorbitcastinst "bitcast i32 %0 to float"
|
|
217 | 233 | castinst = cast!(builder, LLVM.API.LLVMBitCast, int1, LLVM.FloatType(ctx))
|
218 | 234 | @check_ir castinst "bitcast i32 %0 to float"
|
219 | 235 |
|
220 |
| - ptr3typ = LLVM.PointerType(LLVM.FloatType(ctx)) |
| 236 | + floatptrtyp = LLVM.PointerType(LLVM.FloatType(ctx)) |
221 | 237 |
|
222 |
| - pointercastinst = pointercast!(builder, ptr1, ptr3typ) |
| 238 | + pointercastinst = pointercast!(builder, i32ptr1, floatptrtyp) |
223 | 239 | @check_ir pointercastinst "bitcast i32* %4 to float*"
|
224 | 240 |
|
225 | 241 | intcastinst = intcast!(builder, int1, LLVM.Int64Type(ctx))
|
|
272 | 288 | isnotnullinst = isnotnull!(builder, int1)
|
273 | 289 | @check_ir isnotnullinst "icmp ne i32 %0, 0"
|
274 | 290 |
|
275 |
| - ptr2 = parameters(fn)[6] |
| 291 | + i32ptr2 = parameters(fn)[6] |
276 | 292 |
|
277 |
| - ptrdiffinst = ptrdiff!(builder, ptr1, ptr2) |
278 |
| - @check_ir ptrdiffinst "sdiv exact i64 %71, ptrtoint (i32* getelementptr (i32, i32* null, i32 1) to i64)" |
| 293 | + ptrdiffinst = ptrdiff!(builder, i32ptr1, i32ptr2) |
| 294 | + @check_ir ptrdiffinst r"sdiv exact i64 %.+, ptrtoint \(i32\* getelementptr \(i32, i32\* null, i32 1\) to i64\)" |
279 | 295 |
|
280 | 296 | position!(builder)
|
281 | 297 | end
|
|
0 commit comments