From e30b4644b613a130318cdf240ad237b0afbc525a Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Fri, 17 Aug 2012 15:52:15 +0000 Subject: radeon/llvm: Add AsmPrinter --- .../radeon/InstPrinter/AMDGPUInstPrinter.cpp | 34 ++++++++++++++++++++++ .../drivers/radeon/InstPrinter/AMDGPUInstPrinter.h | 34 ++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 src/gallium/drivers/radeon/InstPrinter/AMDGPUInstPrinter.cpp create mode 100644 src/gallium/drivers/radeon/InstPrinter/AMDGPUInstPrinter.h (limited to 'src/gallium/drivers/radeon/InstPrinter') diff --git a/src/gallium/drivers/radeon/InstPrinter/AMDGPUInstPrinter.cpp b/src/gallium/drivers/radeon/InstPrinter/AMDGPUInstPrinter.cpp new file mode 100644 index 00000000000..b6ab9b22fb1 --- /dev/null +++ b/src/gallium/drivers/radeon/InstPrinter/AMDGPUInstPrinter.cpp @@ -0,0 +1,34 @@ + +#include "AMDGPUInstPrinter.h" +#include "llvm/MC/MCInst.h" + +using namespace llvm; + +void AMDGPUInstPrinter::printInst(const MCInst *MI, raw_ostream &OS, + StringRef Annot) { + printInstruction(MI, OS); + + printAnnotation(OS, Annot); +} + +void AMDGPUInstPrinter::printOperand(const MCInst *MI, unsigned OpNo, + raw_ostream &O) { + + const MCOperand &Op = MI->getOperand(OpNo); + if (Op.isReg()) { + O << getRegisterName(Op.getReg()); + } else if (Op.isImm()) { + O << Op.getImm(); + } else if (Op.isFPImm()) { + O << Op.getFPImm(); + } else { + assert(!"unknown operand type in printOperand"); + } +} + +void AMDGPUInstPrinter::printMemOperand(const MCInst *MI, unsigned OpNo, + raw_ostream &O) { + printOperand(MI, OpNo, O); +} + +#include "AMDGPUGenAsmWriter.inc" diff --git a/src/gallium/drivers/radeon/InstPrinter/AMDGPUInstPrinter.h b/src/gallium/drivers/radeon/InstPrinter/AMDGPUInstPrinter.h new file mode 100644 index 00000000000..62c1a5ee04f --- /dev/null +++ b/src/gallium/drivers/radeon/InstPrinter/AMDGPUInstPrinter.h @@ -0,0 +1,34 @@ + +#ifndef AMDGPUINSTPRINTER_H +#define AMDGPUINSTPRINTER_H + +#include "llvm/ADT/StringRef.h" +#include "llvm/MC/MCInstPrinter.h" +#include "llvm/Support/raw_ostream.h" + +namespace llvm { + +class AMDGPUInstPrinter : public MCInstPrinter { +public: + AMDGPUInstPrinter(const MCAsmInfo &MAI, const MCInstrInfo &MII, + const MCRegisterInfo &MRI) + : MCInstPrinter(MAI, MII, MRI) {} + + //Autogenerated by tblgen + void printInstruction(const MCInst *MI, raw_ostream &O); + static const char *getRegisterName(unsigned RegNo); + +// virtual void printRegName(raw_ostream &OS, unsigned RegNo) const; + virtual void printInst(const MCInst *MI, raw_ostream &O, StringRef Annot); + +private: + void printOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O); +// void printUnsignedImm(const MCInst *MI, int OpNo, raw_ostream &O); + void printMemOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O); + + +}; + +} // End namespace llvm + +#endif // AMDGPUINSTRPRINTER_H -- cgit v1.2.3