aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-11-14 20:22:56 +0000
committerChris Lattner <sabre@nondot.org>2010-11-14 20:22:56 +0000
commitfdb2ded765316ee2ee2f796b0e2befa2c23acd1d (patch)
treea37ef947dfc0e12138e17947c72e30c54ffecef2
parent14b0c056e699adc0fdda46aca05ac7b2452e32a2 (diff)
downloadexternal_llvm-fdb2ded765316ee2ee2f796b0e2befa2c23acd1d.zip
external_llvm-fdb2ded765316ee2ee2f796b0e2befa2c23acd1d.tar.gz
external_llvm-fdb2ded765316ee2ee2f796b0e2befa2c23acd1d.tar.bz2
implement basic support for memory operands and crbit operands,
this fixes 3 more ppc tests. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119065 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Target/PowerPC/InstPrinter/PPCInstPrinter.cpp65
-rw-r--r--lib/Target/PowerPC/InstPrinter/PPCInstPrinter.h12
2 files changed, 72 insertions, 5 deletions
diff --git a/lib/Target/PowerPC/InstPrinter/PPCInstPrinter.cpp b/lib/Target/PowerPC/InstPrinter/PPCInstPrinter.cpp
index fcb5f2f..2e5060b 100644
--- a/lib/Target/PowerPC/InstPrinter/PPCInstPrinter.cpp
+++ b/lib/Target/PowerPC/InstPrinter/PPCInstPrinter.cpp
@@ -88,6 +88,71 @@ void PPCInstPrinter::printS16X4ImmOperand(const MCInst *MI, unsigned OpNo,
#endif
}
+void PPCInstPrinter::printcrbitm(const MCInst *MI, unsigned OpNo,
+ raw_ostream &O) {
+ unsigned CCReg = MI->getOperand(OpNo).getReg();
+ unsigned RegNo;
+ switch (CCReg) {
+ default: assert(0 && "Unknown CR register");
+ case PPC::CR0: RegNo = 0; break;
+ case PPC::CR1: RegNo = 1; break;
+ case PPC::CR2: RegNo = 2; break;
+ case PPC::CR3: RegNo = 3; break;
+ case PPC::CR4: RegNo = 4; break;
+ case PPC::CR5: RegNo = 5; break;
+ case PPC::CR6: RegNo = 6; break;
+ case PPC::CR7: RegNo = 7; break;
+ }
+ O << (0x80 >> RegNo);
+}
+
+void PPCInstPrinter::printMemRegImm(const MCInst *MI, unsigned OpNo,
+ raw_ostream &O) {
+ printSymbolLo(MI, OpNo, O);
+ O << '(';
+ assert(MI->getOperand(OpNo+1).isReg() && "Bad operand");
+ // FIXME: Simplify.
+ if (MI->getOperand(OpNo+1).isReg() &&
+ MI->getOperand(OpNo+1).getReg() == PPC::R0)
+ O << "0";
+ else
+ printOperand(MI, OpNo+1, O);
+ O << ')';
+}
+
+void PPCInstPrinter::printMemRegImmShifted(const MCInst *MI, unsigned OpNo,
+ raw_ostream &O) {
+ if (MI->getOperand(OpNo).isImm())
+ printS16X4ImmOperand(MI, OpNo, O);
+ else
+ printSymbolLo(MI, OpNo, O);
+ O << '(';
+
+ assert(MI->getOperand(OpNo+1).isReg() && "Bad operand");
+ // FIXME: Simplify.
+ if (MI->getOperand(OpNo+1).isReg() &&
+ MI->getOperand(OpNo+1).getReg() == PPC::R0)
+ O << "0";
+ else
+ printOperand(MI, OpNo+1, O);
+ O << ')';
+}
+
+
+void PPCInstPrinter::printMemRegReg(const MCInst *MI, unsigned OpNo,
+ raw_ostream &O) {
+ // When used as the base register, r0 reads constant zero rather than
+ // the value contained in the register. For this reason, the darwin
+ // assembler requires that we print r0 as 0 (no r) when used as the base.
+ if (MI->getOperand(OpNo).getReg() == PPC::R0)
+ O << "0";
+ else
+ printOperand(MI, OpNo, O);
+ O << ", ";
+ printOperand(MI, OpNo+1, O);
+}
+
+
/// stripRegisterPrefix - This method strips the character prefix from a
/// register name so that only the number is left. Used by for linux asm.
diff --git a/lib/Target/PowerPC/InstPrinter/PPCInstPrinter.h b/lib/Target/PowerPC/InstPrinter/PPCInstPrinter.h
index ef6a9a5..3d67efa 100644
--- a/lib/Target/PowerPC/InstPrinter/PPCInstPrinter.h
+++ b/lib/Target/PowerPC/InstPrinter/PPCInstPrinter.h
@@ -55,15 +55,17 @@ public:
void printCallOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O) {}
void printAbsAddrOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O) {}
- void printcrbitm(const MCInst *MI, unsigned OpNo, raw_ostream &O) {}
+ void printcrbitm(const MCInst *MI, unsigned OpNo, raw_ostream &O);
- void printMemRegImm(const MCInst *MI, unsigned OpNo, raw_ostream &O) {}
- void printMemRegImmShifted(const MCInst *MI, unsigned OpNo, raw_ostream &O) {}
- void printMemRegReg(const MCInst *MI, unsigned OpNo, raw_ostream &O) {}
+ void printMemRegImm(const MCInst *MI, unsigned OpNo, raw_ostream &O);
+ void printMemRegImmShifted(const MCInst *MI, unsigned OpNo, raw_ostream &O);
+ void printMemRegReg(const MCInst *MI, unsigned OpNo, raw_ostream &O);
// FIXME: Remove
void PrintSpecial(const MCInst *MI, raw_ostream &O, const char *Modifier) {}
- void printSymbolLo(const MCInst *MI, unsigned OpNo, raw_ostream &O) {}
+ void printSymbolLo(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
+ printS16ImmOperand(MI, OpNo, O);
+ }
void printSymbolHi(const MCInst *MI, unsigned OpNo, raw_ostream &O) {}
void printPICLabel(const MCInst *MI, unsigned OpNo, raw_ostream &O) {}
void printTOCEntryLabel(const MCInst *MI, unsigned OpNo, raw_ostream &O) {}