void MSP430AsmPrinter::printInstructionThroughMCStreamer(const MachineInstr *MI)
{
- MSP430MCInstLower MCInstLowering(OutContext, *Mang, getFunctionNumber(), *MAI);
+ MSP430MCInstLower MCInstLowering(OutContext, *Mang, *this);
switch (MI->getOpcode()) {
case TargetInstrInfo::DBG_LABEL:
//===----------------------------------------------------------------------===//
#define DEBUG_TYPE "asm-printer"
+#include "MSP430InstrInfo.h"
#include "MSP430InstPrinter.h"
#include "llvm/MC/MCInst.h"
#include "llvm/MC/MCAsmInfo.h"
}
}
+void MSP430InstPrinter::printCCOperand(const MCInst *MI, unsigned OpNo) {
+ unsigned CC = MI->getOperand(OpNo).getImm();
+
+ switch (CC) {
+ default:
+ llvm_unreachable("Unsupported CC code");
+ break;
+ case MSP430::COND_E:
+ O << "eq";
+ break;
+ case MSP430::COND_NE:
+ O << "ne";
+ break;
+ case MSP430::COND_HS:
+ O << "hs";
+ break;
+ case MSP430::COND_LO:
+ O << "lo";
+ break;
+ case MSP430::COND_GE:
+ O << "ge";
+ break;
+ case MSP430::COND_L:
+ O << 'l';
+ break;
+ }
+}
//===----------------------------------------------------------------------===//
#include "MSP430MCInstLower.h"
+#include "llvm/CodeGen/AsmPrinter.h"
+#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCContext.h"
MCSymbol *MSP430MCInstLower::
GetJumpTableSymbol(const MachineOperand &MO) const {
SmallString<256> Name;
- raw_svector_ostream(Name) << MAI.getPrivateGlobalPrefix() << "JTI"
- << CurFunctionNumber << '_' << MO.getIndex();
+ raw_svector_ostream(Name) << Printer.MAI->getPrivateGlobalPrefix() << "JTI"
+ << Printer.getFunctionNumber() << '_'
+ << MO.getIndex();
switch (MO.getTargetFlags()) {
default: llvm_unreachable("Unknown target flag on GV operand");
MCSymbol *MSP430MCInstLower::
GetConstantPoolIndexSymbol(const MachineOperand &MO) const {
SmallString<256> Name;
- raw_svector_ostream(Name) << MAI.getPrivateGlobalPrefix() << "CPI"
- << CurFunctionNumber << '_' << MO.getIndex();
+ raw_svector_ostream(Name) << Printer.MAI->getPrivateGlobalPrefix() << "CPI"
+ << Printer.getFunctionNumber() << '_'
+ << MO.getIndex();
switch (MO.getTargetFlags()) {
default: llvm_unreachable("Unknown target flag on GV operand");
case MachineOperand::MO_Immediate:
MCOp = MCOperand::CreateImm(MO.getImm());
break;
-#if 0
case MachineOperand::MO_MachineBasicBlock:
MCOp = MCOperand::CreateExpr(MCSymbolRefExpr::Create(
- AsmPrinter.GetMBBSymbol(MO.getMBB()->getNumber()), Ctx));
+ Printer.GetMBBSymbol(MO.getMBB()->getNumber()), Ctx));
break;
-#endif
case MachineOperand::MO_GlobalAddress:
MCOp = LowerSymbolOperand(MO, GetGlobalAddressSymbol(MO));
break;
#include "llvm/Support/Compiler.h"
namespace llvm {
+ class AsmPrinter;
class MCAsmInfo;
class MCContext;
class MCInst;
MCContext &Ctx;
Mangler &Mang;
- const unsigned CurFunctionNumber;
- const MCAsmInfo &MAI;
-
+ AsmPrinter &Printer;
public:
- MSP430MCInstLower(MCContext &ctx, Mangler &mang, unsigned FuncNum,
- const MCAsmInfo &mai)
- : Ctx(ctx), Mang(mang), CurFunctionNumber(FuncNum), MAI(mai) {}
+ MSP430MCInstLower(MCContext &ctx, Mangler &mang, AsmPrinter &printer)
+ : Ctx(ctx), Mang(mang), Printer(printer) {}
void Lower(const MachineInstr *MI, MCInst &OutMI) const;
MCOperand LowerSymbolOperand(const MachineOperand &MO, MCSymbol *Sym) const;