Don't hardcode the %reg format in the streamer.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132451 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola 2011-06-02 02:34:55 +00:00
parent 491a13691d
commit cde4ce411b
11 changed files with 26 additions and 22 deletions

View File

@ -45,8 +45,8 @@ public:
/// "MOV32ri") or empty if we can't resolve it. /// "MOV32ri") or empty if we can't resolve it.
virtual StringRef getOpcodeName(unsigned Opcode) const; virtual StringRef getOpcodeName(unsigned Opcode) const;
/// getRegName - Return the assembler register name. /// printRegName - Print the assembler register name.
virtual StringRef getRegName(unsigned RegNo) const; virtual void printRegName(raw_ostream &OS, unsigned RegNo) const;
unsigned getAvailableFeatures() const { return AvailableFeatures; } unsigned getAvailableFeatures() const { return AvailableFeatures; }
void setAvailableFeatures(unsigned Value) { AvailableFeatures = Value; } void setAvailableFeatures(unsigned Value) { AvailableFeatures = Value; }

View File

@ -825,7 +825,7 @@ void MCAsmStreamer::EmitRegisterName(int64_t Register) {
if (InstPrinter) { if (InstPrinter) {
const TargetAsmInfo &asmInfo = getContext().getTargetAsmInfo(); const TargetAsmInfo &asmInfo = getContext().getTargetAsmInfo();
unsigned LLVMRegister = asmInfo.getLLVMRegNum(Register, true); unsigned LLVMRegister = asmInfo.getLLVMRegNum(Register, true);
OS << '%' << InstPrinter->getRegName(LLVMRegister); InstPrinter->printRegName(OS, LLVMRegister);
} else { } else {
OS << Register; OS << Register;
} }
@ -1169,8 +1169,10 @@ void MCAsmStreamer::EmitPersonality(const MCSymbol *Personality) {
} }
void MCAsmStreamer::EmitSetFP(unsigned FpReg, unsigned SpReg, int64_t Offset) { void MCAsmStreamer::EmitSetFP(unsigned FpReg, unsigned SpReg, int64_t Offset) {
OS << "\t.setfp\t" << InstPrinter->getRegName(FpReg) OS << "\t.setfp\t";
<< ", " << InstPrinter->getRegName(SpReg); InstPrinter->printRegName(OS, FpReg);
OS << ", ";
InstPrinter->printRegName(OS, SpReg);
if (Offset) if (Offset)
OS << ", #" << Offset; OS << ", #" << Offset;
EmitEOL(); EmitEOL();
@ -1189,10 +1191,12 @@ void MCAsmStreamer::EmitRegSave(const SmallVectorImpl<unsigned> &RegList,
else else
OS << "\t.save\t{"; OS << "\t.save\t{";
OS << InstPrinter->getRegName(RegList[0]); InstPrinter->printRegName(OS, RegList[0]);
for (unsigned i = 1, e = RegList.size(); i != e; ++i) for (unsigned i = 1, e = RegList.size(); i != e; ++i) {
OS << ", " << InstPrinter->getRegName(RegList[i]); OS << ", ";
InstPrinter->printRegName(OS, RegList[i]);
}
OS << "}"; OS << "}";
EmitEOL(); EmitEOL();

View File

@ -20,7 +20,6 @@ StringRef MCInstPrinter::getOpcodeName(unsigned Opcode) const {
return ""; return "";
} }
StringRef MCInstPrinter::getRegName(unsigned RegNo) const { void MCInstPrinter::printRegName(raw_ostream &OS, unsigned RegNo) const {
assert(0 && "Target should implement this"); assert(0 && "Target should implement this");
return "";
} }

View File

@ -29,8 +29,8 @@ StringRef ARMInstPrinter::getOpcodeName(unsigned Opcode) const {
return getInstructionName(Opcode); return getInstructionName(Opcode);
} }
StringRef ARMInstPrinter::getRegName(unsigned RegNo) const { void ARMInstPrinter::printRegName(raw_ostream &OS, unsigned RegNo) const {
return getRegisterName(RegNo); OS << getRegisterName(RegNo);
} }
void ARMInstPrinter::printInst(const MCInst *MI, raw_ostream &O) { void ARMInstPrinter::printInst(const MCInst *MI, raw_ostream &O) {

View File

@ -28,7 +28,7 @@ public:
virtual void printInst(const MCInst *MI, raw_ostream &O); virtual void printInst(const MCInst *MI, raw_ostream &O);
virtual StringRef getOpcodeName(unsigned Opcode) const; virtual StringRef getOpcodeName(unsigned Opcode) const;
virtual StringRef getRegName(unsigned RegNo) const; virtual void printRegName(raw_ostream &OS, unsigned RegNo) const;
static const char *getInstructionName(unsigned Opcode); static const char *getInstructionName(unsigned Opcode);

View File

@ -26,8 +26,8 @@ StringRef PPCInstPrinter::getOpcodeName(unsigned Opcode) const {
return getInstructionName(Opcode); return getInstructionName(Opcode);
} }
StringRef PPCInstPrinter::getRegName(unsigned RegNo) const { void PPCInstPrinter::printRegName(raw_ostream &OS, unsigned RegNo) const {
return getRegisterName(RegNo); OS << getRegisterName(RegNo);
} }
void PPCInstPrinter::printInst(const MCInst *MI, raw_ostream &O) { void PPCInstPrinter::printInst(const MCInst *MI, raw_ostream &O) {

View File

@ -33,7 +33,7 @@ public:
return SyntaxVariant == 1; return SyntaxVariant == 1;
} }
StringRef getRegName(unsigned RegNo) const; virtual void printRegName(raw_ostream &OS, unsigned RegNo) const;
virtual void printInst(const MCInst *MI, raw_ostream &O); virtual void printInst(const MCInst *MI, raw_ostream &O);
virtual StringRef getOpcodeName(unsigned Opcode) const; virtual StringRef getOpcodeName(unsigned Opcode) const;

View File

@ -41,8 +41,9 @@ X86ATTInstPrinter::X86ATTInstPrinter(TargetMachine &TM, const MCAsmInfo &MAI)
&TM.getSubtarget<X86Subtarget>())); &TM.getSubtarget<X86Subtarget>()));
} }
StringRef X86ATTInstPrinter::getRegName(unsigned RegNo) const { void X86ATTInstPrinter::printRegName(raw_ostream &OS,
return getRegisterName(RegNo); unsigned RegNo) const {
OS << '%' << getRegisterName(RegNo);
} }
void X86ATTInstPrinter::printInst(const MCInst *MI, raw_ostream &OS) { void X86ATTInstPrinter::printInst(const MCInst *MI, raw_ostream &OS) {

View File

@ -26,7 +26,7 @@ class X86ATTInstPrinter : public MCInstPrinter {
public: public:
X86ATTInstPrinter(TargetMachine &TM, const MCAsmInfo &MAI); X86ATTInstPrinter(TargetMachine &TM, const MCAsmInfo &MAI);
StringRef getRegName(unsigned RegNo) const; virtual void printRegName(raw_ostream &OS, unsigned RegNo) const;
virtual void printInst(const MCInst *MI, raw_ostream &OS); virtual void printInst(const MCInst *MI, raw_ostream &OS);
virtual StringRef getOpcodeName(unsigned Opcode) const; virtual StringRef getOpcodeName(unsigned Opcode) const;

View File

@ -29,8 +29,8 @@ using namespace llvm;
#define GET_INSTRUCTION_NAME #define GET_INSTRUCTION_NAME
#include "X86GenAsmWriter1.inc" #include "X86GenAsmWriter1.inc"
StringRef X86IntelInstPrinter::getRegName(unsigned RegNo) const { void X86IntelInstPrinter::printRegName(raw_ostream &OS, unsigned RegNo) const {
return getRegisterName(RegNo); OS << getRegisterName(RegNo);
} }
void X86IntelInstPrinter::printInst(const MCInst *MI, raw_ostream &OS) { void X86IntelInstPrinter::printInst(const MCInst *MI, raw_ostream &OS) {

View File

@ -27,7 +27,7 @@ public:
X86IntelInstPrinter(TargetMachine &TM, const MCAsmInfo &MAI) X86IntelInstPrinter(TargetMachine &TM, const MCAsmInfo &MAI)
: MCInstPrinter(MAI) {} : MCInstPrinter(MAI) {}
StringRef getRegName(unsigned RegNo) const; virtual void printRegName(raw_ostream &OS, unsigned RegNo) const;
virtual void printInst(const MCInst *MI, raw_ostream &OS); virtual void printInst(const MCInst *MI, raw_ostream &OS);
virtual StringRef getOpcodeName(unsigned Opcode) const; virtual StringRef getOpcodeName(unsigned Opcode) const;