mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-10 02:36:06 +00:00
Add basic block operands & jump kinds
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84709 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
3d6e560eef
commit
dc2165e18e
@ -295,7 +295,7 @@ bool MSP430AsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI,
|
||||
void MSP430AsmPrinter::printInstructionThroughMCStreamer(const MachineInstr *MI)
|
||||
{
|
||||
|
||||
MSP430MCInstLower MCInstLowering(OutContext, *Mang, getFunctionNumber(), *MAI);
|
||||
MSP430MCInstLower MCInstLowering(OutContext, *Mang, *this);
|
||||
|
||||
switch (MI->getOpcode()) {
|
||||
case TargetInstrInfo::DBG_LABEL:
|
||||
|
@ -12,6 +12,7 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#define DEBUG_TYPE "asm-printer"
|
||||
#include "MSP430InstrInfo.h"
|
||||
#include "MSP430InstPrinter.h"
|
||||
#include "llvm/MC/MCInst.h"
|
||||
#include "llvm/MC/MCAsmInfo.h"
|
||||
@ -75,3 +76,30 @@ void MSP430InstPrinter::printSrcMemOperand(const MCInst *MI, unsigned OpNo,
|
||||
}
|
||||
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -39,8 +39,7 @@ namespace llvm
|
||||
void printSrcMemOperand(const MCInst *MI, unsigned OpNo,
|
||||
const char *Modifier = 0);
|
||||
|
||||
void printCCOperand(const MCInst *MI, unsigned OpNo) {
|
||||
}
|
||||
void printCCOperand(const MCInst *MI, unsigned OpNo);
|
||||
|
||||
};
|
||||
}
|
||||
|
@ -13,6 +13,8 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#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"
|
||||
@ -43,8 +45,9 @@ GetGlobalAddressSymbol(const MachineOperand &MO) const {
|
||||
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");
|
||||
@ -58,8 +61,9 @@ GetJumpTableSymbol(const MachineOperand &MO) const {
|
||||
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");
|
||||
@ -107,12 +111,10 @@ void MSP430MCInstLower::Lower(const MachineInstr *MI, MCInst &OutMI) const {
|
||||
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;
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "llvm/Support/Compiler.h"
|
||||
|
||||
namespace llvm {
|
||||
class AsmPrinter;
|
||||
class MCAsmInfo;
|
||||
class MCContext;
|
||||
class MCInst;
|
||||
@ -29,13 +30,10 @@ class VISIBILITY_HIDDEN MSP430MCInstLower {
|
||||
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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user