]> CyberLeo.Net >> Repos - FreeBSD/releng/9.0.git/blob - contrib/llvm/lib/Target/Mips/MipsInstrFormats.td
Copy stable/9 to releng/9.0 as part of the FreeBSD 9.0-RELEASE release
[FreeBSD/releng/9.0.git] / contrib / llvm / lib / Target / Mips / MipsInstrFormats.td
1 //===- MipsInstrFormats.td - Mips Instruction Formats ------*- tablegen -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 //===----------------------------------------------------------------------===//
11 //  Describe MIPS instructions format
12 //
13 //  CPU INSTRUCTION FORMATS
14 //
15 //  opcode  - operation code.
16 //  rs      - src reg.
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.
21 //
22 //===----------------------------------------------------------------------===//
23
24 // Generic Mips Format
25 class MipsInst<dag outs, dag ins, string asmstr, list<dag> pattern,
26                InstrItinClass itin>: Instruction
27 {
28   field bits<32> Inst;
29
30   let Namespace = "Mips";
31
32   bits<6> opcode;
33
34   // Top 5 bits are the 'opcode' field
35   let Inst{31-26} = opcode;
36
37   dag OutOperandList = outs;
38   dag InOperandList  = ins;
39
40   let AsmString   = asmstr;
41   let Pattern     = pattern;
42   let Itinerary   = itin;
43 }
44
45 // Mips Pseudo Instructions Format
46 class MipsPseudo<dag outs, dag ins, string asmstr, list<dag> pattern>:
47       MipsInst<outs, ins, asmstr, pattern, IIPseudo> {
48   let isPseudo = 1;
49 }
50
51 //===----------------------------------------------------------------------===//
52 // Format R instruction class in Mips : <|opcode|rs|rt|rd|shamt|funct|>
53 //===----------------------------------------------------------------------===//
54
55 class FR<bits<6> op, bits<6> _funct, dag outs, dag ins, string asmstr,
56          list<dag> pattern, InstrItinClass itin>:
57       MipsInst<outs, ins, asmstr, pattern, itin>
58 {
59   bits<5>  rd;
60   bits<5>  rs;
61   bits<5>  rt;
62   bits<5>  shamt;
63   bits<6>  funct;
64
65   let opcode = op;
66   let funct  = _funct;
67
68   let Inst{25-21} = rs;
69   let Inst{20-16} = rt;
70   let Inst{15-11} = rd;
71   let Inst{10-6}  = shamt;
72   let Inst{5-0}   = funct;
73 }
74
75 //===----------------------------------------------------------------------===//
76 // Format I instruction class in Mips : <|opcode|rs|rt|immediate|>
77 //===----------------------------------------------------------------------===//
78
79 class FI<bits<6> op, dag outs, dag ins, string asmstr, list<dag> pattern,
80          InstrItinClass itin>: MipsInst<outs, ins, asmstr, pattern, itin>
81 {
82   bits<5>  rt;
83   bits<5>  rs;
84   bits<16> imm16;
85
86   let opcode = op;
87
88   let Inst{25-21} = rs;
89   let Inst{20-16} = rt;
90   let Inst{15-0}  = imm16;
91 }
92
93 class CBranchBase<bits<6> op, dag outs, dag ins, string asmstr,
94                   list<dag> pattern, InstrItinClass itin>:
95   MipsInst<outs, ins, asmstr, pattern, itin>
96 {
97   bits<5>  rs;
98   bits<5>  rt;
99   bits<16> imm16;
100
101   let opcode = op;
102
103   let Inst{25-21} = rs;
104   let Inst{20-16} = rt;
105   let Inst{15-0}  = imm16;
106 }
107
108 //===----------------------------------------------------------------------===//
109 // Format J instruction class in Mips : <|opcode|address|>
110 //===----------------------------------------------------------------------===//
111
112 class FJ<bits<6> op, dag outs, dag ins, string asmstr, list<dag> pattern,
113          InstrItinClass itin>: MipsInst<outs, ins, asmstr, pattern, itin>
114 {
115   bits<26> addr;
116
117   let opcode = op;
118
119   let Inst{25-0} = addr;
120 }
121
122 //===----------------------------------------------------------------------===//
123 //
124 //  FLOATING POINT INSTRUCTION FORMATS
125 //
126 //  opcode  - operation code.
127 //  fs      - src reg.
128 //  ft      - dst reg (on a 2 regs instr) or src reg (on a 3 reg instr).
129 //  fd      - dst reg, only used on 3 regs instr.
130 //  fmt     - double or single precision.
131 //  funct   - combined with opcode field give us an operation code.
132 //
133 //===----------------------------------------------------------------------===//
134
135 //===----------------------------------------------------------------------===//
136 // Format FR instruction class in Mips : <|opcode|fmt|ft|fs|fd|funct|>
137 //===----------------------------------------------------------------------===//
138
139 class FFR<bits<6> op, bits<6> _funct, bits<5> _fmt, dag outs, dag ins,
140           string asmstr, list<dag> pattern> :
141           MipsInst<outs, ins, asmstr, pattern, NoItinerary>
142 {
143   bits<5>  fd;
144   bits<5>  fs;
145   bits<5>  ft;
146   bits<5>  fmt;
147   bits<6>  funct;
148
149   let opcode = op;
150   let funct  = _funct;
151   let fmt    = _fmt;
152
153   let Inst{25-21} = fmt;
154   let Inst{20-16} = ft;
155   let Inst{15-11} = fs;
156   let Inst{10-6}  = fd;
157   let Inst{5-0}   = funct;
158 }
159
160 //===----------------------------------------------------------------------===//
161 // Format FI instruction class in Mips : <|opcode|base|ft|immediate|>
162 //===----------------------------------------------------------------------===//
163
164 class FFI<bits<6> op, dag outs, dag ins, string asmstr, list<dag> pattern>:
165           MipsInst<outs, ins, asmstr, pattern, NoItinerary>
166 {
167   bits<5>  ft;
168   bits<5>  base;
169   bits<16> imm16;
170
171   let opcode = op;
172
173   let Inst{25-21} = base;
174   let Inst{20-16} = ft;
175   let Inst{15-0}  = imm16;
176 }
177
178 //===----------------------------------------------------------------------===//
179 // Compare instruction class in Mips : <|010001|fmt|ft|fs|0000011|condcode|>
180 //===----------------------------------------------------------------------===//
181
182 class FCC<bits<5> _fmt, dag outs, dag ins, string asmstr, list<dag> pattern> :
183           MipsInst<outs, ins, asmstr, pattern, NoItinerary>
184 {
185   bits<5>  fs;
186   bits<5>  ft;
187   bits<4>  cc;
188   bits<5>  fmt;
189
190   let opcode = 0x11;
191   let fmt    = _fmt;
192
193   let Inst{25-21} = fmt;
194   let Inst{20-16} = ft;
195   let Inst{15-11} = fs;
196   let Inst{10-6}  = 0;
197   let Inst{5-4}   = 0b11;
198   let Inst{3-0}   = cc;
199 }
200
201
202 class FCMOV<bits<1> _tf, dag outs, dag ins, string asmstr,
203             list<dag> pattern> :
204   MipsInst<outs, ins, asmstr, pattern, NoItinerary>
205 {
206   bits<5>  rd;
207   bits<5>  rs;
208   bits<3>  N;
209   bits<1>  tf;
210
211   let opcode = 0;
212   let tf = _tf;
213
214   let Inst{25-21} = rs;
215   let Inst{20-18} = N;
216   let Inst{17} = 0;
217   let Inst{16} = tf;
218   let Inst{15-11} = rd;
219   let Inst{10-6}  = 0;
220   let Inst{5-0}   = 1;
221 }
222
223 class FFCMOV<bits<5> _fmt, bits<1> _tf, dag outs, dag ins, string asmstr,
224              list<dag> pattern> :
225   MipsInst<outs, ins, asmstr, pattern, NoItinerary>
226 {
227   bits<5>  fd;
228   bits<5>  fs;
229   bits<3>  N;
230   bits<5>  fmt;
231   bits<1>  tf;
232
233   let opcode = 17;
234   let fmt = _fmt;
235   let tf = _tf;
236
237   let Inst{25-21} = fmt;
238   let Inst{20-18} = N;
239   let Inst{17} = 0;
240   let Inst{16} = tf;
241   let Inst{15-11} = fs;
242   let Inst{10-6}  = fd;
243   let Inst{5-0}   = 17;
244 }
245
246 // FP unary instructions without patterns.
247 class FFR1<bits<6> funct, bits<5> fmt, string opstr, string fmtstr,
248            RegisterClass DstRC, RegisterClass SrcRC> :
249   FFR<0x11, funct, fmt, (outs DstRC:$fd), (ins SrcRC:$fs),
250       !strconcat(opstr, ".", fmtstr, "\t$fd, $fs"), []> {
251   let ft = 0;
252 }
253
254 // FP unary instructions with patterns.
255 class FFR1P<bits<6> funct, bits<5> fmt, string opstr, string fmtstr,
256             RegisterClass DstRC, RegisterClass SrcRC, SDNode OpNode> :
257   FFR<0x11, funct, fmt, (outs DstRC:$fd), (ins SrcRC:$fs),
258       !strconcat(opstr, ".", fmtstr, "\t$fd, $fs"),
259       [(set DstRC:$fd, (OpNode SrcRC:$fs))]> {
260   let ft = 0;
261 }
262
263 class FFR2P<bits<6> funct, bits<5> fmt, string opstr,
264             string fmtstr, RegisterClass RC, SDNode OpNode> :
265   FFR<0x11, funct, fmt, (outs RC:$fd), (ins RC:$fs, RC:$ft),
266       !strconcat(opstr, ".", fmtstr, "\t$fd, $fs, $ft"),
267       [(set RC:$fd, (OpNode RC:$fs, RC:$ft))]>;