summaryrefslogtreecommitdiff
path: root/lib/Target/MSP430
diff options
context:
space:
mode:
authorRoman Divacky <rdivacky@FreeBSD.org>2010-04-06 15:52:58 +0000
committerRoman Divacky <rdivacky@FreeBSD.org>2010-04-06 15:52:58 +0000
commit9f4a1da9a0a56a0b0a7f8249f34b3cdea6179c41 (patch)
tree0dd020f28a4846707f8d60717d9b2921ea187bd8 /lib/Target/MSP430
parentb5efedaf2ab20d844d5a21cdef76b55acbf4f01c (diff)
downloadsrc-test2-9f4a1da9a0a56a0b0a7f8249f34b3cdea6179c41.tar.gz
src-test2-9f4a1da9a0a56a0b0a7f8249f34b3cdea6179c41.zip
Notes
Diffstat (limited to 'lib/Target/MSP430')
-rw-r--r--lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp65
-rw-r--r--lib/Target/MSP430/AsmPrinter/MSP430InstPrinter.cpp13
-rw-r--r--lib/Target/MSP430/AsmPrinter/MSP430InstPrinter.h19
-rw-r--r--lib/Target/MSP430/MSP430.td9
-rw-r--r--lib/Target/MSP430/MSP430InstrFormats.td8
5 files changed, 41 insertions, 73 deletions
diff --git a/lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp b/lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp
index 04ac6f1949f1..56f72bbc1474 100644
--- a/lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp
+++ b/lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp
@@ -24,7 +24,6 @@
#include "llvm/Module.h"
#include "llvm/Assembly/Writer.h"
#include "llvm/CodeGen/AsmPrinter.h"
-#include "llvm/CodeGen/DwarfWriter.h"
#include "llvm/CodeGen/MachineModuleInfo.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/MachineConstantPool.h"
@@ -36,50 +35,36 @@
#include "llvm/Target/TargetData.h"
#include "llvm/Target/TargetLoweringObjectFile.h"
#include "llvm/Target/TargetRegistry.h"
-#include "llvm/Support/FormattedStream.h"
+#include "llvm/Support/raw_ostream.h"
using namespace llvm;
namespace {
class MSP430AsmPrinter : public AsmPrinter {
public:
- MSP430AsmPrinter(formatted_raw_ostream &O, TargetMachine &TM,
- MCStreamer &Streamer)
- : AsmPrinter(O, TM, Streamer) {}
+ MSP430AsmPrinter(TargetMachine &TM, MCStreamer &Streamer)
+ : AsmPrinter(TM, Streamer) {}
virtual const char *getPassName() const {
return "MSP430 Assembly Printer";
}
- void printMCInst(const MCInst *MI) {
- MSP430InstPrinter(O, *MAI).printInstruction(MI);
- }
void printOperand(const MachineInstr *MI, int OpNum,
- const char* Modifier = 0);
- void printPCRelImmOperand(const MachineInstr *MI, int OpNum) {
- printOperand(MI, OpNum);
- }
+ raw_ostream &O, const char* Modifier = 0);
void printSrcMemOperand(const MachineInstr *MI, int OpNum,
- const char* Modifier = 0);
- void printCCOperand(const MachineInstr *MI, int OpNum);
- void printMachineInstruction(const MachineInstr * MI);
+ raw_ostream &O);
bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
- unsigned AsmVariant,
- const char *ExtraCode);
+ unsigned AsmVariant, const char *ExtraCode,
+ raw_ostream &O);
bool PrintAsmMemoryOperand(const MachineInstr *MI,
unsigned OpNo, unsigned AsmVariant,
- const char *ExtraCode);
+ const char *ExtraCode, raw_ostream &O);
void EmitInstruction(const MachineInstr *MI);
-
- void getAnalysisUsage(AnalysisUsage &AU) const {
- AsmPrinter::getAnalysisUsage(AU);
- AU.setPreservesAll();
- }
};
} // end of anonymous namespace
void MSP430AsmPrinter::printOperand(const MachineInstr *MI, int OpNum,
- const char* Modifier) {
+ raw_ostream &O, const char *Modifier) {
const MachineOperand &MO = MI->getOperand(OpNum);
switch (MO.getType()) {
default: assert(0 && "Not implemented yet!");
@@ -126,7 +111,7 @@ void MSP430AsmPrinter::printOperand(const MachineInstr *MI, int OpNum,
}
void MSP430AsmPrinter::printSrcMemOperand(const MachineInstr *MI, int OpNum,
- const char* Modifier) {
+ raw_ostream &O) {
const MachineOperand &Base = MI->getOperand(OpNum);
const MachineOperand &Disp = MI->getOperand(OpNum+1);
@@ -135,48 +120,37 @@ void MSP430AsmPrinter::printSrcMemOperand(const MachineInstr *MI, int OpNum,
// Imm here is in fact global address - print extra modifier.
if (Disp.isImm() && !Base.getReg())
O << '&';
- printOperand(MI, OpNum+1, "nohash");
+ printOperand(MI, OpNum+1, O, "nohash");
// Print register base field
if (Base.getReg()) {
O << '(';
- printOperand(MI, OpNum);
+ printOperand(MI, OpNum, O);
O << ')';
}
}
-void MSP430AsmPrinter::printCCOperand(const MachineInstr *MI, int OpNum) {
- switch (MI->getOperand(OpNum).getImm()) {
- default: assert(0 && "Unknown cond");
- case MSP430CC::COND_E: O << "eq"; break;
- case MSP430CC::COND_NE: O << "ne"; break;
- case MSP430CC::COND_HS: O << "hs"; break;
- case MSP430CC::COND_LO: O << "lo"; break;
- case MSP430CC::COND_GE: O << "ge"; break;
- case MSP430CC::COND_L: O << 'l'; break;
- }
-}
-
/// PrintAsmOperand - Print out an operand for an inline asm expression.
///
bool MSP430AsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
unsigned AsmVariant,
- const char *ExtraCode) {
+ const char *ExtraCode, raw_ostream &O) {
// Does this asm operand have a single letter operand modifier?
if (ExtraCode && ExtraCode[0])
return true; // Unknown modifier.
- printOperand(MI, OpNo);
+ printOperand(MI, OpNo, O);
return false;
}
bool MSP430AsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI,
unsigned OpNo, unsigned AsmVariant,
- const char *ExtraCode) {
+ const char *ExtraCode,
+ raw_ostream &O) {
if (ExtraCode && ExtraCode[0]) {
return true; // Unknown modifier.
}
- printSrcMemOperand(MI, OpNo);
+ printSrcMemOperand(MI, OpNo, O);
return false;
}
@@ -191,10 +165,9 @@ void MSP430AsmPrinter::EmitInstruction(const MachineInstr *MI) {
static MCInstPrinter *createMSP430MCInstPrinter(const Target &T,
unsigned SyntaxVariant,
- const MCAsmInfo &MAI,
- raw_ostream &O) {
+ const MCAsmInfo &MAI) {
if (SyntaxVariant == 0)
- return new MSP430InstPrinter(O, MAI);
+ return new MSP430InstPrinter(MAI);
return 0;
}
diff --git a/lib/Target/MSP430/AsmPrinter/MSP430InstPrinter.cpp b/lib/Target/MSP430/AsmPrinter/MSP430InstPrinter.cpp
index d7636e68a0d6..c15d4085bc8b 100644
--- a/lib/Target/MSP430/AsmPrinter/MSP430InstPrinter.cpp
+++ b/lib/Target/MSP430/AsmPrinter/MSP430InstPrinter.cpp
@@ -28,11 +28,12 @@ using namespace llvm;
#include "MSP430GenAsmWriter.inc"
#undef MachineInstr
-void MSP430InstPrinter::printInst(const MCInst *MI) {
- printInstruction(MI);
+void MSP430InstPrinter::printInst(const MCInst *MI, raw_ostream &O) {
+ printInstruction(MI, O);
}
-void MSP430InstPrinter::printPCRelImmOperand(const MCInst *MI, unsigned OpNo) {
+void MSP430InstPrinter::printPCRelImmOperand(const MCInst *MI, unsigned OpNo,
+ raw_ostream &O) {
const MCOperand &Op = MI->getOperand(OpNo);
if (Op.isImm())
O << Op.getImm();
@@ -43,7 +44,7 @@ void MSP430InstPrinter::printPCRelImmOperand(const MCInst *MI, unsigned OpNo) {
}
void MSP430InstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
- const char *Modifier) {
+ raw_ostream &O, const char *Modifier) {
assert((Modifier == 0 || Modifier[0] == 0) && "No modifiers supported");
const MCOperand &Op = MI->getOperand(OpNo);
if (Op.isReg()) {
@@ -57,6 +58,7 @@ void MSP430InstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
}
void MSP430InstPrinter::printSrcMemOperand(const MCInst *MI, unsigned OpNo,
+ raw_ostream &O,
const char *Modifier) {
const MCOperand &Base = MI->getOperand(OpNo);
const MCOperand &Disp = MI->getOperand(OpNo+1);
@@ -84,7 +86,8 @@ void MSP430InstPrinter::printSrcMemOperand(const MCInst *MI, unsigned OpNo,
O << '(' << getRegisterName(Base.getReg()) << ')';
}
-void MSP430InstPrinter::printCCOperand(const MCInst *MI, unsigned OpNo) {
+void MSP430InstPrinter::printCCOperand(const MCInst *MI, unsigned OpNo,
+ raw_ostream &O) {
unsigned CC = MI->getOperand(OpNo).getImm();
switch (CC) {
diff --git a/lib/Target/MSP430/AsmPrinter/MSP430InstPrinter.h b/lib/Target/MSP430/AsmPrinter/MSP430InstPrinter.h
index 2fac800fcd79..f0e1ce22841b 100644
--- a/lib/Target/MSP430/AsmPrinter/MSP430InstPrinter.h
+++ b/lib/Target/MSP430/AsmPrinter/MSP430InstPrinter.h
@@ -16,29 +16,26 @@
#include "llvm/MC/MCInstPrinter.h"
-namespace llvm
-{
-
+namespace llvm {
class MCOperand;
class MSP430InstPrinter : public MCInstPrinter {
public:
- MSP430InstPrinter(raw_ostream &O, const MCAsmInfo &MAI) :
- MCInstPrinter(O, MAI){
+ MSP430InstPrinter(const MCAsmInfo &MAI) : MCInstPrinter(MAI) {
}
- virtual void printInst(const MCInst *MI);
+ virtual void printInst(const MCInst *MI, raw_ostream &O);
// Autogenerated by tblgen.
- void printInstruction(const MCInst *MI);
+ void printInstruction(const MCInst *MI, raw_ostream &O);
static const char *getRegisterName(unsigned RegNo);
- void printOperand(const MCInst *MI, unsigned OpNo,
+ void printOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O,
const char *Modifier = 0);
- void printPCRelImmOperand(const MCInst *MI, unsigned OpNo);
- void printSrcMemOperand(const MCInst *MI, unsigned OpNo,
+ void printPCRelImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O);
+ void printSrcMemOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O,
const char *Modifier = 0);
- void printCCOperand(const MCInst *MI, unsigned OpNo);
+ void printCCOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O);
};
}
diff --git a/lib/Target/MSP430/MSP430.td b/lib/Target/MSP430/MSP430.td
index fe533d3d2e5c..0f08e3d8ca0f 100644
--- a/lib/Target/MSP430/MSP430.td
+++ b/lib/Target/MSP430/MSP430.td
@@ -48,14 +48,7 @@ include "MSP430CallingConv.td"
include "MSP430InstrInfo.td"
-def MSP430InstrInfo : InstrInfo {
- // Define how we want to layout our TargetSpecific information field... This
- // should be kept up-to-date with the fields in the MSP430InstrInfo.h file.
- let TSFlagsFields = ["FormBits",
- "Size"];
- let TSFlagsShifts = [0,
- 2];
-}
+def MSP430InstrInfo : InstrInfo;
def MSP430InstPrinter : AsmWriter {
string AsmWriterClassName = "InstPrinter";
diff --git a/lib/Target/MSP430/MSP430InstrFormats.td b/lib/Target/MSP430/MSP430InstrFormats.td
index 4ccc7df57664..73aef1facc0f 100644
--- a/lib/Target/MSP430/MSP430InstrFormats.td
+++ b/lib/Target/MSP430/MSP430InstrFormats.td
@@ -61,10 +61,12 @@ class MSP430Inst<dag outs, dag ins, SizeVal sz, Format f,
dag InOperandList = ins;
Format Form = f;
- bits<2> FormBits = Form.Value;
-
SizeVal Sz = sz;
- bits<3> Size = Sz.Value;
+
+ // Define how we want to layout our TargetSpecific information field... This
+ // should be kept up-to-date with the fields in the MSP430InstrInfo.h file.
+ let TSFlags{1-0} = Form.Value;
+ let TSFlags{4-2} = Sz.Value;
let AsmString = asmstr;
}