interp: add support for constant icmp instructions

These instructions sometimes pop up in LLVM 15, but they never occured
in LLVM 14. Implementing them is relatively straightforward: simply
generalize the code that already exists for llvm.ICmp interpreting.
This commit is contained in:
Ayke van Laethem
2022-10-18 23:16:36 +00:00
committed by Ron Evans
parent 0ddcf4af96
commit 08a51535d4
4 changed files with 73 additions and 38 deletions
+15
View File
@@ -3,6 +3,7 @@ target triple = "x86_64--linux"
@intToPtrResult = global i8 0
@ptrToIntResult = global i8 0
@icmpResult = global i8 0
@someArray = internal global {i16, i8, i8} zeroinitializer
@someArrayPointer = global i8* zeroinitializer
@@ -15,6 +16,7 @@ define internal void @main.init() {
call void @testIntToPtr()
call void @testPtrToInt()
call void @testConstGEP()
call void @testICmp()
ret void
}
@@ -48,3 +50,16 @@ define internal void @testConstGEP() {
store i8* getelementptr inbounds (i8, i8* bitcast ({i16, i8, i8}* @someArray to i8*), i32 2), i8** @someArrayPointer
ret void
}
define internal void @testICmp() {
br i1 icmp eq (i64 ptrtoint (i8* @ptrToIntResult to i64), i64 0), label %equal, label %unequal
equal:
; should not be reached
store i8 1, i8* @icmpResult
ret void
unequal:
; should be reached
store i8 2, i8* @icmpResult
ret void
ret void
}