Provide instruction sizes & encoding. No opcodes yet (but not needed so far).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93553 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Anton Korobeynikov 2010-01-15 21:18:39 +00:00
parent cb50e0bd60
commit 05011a8aba
3 changed files with 804 additions and 577 deletions

View File

@ -48,8 +48,14 @@ include "MSP430CallingConv.td"
include "MSP430InstrInfo.td"
def MSP430InstrInfo : InstrInfo {}
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 MSP430InstPrinter : AsmWriter {
string AsmWriterClassName = "InstPrinter";

View File

@ -18,21 +18,14 @@ class Format<bits<2> val> {
bits<2> Value = val;
}
class SourceMode<bits<2> val> {
bits<2> Value = val;
}
class DestMode<bit val> {
bit Value = val;
}
def PseudoFrm : Format<0>;
def SingleOpFrm : Format<1>;
def DoubleOpFrm : Format<2>;
def CondJumpFrm : Format<3>;
def DstReg : DestMode<0>;
def DstMem : DestMode<1>;
class SourceMode<bits<2> val> {
bits<2> Value = val;
}
def SrcReg : SourceMode<0>;
def SrcMem : SourceMode<1>;
@ -40,8 +33,26 @@ def SrcIndReg : SourceMode<2>;
def SrcPostInc : SourceMode<3>;
def SrcImm : SourceMode<3>;
class DestMode<bit val> {
bit Value = val;
}
def DstReg : DestMode<0>;
def DstMem : DestMode<1>;
class SizeVal<bits<3> val> {
bits<3> Value = val;
}
def SizeUnknown : SizeVal<0>; // Unknown / unset size
def SizeSpecial : SizeVal<1>; // Special instruction, e.g. pseudo
def Size2Bytes : SizeVal<2>;
def Size4Bytes : SizeVal<3>;
def Size6Bytes : SizeVal<4>;
// Generic MSP430 Format
class MSP430Inst<dag outs, dag ins, Format f, string asmstr> : Instruction {
class MSP430Inst<dag outs, dag ins, SizeVal sz, Format f,
string asmstr> : Instruction {
field bits<16> Inst;
let Namespace = "MSP430";
@ -52,19 +63,22 @@ class MSP430Inst<dag outs, dag ins, Format f, string asmstr> : Instruction {
Format Form = f;
bits<2> FormBits = Form.Value;
SizeVal Sz = sz;
bits<3> Size = Sz.Value;
let AsmString = asmstr;
}
// FIXME: Create different classes for different addressing modes.
// MSP430 Double Operand (Format I) Instructions
class IForm<bits<4> opcode, DestMode dest, bit bw, SourceMode src,
class IForm<bits<4> opcode, DestMode dest, bit bw, SourceMode src, SizeVal sz,
dag outs, dag ins, string asmstr, list<dag> pattern>
: MSP430Inst<outs, ins, DoubleOpFrm, asmstr> {
: MSP430Inst<outs, ins, sz, DoubleOpFrm, asmstr> {
let Pattern = pattern;
DestMode ad = dest;
SourceMode as = src;
SourceMode as = src;
let Inst{12-15} = opcode;
let Inst{7} = ad.Value;
@ -73,67 +87,67 @@ class IForm<bits<4> opcode, DestMode dest, bit bw, SourceMode src,
}
// 8 bit IForm instructions
class IForm8<bits<4> opcode, DestMode dest, SourceMode src,
class IForm8<bits<4> opcode, DestMode dest, SourceMode src, SizeVal sz,
dag outs, dag ins, string asmstr, list<dag> pattern>
: IForm<opcode, dest, 1, src, outs, ins, asmstr, pattern>;
: IForm<opcode, dest, 1, src, sz, outs, ins, asmstr, pattern>;
class I8rr<bits<4> opcode,
dag outs, dag ins, string asmstr, list<dag> pattern>
: IForm8<opcode, DstReg, SrcReg, outs, ins, asmstr, pattern>;
: IForm8<opcode, DstReg, SrcReg, Size2Bytes, outs, ins, asmstr, pattern>;
class I8ri<bits<4> opcode,
dag outs, dag ins, string asmstr, list<dag> pattern>
: IForm8<opcode, DstReg, SrcImm, outs, ins, asmstr, pattern>;
: IForm8<opcode, DstReg, SrcImm, Size4Bytes, outs, ins, asmstr, pattern>;
class I8rm<bits<4> opcode,
dag outs, dag ins, string asmstr, list<dag> pattern>
: IForm8<opcode, DstReg, SrcMem, outs, ins, asmstr, pattern>;
: IForm8<opcode, DstReg, SrcMem, Size4Bytes, outs, ins, asmstr, pattern>;
class I8mr<bits<4> opcode,
dag outs, dag ins, string asmstr, list<dag> pattern>
: IForm8<opcode, DstMem, SrcReg, outs, ins, asmstr, pattern>;
: IForm8<opcode, DstMem, SrcReg, Size4Bytes, outs, ins, asmstr, pattern>;
class I8mi<bits<4> opcode,
dag outs, dag ins, string asmstr, list<dag> pattern>
: IForm8<opcode, DstMem, SrcImm, outs, ins, asmstr, pattern>;
: IForm8<opcode, DstMem, SrcImm, Size6Bytes, outs, ins, asmstr, pattern>;
class I8mm<bits<4> opcode,
dag outs, dag ins, string asmstr, list<dag> pattern>
: IForm8<opcode, DstMem, SrcMem, outs, ins, asmstr, pattern>;
: IForm8<opcode, DstMem, SrcMem, Size6Bytes, outs, ins, asmstr, pattern>;
// 16 bit IForm instructions
class IForm16<bits<4> opcode, DestMode dest, SourceMode src,
class IForm16<bits<4> opcode, DestMode dest, SourceMode src, SizeVal sz,
dag outs, dag ins, string asmstr, list<dag> pattern>
: IForm<opcode, dest, 0, src, outs, ins, asmstr, pattern>;
: IForm<opcode, dest, 0, src, sz, outs, ins, asmstr, pattern>;
class I16rr<bits<4> opcode,
dag outs, dag ins, string asmstr, list<dag> pattern>
: IForm16<opcode, DstReg, SrcReg, outs, ins, asmstr, pattern>;
: IForm16<opcode, DstReg, SrcReg, Size2Bytes, outs, ins, asmstr, pattern>;
class I16ri<bits<4> opcode,
dag outs, dag ins, string asmstr, list<dag> pattern>
: IForm16<opcode, DstReg, SrcImm, outs, ins, asmstr, pattern>;
: IForm16<opcode, DstReg, SrcImm, Size4Bytes, outs, ins, asmstr, pattern>;
class I16rm<bits<4> opcode,
dag outs, dag ins, string asmstr, list<dag> pattern>
: IForm16<opcode, DstReg, SrcMem, outs, ins, asmstr, pattern>;
: IForm16<opcode, DstReg, SrcMem, Size4Bytes, outs, ins, asmstr, pattern>;
class I16mr<bits<4> opcode,
dag outs, dag ins, string asmstr, list<dag> pattern>
: IForm16<opcode, DstMem, SrcReg, outs, ins, asmstr, pattern>;
: IForm16<opcode, DstMem, SrcReg, Size4Bytes, outs, ins, asmstr, pattern>;
class I16mi<bits<4> opcode,
dag outs, dag ins, string asmstr, list<dag> pattern>
: IForm16<opcode, DstMem, SrcImm, outs, ins, asmstr, pattern>;
: IForm16<opcode, DstMem, SrcImm, Size6Bytes, outs, ins, asmstr, pattern>;
class I16mm<bits<4> opcode,
dag outs, dag ins, string asmstr, list<dag> pattern>
: IForm16<opcode, DstMem, SrcMem, outs, ins, asmstr, pattern>;
: IForm16<opcode, DstMem, SrcMem, Size6Bytes, outs, ins, asmstr, pattern>;
// MSP430 Single Operand (Format II) Instructions
class IIForm<bits<9> opcode, bit bw, SourceMode src,
class IIForm<bits<9> opcode, bit bw, SourceMode src, SizeVal sz,
dag outs, dag ins, string asmstr, list<dag> pattern>
: MSP430Inst<outs, ins, SingleOpFrm, asmstr> {
: MSP430Inst<outs, ins, sz, SingleOpFrm, asmstr> {
let Pattern = pattern;
SourceMode as = src;
@ -144,29 +158,52 @@ class IIForm<bits<9> opcode, bit bw, SourceMode src,
}
// 8 bit IIForm instructions
class IIForm8<bits<9> opcode, SourceMode src,
class IIForm8<bits<9> opcode, SourceMode src, SizeVal sz,
dag outs, dag ins, string asmstr, list<dag> pattern>
: IIForm<opcode, 1, src, outs, ins, asmstr, pattern>;
: IIForm<opcode, 1, src, sz, outs, ins, asmstr, pattern>;
class II8r<bits<9> opcode,
dag outs, dag ins, string asmstr, list<dag> pattern>
: IIForm8<opcode, SrcReg, Size2Bytes, outs, ins, asmstr, pattern>;
class II8m<bits<9> opcode,
dag outs, dag ins, string asmstr, list<dag> pattern>
: IIForm8<opcode, SrcMem, Size4Bytes, outs, ins, asmstr, pattern>;
class II8i<bits<9> opcode,
dag outs, dag ins, string asmstr, list<dag> pattern>
: IIForm8<opcode, SrcImm, Size4Bytes, outs, ins, asmstr, pattern>;
// 16 bit IIForm instructions
class IIForm16<bits<9> opcode, SourceMode src,
class IIForm16<bits<9> opcode, SourceMode src, SizeVal sz,
dag outs, dag ins, string asmstr, list<dag> pattern>
: IIForm<opcode, 0, src, outs, ins, asmstr, pattern>;
: IIForm<opcode, 0, src, sz, outs, ins, asmstr, pattern>;
class II16r<bits<9> opcode,
dag outs, dag ins, string asmstr, list<dag> pattern>
: IIForm16<opcode, SrcReg, Size2Bytes, outs, ins, asmstr, pattern>;
class II16m<bits<9> opcode,
dag outs, dag ins, string asmstr, list<dag> pattern>
: IIForm16<opcode, SrcMem, Size4Bytes, outs, ins, asmstr, pattern>;
class II16i<bits<9> opcode,
dag outs, dag ins, string asmstr, list<dag> pattern>
: IIForm16<opcode, SrcImm, Size4Bytes, outs, ins, asmstr, pattern>;
// MSP430 Conditional Jumps Instructions
class CJForm<bits<3> opcode, bits<3> cond, bit s,
class CJForm<bits<3> opcode, bits<3> cond,
dag outs, dag ins, string asmstr, list<dag> pattern>
: MSP430Inst<outs, ins, CondJumpFrm, asmstr> {
: MSP430Inst<outs, ins, Size2Bytes, CondJumpFrm, asmstr> {
let Pattern = pattern;
let Inst{13-15} = opcode;
let Inst{10-12} = cond;
let Inst{9} = s;
}
// Pseudo instructions
class Pseudo<dag outs, dag ins, string asmstr, list<dag> pattern>
: MSP430Inst<outs, ins, PseudoFrm, asmstr> {
: MSP430Inst<outs, ins, SizeSpecial, PseudoFrm, asmstr> {
let Pattern = pattern;
let Inst{15-0} = 0;
}

File diff suppressed because it is too large Load Diff