[llvm-commits] [llvm] r133619 - in /llvm/trunk/lib/Target/PTX: PTXAsmPrinter.cpp PTXInstrInfo.cpp PTXInstrInfo.h PTXRegisterInfo.cpp PTXRegisterInfo.h
Justin Holewinski
justin.holewinski at gmail.com
Wed Jun 22 09:07:04 PDT 2011
Author: jholewinski
Date: Wed Jun 22 11:07:03 2011
New Revision: 133619
URL: http://llvm.org/viewvc/llvm-project?rev=133619&view=rev
Log:
PTX: Fix FrameIndex mapping bug
Modified:
llvm/trunk/lib/Target/PTX/PTXAsmPrinter.cpp
llvm/trunk/lib/Target/PTX/PTXInstrInfo.cpp
llvm/trunk/lib/Target/PTX/PTXInstrInfo.h
llvm/trunk/lib/Target/PTX/PTXRegisterInfo.cpp
llvm/trunk/lib/Target/PTX/PTXRegisterInfo.h
Modified: llvm/trunk/lib/Target/PTX/PTXAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXAsmPrinter.cpp?rev=133619&r1=133618&r2=133619&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PTX/PTXAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/PTX/PTXAsmPrinter.cpp Wed Jun 22 11:07:03 2011
@@ -204,15 +204,18 @@
}
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));
+ }
}
}
Modified: llvm/trunk/lib/Target/PTX/PTXInstrInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXInstrInfo.cpp?rev=133619&r1=133618&r2=133619&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PTX/PTXInstrInfo.cpp (original)
+++ llvm/trunk/lib/Target/PTX/PTXInstrInfo.cpp Wed Jun 22 11:07:03 2011
@@ -291,7 +291,7 @@
// 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 @@
// 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 @@
// 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);
}
Modified: llvm/trunk/lib/Target/PTX/PTXInstrInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXInstrInfo.h?rev=133619&r1=133618&r2=133619&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PTX/PTXInstrInfo.h (original)
+++ llvm/trunk/lib/Target/PTX/PTXInstrInfo.h Wed Jun 22 11:07:03 2011
@@ -93,7 +93,7 @@
// 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,
Modified: llvm/trunk/lib/Target/PTX/PTXRegisterInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXRegisterInfo.cpp?rev=133619&r1=133618&r2=133619&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PTX/PTXRegisterInfo.cpp (original)
+++ llvm/trunk/lib/Target/PTX/PTXRegisterInfo.cpp Wed Jun 22 11:07:03 2011
@@ -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);
+}
Modified: llvm/trunk/lib/Target/PTX/PTXRegisterInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXRegisterInfo.h?rev=133619&r1=133618&r2=133619&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PTX/PTXRegisterInfo.h (original)
+++ llvm/trunk/lib/Target/PTX/PTXRegisterInfo.h Wed Jun 22 11:07:03 2011
@@ -38,11 +38,9 @@
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");
More information about the llvm-commits
mailing list