use ir::Type in place of Compiler::OperandType

This commit is contained in:
Joshua Warner 2014-04-30 21:54:52 -06:00 committed by Joshua Warner
parent d8914a9646
commit 704c05f818
4 changed files with 802 additions and 651 deletions

View File

@ -34,20 +34,12 @@ class Compiler {
virtual intptr_t getThunk(lir::TernaryOperation op, unsigned size, virtual intptr_t getThunk(lir::TernaryOperation op, unsigned size,
unsigned resultSize, bool* threadParameter) = 0; unsigned resultSize, bool* threadParameter) = 0;
}; };
static const unsigned Aligned = 1 << 0; static const unsigned Aligned = 1 << 0;
static const unsigned NoReturn = 1 << 1; static const unsigned NoReturn = 1 << 1;
static const unsigned TailJump = 1 << 2; static const unsigned TailJump = 1 << 2;
static const unsigned LongJumpOrCall = 1 << 3; static const unsigned LongJumpOrCall = 1 << 3;
enum OperandType {
ObjectType,
AddressType,
IntegerType,
FloatType,
VoidType
};
class Operand { }; class Operand { };
class State { }; class State { };
class Subroutine { }; class Subroutine { };
@ -71,11 +63,11 @@ class Compiler {
virtual Promise* poolAppend(intptr_t value) = 0; virtual Promise* poolAppend(intptr_t value) = 0;
virtual Promise* poolAppendPromise(Promise* value) = 0; virtual Promise* poolAppendPromise(Promise* value) = 0;
virtual Operand* constant(int64_t value, OperandType type) = 0; virtual Operand* constant(int64_t value, ir::Type type) = 0;
virtual Operand* promiseConstant(Promise* value, OperandType type) = 0; virtual Operand* promiseConstant(Promise* value, ir::Type type) = 0;
virtual Operand* address(Promise* address) = 0; virtual Operand* address(Promise* address) = 0;
virtual Operand* memory(Operand* base, virtual Operand* memory(Operand* base,
OperandType type, ir::Type type,
int displacement = 0, int displacement = 0,
Operand* index = 0, Operand* index = 0,
unsigned scale = 1) = 0; unsigned scale = 1) = 0;
@ -94,7 +86,7 @@ class Compiler {
unsigned flags, unsigned flags,
TraceHandler* traceHandler, TraceHandler* traceHandler,
unsigned resultSize, unsigned resultSize,
OperandType resultType, ir::Type resultType,
unsigned argumentCount, unsigned argumentCount,
...) = 0; ...) = 0;
@ -102,7 +94,7 @@ class Compiler {
unsigned flags, unsigned flags,
TraceHandler* traceHandler, TraceHandler* traceHandler,
unsigned resultSize, unsigned resultSize,
OperandType resultType, ir::Type resultType,
unsigned argumentFootprint) = 0; unsigned argumentFootprint) = 0;
virtual void return_(ir::Type type, Operand* value) = 0; virtual void return_(ir::Type type, Operand* value) = 0;

View File

@ -30,6 +30,10 @@ class Type {
// (double/long on 32-bit systems) // (double/long on 32-bit systems)
// TODO: remove when possible // TODO: remove when possible
Half, Half,
// Represents the lack of a return value
// TODO: remove when possible
Void
}; };
private: private:
@ -91,6 +95,10 @@ class Types {
// A 8-byte floating point type // A 8-byte floating point type
Type f8; Type f8;
// A type representing the lack of a return value
// TODO: remove when possible
Type void_;
Types(unsigned bytesPerWord) Types(unsigned bytesPerWord)
: object(Type::Object, bytesPerWord), : object(Type::Object, bytesPerWord),
address(Type::Integer, bytesPerWord), address(Type::Integer, bytesPerWord),
@ -99,7 +107,8 @@ class Types {
i4(Type::Integer, 4), i4(Type::Integer, 4),
i8(Type::Integer, 8), i8(Type::Integer, 8),
f4(Type::Float, 4), f4(Type::Float, 4),
f8(Type::Float, 8) f8(Type::Float, 8),
void_(Type::Void, 0)
{ {
} }
}; };

View File

