mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-25 12:50:00 +00:00
PTX: Fix FrameIndex mapping bug
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133619 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
267010864e
commit
08d03168f2
@ -204,15 +204,18 @@ void PTXAsmPrinter::EmitFunctionBodyStart() {
|
||||
}
|
||||
|
||||
const MachineFrameInfo* FrameInfo = MF->getFrameInfo();
|
||||
DEBUG(dbgs() << "Have " << FrameInfo->getNumObjects() << " frame object(s)\n");
|
||||
DEBUG(dbgs() << "Have " << FrameInfo->getNumObjects()
|
||||
<< " frame object(s)\n");
|
||||
for (unsigned i = 0, e = FrameInfo->getNumObjects(); i != e; ++i) {
|
||||
DEBUG(dbgs() << "Size of object: " << FrameInfo->getObjectSize(i) << "\n");
|
||||
std::string def = "\t.reg .b";
|
||||
def += utostr(FrameInfo->getObjectSize(i)*8); // Convert to bits
|
||||
def += " s";
|
||||
def += utostr(i);
|
||||
def += ";";
|
||||
OutStreamer.EmitRawText(Twine(def));
|
||||
if (FrameInfo->getObjectSize(i) > 0) {
|
||||
std::string def = "\t.reg .b";
|
||||
def += utostr(FrameInfo->getObjectSize(i)*8); // Convert to bits
|
||||
def += " s";
|
||||
def += utostr(i);
|
||||
def += ";";
|
||||
OutStreamer.EmitRawText(Twine(def));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -291,7 +291,7 @@ InsertBranch(MachineBasicBlock &MBB,
|
||||
// Memory operand folding for spills
|
||||
void PTXInstrInfo::storeRegToStackSlot(MachineBasicBlock &MBB,
|
||||
MachineBasicBlock::iterator MII,
|
||||
unsigned SrcReg, bool isKill, int FrameIdx,
|
||||
unsigned SrcReg, bool isKill, int FrameIdx,
|
||||
const TargetRegisterClass *RC,
|
||||
const TargetRegisterInfo *TRI) const {
|
||||
MachineInstr& MI = *MII;
|
||||
@ -318,7 +318,7 @@ void PTXInstrInfo::storeRegToStackSlot(MachineBasicBlock &MBB,
|
||||
|
||||
// Build the store instruction (really a mov)
|
||||
MachineInstrBuilder MIB = BuildMI(MBB, MII, DL, get(OpCode));
|
||||
MIB.addImm(FrameIdx);
|
||||
MIB.addFrameIndex(FrameIdx);
|
||||
MIB.addReg(SrcReg);
|
||||
|
||||
AddDefaultPredicate(MIB);
|
||||
@ -354,7 +354,7 @@ void PTXInstrInfo::loadRegFromStackSlot(MachineBasicBlock &MBB,
|
||||
// Build the load instruction (really a mov)
|
||||
MachineInstrBuilder MIB = BuildMI(MBB, MII, DL, get(OpCode));
|
||||
MIB.addReg(DestReg);
|
||||
MIB.addImm(FrameIdx);
|
||||
MIB.addFrameIndex(FrameIdx);
|
||||
|
||||
AddDefaultPredicate(MIB);
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ public:
|
||||
// efficient code anyway.
|
||||
// virtual MachineInstr* foldMemoryOperandImpl(MachineFunction &MF,
|
||||
// MachineInstr* MI,
|
||||
// const SmallVectorImpl<unsigned> &Ops,
|
||||
// const SmallVectorImpl<unsigned> &Ops,
|
||||
// int FrameIndex) const;
|
||||
|
||||
virtual void storeRegToStackSlot(MachineBasicBlock& MBB,
|
||||
|
@ -13,7 +13,34 @@
|
||||
|
||||
#include "PTX.h"
|
||||
#include "PTXRegisterInfo.h"
|
||||
#include "llvm/CodeGen/MachineFunction.h"
|
||||
#include "llvm/Support/Debug.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
#include "PTXGenRegisterInfo.inc"
|
||||
|
||||
|
||||
void PTXRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II,
|
||||
int SPAdj,
|
||||
RegScavenger *RS) const {
|
||||
unsigned Index;
|
||||
MachineInstr& MI = *II;
|
||||
|
||||
Index = 0;
|
||||
while (!MI.getOperand(Index).isFI()) {
|
||||
++Index;
|
||||
assert(Index < MI.getNumOperands() &&
|
||||
"Instr does not have a FrameIndex operand!");
|
||||
}
|
||||
|
||||
int FrameIndex = MI.getOperand(Index).getIndex();
|
||||
|
||||
DEBUG(dbgs() << "eliminateFrameIndex: " << MI);
|
||||
DEBUG(dbgs() << "- SPAdj: " << SPAdj << "\n");
|
||||
DEBUG(dbgs() << "- FrameIndex: " << FrameIndex << "\n");
|
||||
|
||||
// This frame index is post stack slot re-use assignments
|
||||
MI.getOperand(Index).ChangeToImmediate(FrameIndex);
|
||||
}
|
||||
|
@ -38,11 +38,9 @@ struct PTXRegisterInfo : public PTXGenRegisterInfo {
|
||||
return Reserved; // reserve no regs
|
||||
}
|
||||
|
||||
virtual void eliminateFrameIndex(MachineBasicBlock::iterator MI,
|
||||
virtual void eliminateFrameIndex(MachineBasicBlock::iterator II,
|
||||
int SPAdj,
|
||||
RegScavenger *RS = NULL) const {
|
||||
llvm_unreachable("PTX does not support general function call");
|
||||
}
|
||||
RegScavenger *RS = NULL) const;
|
||||
|
||||
virtual unsigned getFrameRegister(const MachineFunction &MF) const {
|
||||
llvm_unreachable("PTX does not have a frame register");
|
||||
|
Loading…
Reference in New Issue
Block a user