Chromium Code Reviews| Index: src/IceTargetLoweringX8632.cpp |
| diff --git a/src/IceTargetLoweringX8632.cpp b/src/IceTargetLoweringX8632.cpp |
| index 7ed8abff5152680166ca35fe06b044d8211f19c7..a0e440892bf7ef923494b918b3680a18a2d6206e 100644 |
| --- a/src/IceTargetLoweringX8632.cpp |
| +++ b/src/IceTargetLoweringX8632.cpp |
| @@ -3482,8 +3482,35 @@ bool isAdd(const Inst *Inst) { |
| return false; |
| } |
| -void computeAddressOpt(Variable *&Base, Variable *&Index, uint16_t &Shift, |
| - int32_t &Offset) { |
| +void dumpAddressOpt(const Cfg *Func, const Variable *Base, |
| + const Variable *Index, uint16_t Shift, int32_t Offset, |
| + const Inst *Reason) { |
| + if (!Func->getContext()->isVerbose(IceV_AddrOpt)) |
| + return; |
| + Ostream &Str = Func->getContext()->getStrDump(); |
| + Str << "Instruction: "; |
| + Reason->dumpDecorated(Func); |
| + Str << " results in Base="; |
| + if (Base) |
| + Base->dump(Func); |
| + else |
| + Str << "<null>"; |
| + Str << ", Index="; |
| + if (Index) |
| + Index->dump(Func); |
| + else |
| + Str << "<null>"; |
| + Str << ", Shift=" << Shift << ", Offset=" << Offset << "\n"; |
| +} |
| + |
| +void computeAddressOpt(Cfg *Func, const Inst *Instr, Variable *&Base, |
| + Variable *&Index, uint16_t &Shift, int32_t &Offset) { |
| + Func->setCurrentNode(NULL); |
| + if (Func->getContext()->isVerbose(IceV_AddrOpt)) { |
| + Ostream &Str = Func->getContext()->getStrDump(); |
| + Str << "\nStarting computeAddressOpt for instruction:\n "; |
| + Instr->dumpDecorated(Func); |
| + } |
| (void)Offset; // TODO: pattern-match for non-zero offsets. |
| if (Base == NULL) |
| return; |
| @@ -3506,6 +3533,7 @@ void computeAddressOpt(Variable *&Base, Variable *&Index, uint16_t &Shift, |
| // TODO: ensure BaseVariable0 stays single-BB |
|
jvoung (off chromium)
2014/08/27 16:21:07
Does this take care of the TODO?
Maybe not the on
Jim Stichnoth
2014/08/27 20:23:14
I don't think so. This needs to be tuned, but my
|
| true) { |
| Base = BaseVariable0; |
| + dumpAddressOpt(Func, Base, Index, Shift, Offset, BaseInst); |
| continue; |
| } |
| @@ -3523,6 +3551,7 @@ void computeAddressOpt(Variable *&Base, Variable *&Index, uint16_t &Shift, |
| Base = BaseVariable0; |
| Index = BaseVariable1; |
| Shift = 0; // should already have been 0 |
| + dumpAddressOpt(Func, Base, Index, Shift, Offset, BaseInst); |
| continue; |
| } |
| @@ -3560,6 +3589,7 @@ void computeAddressOpt(Variable *&Base, Variable *&Index, uint16_t &Shift, |
| if (Shift + LogMult <= 3) { |
| Index = IndexVariable0; |
| Shift += LogMult; |
| + dumpAddressOpt(Func, Base, Index, Shift, Offset, IndexInst); |
| continue; |
| } |
| } |
| @@ -3589,6 +3619,7 @@ void computeAddressOpt(Variable *&Base, Variable *&Index, uint16_t &Shift, |
| } |
| Base = Var; |
| Offset += IsAdd ? Const->getValue() : -Const->getValue(); |
| + dumpAddressOpt(Func, Base, Index, Shift, Offset, BaseInst); |
| continue; |
| } |
| @@ -3684,7 +3715,7 @@ void TargetX8632::doAddressOptLoad() { |
| const OperandX8632Mem::SegmentRegisters SegmentReg = |
| OperandX8632Mem::DefaultSegment; |
| Variable *Base = llvm::dyn_cast<Variable>(Addr); |
| - computeAddressOpt(Base, Index, Shift, Offset); |
| + computeAddressOpt(Func, Inst, Base, Index, Shift, Offset); |
| if (Base && Addr != Base) { |
| Constant *OffsetOp = Ctx->getConstantInt(IceType_i32, Offset); |
| Addr = OperandX8632Mem::create(Func, Dest->getType(), Base, OffsetOp, Index, |
| @@ -3866,7 +3897,7 @@ void TargetX8632::doAddressOptStore() { |
| // registers there either. |
| const OperandX8632Mem::SegmentRegisters SegmentReg = |
| OperandX8632Mem::DefaultSegment; |
| - computeAddressOpt(Base, Index, Shift, Offset); |
| + computeAddressOpt(Func, Inst, Base, Index, Shift, Offset); |
| if (Base && Addr != Base) { |
| Constant *OffsetOp = Ctx->getConstantInt(IceType_i32, Offset); |
| Addr = OperandX8632Mem::create(Func, Data->getType(), Base, OffsetOp, Index, |