merge add
This commit is contained in:
45
qbe_emit.cm
45
qbe_emit.cm
@@ -277,6 +277,51 @@ var qbe_emit = function(ir, qbe) {
|
||||
continue
|
||||
}
|
||||
|
||||
// --- Generic arithmetic (VM dispatches int/float) ---
|
||||
|
||||
if (op == "add") {
|
||||
p = fresh()
|
||||
emit(qbe.add(p, "%ctx", s(a2), s(a3)))
|
||||
emit(` ${s(a1)} =l copy %${p}`)
|
||||
wb(a1)
|
||||
continue
|
||||
}
|
||||
if (op == "subtract") {
|
||||
p = fresh()
|
||||
emit(qbe.sub(p, "%ctx", s(a2), s(a3)))
|
||||
emit(` ${s(a1)} =l copy %${p}`)
|
||||
wb(a1)
|
||||
continue
|
||||
}
|
||||
if (op == "multiply") {
|
||||
p = fresh()
|
||||
emit(qbe.mul(p, "%ctx", s(a2), s(a3)))
|
||||
emit(` ${s(a1)} =l copy %${p}`)
|
||||
wb(a1)
|
||||
continue
|
||||
}
|
||||
if (op == "divide") {
|
||||
p = fresh()
|
||||
emit(qbe.div(p, "%ctx", s(a2), s(a3)))
|
||||
emit(` ${s(a1)} =l copy %${p}`)
|
||||
wb(a1)
|
||||
continue
|
||||
}
|
||||
if (op == "modulo") {
|
||||
p = fresh()
|
||||
emit(qbe.mod(p, "%ctx", s(a2), s(a3)))
|
||||
emit(` ${s(a1)} =l copy %${p}`)
|
||||
wb(a1)
|
||||
continue
|
||||
}
|
||||
if (op == "negate") {
|
||||
p = fresh()
|
||||
emit(qbe.neg(p, "%ctx", s(a2)))
|
||||
emit(` ${s(a1)} =l copy %${p}`)
|
||||
wb(a1)
|
||||
continue
|
||||
}
|
||||
|
||||
// --- String concat ---
|
||||
|
||||
if (op == "concat") {
|
||||
|
||||
Reference in New Issue
Block a user