aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Korobeynikov <asl@math.spbu.ru>2009-10-21 00:13:05 +0000
committerAnton Korobeynikov <asl@math.spbu.ru>2009-10-21 00:13:05 +0000
commit7199ce5ab3517ffe7d78878bfc78e5ad3fb42054 (patch)
treeb3e95e83275e199b4c3985bb85a66c254ea2ed47
parent3fcbbcd7945d1216a8572ad0c543ba9c98de3723 (diff)
downloadexternal_llvm-7199ce5ab3517ffe7d78878bfc78e5ad3fb42054.zip
external_llvm-7199ce5ab3517ffe7d78878bfc78e5ad3fb42054.tar.gz
external_llvm-7199ce5ab3517ffe7d78878bfc78e5ad3fb42054.tar.bz2
Add basic block operands & jump kinds
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84709 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp2
-rw-r--r--lib/Target/MSP430/AsmPrinter/MSP430InstPrinter.cpp28
-rw-r--r--lib/Target/MSP430/AsmPrinter/MSP430InstPrinter.h3
-rw-r--r--lib/Target/MSP430/AsmPrinter/MSP430MCInstLower.cpp16
-rw-r--r--lib/Target/MSP430/AsmPrinter/MSP430MCInstLower.h10
5 files changed, 43 insertions, 16 deletions
diff --git a/lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp b/lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp
index baaf929..7336880 100644
--- a/lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp
+++ b/lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp
@@ -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:
diff --git a/lib/Target/MSP430/AsmPrinter/MSP430InstPrinter.cpp b/lib/Target/MSP430/AsmPrinter/MSP430InstPrinter.cpp
index 8760ed5..8fcbab5 100644
--- a/lib/Target/MSP430/AsmPrinter/MSP430InstPrinter.cpp
+++ b/lib/Target/MSP430/AsmPrinter/MSP430InstPrinter.cpp
@@ -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;
+ }
+}
diff --git a/lib/Target/MSP430/AsmPrinter/MSP430InstPrinter.h b/lib/Target/MSP430/AsmPrinter/MSP430InstPrinter.h
index b6281cc..3d4b931 100644
--- a/lib/Target/MSP430/AsmPrinter/MSP430InstPrinter.h
+++ b/lib/Target/MSP430/AsmPrinter/MSP430InstPrinter.h
@@ -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);
};
}
diff --git a/lib/Target/MSP430/AsmPrinter/MSP430MCInstLower.cpp b/lib/Target/MSP430/AsmPrinter/MSP430MCInstLower.cpp
index 175b6b3..8c6e2fe 100644
--- a/lib/Target/MSP430/AsmPrinter/MSP430MCInstLower.cpp
+++ b/lib/Target/MSP430/AsmPrinter/MSP430MCInstLower.cpp
@@ -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;
diff --git a/lib/Target/MSP430/AsmPrinter/MSP430MCInstLower.h b/lib/Target/MSP430/AsmPrinter/MSP430MCInstLower.h
index d2a76b9..6064246 100644
--- a/lib/Target/MSP430/AsmPrinter/MSP430MCInstLower.h
+++ b/lib/Target/MSP430/AsmPrinter/MSP430MCInstLower.h
@@ -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;