1 //===- XtensaInstrFormats.td - Xtensa Instruction Formats --*- tablegen -*-===//
3 // The LLVM Compiler Infrastructure
5 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
6 // See https://llvm.org/LICENSE.txt for license information.
7 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
9 //===----------------------------------------------------------------------===//
11 // Base class for Xtensa 16 & 24 bit Formats
12 class XtensaInst<int size, dag outs, dag ins, string asmstr, list<dag> pattern,
13 InstrItinClass itin = NoItinerary>
15 let Namespace = "Xtensa";
19 let OutOperandList = outs;
20 let InOperandList = ins;
22 let AsmString = asmstr;
23 let Pattern = pattern;
28 // Base class for Xtensa 24 bit Format
29 class XtensaInst24<dag outs, dag ins, string asmstr, list<dag> pattern,
30 InstrItinClass itin = NoItinerary>
31 : XtensaInst<3, outs, ins, asmstr, pattern, itin> {
33 field bits<24> SoftFail = 0;
36 // Base class for Xtensa 16 bit Format
37 class XtensaInst16<dag outs, dag ins, string asmstr, list<dag> pattern,
38 InstrItinClass itin = NoItinerary>
39 : XtensaInst<2, outs, ins, asmstr, pattern, itin> {
41 field bits<16> SoftFail = 0;
42 let Predicates = [HasDensity];
45 class RRR_Inst<bits<4> op0, bits<4> op1, bits<4> op2, dag outs, dag ins,
46 string asmstr, list<dag> pattern, InstrItinClass itin = NoItinerary>
47 : XtensaInst24<outs, ins, asmstr, pattern, itin> {
52 let Inst{23-20} = op2;
53 let Inst{19-16} = op1;
60 class RRI4_Inst<bits<4> op0, bits<4> op1, dag outs, dag ins,
61 string asmstr, list<dag> pattern, InstrItinClass itin = NoItinerary>
62 : XtensaInst24<outs, ins, asmstr, pattern, itin> {
68 let Inst{23-20} = imm4;
69 let Inst{19-16} = op1;
76 class RRI8_Inst<bits<4> op0, dag outs, dag ins,
77 string asmstr, list<dag> pattern, InstrItinClass itin = NoItinerary>
78 : XtensaInst24<outs, ins, asmstr, pattern, itin> {
84 let Inst{23-16} = imm8;
91 class RI16_Inst<bits<4> op0, dag outs, dag ins,
92 string asmstr, list<dag> pattern, InstrItinClass itin = NoItinerary>
93 : XtensaInst24<outs, ins, asmstr, pattern, itin> {
97 let Inst{23-8} = imm16;
102 class RSR_Inst<bits<4> op0, bits<4> op1, bits<4> op2, dag outs, dag ins,
103 string asmstr, list<dag> pattern, InstrItinClass itin = NoItinerary>
104 : XtensaInst24<outs, ins, asmstr, pattern, itin> {
108 let Inst{23-20} = op2;
109 let Inst{19-16} = op1;
115 class CALL_Inst<bits<4> op0, dag outs, dag ins,
116 string asmstr, list<dag> pattern, InstrItinClass itin = NoItinerary>
117 : XtensaInst24<outs, ins, asmstr, pattern, itin> {
121 let Inst{23-6} = offset;
126 class CALLX_Inst<bits<4> op0, bits<4> op1, bits<4> op2, dag outs, dag ins,
127 string asmstr, list<dag> pattern, InstrItinClass itin = NoItinerary>
128 : XtensaInst24<outs, ins, asmstr, pattern, itin> {
134 let Inst{23-20} = op2;
135 let Inst{19-16} = op1;
143 class BRI8_Inst<bits<4> op0, dag outs, dag ins,
144 string asmstr, list<dag> pattern, InstrItinClass itin = NoItinerary>
145 : XtensaInst24<outs, ins, asmstr, pattern, itin> {
152 let Inst{23-16} = imm8;
160 class BRI12_Inst<bits<4> op0, bits<2> n, bits<2> m, dag outs, dag ins,
161 string asmstr, list<dag> pattern, InstrItinClass itin = NoItinerary>
162 : XtensaInst24<outs, ins, asmstr, pattern, itin> {
166 let Inst{23-12} = imm12;
173 class RRRN_Inst<bits<4> op0, dag outs, dag ins,
174 string asmstr, list<dag> pattern, InstrItinClass itin = NoItinerary>
175 : XtensaInst16<outs, ins, asmstr, pattern, itin> {
186 class RI7_Inst<bits<4> op0, bits<1> i, dag outs, dag ins,
187 string asmstr, list<dag> pattern, InstrItinClass itin = NoItinerary>
188 : XtensaInst16<outs, ins, asmstr, pattern, itin> {
192 let Inst{15-12} = imm7{3-0};
195 let Inst{6-4} = imm7{6-4};
199 class RI6_Inst<bits<4> op0, bits<1> i, bits<1> z, dag outs, dag ins,
200 string asmstr, list<dag> pattern, InstrItinClass itin = NoItinerary>
201 : XtensaInst16<outs, ins, asmstr, pattern, itin> {
205 let Inst{15-12} = imm6{3-0};
209 let Inst{5-4} = imm6{5-4};
213 // Pseudo instructions
214 class Pseudo<dag outs, dag ins, string asmstr, list<dag> pattern>
215 : XtensaInst<2, outs, ins, asmstr, pattern> {
217 let isCodeGenOnly = 1;