From 8cf77137533f1d83f9ea0085b5ca6d241f4bab9a Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Wed, 3 Dec 2008 18:11:40 +0000 Subject: [PATCH] Extend X86's addFrameReference to add a MachineMemOperand for the frame reference. This will help post-RA scheduling determine that spills to distinct stack slots are independent. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60486 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/MachineFrameInfo.h | 6 +++--- include/llvm/CodeGen/MachineInstrBuilder.h | 5 +++++ 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 a6b91441fac..e8cddad86ff 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 f57168b2766..ffe5fbe0441 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 87c63421bc8..74f9e05ffe4 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 -- 2.34.1