mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-08 04:53:42 +00:00
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:
committed by
Ron Evans
parent
0ddcf4af96
commit
08a51535d4
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user