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
+11
View File
@@ -1031,6 +1031,17 @@ func (v *rawValue) set(llvmValue llvm.Value, r *runner) {
for i := uint32(0); i < ptrSize; i++ {
v.buf[i] = ptrValue.pointer
}
case llvm.ICmp:
size := r.targetData.TypeAllocSize(llvmValue.Operand(0).Type())
lhs := newRawValue(uint32(size))
rhs := newRawValue(uint32(size))
lhs.set(llvmValue.Operand(0), r)
rhs.set(llvmValue.Operand(1), r)
if r.interpretICmp(lhs, rhs, llvmValue.IntPredicate()) {
v.buf[0] = 1 // result is true
} else {
v.buf[0] = 0 // result is false
}
default:
llvmValue.Dump()
println()