use ir::Type in Compiler::loadLocal

This commit is contained in:
Joshua Warner
2014-05-01 07:18:12 -06:00
committed by Joshua Warner
parent 53b68a693d
commit 85f114ea0f
3 changed files with 51 additions and 37 deletions

View File

@ -1214,9 +1214,27 @@ storeLocal(Context* c, unsigned footprint, Value* v, unsigned index, bool copy)
return v;
}
Value*
loadLocal(Context* c, unsigned footprint, unsigned index)
unsigned typeFootprint(Context* c, ir::Type type)
{
// TODO: this function is very Java-specific in nature. Generalize.
switch (type.flavor()) {
case ir::Type::Float:
case ir::Type::Integer:
return type.size() / 4;
case ir::Type::Object:
case ir::Type::Address:
case ir::Type::Half:
return 1;
case ir::Type::Void:
return 0;
default:
abort(c);
}
}
Value* loadLocal(Context* c, ir::Type type, unsigned index)
{
unsigned footprint = typeFootprint(c, type);
assert(c, index + footprint <= c->localFootprint);
if (footprint > 1) {
@ -2103,24 +2121,6 @@ class Client: public Assembler::Client {
Context* c;
};
unsigned typeFootprint(Context* c, ir::Type type)
{
// TODO: this function is very Java-specific in nature. Generalize.
switch (type.flavor()) {
case ir::Type::Float:
case ir::Type::Integer:
return type.size() / 4;
case ir::Type::Object:
case ir::Type::Address:
case ir::Type::Half:
return 1;
case ir::Type::Void:
return 0;
default:
abort(c);
}
}
class MyCompiler: public Compiler {
public:
MyCompiler(System* s, Assembler* assembler, Zone* zone,
@ -2593,8 +2593,9 @@ class MyCompiler: public Compiler {
compiler::storeLocal(&c, footprint, static_cast<Value*>(src), index, true);
}
virtual Operand* loadLocal(unsigned footprint, unsigned index) {
return compiler::loadLocal(&c, footprint, index);
virtual Operand* loadLocal(ir::Type type, unsigned index)
{
return compiler::loadLocal(&c, type, index);
}
virtual void saveLocals() {