Chromium Code Reviews| Index: src/IceInstX8632.cpp |
| diff --git a/src/IceInstX8632.cpp b/src/IceInstX8632.cpp |
| index 2c2f09ca83cbee31035af787e4b76a619446bd8a..83839600407f7491cb76374f519789489e112f34 100644 |
| --- a/src/IceInstX8632.cpp |
| +++ b/src/IceInstX8632.cpp |
| @@ -98,17 +98,33 @@ MachineTraits<TargetX8632>::X86OperandMem::X86OperandMem( |
| } |
| } |
| +namespace { |
| +static int32_t GetRematerializableOffset(Variable *Var, bool IgnoreStackAdjust, |
| + const Ice::TargetLowering *Target) { |
|
John
2015/11/16 14:00:02
const Ice::TargetX8632 *? I would hope llvm would
sehr
2015/11/16 18:42:24
Done.
|
| + int32_t Disp = 0; |
| + Disp += Var->getStackOffset(); |
| + if (static_cast<SizeT>(Var->getRegNum()) == Target->getStackReg()) { |
|
Jim Stichnoth
2015/11/16 14:47:57
Pull "static_cast<SizeT>(Var->getRegNum())" out of
sehr
2015/11/16 18:42:24
Done.
|
| + if (!IgnoreStackAdjust) |
| + Disp += Target->getStackAdjustment(); |
| + } else if (static_cast<SizeT>(Var->getRegNum()) == Target->getFrameReg()) { |
| + Disp += Target->getFrameFixedAllocaOffset(); |
| + } else { |
| + llvm_unreachable("Unexpected rematerializable register type"); |
|
Jim Stichnoth
2015/11/16 14:47:57
llvm::report_fatal_error
sehr
2015/11/16 18:42:24
Done.
|
| + } |
| + return Disp; |
| +} |
| +} // end namespace |
|
Jim Stichnoth
2015/11/16 14:47:57
end of anonymous namespace
sehr
2015/11/16 18:42:24
Done.
|
| + |
| void MachineTraits<TargetX8632>::X86OperandMem::emit(const Cfg *Func) const { |
| if (!BuildDefs::dump()) |
| return; |
| - const ::Ice::TargetLowering *Target = Func->getTarget(); |
| + Ice::TargetLowering *Target = Func->getTarget(); |
|
Jim Stichnoth
2015/11/16 14:47:57
Retain the const?
sehr
2015/11/16 18:42:24
Done.
|
| // If the base is rematerializable, we need to replace it with the correct |
| // physical register (esp or ebp), and update the Offset. |
| int32_t Disp = 0; |
| if (getBase() && getBase()->isRematerializable()) { |
| - Disp += getBase()->getStackOffset(); |
| - if (!getIgnoreStackAdjust()) |
| - Disp += Target->getStackAdjustment(); |
| + Disp += GetRematerializableOffset(getBase(), getIgnoreStackAdjust(), |
| + Target); |
| } |
| // The index should never be rematerializable. But if we ever allow it, then |
| // we should make sure the rematerialization offset is shifted by the Shift |
| @@ -135,7 +151,7 @@ void MachineTraits<TargetX8632>::X86OperandMem::emit(const Cfg *Func) const { |
| // TODO(sehr): ConstantRelocatable still needs updating for |
| // rematerializable base/index and Disp. |
| assert(Disp == 0); |
| - CR->emitWithoutPrefix(Func->getTarget()); |
| + CR->emitWithoutPrefix(Target); |
| } else { |
| llvm_unreachable("Invalid offset type for x86 mem operand"); |
| } |
| @@ -166,9 +182,8 @@ void MachineTraits<TargetX8632>::X86OperandMem::dump(const Cfg *Func, |
| Str << "["; |
| int32_t Disp = 0; |
| if (getBase() && getBase()->isRematerializable()) { |
| - Disp += getBase()->getStackOffset(); |
| - if (!getIgnoreStackAdjust()) |
| - Disp += Func->getTarget()->getStackAdjustment(); |
| + Disp += GetRematerializableOffset(getBase(), getIgnoreStackAdjust(), |
| + Func->getTarget()); |
| } |
| if (getBase()) { |
| if (Func) |
| @@ -233,10 +248,8 @@ MachineTraits<TargetX8632>::X86OperandMem::toAsmAddress( |
| const Ice::TargetLowering *Target) const { |
| int32_t Disp = 0; |
| if (getBase() && getBase()->isRematerializable()) { |
| - Disp += getBase()->getStackOffset(); |
| - if (!getIgnoreStackAdjust()) { |
| - Disp += Target->getStackAdjustment(); |
| - } |
| + Disp += GetRematerializableOffset(getBase(), getIgnoreStackAdjust(), |
| + Target); |
| } |
| // The index should never be rematerializable. But if we ever allow it, then |
| // we should make sure the rematerialization offset is shifted by the Shift |