1 //===- MipsInstrFormats.td - Mips Instruction Formats ------*- 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 //===----------------------------------------------------------------------===//
11 // Describe MIPS instructions format
13 // CPU INSTRUCTION FORMATS
15 // opcode - operation code.
17 // rt - dst reg (on a 2 regs instr) or src reg (on a 3 reg instr).
18 // rd - dst reg, only used on 3 regs instr.
19 // shamt - only used on shift instructions, contains the shift amount.
20 // funct - combined with opcode field give us an operation code.
22 //===----------------------------------------------------------------------===//
24 // Generic Mips Format
25 class MipsInst<dag outs, dag ins, string asmstr, list<dag> pattern,
26 InstrItinClass itin>: Instruction
30 let Namespace = "Mips";
34 // Top 5 bits are the 'opcode' field
35 let Inst{31-26} = opcode;
37 dag OutOperandList = outs;
38 dag InOperandList = ins;
40 let AsmString = asmstr;
41 let Pattern = pattern;
45 // Mips Pseudo Instructions Format
46 class MipsPseudo<dag outs, dag ins, string asmstr, list<dag> pattern>:
47 MipsInst<outs, ins, asmstr, pattern, IIPseudo>;
49 //===----------------------------------------------------------------------===//
50 // Format R instruction class in Mips : <|opcode|rs|rt|rd|shamt|funct|>
51 //===----------------------------------------------------------------------===//
53 class FR<bits<6> op, bits<6> _funct, dag outs, dag ins, string asmstr,
54 list<dag> pattern, InstrItinClass itin>:
55 MipsInst<outs, ins, asmstr, pattern, itin>
69 let Inst{10-6} = shamt;
70 let Inst{5-0} = funct;
73 //===----------------------------------------------------------------------===//
74 // Format I instruction class in Mips : <|opcode|rs|rt|immediate|>
75 //===----------------------------------------------------------------------===//
77 class FI<bits<6> op, dag outs, dag ins, string asmstr, list<dag> pattern,
78 InstrItinClass itin>: MipsInst<outs, ins, asmstr, pattern, itin>
88 let Inst{15-0} = imm16;
91 //===----------------------------------------------------------------------===//
92 // Format J instruction class in Mips : <|opcode|address|>
93 //===----------------------------------------------------------------------===//
95 class FJ<bits<6> op, dag outs, dag ins, string asmstr, list<dag> pattern,
96 InstrItinClass itin>: MipsInst<outs, ins, asmstr, pattern, itin>
102 let Inst{25-0} = addr;
105 //===----------------------------------------------------------------------===//
107 // FLOATING POINT INSTRUCTION FORMATS
109 // opcode - operation code.
111 // ft - dst reg (on a 2 regs instr) or src reg (on a 3 reg instr).
112 // fd - dst reg, only used on 3 regs instr.
113 // fmt - double or single precision.
114 // funct - combined with opcode field give us an operation code.
116 //===----------------------------------------------------------------------===//
118 //===----------------------------------------------------------------------===//
119 // Format FR instruction class in Mips : <|opcode|fmt|ft|fs|fd|funct|>
120 //===----------------------------------------------------------------------===//
122 class FFR<bits<6> op, bits<6> _funct, bits<5> _fmt, dag outs, dag ins,
123 string asmstr, list<dag> pattern> :
124 MipsInst<outs, ins, asmstr, pattern, NoItinerary>
136 let Inst{25-21} = fmt;
137 let Inst{20-16} = ft;
138 let Inst{15-11} = fs;
140 let Inst{5-0} = funct;
143 //===----------------------------------------------------------------------===//
144 // Format FI instruction class in Mips : <|opcode|base|ft|immediate|>
145 //===----------------------------------------------------------------------===//
147 class FFI<bits<6> op, dag outs, dag ins, string asmstr, list<dag> pattern>:
148 MipsInst<outs, ins, asmstr, pattern, NoItinerary>
156 let Inst{25-21} = base;
157 let Inst{20-16} = ft;
158 let Inst{15-0} = imm16;
161 //===----------------------------------------------------------------------===//
162 // Compare instruction class in Mips : <|010001|fmt|ft|fs|0000011|condcode|>
163 //===----------------------------------------------------------------------===//
165 class FCC<bits<5> _fmt, dag outs, dag ins, string asmstr, list<dag> pattern> :
166 MipsInst<outs, ins, asmstr, pattern, NoItinerary>
176 let Inst{25-21} = fmt;
177 let Inst{20-16} = ft;
178 let Inst{15-11} = fs;
180 let Inst{5-4} = 0b11;
185 class FCMOV<bits<1> _tf, dag outs, dag ins, string asmstr,
187 MipsInst<outs, ins, asmstr, pattern, NoItinerary>
197 let Inst{25-21} = rs;
201 let Inst{15-11} = rd;
206 class FFCMOV<bits<5> _fmt, bits<1> _tf, dag outs, dag ins, string asmstr,
208 MipsInst<outs, ins, asmstr, pattern, NoItinerary>
220 let Inst{25-21} = fmt;
224 let Inst{15-11} = fs;