diff options
-rw-r--r-- | include/llvm/CodeGen/MachineFrameInfo.h | 6 | ||||
-rw-r--r-- | include/llvm/CodeGen/MachineInstrBuilder.h | 5 | ||||
-rw-r--r-- | lib/Target/X86/X86InstrBuilder.h | 19 |
3 files changed, 26 insertions, 4 deletions
diff --git a/include/llvm/CodeGen/MachineFrameInfo.h b/include/llvm/CodeGen/MachineFrameInfo.h index a6b91441fa..e8cddad86f 100644 --- a/include/llvm/CodeGen/MachineFrameInfo.h +++ b/include/llvm/CodeGen/MachineFrameInfo.h @@ -99,7 +99,7 @@ class MachineFrameInfo { // the function. This field has no meaning for a variable sized element. int64_t SPOffset; - StackObject(uint64_t Sz, unsigned Al, int64_t SP, bool IM = false) + StackObject(uint64_t Sz, unsigned Al, int64_t SP = 0, bool IM = false) : Size(Sz), Alignment(Al), isImmutable(IM), SPOffset(SP) {} }; @@ -355,7 +355,7 @@ public: /// int CreateStackObject(uint64_t Size, unsigned Alignment) { assert(Size != 0 && "Cannot allocate zero size stack objects!"); - Objects.push_back(StackObject(Size, Alignment, -1)); + Objects.push_back(StackObject(Size, Alignment)); return (int)Objects.size()-NumFixedObjects-1; } @@ -373,7 +373,7 @@ public: /// int CreateVariableSizedObject() { HasVarSizedObjects = true; - Objects.push_back(StackObject(0, 1, -1)); + Objects.push_back(StackObject(0, 1)); return (int)Objects.size()-NumFixedObjects-1; } diff --git a/include/llvm/CodeGen/MachineInstrBuilder.h b/include/llvm/CodeGen/MachineInstrBuilder.h index f57168b276..ffe5fbe044 100644 --- a/include/llvm/CodeGen/MachineInstrBuilder.h +++ b/include/llvm/CodeGen/MachineInstrBuilder.h @@ -89,6 +89,11 @@ public: MI->addOperand(MachineOperand::CreateES(FnName, Offset)); return *this; } + + const MachineInstrBuilder &addMemOperand(const MachineMemOperand &MMO) const { + MI->addMemOperand(*MI->getParent()->getParent(), MMO); + return *this; + } }; /// BuildMI - Builder interface. Specify how to create the initial instruction diff --git a/lib/Target/X86/X86InstrBuilder.h b/lib/Target/X86/X86InstrBuilder.h index 87c63421bc..74f9e05ffe 100644 --- a/lib/Target/X86/X86InstrBuilder.h +++ b/lib/Target/X86/X86InstrBuilder.h @@ -24,7 +24,9 @@ #ifndef X86INSTRBUILDER_H #define X86INSTRBUILDER_H +#include "llvm/CodeGen/MachineFrameInfo.h" #include "llvm/CodeGen/MachineInstrBuilder.h" +#include "llvm/CodeGen/PseudoSourceValue.h" namespace llvm { @@ -109,7 +111,22 @@ inline const MachineInstrBuilder &addFullAddress(const MachineInstrBuilder &MIB, /// inline const MachineInstrBuilder & addFrameReference(const MachineInstrBuilder &MIB, int FI, int Offset = 0) { - return MIB.addFrameIndex(FI).addImm(1).addReg(0).addImm(Offset); + MachineInstr *MI = MIB; + MachineFunction &MF = *MI->getParent()->getParent(); + MachineFrameInfo &MFI = *MF.getFrameInfo(); + const TargetInstrDesc &TID = MI->getDesc(); + unsigned Flags = 0; + if (TID.mayLoad()) + Flags |= MachineMemOperand::MOLoad; + if (TID.mayStore()) + Flags |= MachineMemOperand::MOStore; + MachineMemOperand MMO(PseudoSourceValue::getFixedStack(FI), + Flags, + MFI.getObjectOffset(FI) + Offset, + MFI.getObjectSize(FI), + MFI.getObjectAlignment(FI)); + return MIB.addFrameIndex(FI).addImm(1).addReg(0).addImm(Offset) + .addMemOperand(MMO); } /// addConstantPoolReference - This function is used to add a reference to the |