xref: /aosp_15_r20/external/llvm/lib/Target/MSP430/MSP430InstrFormats.td (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker//===-- MSP430InstrFormats.td - MSP430 Instruction Formats -*- tablegen -*-===//
2*9880d681SAndroid Build Coastguard Worker//
3*9880d681SAndroid Build Coastguard Worker//                     The LLVM Compiler Infrastructure
4*9880d681SAndroid Build Coastguard Worker//
5*9880d681SAndroid Build Coastguard Worker// This file is distributed under the University of Illinois Open Source
6*9880d681SAndroid Build Coastguard Worker// License. See LICENSE.TXT for details.
7*9880d681SAndroid Build Coastguard Worker//
8*9880d681SAndroid Build Coastguard Worker//===----------------------------------------------------------------------===//
9*9880d681SAndroid Build Coastguard Worker
10*9880d681SAndroid Build Coastguard Worker//===----------------------------------------------------------------------===//
11*9880d681SAndroid Build Coastguard Worker//  Describe MSP430 instructions format here
12*9880d681SAndroid Build Coastguard Worker//
13*9880d681SAndroid Build Coastguard Worker
14*9880d681SAndroid Build Coastguard Worker// Format specifies the encoding used by the instruction.  This is part of the
15*9880d681SAndroid Build Coastguard Worker// ad-hoc solution used to emit machine instruction encodings by our machine
16*9880d681SAndroid Build Coastguard Worker// code emitter.
17*9880d681SAndroid Build Coastguard Workerclass Format<bits<2> val> {
18*9880d681SAndroid Build Coastguard Worker  bits<2> Value = val;
19*9880d681SAndroid Build Coastguard Worker}
20*9880d681SAndroid Build Coastguard Worker
21*9880d681SAndroid Build Coastguard Workerdef PseudoFrm   : Format<0>;
22*9880d681SAndroid Build Coastguard Workerdef SingleOpFrm : Format<1>;
23*9880d681SAndroid Build Coastguard Workerdef DoubleOpFrm : Format<2>;
24*9880d681SAndroid Build Coastguard Workerdef CondJumpFrm : Format<3>;
25*9880d681SAndroid Build Coastguard Worker
26*9880d681SAndroid Build Coastguard Workerclass SourceMode<bits<2> val> {
27*9880d681SAndroid Build Coastguard Worker  bits<2> Value = val;
28*9880d681SAndroid Build Coastguard Worker}
29*9880d681SAndroid Build Coastguard Worker
30*9880d681SAndroid Build Coastguard Workerdef SrcReg      : SourceMode<0>;
31*9880d681SAndroid Build Coastguard Workerdef SrcMem      : SourceMode<1>;
32*9880d681SAndroid Build Coastguard Workerdef SrcIndReg   : SourceMode<2>;
33*9880d681SAndroid Build Coastguard Workerdef SrcPostInc  : SourceMode<3>;
34*9880d681SAndroid Build Coastguard Workerdef SrcImm      : SourceMode<3>;
35*9880d681SAndroid Build Coastguard Worker
36*9880d681SAndroid Build Coastguard Workerclass DestMode<bit val> {
37*9880d681SAndroid Build Coastguard Worker  bit Value = val;
38*9880d681SAndroid Build Coastguard Worker}
39*9880d681SAndroid Build Coastguard Worker
40*9880d681SAndroid Build Coastguard Workerdef DstReg      : DestMode<0>;
41*9880d681SAndroid Build Coastguard Workerdef DstMem      : DestMode<1>;
42*9880d681SAndroid Build Coastguard Worker
43*9880d681SAndroid Build Coastguard Workerclass SizeVal<bits<3> val> {
44*9880d681SAndroid Build Coastguard Worker  bits<3> Value = val;
45*9880d681SAndroid Build Coastguard Worker}
46*9880d681SAndroid Build Coastguard Worker
47*9880d681SAndroid Build Coastguard Workerdef SizeUnknown : SizeVal<0>; // Unknown / unset size
48*9880d681SAndroid Build Coastguard Workerdef SizeSpecial : SizeVal<1>; // Special instruction, e.g. pseudo
49*9880d681SAndroid Build Coastguard Workerdef Size2Bytes  : SizeVal<2>;
50*9880d681SAndroid Build Coastguard Workerdef Size4Bytes  : SizeVal<3>;
51*9880d681SAndroid Build Coastguard Workerdef Size6Bytes  : SizeVal<4>;
52*9880d681SAndroid Build Coastguard Worker
53*9880d681SAndroid Build Coastguard Worker// Generic MSP430 Format
54*9880d681SAndroid Build Coastguard Workerclass MSP430Inst<dag outs, dag ins, SizeVal sz, Format f,
55*9880d681SAndroid Build Coastguard Worker                 string asmstr> : Instruction {
56*9880d681SAndroid Build Coastguard Worker  field bits<16> Inst;
57*9880d681SAndroid Build Coastguard Worker
58*9880d681SAndroid Build Coastguard Worker  let Namespace = "MSP430";
59*9880d681SAndroid Build Coastguard Worker
60*9880d681SAndroid Build Coastguard Worker  dag OutOperandList = outs;
61*9880d681SAndroid Build Coastguard Worker  dag InOperandList  = ins;
62*9880d681SAndroid Build Coastguard Worker
63*9880d681SAndroid Build Coastguard Worker  Format Form = f;
64*9880d681SAndroid Build Coastguard Worker  SizeVal Sz = sz;
65*9880d681SAndroid Build Coastguard Worker
66*9880d681SAndroid Build Coastguard Worker  // Define how we want to layout our TargetSpecific information field... This
67*9880d681SAndroid Build Coastguard Worker  // should be kept up-to-date with the fields in the MSP430InstrInfo.h file.
68*9880d681SAndroid Build Coastguard Worker  let TSFlags{1-0} = Form.Value;
69*9880d681SAndroid Build Coastguard Worker  let TSFlags{4-2} = Sz.Value;
70*9880d681SAndroid Build Coastguard Worker
71*9880d681SAndroid Build Coastguard Worker  let AsmString   = asmstr;
72*9880d681SAndroid Build Coastguard Worker}
73*9880d681SAndroid Build Coastguard Worker
74*9880d681SAndroid Build Coastguard Worker// FIXME: Create different classes for different addressing modes.
75*9880d681SAndroid Build Coastguard Worker
76*9880d681SAndroid Build Coastguard Worker// MSP430 Double Operand (Format I) Instructions
77*9880d681SAndroid Build Coastguard Workerclass IForm<bits<4> opcode, DestMode dest, bit bw, SourceMode src, SizeVal sz,
78*9880d681SAndroid Build Coastguard Worker            dag outs, dag ins, string asmstr, list<dag> pattern>
79*9880d681SAndroid Build Coastguard Worker  : MSP430Inst<outs, ins, sz, DoubleOpFrm, asmstr> {
80*9880d681SAndroid Build Coastguard Worker  let Pattern = pattern;
81*9880d681SAndroid Build Coastguard Worker
82*9880d681SAndroid Build Coastguard Worker  DestMode ad = dest;
83*9880d681SAndroid Build Coastguard Worker  SourceMode as = src;
84*9880d681SAndroid Build Coastguard Worker
85*9880d681SAndroid Build Coastguard Worker  let Inst{12-15} = opcode;
86*9880d681SAndroid Build Coastguard Worker  let Inst{7}     = ad.Value;
87*9880d681SAndroid Build Coastguard Worker  let Inst{6}     = bw;
88*9880d681SAndroid Build Coastguard Worker  let Inst{4-5}   = as.Value;
89*9880d681SAndroid Build Coastguard Worker}
90*9880d681SAndroid Build Coastguard Worker
91*9880d681SAndroid Build Coastguard Worker// 8 bit IForm instructions
92*9880d681SAndroid Build Coastguard Workerclass IForm8<bits<4> opcode, DestMode dest, SourceMode src, SizeVal sz,
93*9880d681SAndroid Build Coastguard Worker             dag outs, dag ins, string asmstr, list<dag> pattern>
94*9880d681SAndroid Build Coastguard Worker  : IForm<opcode, dest, 1, src, sz, outs, ins, asmstr, pattern>;
95*9880d681SAndroid Build Coastguard Worker
96*9880d681SAndroid Build Coastguard Workerclass I8rr<bits<4> opcode,
97*9880d681SAndroid Build Coastguard Worker           dag outs, dag ins, string asmstr, list<dag> pattern>
98*9880d681SAndroid Build Coastguard Worker  : IForm8<opcode, DstReg, SrcReg, Size2Bytes, outs, ins, asmstr, pattern>;
99*9880d681SAndroid Build Coastguard Worker
100*9880d681SAndroid Build Coastguard Workerclass I8ri<bits<4> opcode,
101*9880d681SAndroid Build Coastguard Worker           dag outs, dag ins, string asmstr, list<dag> pattern>
102*9880d681SAndroid Build Coastguard Worker  : IForm8<opcode, DstReg, SrcImm, Size4Bytes, outs, ins, asmstr, pattern>;
103*9880d681SAndroid Build Coastguard Worker
104*9880d681SAndroid Build Coastguard Workerclass I8rm<bits<4> opcode,
105*9880d681SAndroid Build Coastguard Worker           dag outs, dag ins, string asmstr, list<dag> pattern>
106*9880d681SAndroid Build Coastguard Worker  : IForm8<opcode, DstReg, SrcMem, Size4Bytes, outs, ins, asmstr, pattern>;
107*9880d681SAndroid Build Coastguard Worker
108*9880d681SAndroid Build Coastguard Workerclass I8mr<bits<4> opcode,
109*9880d681SAndroid Build Coastguard Worker           dag outs, dag ins, string asmstr, list<dag> pattern>
110*9880d681SAndroid Build Coastguard Worker  : IForm8<opcode, DstMem, SrcReg, Size4Bytes, outs, ins, asmstr, pattern>;
111*9880d681SAndroid Build Coastguard Worker
112*9880d681SAndroid Build Coastguard Workerclass I8mi<bits<4> opcode,
113*9880d681SAndroid Build Coastguard Worker           dag outs, dag ins, string asmstr, list<dag> pattern>
114*9880d681SAndroid Build Coastguard Worker  : IForm8<opcode, DstMem, SrcImm, Size6Bytes, outs, ins, asmstr, pattern>;
115*9880d681SAndroid Build Coastguard Worker
116*9880d681SAndroid Build Coastguard Workerclass I8mm<bits<4> opcode,
117*9880d681SAndroid Build Coastguard Worker           dag outs, dag ins, string asmstr, list<dag> pattern>
118*9880d681SAndroid Build Coastguard Worker  : IForm8<opcode, DstMem, SrcMem, Size6Bytes, outs, ins, asmstr, pattern>;
119*9880d681SAndroid Build Coastguard Worker
120*9880d681SAndroid Build Coastguard Worker// 16 bit IForm instructions
121*9880d681SAndroid Build Coastguard Workerclass IForm16<bits<4> opcode, DestMode dest, SourceMode src, SizeVal sz,
122*9880d681SAndroid Build Coastguard Worker              dag outs, dag ins, string asmstr, list<dag> pattern>
123*9880d681SAndroid Build Coastguard Worker  : IForm<opcode, dest, 0, src, sz, outs, ins, asmstr, pattern>;
124*9880d681SAndroid Build Coastguard Worker
125*9880d681SAndroid Build Coastguard Workerclass I16rr<bits<4> opcode,
126*9880d681SAndroid Build Coastguard Worker            dag outs, dag ins, string asmstr, list<dag> pattern>
127*9880d681SAndroid Build Coastguard Worker  : IForm16<opcode, DstReg, SrcReg, Size2Bytes, outs, ins, asmstr, pattern>;
128*9880d681SAndroid Build Coastguard Worker
129*9880d681SAndroid Build Coastguard Workerclass I16ri<bits<4> opcode,
130*9880d681SAndroid Build Coastguard Worker            dag outs, dag ins, string asmstr, list<dag> pattern>
131*9880d681SAndroid Build Coastguard Worker  : IForm16<opcode, DstReg, SrcImm, Size4Bytes, outs, ins, asmstr, pattern>;
132*9880d681SAndroid Build Coastguard Worker
133*9880d681SAndroid Build Coastguard Workerclass I16rm<bits<4> opcode,
134*9880d681SAndroid Build Coastguard Worker            dag outs, dag ins, string asmstr, list<dag> pattern>
135*9880d681SAndroid Build Coastguard Worker  : IForm16<opcode, DstReg, SrcMem, Size4Bytes, outs, ins, asmstr, pattern>;
136*9880d681SAndroid Build Coastguard Worker
137*9880d681SAndroid Build Coastguard Workerclass I16mr<bits<4> opcode,
138*9880d681SAndroid Build Coastguard Worker            dag outs, dag ins, string asmstr, list<dag> pattern>
139*9880d681SAndroid Build Coastguard Worker  : IForm16<opcode, DstMem, SrcReg, Size4Bytes, outs, ins, asmstr, pattern>;
140*9880d681SAndroid Build Coastguard Worker
141*9880d681SAndroid Build Coastguard Workerclass I16mi<bits<4> opcode,
142*9880d681SAndroid Build Coastguard Worker            dag outs, dag ins, string asmstr, list<dag> pattern>
143*9880d681SAndroid Build Coastguard Worker  : IForm16<opcode, DstMem, SrcImm, Size6Bytes, outs, ins, asmstr, pattern>;
144*9880d681SAndroid Build Coastguard Worker
145*9880d681SAndroid Build Coastguard Workerclass I16mm<bits<4> opcode,
146*9880d681SAndroid Build Coastguard Worker            dag outs, dag ins, string asmstr, list<dag> pattern>
147*9880d681SAndroid Build Coastguard Worker  : IForm16<opcode, DstMem, SrcMem, Size6Bytes, outs, ins, asmstr, pattern>;
148*9880d681SAndroid Build Coastguard Worker
149*9880d681SAndroid Build Coastguard Worker// MSP430 Single Operand (Format II) Instructions
150*9880d681SAndroid Build Coastguard Workerclass IIForm<bits<9> opcode, bit bw, SourceMode src, SizeVal sz,
151*9880d681SAndroid Build Coastguard Worker             dag outs, dag ins, string asmstr, list<dag> pattern>
152*9880d681SAndroid Build Coastguard Worker  : MSP430Inst<outs, ins, sz, SingleOpFrm, asmstr> {
153*9880d681SAndroid Build Coastguard Worker  let Pattern = pattern;
154*9880d681SAndroid Build Coastguard Worker
155*9880d681SAndroid Build Coastguard Worker  SourceMode as = src;
156*9880d681SAndroid Build Coastguard Worker
157*9880d681SAndroid Build Coastguard Worker  let Inst{7-15} = opcode;
158*9880d681SAndroid Build Coastguard Worker  let Inst{6}    = bw;
159*9880d681SAndroid Build Coastguard Worker  let Inst{4-5}  = as.Value;
160*9880d681SAndroid Build Coastguard Worker}
161*9880d681SAndroid Build Coastguard Worker
162*9880d681SAndroid Build Coastguard Worker// 8 bit IIForm instructions
163*9880d681SAndroid Build Coastguard Workerclass IIForm8<bits<9> opcode, SourceMode src, SizeVal sz,
164*9880d681SAndroid Build Coastguard Worker              dag outs, dag ins, string asmstr, list<dag> pattern>
165*9880d681SAndroid Build Coastguard Worker  : IIForm<opcode, 1, src, sz, outs, ins, asmstr, pattern>;
166*9880d681SAndroid Build Coastguard Worker
167*9880d681SAndroid Build Coastguard Workerclass II8r<bits<9> opcode,
168*9880d681SAndroid Build Coastguard Worker           dag outs, dag ins, string asmstr, list<dag> pattern>
169*9880d681SAndroid Build Coastguard Worker  : IIForm8<opcode, SrcReg, Size2Bytes, outs, ins, asmstr, pattern>;
170*9880d681SAndroid Build Coastguard Worker
171*9880d681SAndroid Build Coastguard Workerclass II8m<bits<9> opcode,
172*9880d681SAndroid Build Coastguard Worker           dag outs, dag ins, string asmstr, list<dag> pattern>
173*9880d681SAndroid Build Coastguard Worker  : IIForm8<opcode, SrcMem, Size4Bytes, outs, ins, asmstr, pattern>;
174*9880d681SAndroid Build Coastguard Worker
175*9880d681SAndroid Build Coastguard Workerclass II8i<bits<9> opcode,
176*9880d681SAndroid Build Coastguard Worker           dag outs, dag ins, string asmstr, list<dag> pattern>
177*9880d681SAndroid Build Coastguard Worker  : IIForm8<opcode, SrcImm, Size4Bytes, outs, ins, asmstr, pattern>;
178*9880d681SAndroid Build Coastguard Worker
179*9880d681SAndroid Build Coastguard Worker// 16 bit IIForm instructions
180*9880d681SAndroid Build Coastguard Workerclass IIForm16<bits<9> opcode, SourceMode src, SizeVal sz,
181*9880d681SAndroid Build Coastguard Worker               dag outs, dag ins, string asmstr, list<dag> pattern>
182*9880d681SAndroid Build Coastguard Worker  : IIForm<opcode, 0, src, sz, outs, ins, asmstr, pattern>;
183*9880d681SAndroid Build Coastguard Worker
184*9880d681SAndroid Build Coastguard Workerclass II16r<bits<9> opcode,
185*9880d681SAndroid Build Coastguard Worker            dag outs, dag ins, string asmstr, list<dag> pattern>
186*9880d681SAndroid Build Coastguard Worker  : IIForm16<opcode, SrcReg, Size2Bytes, outs, ins, asmstr, pattern>;
187*9880d681SAndroid Build Coastguard Worker
188*9880d681SAndroid Build Coastguard Workerclass II16m<bits<9> opcode,
189*9880d681SAndroid Build Coastguard Worker            dag outs, dag ins, string asmstr, list<dag> pattern>
190*9880d681SAndroid Build Coastguard Worker  : IIForm16<opcode, SrcMem, Size4Bytes, outs, ins, asmstr, pattern>;
191*9880d681SAndroid Build Coastguard Worker
192*9880d681SAndroid Build Coastguard Workerclass II16i<bits<9> opcode,
193*9880d681SAndroid Build Coastguard Worker            dag outs, dag ins, string asmstr, list<dag> pattern>
194*9880d681SAndroid Build Coastguard Worker  : IIForm16<opcode, SrcImm, Size4Bytes, outs, ins, asmstr, pattern>;
195*9880d681SAndroid Build Coastguard Worker
196*9880d681SAndroid Build Coastguard Worker// MSP430 Conditional Jumps Instructions
197*9880d681SAndroid Build Coastguard Workerclass CJForm<bits<3> opcode, bits<3> cond,
198*9880d681SAndroid Build Coastguard Worker             dag outs, dag ins, string asmstr, list<dag> pattern>
199*9880d681SAndroid Build Coastguard Worker  : MSP430Inst<outs, ins, Size2Bytes, CondJumpFrm, asmstr> {
200*9880d681SAndroid Build Coastguard Worker  let Pattern = pattern;
201*9880d681SAndroid Build Coastguard Worker
202*9880d681SAndroid Build Coastguard Worker  let Inst{13-15} = opcode;
203*9880d681SAndroid Build Coastguard Worker  let Inst{10-12} = cond;
204*9880d681SAndroid Build Coastguard Worker}
205*9880d681SAndroid Build Coastguard Worker
206*9880d681SAndroid Build Coastguard Worker// Pseudo instructions
207*9880d681SAndroid Build Coastguard Workerclass Pseudo<dag outs, dag ins, string asmstr, list<dag> pattern>
208*9880d681SAndroid Build Coastguard Worker  : MSP430Inst<outs, ins, SizeSpecial, PseudoFrm, asmstr> {
209*9880d681SAndroid Build Coastguard Worker  let Pattern = pattern;
210*9880d681SAndroid Build Coastguard Worker  let Inst{15-0} = 0;
211*9880d681SAndroid Build Coastguard Worker}
212