github.com/tinygo-org/tinygo@v0.31.3-0.20240404173401-90b0bf646c27/interp/testdata/consteval.ll (about) 1 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" 2 target triple = "x86_64--linux" 3 4 @intToPtrResult = global i8 0 5 @ptrToIntResult = global i8 0 6 @icmpResult = global i8 0 7 @pointerTagResult = global i64 0 8 @someArray = internal global {i16, i8, i8} zeroinitializer 9 @someArrayPointer = global ptr zeroinitializer 10 11 define void @runtime.initAll() { 12 call void @main.init() 13 ret void 14 } 15 16 define internal void @main.init() { 17 call void @testIntToPtr() 18 call void @testPtrToInt() 19 call void @testConstGEP() 20 call void @testICmp() 21 call void @testPointerTag() 22 ret void 23 } 24 25 define internal void @testIntToPtr() { 26 %nil = icmp eq ptr inttoptr (i64 1024 to ptr), null 27 br i1 %nil, label %a, label %b 28 a: 29 ; should not be reached 30 store i8 1, ptr @intToPtrResult 31 ret void 32 b: 33 ; should be reached 34 store i8 2, ptr @intToPtrResult 35 ret void 36 } 37 38 define internal void @testPtrToInt() { 39 %zero = icmp eq i64 ptrtoint (ptr @ptrToIntResult to i64), 0 40 br i1 %zero, label %a, label %b 41 a: 42 ; should not be reached 43 store i8 1, ptr @ptrToIntResult 44 ret void 45 b: 46 ; should be reached 47 store i8 2, ptr @ptrToIntResult 48 ret void 49 } 50 51 define internal void @testConstGEP() { 52 store ptr getelementptr inbounds (i8, ptr @someArray, i32 2), ptr @someArrayPointer 53 ret void 54 } 55 56 define internal void @testICmp() { 57 br i1 icmp eq (i64 ptrtoint (ptr @ptrToIntResult to i64), i64 0), label %equal, label %unequal 58 equal: 59 ; should not be reached 60 store i8 1, ptr @icmpResult 61 ret void 62 unequal: 63 ; should be reached 64 store i8 2, ptr @icmpResult 65 ret void 66 ret void 67 } 68 69 define internal void @testPointerTag() { 70 %val = and i64 ptrtoint (ptr getelementptr inbounds (i8, ptr @someArray, i32 2) to i64), 3 71 store i64 %val, ptr @pointerTagResult 72 ret void 73 }