Commit ad8f7265 by Matt Wala

Various improvements related to legalization code.

1) In makeHelperCall(), function pointers that are created should have type IceType_i32, not the functions' own return type. 2) In legalize(), change the name of WillHaveRegister to MustHaveRegister. Add a comment to clarify the condition being computed. 3) In legalize(), add an assert to make sure that vector "constants" don't get legalized (other than undef). There should be no constants of vector type. 4) In copyToReg(), replace an unnecessary use of Src->getType(). BUG=none R=stichnot@chromium.org Review URL: https://codereview.chromium.org/385133006
parent 0ecabc82
...@@ -2756,7 +2756,7 @@ void TargetX8632::lowerUnreachable(const InstUnreachable * /*Inst*/) { ...@@ -2756,7 +2756,7 @@ void TargetX8632::lowerUnreachable(const InstUnreachable * /*Inst*/) {
Variable *TargetX8632::copyToReg(Operand *Src, int32_t RegNum) { Variable *TargetX8632::copyToReg(Operand *Src, int32_t RegNum) {
Type Ty = Src->getType(); Type Ty = Src->getType();
Variable *Reg = makeReg(Ty, RegNum); Variable *Reg = makeReg(Ty, RegNum);
if (isVectorType(Src->getType())) { if (isVectorType(Ty)) {
_movp(Reg, Src); _movp(Reg, Src);
} else { } else {
_mov(Reg, Src); _mov(Reg, Src);
...@@ -2827,6 +2827,8 @@ Operand *TargetX8632::legalize(Operand *From, LegalMask Allowed, ...@@ -2827,6 +2827,8 @@ Operand *TargetX8632::legalize(Operand *From, LegalMask Allowed,
From = Ctx->getConstantZero(From->getType()); From = Ctx->getConstantZero(From->getType());
} }
} }
// There should be no constants of vector type (other than undef).
assert(!isVectorType(From->getType()));
bool NeedsReg = false; bool NeedsReg = false;
if (!(Allowed & Legal_Imm)) if (!(Allowed & Legal_Imm))
// Immediate specifically not allowed // Immediate specifically not allowed
...@@ -2846,13 +2848,16 @@ Operand *TargetX8632::legalize(Operand *From, LegalMask Allowed, ...@@ -2846,13 +2848,16 @@ Operand *TargetX8632::legalize(Operand *From, LegalMask Allowed,
return From; return From;
} }
if (Variable *Var = llvm::dyn_cast<Variable>(From)) { if (Variable *Var = llvm::dyn_cast<Variable>(From)) {
// Check if the variable is guaranteed a physical register. This
// can happen either when the variable is pre-colored or when it is
// assigned infinite weight.
bool MustHaveRegister =
(Var->hasReg() || Var->getWeight() == RegWeight::Inf);
// We need a new physical register for the operand if: // We need a new physical register for the operand if:
// Mem is not allowed and Var isn't guaranteed a physical // Mem is not allowed and Var isn't guaranteed a physical
// register, or // register, or
// RegNum is required and Var->getRegNum() doesn't match. // RegNum is required and Var->getRegNum() doesn't match.
bool WillHaveRegister = if ((!(Allowed & Legal_Mem) && !MustHaveRegister) ||
(Var->hasReg() || Var->getWeight() == RegWeight::Inf);
if ((!(Allowed & Legal_Mem) && !WillHaveRegister) ||
(RegNum != Variable::NoRegister && RegNum != Var->getRegNum())) { (RegNum != Variable::NoRegister && RegNum != Var->getRegNum())) {
Variable *Reg = copyToReg(From, RegNum); Variable *Reg = copyToReg(From, RegNum);
if (RegNum == Variable::NoRegister) { if (RegNum == Variable::NoRegister) {
......
...@@ -136,8 +136,9 @@ protected: ...@@ -136,8 +136,9 @@ protected:
InstCall *makeHelperCall(const IceString &Name, Variable *Dest, InstCall *makeHelperCall(const IceString &Name, Variable *Dest,
SizeT MaxSrcs) { SizeT MaxSrcs) {
bool SuppressMangling = true; bool SuppressMangling = true;
Type Ty = Dest ? Dest->getType() : IceType_void; const Type FunctionPointerType = IceType_i32;
Constant *CallTarget = Ctx->getConstantSym(Ty, 0, Name, SuppressMangling); Constant *CallTarget =
Ctx->getConstantSym(FunctionPointerType, 0, Name, SuppressMangling);
InstCall *Call = InstCall::create(Func, MaxSrcs, Dest, CallTarget); InstCall *Call = InstCall::create(Func, MaxSrcs, Dest, CallTarget);
return Call; return Call;
} }
......
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