diff options
author | Chris Lattner <sabre@nondot.org> | 2009-10-19 21:21:39 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-10-19 21:21:39 +0000 |
commit | cc309683cabf05c1ec7175ecdaf5ba97a36fb1cc (patch) | |
tree | 05be8e43b76a1123e9376041914ef5864ef56077 /lib/Target | |
parent | b472cd8f456dc9cb9e8071c2ea9e068a07566308 (diff) | |
download | external_llvm-cc309683cabf05c1ec7175ecdaf5ba97a36fb1cc.zip external_llvm-cc309683cabf05c1ec7175ecdaf5ba97a36fb1cc.tar.gz external_llvm-cc309683cabf05c1ec7175ecdaf5ba97a36fb1cc.tar.bz2 |
add printing support for SOImm operands, getting us to:
_main:
stm ,
mov r7, sp
sub sp, sp, #4
mov r0, #0
str r0,
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84535 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target')
-rw-r--r-- | lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp | 2 | ||||
-rw-r--r-- | lib/Target/ARM/AsmPrinter/ARMInstPrinter.cpp | 34 | ||||
-rw-r--r-- | lib/Target/ARM/AsmPrinter/ARMInstPrinter.h | 8 |
3 files changed, 40 insertions, 4 deletions
diff --git a/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp b/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp index ec26b26..d5e2991 100644 --- a/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp +++ b/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp @@ -85,7 +85,7 @@ namespace { } void printMCInst(const MCInst *MI) { - ARMInstPrinter(O, *MAI).printInstruction(MI); + ARMInstPrinter(O, *MAI, VerboseAsm).printInstruction(MI); } void printInstructionThroughMCStreamer(const MachineInstr *MI); diff --git a/lib/Target/ARM/AsmPrinter/ARMInstPrinter.cpp b/lib/Target/ARM/AsmPrinter/ARMInstPrinter.cpp index fc1e53f..8393e24 100644 --- a/lib/Target/ARM/AsmPrinter/ARMInstPrinter.cpp +++ b/lib/Target/ARM/AsmPrinter/ARMInstPrinter.cpp @@ -13,8 +13,9 @@ #define DEBUG_TYPE "asm-printer" #include "ARMInstPrinter.h" +#include "ARMAddressingModes.h" #include "llvm/MC/MCInst.h" -//#include "llvm/MC/MCAsmInfo.h" +#include "llvm/MC/MCAsmInfo.h" //#include "llvm/MC/MCExpr.h" //#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FormattedStream.h" @@ -47,3 +48,34 @@ void ARMInstPrinter::printOperand(const MCInst *MI, unsigned OpNo, //Op.getExpr()->print(O, &MAI); } } + +static void printSOImm(raw_ostream &O, int64_t V, bool VerboseAsm, + const MCAsmInfo *MAI) { + // Break it up into two parts that make up a shifter immediate. + V = ARM_AM::getSOImmVal(V); + assert(V != -1 && "Not a valid so_imm value!"); + + unsigned Imm = ARM_AM::getSOImmValImm(V); + unsigned Rot = ARM_AM::getSOImmValRot(V); + + // Print low-level immediate formation info, per + // A5.1.3: "Data-processing operands - Immediate". + if (Rot) { + O << "#" << Imm << ", " << Rot; + // Pretty printed version. + if (VerboseAsm) + O << ' ' << MAI->getCommentString() + << ' ' << (int)ARM_AM::rotr32(Imm, Rot); + } else { + O << "#" << Imm; + } +} + + +/// printSOImmOperand - SOImm is 4-bit rotate amount in bits 8-11 with 8-bit +/// immediate in bits 0-7. +void ARMInstPrinter::printSOImmOperand(const MCInst *MI, unsigned OpNum) { + const MCOperand &MO = MI->getOperand(OpNum); + assert(MO.isImm() && "Not a valid so_imm value!"); + printSOImm(O, MO.getImm(), VerboseAsm, &MAI); +} diff --git a/lib/Target/ARM/AsmPrinter/ARMInstPrinter.h b/lib/Target/ARM/AsmPrinter/ARMInstPrinter.h index 9c4355f..2b99dfd 100644 --- a/lib/Target/ARM/AsmPrinter/ARMInstPrinter.h +++ b/lib/Target/ARM/AsmPrinter/ARMInstPrinter.h @@ -20,8 +20,10 @@ namespace llvm { class MCOperand; class ARMInstPrinter : public MCInstPrinter { + bool VerboseAsm; public: - ARMInstPrinter(raw_ostream &O, const MCAsmInfo &MAI) : MCInstPrinter(O, MAI){} + ARMInstPrinter(raw_ostream &O, const MCAsmInfo &MAI, bool verboseAsm) + : MCInstPrinter(O, MAI), VerboseAsm(verboseAsm) {} virtual void printInst(const MCInst *MI); @@ -33,7 +35,9 @@ public: void printOperand(const MCInst *MI, unsigned OpNo, const char *Modifier = 0); - void printSOImmOperand(const MCInst *MI, unsigned OpNum) {} + void printSOImmOperand(const MCInst *MI, unsigned OpNum); + + void printSOImm2PartOperand(const MCInst *MI, unsigned OpNum) {} void printSORegOperand(const MCInst *MI, unsigned OpNum) {} void printAddrMode2Operand(const MCInst *MI, unsigned OpNum) {} |