1 //===- MSP430InstrFormats.td - MSP430 Instruction Formats-----*- tblgen -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 //===----------------------------------------------------------------------===//
11 // Describe MSP430 instructions format here
14 // Format specifies the encoding used by the instruction. This is part of the
15 // ad-hoc solution used to emit machine instruction encodings by our machine
17 class Format<bits<2> val> {
21 class SourceMode<bits<2> val> {
25 class DestMode<bit val> {
29 def PseudoFrm : Format<0>;
30 def SingleOpFrm : Format<1>;
31 def DoubleOpFrm : Format<2>;
32 def CondJumpFrm : Format<3>;
34 def DstReg : DestMode<0>;
35 def DstMem : DestMode<1>;
37 def SrcReg : SourceMode<0>;
38 def SrcMem : SourceMode<1>;
39 def SrcIndReg : SourceMode<2>;
40 def SrcPostInc : SourceMode<3>;
41 def SrcImm : SourceMode<3>;
43 // Generic MSP430 Format
44 class MSP430Inst<dag outs, dag ins, Format f, string asmstr> : Instruction {
47 let Namespace = "MSP430";
49 dag OutOperandList = outs;
50 dag InOperandList = ins;
53 bits<2> FormBits = Form.Value;
55 let AsmString = asmstr;
58 // FIXME: Create different classes for different addressing modes.
60 // MSP430 Double Operand (Format I) Instructions
61 class IForm<bits<4> opcode, DestMode dest, bit bw, SourceMode src,
62 dag outs, dag ins, string asmstr, list<dag> pattern>
63 : MSP430Inst<outs, ins, DoubleOpFrm, asmstr> {
64 let Pattern = pattern;
69 let Inst{12-15} = opcode;
70 let Inst{7} = ad.Value;
72 let Inst{4-5} = as.Value;
75 // 8 bit IForm instructions
76 class IForm8<bits<4> opcode, DestMode dest, SourceMode src,
77 dag outs, dag ins, string asmstr, list<dag> pattern>
78 : IForm<opcode, dest, 1, src, outs, ins, asmstr, pattern>;
80 class I8rr<bits<4> opcode,
81 dag outs, dag ins, string asmstr, list<dag> pattern>
82 : IForm8<opcode, DstReg, SrcReg, outs, ins, asmstr, pattern>;
84 class I8ri<bits<4> opcode,
85 dag outs, dag ins, string asmstr, list<dag> pattern>
86 : IForm8<opcode, DstReg, SrcImm, outs, ins, asmstr, pattern>;
88 class I8rm<bits<4> opcode,
89 dag outs, dag ins, string asmstr, list<dag> pattern>
90 : IForm8<opcode, DstReg, SrcMem, outs, ins, asmstr, pattern>;
92 class I8mr<bits<4> opcode,
93 dag outs, dag ins, string asmstr, list<dag> pattern>
94 : IForm8<opcode, DstMem, SrcReg, outs, ins, asmstr, pattern>;
96 class I8mi<bits<4> opcode,
97 dag outs, dag ins, string asmstr, list<dag> pattern>
98 : IForm8<opcode, DstMem, SrcImm, outs, ins, asmstr, pattern>;
100 class I8mm<bits<4> opcode,
101 dag outs, dag ins, string asmstr, list<dag> pattern>
102 : IForm8<opcode, DstMem, SrcMem, outs, ins, asmstr, pattern>;
104 // 16 bit IForm instructions
105 class IForm16<bits<4> opcode, DestMode dest, SourceMode src,
106 dag outs, dag ins, string asmstr, list<dag> pattern>
107 : IForm<opcode, dest, 0, src, outs, ins, asmstr, pattern>;
109 class I16rr<bits<4> opcode,
110 dag outs, dag ins, string asmstr, list<dag> pattern>
111 : IForm16<opcode, DstReg, SrcReg, outs, ins, asmstr, pattern>;
113 class I16ri<bits<4> opcode,
114 dag outs, dag ins, string asmstr, list<dag> pattern>
115 : IForm16<opcode, DstReg, SrcImm, outs, ins, asmstr, pattern>;
117 class I16rm<bits<4> opcode,
118 dag outs, dag ins, string asmstr, list<dag> pattern>
119 : IForm16<opcode, DstReg, SrcMem, outs, ins, asmstr, pattern>;
121 class I16mr<bits<4> opcode,
122 dag outs, dag ins, string asmstr, list<dag> pattern>
123 : IForm16<opcode, DstMem, SrcReg, outs, ins, asmstr, pattern>;
125 class I16mi<bits<4> opcode,
126 dag outs, dag ins, string asmstr, list<dag> pattern>
127 : IForm16<opcode, DstMem, SrcImm, outs, ins, asmstr, pattern>;
129 class I16mm<bits<4> opcode,
130 dag outs, dag ins, string asmstr, list<dag> pattern>
131 : IForm16<opcode, DstMem, SrcMem, outs, ins, asmstr, pattern>;
133 // MSP430 Single Operand (Format II) Instructions
134 class IIForm<bits<9> opcode, bit bw, SourceMode src,
135 dag outs, dag ins, string asmstr, list<dag> pattern>
136 : MSP430Inst<outs, ins, SingleOpFrm, asmstr> {
137 let Pattern = pattern;
141 let Inst{7-15} = opcode;
143 let Inst{4-5} = as.Value;
146 // 8 bit IIForm instructions
147 class IIForm8<bits<9> opcode, SourceMode src,
148 dag outs, dag ins, string asmstr, list<dag> pattern>
149 : IIForm<opcode, 1, src, outs, ins, asmstr, pattern>;
151 // 16 bit IIForm instructions
152 class IIForm16<bits<9> opcode, SourceMode src,
153 dag outs, dag ins, string asmstr, list<dag> pattern>
154 : IIForm<opcode, 0, src, outs, ins, asmstr, pattern>;
156 // MSP430 Conditional Jumps Instructions
157 class CJForm<bits<3> opcode, bits<3> cond, bit s,
158 dag outs, dag ins, string asmstr, list<dag> pattern>
159 : MSP430Inst<outs, ins, CondJumpFrm, asmstr> {
160 let Pattern = pattern;
162 let Inst{13-15} = opcode;
163 let Inst{10-12} = cond;
167 // Pseudo instructions
168 class Pseudo<dag outs, dag ins, string asmstr, list<dag> pattern>
169 : MSP430Inst<outs, ins, PseudoFrm, asmstr> {
170 let Pattern = pattern;