integer constant program working up to ir

This commit is contained in:
water
2020-09-06 12:45:31 -04:00
parent 2b67b1078f
commit 8bf0bd86d3
20 changed files with 1142 additions and 34 deletions
+13 -2
View File
@@ -1,11 +1,16 @@
#include "Val.h"
#include "Env.h"
/*!
* Fallback to_gpr if a more optimized one is not provided.
*/
const RegVal* Val::to_gpr(FunctionEnv* fe) const {
(void)fe;
throw std::runtime_error("Val::to_gpr NYI"); // todo
auto rv = to_reg(fe);
if(rv->ireg().kind == emitter::RegKind::GPR) {
return rv;
} else {
throw std::runtime_error("Val::to_gpr NYI"); // todo
}
}
/*!
@@ -38,4 +43,10 @@ const RegVal * RegVal::to_xmm(FunctionEnv* fe) const {
} else {
throw std::runtime_error("RegVal::to_xmm NYI"); // todo
}
}
const RegVal * IntegerConstantVal::to_reg(FunctionEnv* fe) const {
auto rv = fe->make_gpr(m_ts);
fe->emit(std::make_unique<IR_LoadConstant64>(rv, m_value));
return rv;
}