@ -156,7 +156,7 @@ popRead(Context* c, Event* e UNUSED, Value* v)
if (valid(nextWord->reads)) { if (valid(nextWord->reads)) {
deadWord(c, v); deadWord(c, v);
} else { } else {
deadWord(c, nextWord); deadWord(c, nextWord);
} }
} }
@ -186,22 +186,6 @@ addBuddy(Value* original, Value* buddy)
} }
} }
lir::ValueType
valueType(Context* c, Compiler::OperandType type)
{
switch (type) {
case Compiler::ObjectType:
case Compiler::AddressType:
case Compiler::IntegerType:
case Compiler::VoidType:
return lir::ValueGeneral;
case Compiler::FloatType:
return lir::ValueFloat;
default:
abort(c);
}
}
void void
move(Context* c, Value* value, Site* src, Site* dst); move(Context* c, Value* value, Site* src, Site* dst);
@ -2121,6 +2105,8 @@ unsigned typeFootprint(Context* c, ir::Type type)
case ir::Type::Address: case ir::Type::Address:
case ir::Type::Half: case ir::Type::Half:
return 1; return 1;
case ir::Type::Void:
return 0;
default: default:
abort(c); abort(c);
} }
@ -2306,13 +2292,14 @@ class MyCompiler: public Compiler {
return p; return p;
} }
virtual Operand* constant(int64_t value, Compiler::OperandType type) { virtual Operand* constant(int64_t value, ir::Type type)
{
return promiseConstant(resolvedPromise(&c, value), type); return promiseConstant(resolvedPromise(&c, value), type);
} }
virtual Operand* promiseConstant(Promise* value, Compiler::OperandType type) { virtual Operand* promiseConstant(Promise* value, ir::Type type)
return compiler::value {
(&c, valueType(&c, type), compiler::constantSite(&c, value)); return compiler::value(&c, type, compiler::constantSite(&c, value));
} }
virtual Operand* address(Promise* address) { virtual Operand* address(Promise* address) {
@ -2320,12 +2307,12 @@ class MyCompiler: public Compiler {
} }
virtual Operand* memory(Operand* base, virtual Operand* memory(Operand* base,
OperandType type, ir::Type type,
int displacement = 0, int displacement = 0,
Operand* index = 0, Operand* index = 0,
unsigned scale = 1) unsigned scale = 1)
{ {
Value* result = value(&c, valueType(&c, type)); Value* result = value(&c, type);
appendMemory(&c, static_cast<Value*>(base), displacement, appendMemory(&c, static_cast<Value*>(base), displacement,
static_cast<Value*>(index), scale, result); static_cast<Value*>(index), scale, result);
@ -2441,7 +2428,7 @@ class MyCompiler: public Compiler {
unsigned flags, unsigned flags,
TraceHandler* traceHandler, TraceHandler* traceHandler,
unsigned resultSize, unsigned resultSize,
OperandType resultType, ir::Type resultType,
unsigned argumentCount, unsigned argumentCount,
...) ...)
{ {
@ -2479,7 +2466,7 @@ class MyCompiler: public Compiler {
(&c, RUNTIME_ARRAY_BODY(arguments)[i], argumentStack); (&c, RUNTIME_ARRAY_BODY(arguments)[i], argumentStack);
} }
Value* result = value(&c, valueType(&c, resultType)); Value* result = value(&c, resultType);
appendCall(&c, static_cast<Value*>(address), flags, traceHandler, result, appendCall(&c, static_cast<Value*>(address), flags, traceHandler, result,
resultSize, argumentStack, index, 0); resultSize, argumentStack, index, 0);
@ -2490,10 +2477,10 @@ class MyCompiler: public Compiler {
unsigned flags, unsigned flags,
TraceHandler* traceHandler, TraceHandler* traceHandler,
unsigned resultSize, unsigned resultSize,
OperandType resultType, ir::Type resultType,
unsigned argumentFootprint) unsigned argumentFootprint)
{ {
Value* result = value(&c, valueType(&c, resultType)); Value* result = value(&c, resultType);
appendCall(&c, static_cast<Value*>(address), flags, traceHandler, result, appendCall(&c, static_cast<Value*>(address), flags, traceHandler, result,
resultSize, c.stack, 0, argumentFootprint); resultSize, c.stack, 0, argumentFootprint);
return result; return result;

File diff suppressed because it is too large Load Diff