summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2016-04-06 10:03:47 +0200
committerHans de Goede <hdegoede@redhat.com>2016-06-28 11:53:42 +0200
commiteacbdabecf8c51d7af1c6469d2316576451ae71d (patch)
tree15df3128744b9427da228460da4533dd9d665ab6
parent9240d3d02673bb71915a12055d78dd06d2416762 (diff)
TGSI: Use a machine-wide ConstantPool
Not really pretty, maybe add module wide constant pool functionality to the Module class, and use that ? Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-rw-r--r--lib/Target/TGSI/TGSI.h3
-rw-r--r--lib/Target/TGSI/TGSIAsmPrinter.cpp11
-rw-r--r--lib/Target/TGSI/TGSIPreEmitImmPass.cpp11
-rw-r--r--lib/Target/TGSI/TGSITargetMachine.cpp5
-rw-r--r--lib/Target/TGSI/TGSITargetMachine.h3
5 files changed, 23 insertions, 10 deletions
diff --git a/lib/Target/TGSI/TGSI.h b/lib/Target/TGSI/TGSI.h
index 83a1644bc3a..c906c8f98ad 100644
--- a/lib/Target/TGSI/TGSI.h
+++ b/lib/Target/TGSI/TGSI.h
@@ -16,6 +16,7 @@
#define TGSI_H
#include "MCTargetDesc/TGSIMCTargetDesc.h"
+#include "llvm/CodeGen/MachineConstantPool.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/Module.h"
#include "llvm/Support/ErrorHandling.h"
@@ -27,7 +28,7 @@ namespace llvm {
class TGSITargetMachine;
FunctionPass *createTGSIISelDag(TGSITargetMachine &tm);
- FunctionPass *createTGSIPreEmitImmPass();
+ FunctionPass *createTGSIPreEmitImmPass(MachineConstantPool &MCP);
namespace tgsi {
enum AddressSpace {
diff --git a/lib/Target/TGSI/TGSIAsmPrinter.cpp b/lib/Target/TGSI/TGSIAsmPrinter.cpp
index ec4b5a446ed..b6a4b4c8a5e 100644
--- a/lib/Target/TGSI/TGSIAsmPrinter.cpp
+++ b/lib/Target/TGSI/TGSIAsmPrinter.cpp
@@ -38,10 +38,11 @@ using namespace llvm;
namespace {
class TGSIAsmPrinter : public AsmPrinter {
+ unsigned cpi;
public:
explicit TGSIAsmPrinter(TargetMachine &TM,
std::unique_ptr<MCStreamer> Streamer)
- : AsmPrinter(TM, std::move(Streamer)) {}
+ : AsmPrinter(TM, std::move(Streamer)), cpi(0) {}
virtual const char *getPassName() const {
return "TGSI Assembly Printer";
@@ -171,16 +172,16 @@ void TGSIAsmPrinter::EmitFunctionBodyEnd() {
}
void TGSIAsmPrinter::EmitConstantPool() {
- const MachineConstantPool *MCP = MF->getConstantPool();
- const std::vector<MachineConstantPoolEntry> &CP = MCP->getConstants();
+ TGSITargetMachine &TTM = static_cast<TGSITargetMachine &>(TM);
+ const std::vector<MachineConstantPoolEntry> &CP = TTM.MCP.getConstants();
if (CP.empty()) return;
MCTargetStreamer &TS = *OutStreamer->getTargetStreamer();
TGSITargetStreamer &TTS = static_cast<TGSITargetStreamer &>(TS);
- for (unsigned i = 0; i < CP.size(); i++)
- TTS.EmitConstantPoolEntry(CP[i]);
+ while (cpi < CP.size())
+ TTS.EmitConstantPoolEntry(CP[cpi++]);
}
extern "C" void LLVMInitializeTGSIAsmPrinter() {
diff --git a/lib/Target/TGSI/TGSIPreEmitImmPass.cpp b/lib/Target/TGSI/TGSIPreEmitImmPass.cpp
index 55c86b8de9d..32c0cf82072 100644
--- a/lib/Target/TGSI/TGSIPreEmitImmPass.cpp
+++ b/lib/Target/TGSI/TGSIPreEmitImmPass.cpp
@@ -41,7 +41,6 @@ namespace {
protected:
bool processBlock(MachineFunction &MF, MachineBasicBlock &MBB) {
- MachineConstantPool *MCP = MF.getConstantPool();
bool Changed = false;
for (MachineBasicBlock::iterator I = MBB.begin(); I != MBB.end(); I++) {
@@ -71,6 +70,8 @@ protected:
}
public:
+ MachineConstantPool *MCP;
+
virtual bool doInitialization(Module &M) override {
LCtx = &M.getContext();
return false;
@@ -102,4 +103,10 @@ INITIALIZE_PASS(TGSIPreEmitImm, DEBUG_TYPE,
char TGSIPreEmitImm::ID = 0;
FunctionPass*
-llvm::createTGSIPreEmitImmPass() { return new TGSIPreEmitImm(); }
+llvm::createTGSIPreEmitImmPass(MachineConstantPool &MCP) {
+ TGSIPreEmitImm *pass = new TGSIPreEmitImm();
+
+ pass->MCP = &MCP;
+
+ return pass;
+}
diff --git a/lib/Target/TGSI/TGSITargetMachine.cpp b/lib/Target/TGSI/TGSITargetMachine.cpp
index 3279cdb0156..57a165b825a 100644
--- a/lib/Target/TGSI/TGSITargetMachine.cpp
+++ b/lib/Target/TGSI/TGSITargetMachine.cpp
@@ -38,7 +38,7 @@ namespace {
}
void addPreEmitPass() override {
- addPass(createTGSIPreEmitImmPass(), false);
+ addPass(createTGSIPreEmitImmPass(getTGSITargetMachine().MCP), false);
}
};
}
@@ -63,7 +63,8 @@ TGSITargetMachine::TGSITargetMachine(const Target &T, const Triple &TT,
: LLVMTargetMachine(T, computeDataLayout(TT, CPU, Options),
TT, CPU, FS, Options, Reloc::Static, CM, OL),
TLOF(make_unique<TGSITargetObjectFile>()),
- Subtarget(TT, CPU, FS, *this) {
+ Subtarget(TT, CPU, FS, *this),
+ MCP(DL) {
initAsmInfo();
}
diff --git a/lib/Target/TGSI/TGSITargetMachine.h b/lib/Target/TGSI/TGSITargetMachine.h
index f12aeb00013..ce30ce1a87c 100644
--- a/lib/Target/TGSI/TGSITargetMachine.h
+++ b/lib/Target/TGSI/TGSITargetMachine.h
@@ -16,6 +16,7 @@
#include "TGSISubtarget.h"
#include "llvm/Analysis/TargetTransformInfo.h"
+#include "llvm/CodeGen/MachineConstantPool.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/Target/TargetMachine.h"
@@ -24,6 +25,8 @@ namespace llvm {
std::unique_ptr<TargetLoweringObjectFile> TLOF;
TGSISubtarget Subtarget;
public:
+ MachineConstantPool MCP; /* TGSI uses a machine wide constantpool */
+
TGSITargetMachine(const Target &T, const Triple &TT,
StringRef CPU, StringRef FS,
const TargetOptions &Options,