1 //===- MBlazeInstrFormats.td - MB Instruction defs ---------*- tablegen -*-===//
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 // Format specifies the encoding used by the instruction. This is part of the
11 // ad-hoc solution used to emit machine instruction encodings by our machine
13 class Format<bits<6> val> {
17 def FPseudo : Format<0>;
18 def FRRR : Format<1>; // ADD, OR, etc.
19 def FRRI : Format<2>; // ADDI, ORI, etc.
20 def FCRR : Format<3>; // PUTD, WDC, WIC, BEQ, BNE, BGE, etc.
21 def FCRI : Format<4>; // RTID, RTED, RTSD, BEQI, BNEI, BGEI, etc.
22 def FRCR : Format<5>; // BRLD, BRALD, GETD
23 def FRCI : Format<6>; // BRLID, BRALID, MSRCLR, MSRSET
24 def FCCR : Format<7>; // BR, BRA, BRD, etc.
25 def FCCI : Format<8>; // IMM, BRI, BRAI, BRID, etc.
26 def FRRCI : Format<9>; // BSRLI, BSRAI, BSLLI
27 def FRRC : Format<10>; // SEXT8, SEXT16, SRA, SRC, SRL, FLT, FINT, FSQRT
28 def FRCX : Format<11>; // GET
29 def FRCS : Format<12>; // MFS
30 def FCRCS : Format<13>; // MTS
31 def FCRCX : Format<14>; // PUT
32 def FCX : Format<15>; // TPUT
33 def FCR : Format<16>; // TPUTD
34 def FRIR : Format<17>; // RSUBI
35 def FRRRR : Format<18>; // RSUB, FRSUB
36 def FRI : Format<19>; // RSUB, FRSUB
37 def FC : Format<20>; // NOP
39 //===----------------------------------------------------------------------===//
40 // Describe MBlaze instructions format
42 // CPU INSTRUCTION FORMATS
44 // opcode - operation code.
46 // ra - first src. reg.
47 // rb - second src. reg.
48 // imm16 - 16-bit immediate value.
50 //===----------------------------------------------------------------------===//
52 // Generic MBlaze Format
53 class MBlazeInst<bits<6> op, Format form, dag outs, dag ins, string asmstr,
54 list<dag> pattern, InstrItinClass itin> : Instruction {
55 let Namespace = "MBlaze";
60 bits<6> FormBits = Form.Value;
62 // Top 6 bits are the 'opcode' field
63 let Inst{0-5} = opcode;
65 // If the instruction is marked as a pseudo, set isCodeGenOnly so that the
66 // assembler and disassmbler ignore it.
67 let isCodeGenOnly = !eq(!cast<string>(form), "FPseudo");
69 dag OutOperandList = outs;
70 dag InOperandList = ins;
72 let AsmString = asmstr;
73 let Pattern = pattern;
76 // TSFlags layout should be kept in sync with MBlazeInstrInfo.h.
77 let TSFlags{5-0} = FormBits;
80 //===----------------------------------------------------------------------===//
81 // Pseudo instruction class
82 //===----------------------------------------------------------------------===//
83 class MBlazePseudo<dag outs, dag ins, string asmstr, list<dag> pattern>:
84 MBlazeInst<0x0, FPseudo, outs, ins, asmstr, pattern, IIC_Pseudo>;
86 //===----------------------------------------------------------------------===//
87 // Type A instruction class in MBlaze : <|opcode|rd|ra|rb|flags|>
88 //===----------------------------------------------------------------------===//
90 class TA<bits<6> op, bits<11> flags, dag outs, dag ins, string asmstr,
91 list<dag> pattern, InstrItinClass itin> :
92 MBlazeInst<op,FRRR,outs, ins, asmstr, pattern, itin>
100 let Inst{16-20} = rb;
101 let Inst{21-31} = flags;
104 //===----------------------------------------------------------------------===//
105 // Type B instruction class in MBlaze : <|opcode|rd|ra|immediate|>
106 //===----------------------------------------------------------------------===//
108 class TB<bits<6> op, dag outs, dag ins, string asmstr, list<dag> pattern,
109 InstrItinClass itin> :
110 MBlazeInst<op, FRRI, outs, ins, asmstr, pattern, itin>
117 let Inst{11-15} = ra;
118 let Inst{16-31} = imm16;
121 //===----------------------------------------------------------------------===//
122 // Type A instruction class in MBlaze but with the operands reversed
123 // in the LLVM DAG : <|opcode|rd|ra|rb|flags|>
124 //===----------------------------------------------------------------------===//
126 class TAR<bits<6> op, bits<11> flags, dag outs, dag ins, string asmstr,
127 list<dag> pattern, InstrItinClass itin> :
128 TA<op, flags, outs, ins, asmstr, pattern, itin>
141 //===----------------------------------------------------------------------===//
142 // Type B instruction class in MBlaze but with the operands reversed in
143 // the LLVM DAG : <|opcode|rd|ra|immediate|>
144 //===----------------------------------------------------------------------===//
145 class TBR<bits<6> op, dag outs, dag ins, string asmstr, list<dag> pattern,
146 InstrItinClass itin> :
147 TB<op, outs, ins, asmstr, pattern, itin> {
159 //===----------------------------------------------------------------------===//
160 // Shift immediate instruction class in MBlaze : <|opcode|rd|ra|immediate|>
161 //===----------------------------------------------------------------------===//
162 class SHT<bits<6> op, bits<2> flags, dag outs, dag ins, string asmstr,
163 list<dag> pattern, InstrItinClass itin> :
164 MBlazeInst<op, FRRI, outs, ins, asmstr, pattern, itin> {
170 let Inst{11-15} = ra;
171 let Inst{16-20} = 0x0;
172 let Inst{21-22} = flags;
173 let Inst{23-26} = 0x0;
174 let Inst{27-31} = imm5;
177 //===----------------------------------------------------------------------===//
178 // Special instruction class in MBlaze : <|opcode|rd|imm14|>
179 //===----------------------------------------------------------------------===//
180 class SPC<bits<6> op, bits<2> flags, dag outs, dag ins, string asmstr,
181 list<dag> pattern, InstrItinClass itin> :
182 MBlazeInst<op, FRI, outs, ins, asmstr, pattern, itin> {
187 let Inst{11-15} = 0x0;
188 let Inst{16-17} = flags;
189 let Inst{18-31} = imm14;
192 //===----------------------------------------------------------------------===//
193 // MSR instruction class in MBlaze : <|opcode|rd|imm15|>
194 //===----------------------------------------------------------------------===//
195 class MSR<bits<6> op, bits<6> flags, dag outs, dag ins, string asmstr,
196 list<dag> pattern, InstrItinClass itin> :
197 MBlazeInst<op, FRI, outs, ins, asmstr, pattern, itin> {
202 let Inst{11-16} = flags;
203 let Inst{17-31} = imm15;