summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2016-04-06 14:23:43 +0200
committerHans de Goede <hdegoede@redhat.com>2016-06-28 11:53:42 +0200
commit4bdd4a0c2762e14d33a9723b20cb86854ebf89d4 (patch)
tree27438641fa925d394b37ddcc6b8f653a23b118a1
parenteacbdabecf8c51d7af1c6469d2316576451ae71d (diff)
TGSI: Add instruction labels to the asm output
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-rw-r--r--lib/Target/TGSI/MCTargetDesc/TGSIASMStreamer.cpp7
-rw-r--r--lib/Target/TGSI/MCTargetDesc/TGSITargetStreamer.cpp1
-rw-r--r--lib/Target/TGSI/MCTargetDesc/TGSITargetStreamer.h1
-rw-r--r--lib/Target/TGSI/TGSIAsmPrinter.cpp24
4 files changed, 27 insertions, 6 deletions
diff --git a/lib/Target/TGSI/MCTargetDesc/TGSIASMStreamer.cpp b/lib/Target/TGSI/MCTargetDesc/TGSIASMStreamer.cpp
index fce6da02438..dde6e06cbc6 100644
--- a/lib/Target/TGSI/MCTargetDesc/TGSIASMStreamer.cpp
+++ b/lib/Target/TGSI/MCTargetDesc/TGSIASMStreamer.cpp
@@ -20,12 +20,14 @@ class TGSITargetAsmStreamer : public TGSITargetStreamer {
formatted_raw_ostream &OS;
MCInstPrinter &InstPrinter;
bool IsVerboseAsm;
+ unsigned instructionCount;
public:
TGSITargetAsmStreamer(MCStreamer &S, formatted_raw_ostream &OS,
MCInstPrinter &InstPrinter, bool VerboseAsm);
virtual void EmitConstantPoolEntry(const MachineConstantPoolEntry &CPE) override;
virtual void EmitStartOfAsmFile() override;
+ virtual void EmitInstructionLabel(unsigned val) override;
};
TGSITargetAsmStreamer::TGSITargetAsmStreamer(MCStreamer &S,
@@ -54,6 +56,11 @@ void TGSITargetAsmStreamer::EmitStartOfAsmFile()
OS << "DCL TEMP[0..31], LOCAL\n";
}
+void TGSITargetAsmStreamer::EmitInstructionLabel(unsigned val)
+{
+ OS << val << ":";
+}
+
MCTargetStreamer *createTGSITargetAsmStreamer(MCStreamer &S,
formatted_raw_ostream &OS,
MCInstPrinter *InstPrint,
diff --git a/lib/Target/TGSI/MCTargetDesc/TGSITargetStreamer.cpp b/lib/Target/TGSI/MCTargetDesc/TGSITargetStreamer.cpp
index 7e756c79a07..998a2f6a43a 100644
--- a/lib/Target/TGSI/MCTargetDesc/TGSITargetStreamer.cpp
+++ b/lib/Target/TGSI/MCTargetDesc/TGSITargetStreamer.cpp
@@ -22,3 +22,4 @@ TGSITargetStreamer::~TGSITargetStreamer() {}
void TGSITargetStreamer::EmitConstantPoolEntry(
const MachineConstantPoolEntry &CPE) {}
void TGSITargetStreamer::EmitStartOfAsmFile() {}
+void TGSITargetStreamer::EmitInstructionLabel(unsigned val) {}
diff --git a/lib/Target/TGSI/MCTargetDesc/TGSITargetStreamer.h b/lib/Target/TGSI/MCTargetDesc/TGSITargetStreamer.h
index dc3cd031978..0614d95ffe8 100644
--- a/lib/Target/TGSI/MCTargetDesc/TGSITargetStreamer.h
+++ b/lib/Target/TGSI/MCTargetDesc/TGSITargetStreamer.h
@@ -22,6 +22,7 @@ public:
virtual void EmitConstantPoolEntry(const MachineConstantPoolEntry &CPE);
virtual void EmitStartOfAsmFile();
+ virtual void EmitInstructionLabel(unsigned val);
};
} // namespace llvm.
diff --git a/lib/Target/TGSI/TGSIAsmPrinter.cpp b/lib/Target/TGSI/TGSIAsmPrinter.cpp
index b6a4b4c8a5e..713cabb6ddc 100644
--- a/lib/Target/TGSI/TGSIAsmPrinter.cpp
+++ b/lib/Target/TGSI/TGSIAsmPrinter.cpp
@@ -39,10 +39,12 @@ using namespace llvm;
namespace {
class TGSIAsmPrinter : public AsmPrinter {
unsigned cpi;
+ unsigned instructionCount;
public:
explicit TGSIAsmPrinter(TargetMachine &TM,
std::unique_ptr<MCStreamer> Streamer)
- : AsmPrinter(TM, std::move(Streamer)), cpi(0) {}
+ : AsmPrinter(TM, std::move(Streamer)), cpi(0),
+ instructionCount(0) {}
virtual const char *getPassName() const {
return "TGSI Assembly Printer";
@@ -58,8 +60,8 @@ namespace {
void printOperand(const MachineInstr *MI, int opNum, raw_ostream &OS);
void printInstruction(const MachineInstr *MI, raw_ostream &OS);
static const char *getRegisterName(unsigned RegNo);
-
-
+ private:
+ void EmitMCInstruction(const MCInst &mci);
};
}
@@ -140,10 +142,20 @@ static void LowerMachineInstrToMCInst(const MachineInstr *mi, MCInst &mci,
}
}
+void TGSIAsmPrinter::EmitMCInstruction(const MCInst &mci) {
+ MCTargetStreamer &TS = *OutStreamer->getTargetStreamer();
+ TGSITargetStreamer &TTS = static_cast<TGSITargetStreamer &>(TS);
+
+ TTS.EmitInstructionLabel(instructionCount);
+ OutStreamer->EmitInstruction(mci, getSubtargetInfo());
+ instructionCount++;
+}
+
void TGSIAsmPrinter::EmitInstruction(const MachineInstr *mi) {
MCInst mci;
+
LowerMachineInstrToMCInst(mi, mci, *this);
- OutStreamer->EmitInstruction(mci, getSubtargetInfo());
+ EmitMCInstruction(mci);
}
void TGSIAsmPrinter::EmitStartOfAsmFile(Module &M)
@@ -162,13 +174,13 @@ void TGSIAsmPrinter::EmitFunctionBodyStart() {
MCInst mci;
mci.setOpcode(TGSI::BGNSUB);
- OutStreamer->EmitInstruction(mci, getSubtargetInfo());
+ EmitMCInstruction(mci);
}
void TGSIAsmPrinter::EmitFunctionBodyEnd() {
MCInst mci;
mci.setOpcode(TGSI::ENDSUB);
- OutStreamer->EmitInstruction(mci, getSubtargetInfo());
+ EmitMCInstruction(mci);
}
void TGSIAsmPrinter::EmitConstantPool() {