mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-14 15:28:20 +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:
@@ -295,7 +295,7 @@ bool MSP430AsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI,
|
|||||||
void MSP430AsmPrinter::printInstructionThroughMCStreamer(const MachineInstr *MI)
|
void MSP430AsmPrinter::printInstructionThroughMCStreamer(const MachineInstr *MI)
|
||||||
{
|
{
|
||||||
|
|
||||||
MSP430MCInstLower MCInstLowering(OutContext, *Mang, getFunctionNumber(), *MAI);
|
MSP430MCInstLower MCInstLowering(OutContext, *Mang, *this);
|
||||||
|
|
||||||
switch (MI->getOpcode()) {
|
switch (MI->getOpcode()) {
|
||||||
case TargetInstrInfo::DBG_LABEL:
|
case TargetInstrInfo::DBG_LABEL:
|
||||||
|
@@ -12,6 +12,7 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#define DEBUG_TYPE "asm-printer"
|
#define DEBUG_TYPE "asm-printer"
|
||||||
|
#include "MSP430InstrInfo.h"
|
||||||
#include "MSP430InstPrinter.h"
|
#include "MSP430InstPrinter.h"
|
||||||
#include "llvm/MC/MCInst.h"
|
#include "llvm/MC/MCInst.h"
|
||||||
#include "llvm/MC/MCAsmInfo.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,
|
void printSrcMemOperand(const MCInst *MI, unsigned OpNo,
|
||||||
const char *Modifier = 0);
|
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 "MSP430MCInstLower.h"
|
||||||
|
#include "llvm/CodeGen/AsmPrinter.h"
|
||||||
|
#include "llvm/CodeGen/MachineBasicBlock.h"
|
||||||
#include "llvm/CodeGen/MachineInstr.h"
|
#include "llvm/CodeGen/MachineInstr.h"
|
||||||
#include "llvm/MC/MCAsmInfo.h"
|
#include "llvm/MC/MCAsmInfo.h"
|
||||||
#include "llvm/MC/MCContext.h"
|
#include "llvm/MC/MCContext.h"
|
||||||
@@ -43,8 +45,9 @@ GetGlobalAddressSymbol(const MachineOperand &MO) const {
|
|||||||
MCSymbol *MSP430MCInstLower::
|
MCSymbol *MSP430MCInstLower::
|
||||||
GetJumpTableSymbol(const MachineOperand &MO) const {
|
GetJumpTableSymbol(const MachineOperand &MO) const {
|
||||||
SmallString<256> Name;
|
SmallString<256> Name;
|
||||||
raw_svector_ostream(Name) << MAI.getPrivateGlobalPrefix() << "JTI"
|
raw_svector_ostream(Name) << Printer.MAI->getPrivateGlobalPrefix() << "JTI"
|
||||||
<< CurFunctionNumber << '_' << MO.getIndex();
|
<< Printer.getFunctionNumber() << '_'
|
||||||
|
<< MO.getIndex();
|
||||||
|
|
||||||
switch (MO.getTargetFlags()) {
|
switch (MO.getTargetFlags()) {
|
||||||
default: llvm_unreachable("Unknown target flag on GV operand");
|
default: llvm_unreachable("Unknown target flag on GV operand");
|
||||||
@@ -58,8 +61,9 @@ GetJumpTableSymbol(const MachineOperand &MO) const {
|
|||||||
MCSymbol *MSP430MCInstLower::
|
MCSymbol *MSP430MCInstLower::
|
||||||
GetConstantPoolIndexSymbol(const MachineOperand &MO) const {
|
GetConstantPoolIndexSymbol(const MachineOperand &MO) const {
|
||||||
SmallString<256> Name;
|
SmallString<256> Name;
|
||||||
raw_svector_ostream(Name) << MAI.getPrivateGlobalPrefix() << "CPI"
|
raw_svector_ostream(Name) << Printer.MAI->getPrivateGlobalPrefix() << "CPI"
|
||||||
<< CurFunctionNumber << '_' << MO.getIndex();
|
<< Printer.getFunctionNumber() << '_'
|
||||||
|
<< MO.getIndex();
|
||||||
|
|
||||||
switch (MO.getTargetFlags()) {
|
switch (MO.getTargetFlags()) {
|
||||||
default: llvm_unreachable("Unknown target flag on GV operand");
|
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:
|
case MachineOperand::MO_Immediate:
|
||||||
MCOp = MCOperand::CreateImm(MO.getImm());
|
MCOp = MCOperand::CreateImm(MO.getImm());
|
||||||
break;
|
break;
|
||||||
#if 0
|
|
||||||
case MachineOperand::MO_MachineBasicBlock:
|
case MachineOperand::MO_MachineBasicBlock:
|
||||||
MCOp = MCOperand::CreateExpr(MCSymbolRefExpr::Create(
|
MCOp = MCOperand::CreateExpr(MCSymbolRefExpr::Create(
|
||||||
AsmPrinter.GetMBBSymbol(MO.getMBB()->getNumber()), Ctx));
|
Printer.GetMBBSymbol(MO.getMBB()->getNumber()), Ctx));
|
||||||
break;
|
break;
|
||||||
#endif
|
|
||||||
case MachineOperand::MO_GlobalAddress:
|
case MachineOperand::MO_GlobalAddress:
|
||||||
MCOp = LowerSymbolOperand(MO, GetGlobalAddressSymbol(MO));
|
MCOp = LowerSymbolOperand(MO, GetGlobalAddressSymbol(MO));
|
||||||
break;
|
break;
|
||||||
|
@@ -13,6 +13,7 @@
|
|||||||
#include "llvm/Support/Compiler.h"
|
#include "llvm/Support/Compiler.h"
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
class AsmPrinter;
|
||||||
class MCAsmInfo;
|
class MCAsmInfo;
|
||||||
class MCContext;
|
class MCContext;
|
||||||
class MCInst;
|
class MCInst;
|
||||||
@@ -29,13 +30,10 @@ class VISIBILITY_HIDDEN MSP430MCInstLower {
|
|||||||
MCContext &Ctx;
|
MCContext &Ctx;
|
||||||
Mangler &Mang;
|
Mangler &Mang;
|
||||||
|
|
||||||
const unsigned CurFunctionNumber;
|
AsmPrinter &Printer;
|
||||||
const MCAsmInfo &MAI;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MSP430MCInstLower(MCContext &ctx, Mangler &mang, unsigned FuncNum,
|
MSP430MCInstLower(MCContext &ctx, Mangler &mang, AsmPrinter &printer)
|
||||||
const MCAsmInfo &mai)
|
: Ctx(ctx), Mang(mang), Printer(printer) {}
|
||||||
: Ctx(ctx), Mang(mang), CurFunctionNumber(FuncNum), MAI(mai) {}
|
|
||||||
void Lower(const MachineInstr *MI, MCInst &OutMI) const;
|
void Lower(const MachineInstr *MI, MCInst &OutMI) const;
|
||||||
|
|
||||||
MCOperand LowerSymbolOperand(const MachineOperand &MO, MCSymbol *Sym) const;
|
MCOperand LowerSymbolOperand(const MachineOperand &MO, MCSymbol *Sym) const;
|
||||||
|
Reference in New Issue
Block a user