diff --git a/include/avian/codegen/architecture.h b/include/avian/codegen/architecture.h index 756a67012c..eabe7542dd 100644 --- a/include/avian/codegen/architecture.h +++ b/include/avian/codegen/architecture.h @@ -85,7 +85,7 @@ class Architecture { virtual bool argumentAlignment() = 0; virtual bool argumentRegisterAlignment() = 0; virtual unsigned argumentRegisterCount() = 0; - virtual int argumentRegister(unsigned index) = 0; + virtual Register argumentRegister(unsigned index) = 0; virtual bool hasLinkRegister() = 0; diff --git a/include/avian/codegen/assembler.h b/include/avian/codegen/assembler.h index a233fa82bf..06179aa777 100644 --- a/include/avian/codegen/assembler.h +++ b/include/avian/codegen/assembler.h @@ -53,10 +53,10 @@ class Assembler { public: class Client { public: - virtual int acquireTemporary(RegisterMask mask = ~static_cast(0)) = 0; - virtual void releaseTemporary(int r) = 0; + virtual Register acquireTemporary(RegisterMask mask = ~static_cast(0)) = 0; + virtual void releaseTemporary(Register r) = 0; - virtual void save(int r) = 0; + virtual void save(Register r) = 0; }; class Block { diff --git a/include/avian/codegen/registers.h b/include/avian/codegen/registers.h index 0ddbf6e7dd..19261f0f23 100644 --- a/include/avian/codegen/registers.h +++ b/include/avian/codegen/registers.h @@ -17,6 +17,7 @@ namespace avian { namespace codegen { typedef uint64_t RegisterMask; +typedef int Register; class BoundedRegisterMask { public: @@ -62,7 +63,7 @@ class RegisterIterator { return index < mask.limit; } - inline int next() + inline Register next() { int r = index; do { diff --git a/src/codegen/compiler.cpp b/src/codegen/compiler.cpp index d4f05b4f8e..32047d52fc 100644 --- a/src/codegen/compiler.cpp +++ b/src/codegen/compiler.cpp @@ -2210,22 +2210,22 @@ class Client : public Assembler::Client { { } - virtual int acquireTemporary(RegisterMask mask) + virtual Register acquireTemporary(RegisterMask mask) { unsigned cost; - int r = pickRegisterTarget(c, 0, mask, &cost); + Register r = pickRegisterTarget(c, 0, mask, &cost); expect(c, cost < Target::Impossible); save(r); c->registerResources[r].increment(c); return r; } - virtual void releaseTemporary(int r) + virtual void releaseTemporary(Register r) { c->registerResources[r].decrement(c); } - virtual void save(int r) + virtual void save(Register r) { RegisterResource* reg = c->registerResources + r; diff --git a/src/codegen/compiler/event.cpp b/src/codegen/compiler/event.cpp index e2312db18f..789d470f44 100644 --- a/src/codegen/compiler/event.cpp +++ b/src/codegen/compiler/event.cpp @@ -396,7 +396,7 @@ class CallEvent : public Event { SiteMask targetMask; if (index + (c->arch->argumentRegisterAlignment() ? footprint : 1) <= c->arch->argumentRegisterCount()) { - int number = c->arch->argumentRegister(index); + Register number = c->arch->argumentRegister(index); if (DebugReads) { fprintf(stderr, "reg %d arg read %p\n", number, v); diff --git a/src/codegen/compiler/regalloc.cpp b/src/codegen/compiler/regalloc.cpp index 52ff8f8da5..5f597537b8 100644 --- a/src/codegen/compiler/regalloc.cpp +++ b/src/codegen/compiler/regalloc.cpp @@ -57,10 +57,10 @@ unsigned resourceCost(Context* c, } bool pickRegisterTarget(Context* c, - int i, + Register i, Value* v, RegisterMask mask, - int* target, + Register* target, unsigned* cost, CostCalculator* costCalculator) { @@ -85,17 +85,17 @@ bool pickRegisterTarget(Context* c, return false; } -int pickRegisterTarget(Context* c, +Register pickRegisterTarget(Context* c, Value* v, RegisterMask mask, unsigned* cost, CostCalculator* costCalculator) { - int target = lir::NoRegister; + Register target = lir::NoRegister; *cost = Target::Impossible; if (mask & c->regFile->generalRegisters.mask) { - for (int i = c->regFile->generalRegisters.limit - 1; + for (Register i = c->regFile->generalRegisters.limit - 1; i >= c->regFile->generalRegisters.start; --i) { if (pickRegisterTarget(c, i, v, mask, &target, cost, costCalculator)) { @@ -105,8 +105,8 @@ int pickRegisterTarget(Context* c, } if (mask & c->regFile->floatRegisters.mask) { - for (int i = c->regFile->floatRegisters.start; - i < static_cast(c->regFile->floatRegisters.limit); + for (Register i = c->regFile->floatRegisters.start; + i < static_cast(c->regFile->floatRegisters.limit); ++i) { if (pickRegisterTarget(c, i, v, mask, &target, cost, costCalculator)) { return i; @@ -123,7 +123,7 @@ Target pickRegisterTarget(Context* c, CostCalculator* costCalculator) { unsigned cost; - int number = pickRegisterTarget(c, v, mask, &cost, costCalculator); + Register number = pickRegisterTarget(c, v, mask, &cost, costCalculator); return Target(number, lir::RegisterOperand, cost); } diff --git a/src/codegen/compiler/regalloc.h b/src/codegen/compiler/regalloc.h index 6aa782ab04..e512e63183 100644 --- a/src/codegen/compiler/regalloc.h +++ b/src/codegen/compiler/regalloc.h @@ -55,7 +55,7 @@ class Target { { } - Target(int index, lir::OperandType type, unsigned cost) + Target(Register index, lir::OperandType type, unsigned cost) : index(index), type(type), cost(cost) { }