Commit dd165074 by Jim Stichnoth

Subzero: Remove the LEAHACK workarounds.

They are no longer needed now that we aren't using the buggy llvm-mc parser for Intel syntax. This also gets all spec2k components to work with -build-on-read. Also, adds an emit-time check that infinite-weight Variables actually got a physical register. BUG= none R=jvoung@chromium.org Review URL: https://codereview.chromium.org/696153002
parent bca2f655
...@@ -509,6 +509,8 @@ void TargetX8632::emitVariable(const Variable *Var) const { ...@@ -509,6 +509,8 @@ void TargetX8632::emitVariable(const Variable *Var) const {
Str << "%" << getRegName(Var->getRegNum(), Var->getType()); Str << "%" << getRegName(Var->getRegNum(), Var->getType());
return; return;
} }
if (Var->getWeight().isInf())
llvm_unreachable("Infinite-weight Variable has no register assigned");
const Type Ty = IceType_i32; const Type Ty = IceType_i32;
int32_t Offset = Var->getStackOffset(); int32_t Offset = Var->getStackOffset();
if (!hasFramePointer()) if (!hasFramePointer())
...@@ -519,7 +521,10 @@ void TargetX8632::emitVariable(const Variable *Var) const { ...@@ -519,7 +521,10 @@ void TargetX8632::emitVariable(const Variable *Var) const {
} }
x86::Address TargetX8632::stackVarToAsmOperand(const Variable *Var) const { x86::Address TargetX8632::stackVarToAsmOperand(const Variable *Var) const {
assert(!Var->hasReg()); if (Var->hasReg())
llvm_unreachable("Stack Variable has a register assigned");
if (Var->getWeight().isInf())
llvm_unreachable("Infinite-weight Variable has no register assigned");
int32_t Offset = Var->getStackOffset(); int32_t Offset = Var->getStackOffset();
if (!hasFramePointer()) if (!hasFramePointer())
Offset += getStackAdjustment(); Offset += getStackAdjustment();
...@@ -1850,9 +1855,7 @@ void TargetX8632::lowerCall(const InstCall *Instr) { ...@@ -1850,9 +1855,7 @@ void TargetX8632::lowerCall(const InstCall *Instr) {
break; break;
} }
} }
// TODO(stichnot): LEAHACK: remove Legal_All (and use default) once Operand *CallTarget = legalize(Instr->getCallTarget());
// a proper emitter is used.
Operand *CallTarget = legalize(Instr->getCallTarget(), Legal_All);
Inst *NewCall = InstX8632Call::create(Func, ReturnReg, CallTarget); Inst *NewCall = InstX8632Call::create(Func, ReturnReg, CallTarget);
Context.insert(NewCall); Context.insert(NewCall);
if (ReturnRegHi) if (ReturnRegHi)
...@@ -4407,11 +4410,6 @@ Operand *TargetX8632::legalize(Operand *From, LegalMask Allowed, ...@@ -4407,11 +4410,6 @@ Operand *TargetX8632::legalize(Operand *From, LegalMask Allowed,
if (!(Allowed & Legal_Imm)) if (!(Allowed & Legal_Imm))
// Immediate specifically not allowed // Immediate specifically not allowed
NeedsReg = true; NeedsReg = true;
// TODO(stichnot): LEAHACK: remove Legal_Reloc once a proper
// emitter is used.
if (!(Allowed & Legal_Reloc) && llvm::isa<ConstantRelocatable>(From))
// Relocatable specifically not allowed
NeedsReg = true;
if (!(Allowed & Legal_Mem) && isScalarFloatingType(From->getType())) if (!(Allowed & Legal_Mem) && isScalarFloatingType(From->getType()))
// On x86, FP constants are lowered to mem operands. // On x86, FP constants are lowered to mem operands.
NeedsReg = true; NeedsReg = true;
......
...@@ -147,13 +147,10 @@ protected: ...@@ -147,13 +147,10 @@ protected:
Legal_Reg = 1 << 0, // physical register, not stack location Legal_Reg = 1 << 0, // physical register, not stack location
Legal_Imm = 1 << 1, Legal_Imm = 1 << 1,
Legal_Mem = 1 << 2, // includes [eax+4*ecx] as well as [esp+12] Legal_Mem = 1 << 2, // includes [eax+4*ecx] as well as [esp+12]
// TODO(stichnot): LEAHACK: remove Legal_Reloc once a proper
// emitter is used.
Legal_Reloc = 1 << 3,
Legal_All = ~Legal_None Legal_All = ~Legal_None
}; };
typedef uint32_t LegalMask; typedef uint32_t LegalMask;
Operand *legalize(Operand *From, LegalMask Allowed = Legal_All & ~Legal_Reloc, Operand *legalize(Operand *From, LegalMask Allowed = Legal_All,
int32_t RegNum = Variable::NoRegister); int32_t RegNum = Variable::NoRegister);
Variable *legalizeToVar(Operand *From, int32_t RegNum = Variable::NoRegister); Variable *legalizeToVar(Operand *From, int32_t RegNum = Variable::NoRegister);
// Turn a pointer operand into a memory operand that can be // Turn a pointer operand into a memory operand that can be
......
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