blob: ff2ed871701b7679e2ec82db335ff1d00fb39d2f [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001//===- SparcInstrInfo.td - Target Description for Sparc Target ------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file was developed by the LLVM research group and is distributed under
6// the University of Illinois Open Source License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file describes the Sparc instructions in TableGen format.
11//
12//===----------------------------------------------------------------------===//
13
14//===----------------------------------------------------------------------===//
15// Instruction format superclass
16//===----------------------------------------------------------------------===//
17
18include "SparcInstrFormats.td"
19
20//===----------------------------------------------------------------------===//
21// Feature predicates.
22//===----------------------------------------------------------------------===//
23
24// HasV9 - This predicate is true when the target processor supports V9
25// instructions. Note that the machine may be running in 32-bit mode.
26def HasV9 : Predicate<"Subtarget.isV9()">;
27
28// HasNoV9 - This predicate is true when the target doesn't have V9
29// instructions. Use of this is just a hack for the isel not having proper
30// costs for V8 instructions that are more expensive than their V9 ones.
31def HasNoV9 : Predicate<"!Subtarget.isV9()">;
32
33// HasVIS - This is true when the target processor has VIS extensions.
34def HasVIS : Predicate<"Subtarget.isVIS()">;
35
36// UseDeprecatedInsts - This predicate is true when the target processor is a
37// V8, or when it is V9 but the V8 deprecated instructions are efficient enough
38// to use when appropriate. In either of these cases, the instruction selector
39// will pick deprecated instructions.
40def UseDeprecatedInsts : Predicate<"Subtarget.useDeprecatedV8Instructions()">;
41
42//===----------------------------------------------------------------------===//
43// Instruction Pattern Stuff
44//===----------------------------------------------------------------------===//
45
46def simm11 : PatLeaf<(imm), [{
47 // simm11 predicate - True if the imm fits in a 11-bit sign extended field.
48 return (((int)N->getValue() << (32-11)) >> (32-11)) == (int)N->getValue();
49}]>;
50
51def simm13 : PatLeaf<(imm), [{
52 // simm13 predicate - True if the imm fits in a 13-bit sign extended field.
53 return (((int)N->getValue() << (32-13)) >> (32-13)) == (int)N->getValue();
54}]>;
55
56def LO10 : SDNodeXForm<imm, [{
57 return CurDAG->getTargetConstant((unsigned)N->getValue() & 1023, MVT::i32);
58}]>;
59
60def HI22 : SDNodeXForm<imm, [{
61 // Transformation function: shift the immediate value down into the low bits.
62 return CurDAG->getTargetConstant((unsigned)N->getValue() >> 10, MVT::i32);
63}]>;
64
65def SETHIimm : PatLeaf<(imm), [{
66 return (((unsigned)N->getValue() >> 10) << 10) == (unsigned)N->getValue();
67}], HI22>;
68
69// Addressing modes.
70def ADDRrr : ComplexPattern<i32, 2, "SelectADDRrr", [], []>;
71def ADDRri : ComplexPattern<i32, 2, "SelectADDRri", [frameindex], []>;
72
73// Address operands
74def MEMrr : Operand<i32> {
75 let PrintMethod = "printMemOperand";
76 let MIOperandInfo = (ops IntRegs, IntRegs);
77}
78def MEMri : Operand<i32> {
79 let PrintMethod = "printMemOperand";
80 let MIOperandInfo = (ops IntRegs, i32imm);
81}
82
83// Branch targets have OtherVT type.
84def brtarget : Operand<OtherVT>;
85def calltarget : Operand<i32>;
86
87// Operand for printing out a condition code.
88let PrintMethod = "printCCOperand" in
89 def CCOp : Operand<i32>;
90
91def SDTSPcmpfcc :
92SDTypeProfile<0, 2, [SDTCisFP<0>, SDTCisSameAs<0, 1>]>;
93def SDTSPbrcc :
94SDTypeProfile<0, 2, [SDTCisVT<0, OtherVT>, SDTCisVT<1, i32>]>;
95def SDTSPselectcc :
96SDTypeProfile<1, 3, [SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>, SDTCisVT<3, i32>]>;
97def SDTSPFTOI :
98SDTypeProfile<1, 1, [SDTCisVT<0, f32>, SDTCisFP<1>]>;
99def SDTSPITOF :
100SDTypeProfile<1, 1, [SDTCisFP<0>, SDTCisVT<1, f32>]>;
101
102def SPcmpicc : SDNode<"SPISD::CMPICC", SDTIntBinOp, [SDNPOutFlag]>;
103def SPcmpfcc : SDNode<"SPISD::CMPFCC", SDTSPcmpfcc, [SDNPOutFlag]>;
104def SPbricc : SDNode<"SPISD::BRICC", SDTSPbrcc, [SDNPHasChain, SDNPInFlag]>;
105def SPbrfcc : SDNode<"SPISD::BRFCC", SDTSPbrcc, [SDNPHasChain, SDNPInFlag]>;
106
107def SPhi : SDNode<"SPISD::Hi", SDTIntUnaryOp>;
108def SPlo : SDNode<"SPISD::Lo", SDTIntUnaryOp>;
109
110def SPftoi : SDNode<"SPISD::FTOI", SDTSPFTOI>;
111def SPitof : SDNode<"SPISD::ITOF", SDTSPITOF>;
112
113def SPselecticc : SDNode<"SPISD::SELECT_ICC", SDTSPselectcc, [SDNPInFlag]>;
114def SPselectfcc : SDNode<"SPISD::SELECT_FCC", SDTSPselectcc, [SDNPInFlag]>;
115
116// These are target-independent nodes, but have target-specific formats.
117def SDT_SPCallSeq : SDTypeProfile<0, 1, [ SDTCisVT<0, i32> ]>;
118def callseq_start : SDNode<"ISD::CALLSEQ_START", SDT_SPCallSeq,
119 [SDNPHasChain, SDNPOutFlag]>;
120def callseq_end : SDNode<"ISD::CALLSEQ_END", SDT_SPCallSeq,
121 [SDNPHasChain, SDNPOutFlag]>;
122
123def SDT_SPCall : SDTypeProfile<0, 1, [SDTCisVT<0, i32>]>;
124def call : SDNode<"SPISD::CALL", SDT_SPCall,
125 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
126
127def SDT_SPRetFlag : SDTypeProfile<0, 0, []>;
128def retflag : SDNode<"SPISD::RET_FLAG", SDT_SPRetFlag,
129 [SDNPHasChain, SDNPOptInFlag]>;
130
131//===----------------------------------------------------------------------===//
132// SPARC Flag Conditions
133//===----------------------------------------------------------------------===//
134
135// Note that these values must be kept in sync with the CCOp::CondCode enum
136// values.
137class ICC_VAL<int N> : PatLeaf<(i32 N)>;
138def ICC_NE : ICC_VAL< 9>; // Not Equal
139def ICC_E : ICC_VAL< 1>; // Equal
140def ICC_G : ICC_VAL<10>; // Greater
141def ICC_LE : ICC_VAL< 2>; // Less or Equal
142def ICC_GE : ICC_VAL<11>; // Greater or Equal
143def ICC_L : ICC_VAL< 3>; // Less
144def ICC_GU : ICC_VAL<12>; // Greater Unsigned
145def ICC_LEU : ICC_VAL< 4>; // Less or Equal Unsigned
146def ICC_CC : ICC_VAL<13>; // Carry Clear/Great or Equal Unsigned
147def ICC_CS : ICC_VAL< 5>; // Carry Set/Less Unsigned
148def ICC_POS : ICC_VAL<14>; // Positive
149def ICC_NEG : ICC_VAL< 6>; // Negative
150def ICC_VC : ICC_VAL<15>; // Overflow Clear
151def ICC_VS : ICC_VAL< 7>; // Overflow Set
152
153class FCC_VAL<int N> : PatLeaf<(i32 N)>;
154def FCC_U : FCC_VAL<23>; // Unordered
155def FCC_G : FCC_VAL<22>; // Greater
156def FCC_UG : FCC_VAL<21>; // Unordered or Greater
157def FCC_L : FCC_VAL<20>; // Less
158def FCC_UL : FCC_VAL<19>; // Unordered or Less
159def FCC_LG : FCC_VAL<18>; // Less or Greater
160def FCC_NE : FCC_VAL<17>; // Not Equal
161def FCC_E : FCC_VAL<25>; // Equal
162def FCC_UE : FCC_VAL<24>; // Unordered or Equal
163def FCC_GE : FCC_VAL<25>; // Greater or Equal
164def FCC_UGE : FCC_VAL<26>; // Unordered or Greater or Equal
165def FCC_LE : FCC_VAL<27>; // Less or Equal
166def FCC_ULE : FCC_VAL<28>; // Unordered or Less or Equal
167def FCC_O : FCC_VAL<29>; // Ordered
168
169//===----------------------------------------------------------------------===//
170// Instruction Class Templates
171//===----------------------------------------------------------------------===//
172
173/// F3_12 multiclass - Define a normal F3_1/F3_2 pattern in one shot.
174multiclass F3_12<string OpcStr, bits<6> Op3Val, SDNode OpNode> {
175 def rr : F3_1<2, Op3Val,
Evan Chengb783fa32007-07-19 01:14:50 +0000176 (outs IntRegs:$dst), (ins IntRegs:$b, IntRegs:$c),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000177 !strconcat(OpcStr, " $b, $c, $dst"),
178 [(set IntRegs:$dst, (OpNode IntRegs:$b, IntRegs:$c))]>;
179 def ri : F3_2<2, Op3Val,
Evan Chengb783fa32007-07-19 01:14:50 +0000180 (outs IntRegs:$dst), (ins IntRegs:$b, i32imm:$c),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000181 !strconcat(OpcStr, " $b, $c, $dst"),
182 [(set IntRegs:$dst, (OpNode IntRegs:$b, simm13:$c))]>;
183}
184
185/// F3_12np multiclass - Define a normal F3_1/F3_2 pattern in one shot, with no
186/// pattern.
187multiclass F3_12np<string OpcStr, bits<6> Op3Val> {
188 def rr : F3_1<2, Op3Val,
Evan Chengb783fa32007-07-19 01:14:50 +0000189 (outs IntRegs:$dst), (ins IntRegs:$b, IntRegs:$c),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000190 !strconcat(OpcStr, " $b, $c, $dst"), []>;
191 def ri : F3_2<2, Op3Val,
Evan Chengb783fa32007-07-19 01:14:50 +0000192 (outs IntRegs:$dst), (ins IntRegs:$b, i32imm:$c),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000193 !strconcat(OpcStr, " $b, $c, $dst"), []>;
194}
195
196//===----------------------------------------------------------------------===//
197// Instructions
198//===----------------------------------------------------------------------===//
199
200// Pseudo instructions.
Evan Chengb783fa32007-07-19 01:14:50 +0000201class Pseudo<dag outs, dag ins, string asmstr, list<dag> pattern>
202 : InstSP<outs, ins, asmstr, pattern>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000203
Evan Chengb783fa32007-07-19 01:14:50 +0000204def ADJCALLSTACKDOWN : Pseudo<(outs), (ins i32imm:$amt),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000205 "!ADJCALLSTACKDOWN $amt",
206 [(callseq_start imm:$amt)]>, Imp<[O6],[O6]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000207def ADJCALLSTACKUP : Pseudo<(outs), (ins i32imm:$amt),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000208 "!ADJCALLSTACKUP $amt",
209 [(callseq_end imm:$amt)]>, Imp<[O6],[O6]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000210def IMPLICIT_DEF_Int : Pseudo<(outs IntRegs:$dst), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000211 "!IMPLICIT_DEF $dst",
212 [(set IntRegs:$dst, (undef))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000213def IMPLICIT_DEF_FP : Pseudo<(outs FPRegs:$dst), (ins), "!IMPLICIT_DEF $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000214 [(set FPRegs:$dst, (undef))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000215def IMPLICIT_DEF_DFP : Pseudo<(outs DFPRegs:$dst), (ins), "!IMPLICIT_DEF $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000216 [(set DFPRegs:$dst, (undef))]>;
217
218// FpMOVD/FpNEGD/FpABSD - These are lowered to single-precision ops by the
219// fpmover pass.
220let Predicates = [HasNoV9] in { // Only emit these in V8 mode.
Evan Chengb783fa32007-07-19 01:14:50 +0000221 def FpMOVD : Pseudo<(outs DFPRegs:$dst), (ins DFPRegs:$src),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000222 "!FpMOVD $src, $dst", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000223 def FpNEGD : Pseudo<(outs DFPRegs:$dst), (ins DFPRegs:$src),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000224 "!FpNEGD $src, $dst",
225 [(set DFPRegs:$dst, (fneg DFPRegs:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000226 def FpABSD : Pseudo<(outs DFPRegs:$dst), (ins DFPRegs:$src),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000227 "!FpABSD $src, $dst",
228 [(set DFPRegs:$dst, (fabs DFPRegs:$src))]>;
229}
230
231// SELECT_CC_* - Used to implement the SELECT_CC DAG operation. Expanded by the
232// scheduler into a branch sequence. This has to handle all permutations of
233// selection between i32/f32/f64 on ICC and FCC.
234let usesCustomDAGSchedInserter = 1 in { // Expanded by the scheduler.
235 def SELECT_CC_Int_ICC
Evan Chengb783fa32007-07-19 01:14:50 +0000236 : Pseudo<(outs IntRegs:$dst), (ins IntRegs:$T, IntRegs:$F, i32imm:$Cond),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000237 "; SELECT_CC_Int_ICC PSEUDO!",
238 [(set IntRegs:$dst, (SPselecticc IntRegs:$T, IntRegs:$F,
239 imm:$Cond))]>;
240 def SELECT_CC_Int_FCC
Evan Chengb783fa32007-07-19 01:14:50 +0000241 : Pseudo<(outs IntRegs:$dst), (ins IntRegs:$T, IntRegs:$F, i32imm:$Cond),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000242 "; SELECT_CC_Int_FCC PSEUDO!",
243 [(set IntRegs:$dst, (SPselectfcc IntRegs:$T, IntRegs:$F,
244 imm:$Cond))]>;
245 def SELECT_CC_FP_ICC
Evan Chengb783fa32007-07-19 01:14:50 +0000246 : Pseudo<(outs FPRegs:$dst), (ins FPRegs:$T, FPRegs:$F, i32imm:$Cond),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000247 "; SELECT_CC_FP_ICC PSEUDO!",
248 [(set FPRegs:$dst, (SPselecticc FPRegs:$T, FPRegs:$F,
249 imm:$Cond))]>;
250 def SELECT_CC_FP_FCC
Evan Chengb783fa32007-07-19 01:14:50 +0000251 : Pseudo<(outs FPRegs:$dst), (ins FPRegs:$T, FPRegs:$F, i32imm:$Cond),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000252 "; SELECT_CC_FP_FCC PSEUDO!",
253 [(set FPRegs:$dst, (SPselectfcc FPRegs:$T, FPRegs:$F,
254 imm:$Cond))]>;
255 def SELECT_CC_DFP_ICC
Evan Chengb783fa32007-07-19 01:14:50 +0000256 : Pseudo<(outs DFPRegs:$dst), (ins DFPRegs:$T, DFPRegs:$F, i32imm:$Cond),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000257 "; SELECT_CC_DFP_ICC PSEUDO!",
258 [(set DFPRegs:$dst, (SPselecticc DFPRegs:$T, DFPRegs:$F,
259 imm:$Cond))]>;
260 def SELECT_CC_DFP_FCC
Evan Chengb783fa32007-07-19 01:14:50 +0000261 : Pseudo<(outs DFPRegs:$dst), (ins DFPRegs:$T, DFPRegs:$F, i32imm:$Cond),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000262 "; SELECT_CC_DFP_FCC PSEUDO!",
263 [(set DFPRegs:$dst, (SPselectfcc DFPRegs:$T, DFPRegs:$F,
264 imm:$Cond))]>;
265}
266
267
268// Section A.3 - Synthetic Instructions, p. 85
269// special cases of JMPL:
Evan Cheng37e7c752007-07-21 00:34:19 +0000270let isReturn = 1, isTerminator = 1, hasDelaySlot = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000271 let rd = O7.Num, rs1 = G0.Num, simm13 = 8 in
Evan Chengb783fa32007-07-19 01:14:50 +0000272 def RETL: F3_2<2, 0b111000, (outs), (ins), "retl", [(retflag)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000273}
274
275// Section B.1 - Load Integer Instructions, p. 90
276def LDSBrr : F3_1<3, 0b001001,
Evan Chengb783fa32007-07-19 01:14:50 +0000277 (outs IntRegs:$dst), (ins MEMrr:$addr),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000278 "ldsb [$addr], $dst",
279 [(set IntRegs:$dst, (sextloadi8 ADDRrr:$addr))]>;
280def LDSBri : F3_2<3, 0b001001,
Evan Chengb783fa32007-07-19 01:14:50 +0000281 (outs IntRegs:$dst), (ins MEMri:$addr),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000282 "ldsb [$addr], $dst",
283 [(set IntRegs:$dst, (sextloadi8 ADDRri:$addr))]>;
284def LDSHrr : F3_1<3, 0b001010,
Evan Chengb783fa32007-07-19 01:14:50 +0000285 (outs IntRegs:$dst), (ins MEMrr:$addr),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000286 "ldsh [$addr], $dst",
287 [(set IntRegs:$dst, (sextloadi16 ADDRrr:$addr))]>;
288def LDSHri : F3_2<3, 0b001010,
Evan Chengb783fa32007-07-19 01:14:50 +0000289 (outs IntRegs:$dst), (ins MEMri:$addr),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000290 "ldsh [$addr], $dst",
291 [(set IntRegs:$dst, (sextloadi16 ADDRri:$addr))]>;
292def LDUBrr : F3_1<3, 0b000001,
Evan Chengb783fa32007-07-19 01:14:50 +0000293 (outs IntRegs:$dst), (ins MEMrr:$addr),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000294 "ldub [$addr], $dst",
295 [(set IntRegs:$dst, (zextloadi8 ADDRrr:$addr))]>;
296def LDUBri : F3_2<3, 0b000001,
Evan Chengb783fa32007-07-19 01:14:50 +0000297 (outs IntRegs:$dst), (ins MEMri:$addr),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000298 "ldub [$addr], $dst",
299 [(set IntRegs:$dst, (zextloadi8 ADDRri:$addr))]>;
300def LDUHrr : F3_1<3, 0b000010,
Evan Chengb783fa32007-07-19 01:14:50 +0000301 (outs IntRegs:$dst), (ins MEMrr:$addr),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000302 "lduh [$addr], $dst",
303 [(set IntRegs:$dst, (zextloadi16 ADDRrr:$addr))]>;
304def LDUHri : F3_2<3, 0b000010,
Evan Chengb783fa32007-07-19 01:14:50 +0000305 (outs IntRegs:$dst), (ins MEMri:$addr),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000306 "lduh [$addr], $dst",
307 [(set IntRegs:$dst, (zextloadi16 ADDRri:$addr))]>;
308def LDrr : F3_1<3, 0b000000,
Evan Chengb783fa32007-07-19 01:14:50 +0000309 (outs IntRegs:$dst), (ins MEMrr:$addr),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000310 "ld [$addr], $dst",
311 [(set IntRegs:$dst, (load ADDRrr:$addr))]>;
312def LDri : F3_2<3, 0b000000,
Evan Chengb783fa32007-07-19 01:14:50 +0000313 (outs IntRegs:$dst), (ins MEMri:$addr),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000314 "ld [$addr], $dst",
315 [(set IntRegs:$dst, (load ADDRri:$addr))]>;
316
317// Section B.2 - Load Floating-point Instructions, p. 92
318def LDFrr : F3_1<3, 0b100000,
Evan Chengb783fa32007-07-19 01:14:50 +0000319 (outs FPRegs:$dst), (ins MEMrr:$addr),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000320 "ld [$addr], $dst",
321 [(set FPRegs:$dst, (load ADDRrr:$addr))]>;
322def LDFri : F3_2<3, 0b100000,
Evan Chengb783fa32007-07-19 01:14:50 +0000323 (outs FPRegs:$dst), (ins MEMri:$addr),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000324 "ld [$addr], $dst",
325 [(set FPRegs:$dst, (load ADDRri:$addr))]>;
326def LDDFrr : F3_1<3, 0b100011,
Evan Chengb783fa32007-07-19 01:14:50 +0000327 (outs DFPRegs:$dst), (ins MEMrr:$addr),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000328 "ldd [$addr], $dst",
329 [(set DFPRegs:$dst, (load ADDRrr:$addr))]>;
330def LDDFri : F3_2<3, 0b100011,
Evan Chengb783fa32007-07-19 01:14:50 +0000331 (outs DFPRegs:$dst), (ins MEMri:$addr),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000332 "ldd [$addr], $dst",
333 [(set DFPRegs:$dst, (load ADDRri:$addr))]>;
334
335// Section B.4 - Store Integer Instructions, p. 95
336def STBrr : F3_1<3, 0b000101,
Evan Chengb783fa32007-07-19 01:14:50 +0000337 (outs), (ins MEMrr:$addr, IntRegs:$src),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000338 "stb $src, [$addr]",
339 [(truncstorei8 IntRegs:$src, ADDRrr:$addr)]>;
340def STBri : F3_2<3, 0b000101,
Evan Chengb783fa32007-07-19 01:14:50 +0000341 (outs), (ins MEMri:$addr, IntRegs:$src),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000342 "stb $src, [$addr]",
343 [(truncstorei8 IntRegs:$src, ADDRri:$addr)]>;
344def STHrr : F3_1<3, 0b000110,
Evan Chengb783fa32007-07-19 01:14:50 +0000345 (outs), (ins MEMrr:$addr, IntRegs:$src),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000346 "sth $src, [$addr]",
347 [(truncstorei16 IntRegs:$src, ADDRrr:$addr)]>;
348def STHri : F3_2<3, 0b000110,
Evan Chengb783fa32007-07-19 01:14:50 +0000349 (outs), (ins MEMri:$addr, IntRegs:$src),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000350 "sth $src, [$addr]",
351 [(truncstorei16 IntRegs:$src, ADDRri:$addr)]>;
352def STrr : F3_1<3, 0b000100,
Evan Chengb783fa32007-07-19 01:14:50 +0000353 (outs), (ins MEMrr:$addr, IntRegs:$src),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000354 "st $src, [$addr]",
355 [(store IntRegs:$src, ADDRrr:$addr)]>;
356def STri : F3_2<3, 0b000100,
Evan Chengb783fa32007-07-19 01:14:50 +0000357 (outs), (ins MEMri:$addr, IntRegs:$src),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000358 "st $src, [$addr]",
359 [(store IntRegs:$src, ADDRri:$addr)]>;
360
361// Section B.5 - Store Floating-point Instructions, p. 97
362def STFrr : F3_1<3, 0b100100,
Evan Chengb783fa32007-07-19 01:14:50 +0000363 (outs), (ins MEMrr:$addr, FPRegs:$src),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000364 "st $src, [$addr]",
365 [(store FPRegs:$src, ADDRrr:$addr)]>;
366def STFri : F3_2<3, 0b100100,
Evan Chengb783fa32007-07-19 01:14:50 +0000367 (outs), (ins MEMri:$addr, FPRegs:$src),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000368 "st $src, [$addr]",
369 [(store FPRegs:$src, ADDRri:$addr)]>;
370def STDFrr : F3_1<3, 0b100111,
Evan Chengb783fa32007-07-19 01:14:50 +0000371 (outs), (ins MEMrr:$addr, DFPRegs:$src),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000372 "std $src, [$addr]",
373 [(store DFPRegs:$src, ADDRrr:$addr)]>;
374def STDFri : F3_2<3, 0b100111,
Evan Chengb783fa32007-07-19 01:14:50 +0000375 (outs), (ins MEMri:$addr, DFPRegs:$src),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000376 "std $src, [$addr]",
377 [(store DFPRegs:$src, ADDRri:$addr)]>;
378
379// Section B.9 - SETHI Instruction, p. 104
380def SETHIi: F2_1<0b100,
Evan Chengb783fa32007-07-19 01:14:50 +0000381 (outs IntRegs:$dst), (ins i32imm:$src),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000382 "sethi $src, $dst",
383 [(set IntRegs:$dst, SETHIimm:$src)]>;
384
385// Section B.10 - NOP Instruction, p. 105
386// (It's a special case of SETHI)
387let rd = 0, imm22 = 0 in
Evan Chengb783fa32007-07-19 01:14:50 +0000388 def NOP : F2_1<0b100, (outs), (ins), "nop", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000389
390// Section B.11 - Logical Instructions, p. 106
391defm AND : F3_12<"and", 0b000001, and>;
392
393def ANDNrr : F3_1<2, 0b000101,
Evan Chengb783fa32007-07-19 01:14:50 +0000394 (outs IntRegs:$dst), (ins IntRegs:$b, IntRegs:$c),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000395 "andn $b, $c, $dst",
396 [(set IntRegs:$dst, (and IntRegs:$b, (not IntRegs:$c)))]>;
397def ANDNri : F3_2<2, 0b000101,
Evan Chengb783fa32007-07-19 01:14:50 +0000398 (outs IntRegs:$dst), (ins IntRegs:$b, i32imm:$c),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000399 "andn $b, $c, $dst", []>;
400
401defm OR : F3_12<"or", 0b000010, or>;
402
403def ORNrr : F3_1<2, 0b000110,
Evan Chengb783fa32007-07-19 01:14:50 +0000404 (outs IntRegs:$dst), (ins IntRegs:$b, IntRegs:$c),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000405 "orn $b, $c, $dst",
406 [(set IntRegs:$dst, (or IntRegs:$b, (not IntRegs:$c)))]>;
407def ORNri : F3_2<2, 0b000110,
Evan Chengb783fa32007-07-19 01:14:50 +0000408 (outs IntRegs:$dst), (ins IntRegs:$b, i32imm:$c),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000409 "orn $b, $c, $dst", []>;
410defm XOR : F3_12<"xor", 0b000011, xor>;
411
412def XNORrr : F3_1<2, 0b000111,
Evan Chengb783fa32007-07-19 01:14:50 +0000413 (outs IntRegs:$dst), (ins IntRegs:$b, IntRegs:$c),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000414 "xnor $b, $c, $dst",
415 [(set IntRegs:$dst, (not (xor IntRegs:$b, IntRegs:$c)))]>;
416def XNORri : F3_2<2, 0b000111,
Evan Chengb783fa32007-07-19 01:14:50 +0000417 (outs IntRegs:$dst), (ins IntRegs:$b, i32imm:$c),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000418 "xnor $b, $c, $dst", []>;
419
420// Section B.12 - Shift Instructions, p. 107
421defm SLL : F3_12<"sll", 0b100101, shl>;
422defm SRL : F3_12<"srl", 0b100110, srl>;
423defm SRA : F3_12<"sra", 0b100111, sra>;
424
425// Section B.13 - Add Instructions, p. 108
426defm ADD : F3_12<"add", 0b000000, add>;
427
428// "LEA" forms of add (patterns to make tblgen happy)
429def LEA_ADDri : F3_2<2, 0b000000,
Evan Chengb783fa32007-07-19 01:14:50 +0000430 (outs IntRegs:$dst), (ins MEMri:$addr),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000431 "add ${addr:arith}, $dst",
432 [(set IntRegs:$dst, ADDRri:$addr)]>;
433
434defm ADDCC : F3_12<"addcc", 0b010000, addc>;
435defm ADDX : F3_12<"addx", 0b001000, adde>;
436
437// Section B.15 - Subtract Instructions, p. 110
438defm SUB : F3_12 <"sub" , 0b000100, sub>;
439defm SUBX : F3_12 <"subx" , 0b001100, sube>;
440defm SUBCC : F3_12 <"subcc", 0b010100, SPcmpicc>;
441
442def SUBXCCrr: F3_1<2, 0b011100,
Evan Chengb783fa32007-07-19 01:14:50 +0000443 (outs IntRegs:$dst), (ins IntRegs:$b, IntRegs:$c),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000444 "subxcc $b, $c, $dst", []>;
445
446// Section B.18 - Multiply Instructions, p. 113
447defm UMUL : F3_12np<"umul", 0b001010>;
448defm SMUL : F3_12 <"smul", 0b001011, mul>;
449
450
451// Section B.19 - Divide Instructions, p. 115
452defm UDIV : F3_12np<"udiv", 0b001110>;
453defm SDIV : F3_12np<"sdiv", 0b001111>;
454
455// Section B.20 - SAVE and RESTORE, p. 117
456defm SAVE : F3_12np<"save" , 0b111100>;
457defm RESTORE : F3_12np<"restore", 0b111101>;
458
459// Section B.21 - Branch on Integer Condition Codes Instructions, p. 119
460
461// conditional branch class:
Evan Chengb783fa32007-07-19 01:14:50 +0000462class BranchSP<bits<4> cc, dag ins, string asmstr, list<dag> pattern>
463 : F2_2<cc, 0b010, (outs), ins, asmstr, pattern> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000464 let isBranch = 1;
465 let isTerminator = 1;
466 let hasDelaySlot = 1;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000467}
468
469let isBarrier = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000470 def BA : BranchSP<0b1000, (ins brtarget:$dst),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000471 "ba $dst",
472 [(br bb:$dst)]>;
473
474// FIXME: the encoding for the JIT should look at the condition field.
Evan Chengb783fa32007-07-19 01:14:50 +0000475def BCOND : BranchSP<0, (ins brtarget:$dst, CCOp:$cc),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000476 "b$cc $dst",
477 [(SPbricc bb:$dst, imm:$cc)]>;
478
479
480// Section B.22 - Branch on Floating-point Condition Codes Instructions, p. 121
481
482// floating-point conditional branch class:
Evan Chengb783fa32007-07-19 01:14:50 +0000483class FPBranchSP<bits<4> cc, dag ins, string asmstr, list<dag> pattern>
484 : F2_2<cc, 0b110, (outs), ins, asmstr, pattern> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000485 let isBranch = 1;
486 let isTerminator = 1;
487 let hasDelaySlot = 1;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000488}
489
490// FIXME: the encoding for the JIT should look at the condition field.
Evan Chengb783fa32007-07-19 01:14:50 +0000491def FBCOND : FPBranchSP<0, (ins brtarget:$dst, CCOp:$cc),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000492 "fb$cc $dst",
493 [(SPbrfcc bb:$dst, imm:$cc)]>;
494
495
496// Section B.24 - Call and Link Instruction, p. 125
497// This is the only Format 1 instruction
498let Uses = [O0, O1, O2, O3, O4, O5],
Evan Cheng37e7c752007-07-21 00:34:19 +0000499 hasDelaySlot = 1, isCall = 1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000500 Defs = [O0, O1, O2, O3, O4, O5, O7, G1, G2, G3, G4, G5, G6, G7,
501 D0, D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, D14, D15] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000502 def CALL : InstSP<(outs), (ins calltarget:$dst),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000503 "call $dst", []> {
504 bits<30> disp;
505 let op = 1;
506 let Inst{29-0} = disp;
507 }
508
509 // indirect calls
510 def JMPLrr : F3_1<2, 0b111000,
Evan Chengb783fa32007-07-19 01:14:50 +0000511 (outs), (ins MEMrr:$ptr),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000512 "call $ptr",
513 [(call ADDRrr:$ptr)]>;
514 def JMPLri : F3_2<2, 0b111000,
Evan Chengb783fa32007-07-19 01:14:50 +0000515 (outs), (ins MEMri:$ptr),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000516 "call $ptr",
517 [(call ADDRri:$ptr)]>;
518}
519
520// Section B.28 - Read State Register Instructions
521def RDY : F3_1<2, 0b101000,
Evan Chengb783fa32007-07-19 01:14:50 +0000522 (outs IntRegs:$dst), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000523 "rd %y, $dst", []>;
524
525// Section B.29 - Write State Register Instructions
526def WRYrr : F3_1<2, 0b110000,
Evan Chengb783fa32007-07-19 01:14:50 +0000527 (outs), (ins IntRegs:$b, IntRegs:$c),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000528 "wr $b, $c, %y", []>;
529def WRYri : F3_2<2, 0b110000,
Evan Chengb783fa32007-07-19 01:14:50 +0000530 (outs), (ins IntRegs:$b, i32imm:$c),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000531 "wr $b, $c, %y", []>;
532
533// Convert Integer to Floating-point Instructions, p. 141
534def FITOS : F3_3<2, 0b110100, 0b011000100,
Evan Chengb783fa32007-07-19 01:14:50 +0000535 (outs FPRegs:$dst), (ins FPRegs:$src),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000536 "fitos $src, $dst",
537 [(set FPRegs:$dst, (SPitof FPRegs:$src))]>;
538def FITOD : F3_3<2, 0b110100, 0b011001000,
Evan Chengb783fa32007-07-19 01:14:50 +0000539 (outs DFPRegs:$dst), (ins FPRegs:$src),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000540 "fitod $src, $dst",
541 [(set DFPRegs:$dst, (SPitof FPRegs:$src))]>;
542
543// Convert Floating-point to Integer Instructions, p. 142
544def FSTOI : F3_3<2, 0b110100, 0b011010001,
Evan Chengb783fa32007-07-19 01:14:50 +0000545 (outs FPRegs:$dst), (ins FPRegs:$src),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000546 "fstoi $src, $dst",
547 [(set FPRegs:$dst, (SPftoi FPRegs:$src))]>;
548def FDTOI : F3_3<2, 0b110100, 0b011010010,
Evan Chengb783fa32007-07-19 01:14:50 +0000549 (outs FPRegs:$dst), (ins DFPRegs:$src),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000550 "fdtoi $src, $dst",
551 [(set FPRegs:$dst, (SPftoi DFPRegs:$src))]>;
552
553// Convert between Floating-point Formats Instructions, p. 143
554def FSTOD : F3_3<2, 0b110100, 0b011001001,
Evan Chengb783fa32007-07-19 01:14:50 +0000555 (outs DFPRegs:$dst), (ins FPRegs:$src),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000556 "fstod $src, $dst",
557 [(set DFPRegs:$dst, (fextend FPRegs:$src))]>;
558def FDTOS : F3_3<2, 0b110100, 0b011000110,
Evan Chengb783fa32007-07-19 01:14:50 +0000559 (outs FPRegs:$dst), (ins DFPRegs:$src),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000560 "fdtos $src, $dst",
561 [(set FPRegs:$dst, (fround DFPRegs:$src))]>;
562
563// Floating-point Move Instructions, p. 144
564def FMOVS : F3_3<2, 0b110100, 0b000000001,
Evan Chengb783fa32007-07-19 01:14:50 +0000565 (outs FPRegs:$dst), (ins FPRegs:$src),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000566 "fmovs $src, $dst", []>;
567def FNEGS : F3_3<2, 0b110100, 0b000000101,
Evan Chengb783fa32007-07-19 01:14:50 +0000568 (outs FPRegs:$dst), (ins FPRegs:$src),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000569 "fnegs $src, $dst",
570 [(set FPRegs:$dst, (fneg FPRegs:$src))]>;
571def FABSS : F3_3<2, 0b110100, 0b000001001,
Evan Chengb783fa32007-07-19 01:14:50 +0000572 (outs FPRegs:$dst), (ins FPRegs:$src),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000573 "fabss $src, $dst",
574 [(set FPRegs:$dst, (fabs FPRegs:$src))]>;
575
576
577// Floating-point Square Root Instructions, p.145
578def FSQRTS : F3_3<2, 0b110100, 0b000101001,
Evan Chengb783fa32007-07-19 01:14:50 +0000579 (outs FPRegs:$dst), (ins FPRegs:$src),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000580 "fsqrts $src, $dst",
581 [(set FPRegs:$dst, (fsqrt FPRegs:$src))]>;
582def FSQRTD : F3_3<2, 0b110100, 0b000101010,
Evan Chengb783fa32007-07-19 01:14:50 +0000583 (outs DFPRegs:$dst), (ins DFPRegs:$src),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000584 "fsqrtd $src, $dst",
585 [(set DFPRegs:$dst, (fsqrt DFPRegs:$src))]>;
586
587
588
589// Floating-point Add and Subtract Instructions, p. 146
590def FADDS : F3_3<2, 0b110100, 0b001000001,
Evan Chengb783fa32007-07-19 01:14:50 +0000591 (outs FPRegs:$dst), (ins FPRegs:$src1, FPRegs:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000592 "fadds $src1, $src2, $dst",
593 [(set FPRegs:$dst, (fadd FPRegs:$src1, FPRegs:$src2))]>;
594def FADDD : F3_3<2, 0b110100, 0b001000010,
Evan Chengb783fa32007-07-19 01:14:50 +0000595 (outs DFPRegs:$dst), (ins DFPRegs:$src1, DFPRegs:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000596 "faddd $src1, $src2, $dst",
597 [(set DFPRegs:$dst, (fadd DFPRegs:$src1, DFPRegs:$src2))]>;
598def FSUBS : F3_3<2, 0b110100, 0b001000101,
Evan Chengb783fa32007-07-19 01:14:50 +0000599 (outs FPRegs:$dst), (ins FPRegs:$src1, FPRegs:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000600 "fsubs $src1, $src2, $dst",
601 [(set FPRegs:$dst, (fsub FPRegs:$src1, FPRegs:$src2))]>;
602def FSUBD : F3_3<2, 0b110100, 0b001000110,
Evan Chengb783fa32007-07-19 01:14:50 +0000603 (outs DFPRegs:$dst), (ins DFPRegs:$src1, DFPRegs:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000604 "fsubd $src1, $src2, $dst",
605 [(set DFPRegs:$dst, (fsub DFPRegs:$src1, DFPRegs:$src2))]>;
606
607// Floating-point Multiply and Divide Instructions, p. 147
608def FMULS : F3_3<2, 0b110100, 0b001001001,
Evan Chengb783fa32007-07-19 01:14:50 +0000609 (outs FPRegs:$dst), (ins FPRegs:$src1, FPRegs:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000610 "fmuls $src1, $src2, $dst",
611 [(set FPRegs:$dst, (fmul FPRegs:$src1, FPRegs:$src2))]>;
612def FMULD : F3_3<2, 0b110100, 0b001001010,
Evan Chengb783fa32007-07-19 01:14:50 +0000613 (outs DFPRegs:$dst), (ins DFPRegs:$src1, DFPRegs:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000614 "fmuld $src1, $src2, $dst",
615 [(set DFPRegs:$dst, (fmul DFPRegs:$src1, DFPRegs:$src2))]>;
616def FSMULD : F3_3<2, 0b110100, 0b001101001,
Evan Chengb783fa32007-07-19 01:14:50 +0000617 (outs DFPRegs:$dst), (ins FPRegs:$src1, FPRegs:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000618 "fsmuld $src1, $src2, $dst",
619 [(set DFPRegs:$dst, (fmul (fextend FPRegs:$src1),
620 (fextend FPRegs:$src2)))]>;
621def FDIVS : F3_3<2, 0b110100, 0b001001101,
Evan Chengb783fa32007-07-19 01:14:50 +0000622 (outs FPRegs:$dst), (ins FPRegs:$src1, FPRegs:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000623 "fdivs $src1, $src2, $dst",
624 [(set FPRegs:$dst, (fdiv FPRegs:$src1, FPRegs:$src2))]>;
625def FDIVD : F3_3<2, 0b110100, 0b001001110,
Evan Chengb783fa32007-07-19 01:14:50 +0000626 (outs DFPRegs:$dst), (ins DFPRegs:$src1, DFPRegs:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000627 "fdivd $src1, $src2, $dst",
628 [(set DFPRegs:$dst, (fdiv DFPRegs:$src1, DFPRegs:$src2))]>;
629
630// Floating-point Compare Instructions, p. 148
631// Note: the 2nd template arg is different for these guys.
632// Note 2: the result of a FCMP is not available until the 2nd cycle
633// after the instr is retired, but there is no interlock. This behavior
634// is modelled with a forced noop after the instruction.
635def FCMPS : F3_3<2, 0b110101, 0b001010001,
Evan Chengb783fa32007-07-19 01:14:50 +0000636 (outs), (ins FPRegs:$src1, FPRegs:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000637 "fcmps $src1, $src2\n\tnop",
638 [(SPcmpfcc FPRegs:$src1, FPRegs:$src2)]>;
639def FCMPD : F3_3<2, 0b110101, 0b001010010,
Evan Chengb783fa32007-07-19 01:14:50 +0000640 (outs), (ins DFPRegs:$src1, DFPRegs:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000641 "fcmpd $src1, $src2\n\tnop",
642 [(SPcmpfcc DFPRegs:$src1, DFPRegs:$src2)]>;
643
644
645//===----------------------------------------------------------------------===//
646// V9 Instructions
647//===----------------------------------------------------------------------===//
648
649// V9 Conditional Moves.
650let Predicates = [HasV9], isTwoAddress = 1 in {
651 // Move Integer Register on Condition (MOVcc) p. 194 of the V9 manual.
652 // FIXME: Add instruction encodings for the JIT some day.
653 def MOVICCrr
Evan Chengb783fa32007-07-19 01:14:50 +0000654 : Pseudo<(outs IntRegs:$dst), (ins IntRegs:$T, IntRegs:$F, CCOp:$cc),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000655 "mov$cc %icc, $F, $dst",
656 [(set IntRegs:$dst,
657 (SPselecticc IntRegs:$F, IntRegs:$T, imm:$cc))]>;
658 def MOVICCri
Evan Chengb783fa32007-07-19 01:14:50 +0000659 : Pseudo<(outs IntRegs:$dst), (ins IntRegs:$T, i32imm:$F, CCOp:$cc),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000660 "mov$cc %icc, $F, $dst",
661 [(set IntRegs:$dst,
662 (SPselecticc simm11:$F, IntRegs:$T, imm:$cc))]>;
663
664 def MOVFCCrr
Evan Chengb783fa32007-07-19 01:14:50 +0000665 : Pseudo<(outs IntRegs:$dst), (ins IntRegs:$T, IntRegs:$F, CCOp:$cc),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000666 "mov$cc %fcc0, $F, $dst",
667 [(set IntRegs:$dst,
668 (SPselectfcc IntRegs:$F, IntRegs:$T, imm:$cc))]>;
669 def MOVFCCri
Evan Chengb783fa32007-07-19 01:14:50 +0000670 : Pseudo<(outs IntRegs:$dst), (ins IntRegs:$T, i32imm:$F, CCOp:$cc),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000671 "mov$cc %fcc0, $F, $dst",
672 [(set IntRegs:$dst,
673 (SPselectfcc simm11:$F, IntRegs:$T, imm:$cc))]>;
674
675 def FMOVS_ICC
Evan Chengb783fa32007-07-19 01:14:50 +0000676 : Pseudo<(outs FPRegs:$dst), (ins FPRegs:$T, FPRegs:$F, CCOp:$cc),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000677 "fmovs$cc %icc, $F, $dst",
678 [(set FPRegs:$dst,
679 (SPselecticc FPRegs:$F, FPRegs:$T, imm:$cc))]>;
680 def FMOVD_ICC
Evan Chengb783fa32007-07-19 01:14:50 +0000681 : Pseudo<(outs DFPRegs:$dst), (ins DFPRegs:$T, DFPRegs:$F, CCOp:$cc),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000682 "fmovd$cc %icc, $F, $dst",
683 [(set DFPRegs:$dst,
684 (SPselecticc DFPRegs:$F, DFPRegs:$T, imm:$cc))]>;
685 def FMOVS_FCC
Evan Chengb783fa32007-07-19 01:14:50 +0000686 : Pseudo<(outs FPRegs:$dst), (ins FPRegs:$T, FPRegs:$F, CCOp:$cc),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000687 "fmovs$cc %fcc0, $F, $dst",
688 [(set FPRegs:$dst,
689 (SPselectfcc FPRegs:$F, FPRegs:$T, imm:$cc))]>;
690 def FMOVD_FCC
Evan Chengb783fa32007-07-19 01:14:50 +0000691 : Pseudo<(outs DFPRegs:$dst), (ins DFPRegs:$T, DFPRegs:$F, CCOp:$cc),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000692 "fmovd$cc %fcc0, $F, $dst",
693 [(set DFPRegs:$dst,
694 (SPselectfcc DFPRegs:$F, DFPRegs:$T, imm:$cc))]>;
695
696}
697
698// Floating-Point Move Instructions, p. 164 of the V9 manual.
699let Predicates = [HasV9] in {
700 def FMOVD : F3_3<2, 0b110100, 0b000000010,
Evan Chengb783fa32007-07-19 01:14:50 +0000701 (outs DFPRegs:$dst), (ins DFPRegs:$src),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000702 "fmovd $src, $dst", []>;
703 def FNEGD : F3_3<2, 0b110100, 0b000000110,
Evan Chengb783fa32007-07-19 01:14:50 +0000704 (outs DFPRegs:$dst), (ins DFPRegs:$src),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000705 "fnegd $src, $dst",
706 [(set DFPRegs:$dst, (fneg DFPRegs:$src))]>;
707 def FABSD : F3_3<2, 0b110100, 0b000001010,
Evan Chengb783fa32007-07-19 01:14:50 +0000708 (outs DFPRegs:$dst), (ins DFPRegs:$src),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000709 "fabsd $src, $dst",
710 [(set DFPRegs:$dst, (fabs DFPRegs:$src))]>;
711}
712
713// POPCrr - This does a ctpop of a 64-bit register. As such, we have to clear
714// the top 32-bits before using it. To do this clearing, we use a SLLri X,0.
715def POPCrr : F3_1<2, 0b101110,
Evan Chengb783fa32007-07-19 01:14:50 +0000716 (outs IntRegs:$dst), (ins IntRegs:$src),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000717 "popc $src, $dst", []>, Requires<[HasV9]>;
718def : Pat<(ctpop IntRegs:$src),
719 (POPCrr (SLLri IntRegs:$src, 0))>;
720
721//===----------------------------------------------------------------------===//
722// Non-Instruction Patterns
723//===----------------------------------------------------------------------===//
724
725// Small immediates.
726def : Pat<(i32 simm13:$val),
727 (ORri G0, imm:$val)>;
728// Arbitrary immediates.
729def : Pat<(i32 imm:$val),
730 (ORri (SETHIi (HI22 imm:$val)), (LO10 imm:$val))>;
731
732// subc
733def : Pat<(subc IntRegs:$b, IntRegs:$c),
734 (SUBCCrr IntRegs:$b, IntRegs:$c)>;
735def : Pat<(subc IntRegs:$b, simm13:$val),
736 (SUBCCri IntRegs:$b, imm:$val)>;
737
738// Global addresses, constant pool entries
739def : Pat<(SPhi tglobaladdr:$in), (SETHIi tglobaladdr:$in)>;
740def : Pat<(SPlo tglobaladdr:$in), (ORri G0, tglobaladdr:$in)>;
741def : Pat<(SPhi tconstpool:$in), (SETHIi tconstpool:$in)>;
742def : Pat<(SPlo tconstpool:$in), (ORri G0, tconstpool:$in)>;
743
744// Add reg, lo. This is used when taking the addr of a global/constpool entry.
745def : Pat<(add IntRegs:$r, (SPlo tglobaladdr:$in)),
746 (ADDri IntRegs:$r, tglobaladdr:$in)>;
747def : Pat<(add IntRegs:$r, (SPlo tconstpool:$in)),
748 (ADDri IntRegs:$r, tconstpool:$in)>;
749
750// Calls:
751def : Pat<(call tglobaladdr:$dst),
752 (CALL tglobaladdr:$dst)>;
753def : Pat<(call texternalsym:$dst),
754 (CALL texternalsym:$dst)>;
755
756def : Pat<(ret), (RETL)>;
757
758// Map integer extload's to zextloads.
759def : Pat<(i32 (extloadi1 ADDRrr:$src)), (LDUBrr ADDRrr:$src)>;
760def : Pat<(i32 (extloadi1 ADDRri:$src)), (LDUBri ADDRri:$src)>;
761def : Pat<(i32 (extloadi8 ADDRrr:$src)), (LDUBrr ADDRrr:$src)>;
762def : Pat<(i32 (extloadi8 ADDRri:$src)), (LDUBri ADDRri:$src)>;
763def : Pat<(i32 (extloadi16 ADDRrr:$src)), (LDUHrr ADDRrr:$src)>;
764def : Pat<(i32 (extloadi16 ADDRri:$src)), (LDUHri ADDRri:$src)>;
765
766// zextload bool -> zextload byte
767def : Pat<(i32 (zextloadi1 ADDRrr:$src)), (LDUBrr ADDRrr:$src)>;
768def : Pat<(i32 (zextloadi1 ADDRri:$src)), (LDUBri ADDRri:$src)>;
769
770// truncstore bool -> truncstore byte.
771def : Pat<(truncstorei1 IntRegs:$src, ADDRrr:$addr),
772 (STBrr ADDRrr:$addr, IntRegs:$src)>;
773def : Pat<(truncstorei1 IntRegs:$src, ADDRri:$addr),
774 (STBri ADDRri:$addr, IntRegs:$src)>;