Commit 25521cb7 authored by Travis Hance's avatar Travis Hance

no need to have Location::Constant around any more

parent db9c9510
...@@ -90,9 +90,6 @@ bool Location::isClobberedByCall() const { ...@@ -90,9 +90,6 @@ bool Location::isClobberedByCall() const {
if (type == Scratch) if (type == Scratch)
return false; return false;
if (type == Constant)
return false;
if (type == Stack) if (type == Stack)
return false; return false;
...@@ -115,11 +112,6 @@ void Location::dump() const { ...@@ -115,11 +112,6 @@ void Location::dump() const {
return; return;
} }
if (type == Constant) {
printf("imm(%d)\n", constant_val);
return;
}
if (type == Stack) { if (type == Stack) {
printf("stack(%d)\n", stack_offset); printf("stack(%d)\n", stack_offset);
return; return;
...@@ -484,14 +476,13 @@ void RewriterVar::dump() { ...@@ -484,14 +476,13 @@ void RewriterVar::dump() {
} }
assembler::Immediate RewriterVar::tryGetAsImmediate(bool* is_immediate) { assembler::Immediate RewriterVar::tryGetAsImmediate(bool* is_immediate) {
for (Location l : locations) { if (this->is_constant && !isLargeConstant(this->constant_value)) {
if (l.type == Location::Constant) { *is_immediate = true;
*is_immediate = true; return assembler::Immediate(this->constant_value);
return assembler::Immediate(l.constant_val); } else {
} *is_immediate = false;
return assembler::Immediate((uint64_t)0);
} }
*is_immediate = false;
return assembler::Immediate((uint64_t)0);
} }
assembler::Register RewriterVar::getInReg(Location dest, bool allow_constant_in_reg, Location otherThan) { assembler::Register RewriterVar::getInReg(Location dest, bool allow_constant_in_reg, Location otherThan) {
...@@ -499,9 +490,7 @@ assembler::Register RewriterVar::getInReg(Location dest, bool allow_constant_in_ ...@@ -499,9 +490,7 @@ assembler::Register RewriterVar::getInReg(Location dest, bool allow_constant_in_
#ifndef NDEBUG #ifndef NDEBUG
if (!allow_constant_in_reg) { if (!allow_constant_in_reg) {
for (Location l : locations) { assert(!is_constant || isLargeConstant(constant_value));
ASSERT(l.type != Location::Constant, "why do you want this in a register?");
}
} }
#endif #endif
...@@ -548,9 +537,7 @@ assembler::Register RewriterVar::getInReg(Location dest, bool allow_constant_in_ ...@@ -548,9 +537,7 @@ assembler::Register RewriterVar::getInReg(Location dest, bool allow_constant_in_
assembler::Register reg = rewriter->allocReg(dest, otherThan); assembler::Register reg = rewriter->allocReg(dest, otherThan);
assert(rewriter->vars_by_location.count(reg) == 0); assert(rewriter->vars_by_location.count(reg) == 0);
if (l.type == Location::Constant) { if (l.type == Location::Scratch || l.type == Location::Stack) {
rewriter->assembler->mov(assembler::Immediate(l.constant_val), reg);
} else if (l.type == Location::Scratch || l.type == Location::Stack) {
assembler::Indirect mem = rewriter->indirectFor(l); assembler::Indirect mem = rewriter->indirectFor(l);
rewriter->assembler->mov(mem, reg); rewriter->assembler->mov(mem, reg);
} else { } else {
...@@ -564,12 +551,8 @@ assembler::Register RewriterVar::getInReg(Location dest, bool allow_constant_in_ ...@@ -564,12 +551,8 @@ assembler::Register RewriterVar::getInReg(Location dest, bool allow_constant_in_
assembler::XMMRegister RewriterVar::getInXMMReg(Location dest) { assembler::XMMRegister RewriterVar::getInXMMReg(Location dest) {
assert(dest.type == Location::XMMRegister || dest.type == Location::AnyReg); assert(dest.type == Location::XMMRegister || dest.type == Location::AnyReg);
assert(!this->is_constant);
assert(locations.size()); assert(locations.size());
#ifndef NDEBUG
for (Location l : locations) {
ASSERT(l.type != Location::Constant, "why do you want this in a register?");
}
#endif
// Not sure if this is worth it, // Not sure if this is worth it,
// but first try to see if we're already in this specific register // but first try to see if we're already in this specific register
...@@ -632,23 +615,10 @@ void Rewriter::_trap() { ...@@ -632,23 +615,10 @@ void Rewriter::_trap() {
RewriterVar* Rewriter::loadConst(int64_t val, Location dest) { RewriterVar* Rewriter::loadConst(int64_t val, Location dest) {
RewriterVar*& const_loader_var = const_loader.constToVar[val]; RewriterVar*& const_loader_var = const_loader.constToVar[val];
if (const_loader_var) if (!const_loader_var) {
return const_loader_var; const_loader_var = createNewConstantVar(val);
if (!isLargeConstant(val)) {
Location l(Location::Constant, val);
RewriterVar*& var = vars_by_location[l];
if (!var) {
var = createNewConstantVar(val);
var->locations.insert(l);
}
const_loader_var = var;
return var;
} else {
RewriterVar* result = createNewConstantVar(val);
const_loader_var = result;
return result;
} }
return const_loader_var;
} }
RewriterVar* Rewriter::call(bool can_call_into_python, void* func_addr) { RewriterVar* Rewriter::call(bool can_call_into_python, void* func_addr) {
...@@ -1440,14 +1410,19 @@ void Rewriter::addLocationToVar(RewriterVar* var, Location l) { ...@@ -1440,14 +1410,19 @@ void Rewriter::addLocationToVar(RewriterVar* var, Location l) {
var->locations.insert(l); var->locations.insert(l);
vars_by_location[l] = var; vars_by_location[l] = var;
#ifndef NDEBUG
// Check that the var is not in more than one of: stack, scratch, const // Check that the var is not in more than one of: stack, scratch, const
int count = 0; int count = 0;
if (var->is_constant && !isLargeConstant(var->constant_value)) {
count++;
}
for (Location l : var->locations) { for (Location l : var->locations) {
if (l.type == Location::Stack || l.type == Location::Scratch || l.type == Location::Constant) { if (l.type == Location::Stack || l.type == Location::Scratch) {
count++; count++;
} }
} }
assert(count <= 1); assert(count <= 1);
#endif
} }
void Rewriter::removeLocationFromVar(RewriterVar* var, Location l) { void Rewriter::removeLocationFromVar(RewriterVar* var, Location l) {
......
...@@ -46,7 +46,6 @@ public: ...@@ -46,7 +46,6 @@ public:
Scratch, // stack location, relative to the scratch start Scratch, // stack location, relative to the scratch start
// For representing constants that fit in 32-bits, that can be encoded as immediates // For representing constants that fit in 32-bits, that can be encoded as immediates
Constant,
AnyReg, // special type for use when specifying a location as a destination AnyReg, // special type for use when specifying a location as a destination
None, // special type that represents the lack of a location, ex where a "ret void" gets returned None, // special type that represents the lack of a location, ex where a "ret void" gets returned
Uninitialized, // special type for an uninitialized (and invalid) location Uninitialized, // special type for an uninitialized (and invalid) location
...@@ -65,9 +64,6 @@ public: ...@@ -65,9 +64,6 @@ public:
// only valid if type == Scratch; offset from the beginning of the scratch area // only valid if type == Scratch; offset from the beginning of the scratch area
int32_t scratch_offset; int32_t scratch_offset;
// only valid if type==Constant
int32_t constant_val;
int32_t _data; int32_t _data;
}; };
...@@ -131,7 +127,6 @@ private: ...@@ -131,7 +127,6 @@ private:
T map_xmm[N_XMM]; T map_xmm[N_XMM];
T map_scratch[N_SCRATCH]; T map_scratch[N_SCRATCH];
T map_stack[N_STACK]; T map_stack[N_STACK];
std::unordered_map<int32_t, T> map_const;
public: public:
LocMap() { LocMap() {
...@@ -159,8 +154,6 @@ public: ...@@ -159,8 +154,6 @@ public:
assert(0 <= l.scratch_offset / 8); assert(0 <= l.scratch_offset / 8);
assert(l.scratch_offset / 8 < N_SCRATCH); assert(l.scratch_offset / 8 < N_SCRATCH);
return map_scratch[l.scratch_offset / 8]; return map_scratch[l.scratch_offset / 8];
case Location::Constant:
return map_const[l.constant_val];
default: default:
RELEASE_ASSERT(0, "%d", l.type); RELEASE_ASSERT(0, "%d", l.type);
} }
...@@ -197,11 +190,6 @@ public: ...@@ -197,11 +190,6 @@ public:
m.emplace(Location(Location::Stack, i * 8), map_stack[i]); m.emplace(Location(Location::Stack, i * 8), map_stack[i]);
} }
} }
for (std::pair<int32_t, RewriterVar*> p : map_const) {
if (p.second != NULL) {
m.emplace(Location(Location::Constant, p.first), p.second);
}
}
return m; return m;
} }
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment