forked from OSchip/llvm-project
add printing support for SOImm operands, getting us to:
_main: stm , mov r7, sp sub sp, sp, #4 mov r0, #0 str r0, llvm-svn: 84535
This commit is contained in:
parent
9dd89ba393
commit
89d47205b5
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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) {}
|
||||
|
|
Loading…
Reference in New Issue