summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-10-19 22:09:23 +0000
committerChris Lattner <sabre@nondot.org>2009-10-19 22:09:23 +0000
commitef2979b1da51df19c10175a48b0d37ac926bf8f3 (patch)
treeaafc1d91adeaec1fb661ce6c848195b156b3148e
parentc59e56190e918595916017171898368bdc89ef0d (diff)
downloadbcm5719-llvm-ef2979b1da51df19c10175a48b0d37ac926bf8f3.tar.gz
bcm5719-llvm-ef2979b1da51df19c10175a48b0d37ac926bf8f3.zip
add register list and hacked up addrmode #4 support, we now get this:
_main: stmsp! sp!, {r7, lr} mov r7, sp sub sp, sp, #4 mov r0, #0 str r0, [sp] ldr r0, LCPI1_0 bl _printf ldr r0, [sp] mov sp, r7 ldmsp! sp!, {r7, pc} Note the unhappy ldm/stm because of modifiers being ignored. llvm-svn: 84546
-rw-r--r--llvm/lib/Target/ARM/AsmPrinter/ARMInstPrinter.cpp46
-rw-r--r--llvm/lib/Target/ARM/AsmPrinter/ARMInstPrinter.h4
2 files changed, 48 insertions, 2 deletions
diff --git a/llvm/lib/Target/ARM/AsmPrinter/ARMInstPrinter.cpp b/llvm/lib/Target/ARM/AsmPrinter/ARMInstPrinter.cpp
index 95ff0a23d64..6738bbf27ca 100644
--- a/llvm/lib/Target/ARM/AsmPrinter/ARMInstPrinter.cpp
+++ b/llvm/lib/Target/ARM/AsmPrinter/ARMInstPrinter.cpp
@@ -19,6 +19,7 @@
#include "llvm/MC/MCExpr.h"
#include "llvm/Support/raw_ostream.h"
#include "ARMGenInstrNames.inc"
+#include "ARMGenRegisterNames.inc"
using namespace llvm;
// Include the auto-generated portion of the assembly writer.
@@ -111,3 +112,48 @@ void ARMInstPrinter::printAddrMode2Operand(const MCInst *MI, unsigned Op) {
<< " #" << ShImm;
O << "]";
}
+
+
+void ARMInstPrinter::printAddrMode4Operand(const MCInst *MI, unsigned OpNum,
+ const char *Modifier) {
+ // FIXME: ENABLE assert.
+ //assert((Modifier == 0 || Modifier[0] == 0) && "Cannot print modifiers");
+
+ const MCOperand &MO1 = MI->getOperand(OpNum);
+ const MCOperand &MO2 = MI->getOperand(OpNum+1);
+ ARM_AM::AMSubMode Mode = ARM_AM::getAM4SubMode(MO2.getImm());
+ if (0 && Modifier && strcmp(Modifier, "submode") == 0) {
+ if (MO1.getReg() == ARM::SP) {
+ // FIXME
+ bool isLDM = (MI->getOpcode() == ARM::LDM ||
+ MI->getOpcode() == ARM::LDM_RET ||
+ MI->getOpcode() == ARM::t2LDM ||
+ MI->getOpcode() == ARM::t2LDM_RET);
+ O << ARM_AM::getAMSubModeAltStr(Mode, isLDM);
+ } else
+ O << ARM_AM::getAMSubModeStr(Mode);
+ } else if (0 && Modifier && strcmp(Modifier, "wide") == 0) {
+ ARM_AM::AMSubMode Mode = ARM_AM::getAM4SubMode(MO2.getImm());
+ if (Mode == ARM_AM::ia)
+ O << ".w";
+ } else {
+ printOperand(MI, OpNum);
+ if (ARM_AM::getAM4WBFlag(MO2.getImm()))
+ O << "!";
+ }
+}
+
+void ARMInstPrinter::printRegisterList(const MCInst *MI, unsigned OpNum) {
+ O << "{";
+ // Always skip the first operand, it's the optional (and implicit writeback).
+ for (unsigned i = OpNum+1, e = MI->getNumOperands(); i != e; ++i) {
+#if 0 // FIXME: HANDLE WHEN LOWERING??
+ if (MI->getOperand(i).isImplicit())
+ continue;
+#endif
+ if (i != OpNum+1) O << ", ";
+
+ O << getRegisterName(MI->getOperand(i).getReg());
+ }
+ O << "}";
+}
diff --git a/llvm/lib/Target/ARM/AsmPrinter/ARMInstPrinter.h b/llvm/lib/Target/ARM/AsmPrinter/ARMInstPrinter.h
index f129c0482c9..4f744c400cb 100644
--- a/llvm/lib/Target/ARM/AsmPrinter/ARMInstPrinter.h
+++ b/llvm/lib/Target/ARM/AsmPrinter/ARMInstPrinter.h
@@ -45,7 +45,7 @@ public:
void printAddrMode3Operand(const MCInst *MI, unsigned OpNum) {}
void printAddrMode3OffsetOperand(const MCInst *MI, unsigned OpNum) {}
void printAddrMode4Operand(const MCInst *MI, unsigned OpNum,
- const char *Modifier = 0) {}
+ const char *Modifier = 0);
void printAddrMode5Operand(const MCInst *MI, unsigned OpNum,
const char *Modifier = 0) {}
void printAddrMode6Operand(const MCInst *MI, unsigned OpNum) {}
@@ -72,7 +72,7 @@ public:
void printPredicateOperand(const MCInst *MI, unsigned OpNum) {}
void printSBitModifierOperand(const MCInst *MI, unsigned OpNum) {}
void printPCLabel(const MCInst *MI, unsigned OpNum) {}
- void printRegisterList(const MCInst *MI, unsigned OpNum) {}
+ void printRegisterList(const MCInst *MI, unsigned OpNum);
void printCPInstOperand(const MCInst *MI, unsigned OpNum,
const char *Modifier) {}
void printJTBlockOperand(const MCInst *MI, unsigned OpNum) {}
OpenPOWER on IntegriCloud