llvm.org GIT mirror llvm / a395f4d
Change MachineInstrBuilder::addDisp to copy over target flags by default. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165677 91177308-0d34-0410-b5e6-96231b3b80d8 Evan Cheng 7 years ago
2 changed file(s) with 15 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
175175 }
176176
177177 // Add a displacement from an existing MachineOperand with an added offset.
178 const MachineInstrBuilder &addDisp(const MachineOperand &Disp,
179 int64_t off) const {
178 const MachineInstrBuilder &addDisp(const MachineOperand &Disp, int64_t off,
179 unsigned char TargetFlags = 0) const {
180180 switch (Disp.getType()) {
181181 default:
182182 llvm_unreachable("Unhandled operand type in addDisp()");
183183 case MachineOperand::MO_Immediate:
184184 return addImm(Disp.getImm() + off);
185 case MachineOperand::MO_GlobalAddress:
186 return addGlobalAddress(Disp.getGlobal(), Disp.getOffset() + off);
185 case MachineOperand::MO_GlobalAddress: {
186 // If caller specifies new TargetFlags then use it, otherwise the
187 // default behavior is to copy the target flags from the existing
188 // MachineOperand. This means if the caller wants to clear the
189 // target flags it needs to do so explicitly.
190 if (TargetFlags)
191 return addGlobalAddress(Disp.getGlobal(), Disp.getOffset() + off,
192 TargetFlags);
193 return addGlobalAddress(Disp.getGlobal(), Disp.getOffset() + off,
194 Disp.getTargetFlags());
195 }
187196 }
188197 }
189198 };
1232812328 // Hi
1232912329 MIB = BuildMI(thisMBB, DL, TII->get(LOADOpc), X86::EDX);
1233012330 for (unsigned i = 0; i < X86::AddrNumOperands; ++i) {
12331 if (i == X86::AddrDisp) {
12331 if (i == X86::AddrDisp)
1233212332 MIB.addDisp(MI->getOperand(MemOpndSlot + i), 4); // 4 == sizeof(i32)
12333 // Don't forget to transfer the target flag.
12334 MachineOperand &MO = MIB->getOperand(MIB->getNumOperands()-1);
12335 MO.setTargetFlags(MI->getOperand(MemOpndSlot + i).getTargetFlags());
12336 } else
12333 else
1233712334 MIB.addOperand(MI->getOperand(MemOpndSlot + i));
1233812335 }
1233912336 MIB.setMemRefs(MMOBegin, MMOEnd);