1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 11:42:57 +01:00

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.

llvm-svn: 60486
This commit is contained in:
Dan Gohman 2008-12-03 18:11:40 +00:00
parent 0b01e188e5
commit fc05cdda64
3 changed files with 26 additions and 4 deletions

View File

@ -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;
}

View File

@ -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

View File

@ -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