blob: 2f1a6f81528ac8106a90b502eeab870bb2e1e282 [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001//===- MipsInstrInfo.td - Mips Register defs --------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner081ce942007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007//
8//===----------------------------------------------------------------------===//
9
10//===----------------------------------------------------------------------===//
11// Instruction format superclass
12//===----------------------------------------------------------------------===//
13
14include "MipsInstrFormats.td"
15
16//===----------------------------------------------------------------------===//
17// Mips profiles and nodes
18//===----------------------------------------------------------------------===//
19
Bruno Cardoso Lopes4fb1f542008-07-05 19:05:21 +000020def SDT_MipsRet : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
21def SDT_MipsJmpLink : SDTypeProfile<0, 1, [SDTCisVT<0, iPTR>]>;
22def SDT_MipsSelectCC : SDTypeProfile<1, 3, [SDTCisSameAs<0, 1>,
23 SDTCisSameAs<1, 2>, SDTCisInt<3>]>;
24def SDT_MipsCallSeqStart : SDCallSeqStart<[SDTCisVT<0, i32>]>;
25def SDT_MipsCallSeqEnd : SDCallSeqEnd<[SDTCisVT<0, i32>, SDTCisVT<1, i32>]>;
26
Dan Gohmanf17a25c2007-07-18 16:29:46 +000027// Call
Bruno Cardoso Lopes4fb1f542008-07-05 19:05:21 +000028def MipsJmpLink : SDNode<"MipsISD::JmpLink",SDT_MipsJmpLink, [SDNPHasChain,
29 SDNPOutFlag]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000030
Bruno Cardoso Lopes218d5822007-11-05 03:02:32 +000031// Hi and Lo nodes are used to handle global addresses. Used on
32// MipsISelLowering to lower stuff like GlobalAddress, ExternalSymbol
33// static model. (nothing to do with Mips Registers Hi and Lo)
Bruno Cardoso Lopes12355a82008-07-21 18:52:34 +000034def MipsHi : SDNode<"MipsISD::Hi", SDTIntUnaryOp>;
35def MipsLo : SDNode<"MipsISD::Lo", SDTIntUnaryOp>;
36def MipsGPRel : SDNode<"MipsISD::GPRel", SDTIntUnaryOp>;
Bruno Cardoso Lopes2cacce92007-10-09 02:55:31 +000037
Eric Christopher7300ac12007-10-26 04:00:13 +000038// Return
Bruno Cardoso Lopes4fb1f542008-07-05 19:05:21 +000039def MipsRet : SDNode<"MipsISD::Ret", SDT_MipsRet, [SDNPHasChain,
40 SDNPOptInFlag]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000041
42// These are target-independent nodes, but have target-specific formats.
Bruno Cardoso Lopes4fb1f542008-07-05 19:05:21 +000043def callseq_start : SDNode<"ISD::CALLSEQ_START", SDT_MipsCallSeqStart,
44 [SDNPHasChain, SDNPOutFlag]>;
45def callseq_end : SDNode<"ISD::CALLSEQ_END", SDT_MipsCallSeqEnd,
46 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Bill Wendling22f8deb2007-11-13 00:44:25 +000047
Bruno Cardoso Lopes4fb1f542008-07-05 19:05:21 +000048// Select Condition Code
49def MipsSelectCC : SDNode<"MipsISD::SelectCC", SDT_MipsSelectCC>;
Bruno Cardoso Lopesed7723d2008-06-06 00:58:26 +000050
Bruno Cardoso Lopes2cacce92007-10-09 02:55:31 +000051//===----------------------------------------------------------------------===//
52// Mips Instruction Predicate Definitions.
53//===----------------------------------------------------------------------===//
Bruno Cardoso Lopesdfd657f2008-07-09 05:32:22 +000054def HasSEInReg : Predicate<"Subtarget.hasSEInReg()">;
Bruno Cardoso Lopes2cacce92007-10-09 02:55:31 +000055
56//===----------------------------------------------------------------------===//
57// Mips Operand, Complex Patterns and Transformations Definitions.
58//===----------------------------------------------------------------------===//
59
Dan Gohmanf17a25c2007-07-18 16:29:46 +000060// Instruction operand types
61def brtarget : Operand<OtherVT>;
62def calltarget : Operand<i32>;
63def uimm16 : Operand<i32>;
64def simm16 : Operand<i32>;
Eric Christopher7300ac12007-10-26 04:00:13 +000065def shamt : Operand<i32>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000066
67// Address operand
68def mem : Operand<i32> {
69 let PrintMethod = "printMemOperand";
70 let MIOperandInfo = (ops simm16, CPURegs);
71}
72
Dan Gohmanf17a25c2007-07-18 16:29:46 +000073// Transformation Function - get the lower 16 bits.
74def LO16 : SDNodeXForm<imm, [{
75 return getI32Imm((unsigned)N->getValue() & 0xFFFF);
76}]>;
77
78// Transformation Function - get the higher 16 bits.
79def HI16 : SDNodeXForm<imm, [{
80 return getI32Imm((unsigned)N->getValue() >> 16);
81}]>;
82
83// Node immediate fits as 16-bit sign extended on target immediate.
84// e.g. addi, andi
85def immSExt16 : PatLeaf<(imm), [{
86 if (N->getValueType(0) == MVT::i32)
87 return (int32_t)N->getValue() == (short)N->getValue();
Eric Christopher7300ac12007-10-26 04:00:13 +000088 else
Dan Gohmanf17a25c2007-07-18 16:29:46 +000089 return (int64_t)N->getValue() == (short)N->getValue();
90}]>;
91
92// Node immediate fits as 16-bit zero extended on target immediate.
93// The LO16 param means that only the lower 16 bits of the node
94// immediate are caught.
95// e.g. addiu, sltiu
96def immZExt16 : PatLeaf<(imm), [{
97 if (N->getValueType(0) == MVT::i32)
98 return (uint32_t)N->getValue() == (unsigned short)N->getValue();
Eric Christopher7300ac12007-10-26 04:00:13 +000099 else
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000100 return (uint64_t)N->getValue() == (unsigned short)N->getValue();
101}], LO16>;
102
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000103// Node immediate fits as 32-bit zero extended on target immediate.
104//def immZExt32 : PatLeaf<(imm), [{
105// return (uint64_t)N->getValue() == (uint32_t)N->getValue();
106//}], LO16>;
107
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000108// shamt field must fit in 5 bits.
109def immZExt5 : PatLeaf<(imm), [{
110 return N->getValue() == ((N->getValue()) & 0x1f) ;
111}]>;
112
Eric Christopher7300ac12007-10-26 04:00:13 +0000113// Mips Address Mode! SDNode frameindex could possibily be a match
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000114// since load and store instructions from stack used it.
115def addr : ComplexPattern<i32, 2, "SelectAddr", [frameindex], []>;
116
117//===----------------------------------------------------------------------===//
118// Instructions specific format
119//===----------------------------------------------------------------------===//
120
121// Arithmetic 3 register operands
Eric Christopher7300ac12007-10-26 04:00:13 +0000122let isCommutable = 1 in
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000123class ArithR<bits<6> op, bits<6> func, string instr_asm, SDNode OpNode,
Eric Christopher7300ac12007-10-26 04:00:13 +0000124 InstrItinClass itin>:
125 FR< op,
126 func,
127 (outs CPURegs:$dst),
128 (ins CPURegs:$b, CPURegs:$c),
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +0000129 !strconcat(instr_asm, "\t$dst, $b, $c"),
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000130 [(set CPURegs:$dst, (OpNode CPURegs:$b, CPURegs:$c))], itin>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000131
Eric Christopher7300ac12007-10-26 04:00:13 +0000132let isCommutable = 1 in
133class ArithOverflowR<bits<6> op, bits<6> func, string instr_asm>:
134 FR< op,
135 func,
136 (outs CPURegs:$dst),
137 (ins CPURegs:$b, CPURegs:$c),
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +0000138 !strconcat(instr_asm, "\t$dst, $b, $c"),
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000139 [], IIAlu>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000140
141// Arithmetic 2 register operands
Eric Christopher7300ac12007-10-26 04:00:13 +0000142class ArithI<bits<6> op, string instr_asm, SDNode OpNode,
143 Operand Od, PatLeaf imm_type> :
144 FI< op,
145 (outs CPURegs:$dst),
146 (ins CPURegs:$b, Od:$c),
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +0000147 !strconcat(instr_asm, "\t$dst, $b, $c"),
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000148 [(set CPURegs:$dst, (OpNode CPURegs:$b, imm_type:$c))], IIAlu>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000149
150// Arithmetic Multiply ADD/SUB
151let rd=0 in
Eric Christopher7300ac12007-10-26 04:00:13 +0000152class MArithR<bits<6> func, string instr_asm> :
153 FR< 0x1c,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000154 func,
Eric Christopher7300ac12007-10-26 04:00:13 +0000155 (outs CPURegs:$rs),
156 (ins CPURegs:$rt),
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +0000157 !strconcat(instr_asm, "\t$rs, $rt"),
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000158 [], IIImul>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000159
160// Logical
161class LogicR<bits<6> func, string instr_asm, SDNode OpNode>:
Eric Christopher7300ac12007-10-26 04:00:13 +0000162 FR< 0x00,
163 func,
164 (outs CPURegs:$dst),
165 (ins CPURegs:$b, CPURegs:$c),
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +0000166 !strconcat(instr_asm, "\t$dst, $b, $c"),
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000167 [(set CPURegs:$dst, (OpNode CPURegs:$b, CPURegs:$c))], IIAlu>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000168
169class LogicI<bits<6> op, string instr_asm, SDNode OpNode>:
170 FI< op,
Evan Chengb783fa32007-07-19 01:14:50 +0000171 (outs CPURegs:$dst),
172 (ins CPURegs:$b, uimm16:$c),
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +0000173 !strconcat(instr_asm, "\t$dst, $b, $c"),
Bruno Cardoso Lopesf2377552008-06-06 06:37:31 +0000174 [(set CPURegs:$dst, (OpNode CPURegs:$b, immZExt16:$c))], IIAlu>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000175
176class LogicNOR<bits<6> op, bits<6> func, string instr_asm>:
Eric Christopher7300ac12007-10-26 04:00:13 +0000177 FR< op,
178 func,
179 (outs CPURegs:$dst),
180 (ins CPURegs:$b, CPURegs:$c),
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +0000181 !strconcat(instr_asm, "\t$dst, $b, $c"),
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000182 [(set CPURegs:$dst, (not (or CPURegs:$b, CPURegs:$c)))], IIAlu>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000183
184// Shifts
185let rt = 0 in
186class LogicR_shift_imm<bits<6> func, string instr_asm, SDNode OpNode>:
Eric Christopher7300ac12007-10-26 04:00:13 +0000187 FR< 0x00,
188 func,
Evan Chengb783fa32007-07-19 01:14:50 +0000189 (outs CPURegs:$dst),
190 (ins CPURegs:$b, shamt:$c),
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +0000191 !strconcat(instr_asm, "\t$dst, $b, $c"),
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000192 [(set CPURegs:$dst, (OpNode CPURegs:$b, immZExt5:$c))], IIAlu>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000193
194class LogicR_shift_reg<bits<6> func, string instr_asm, SDNode OpNode>:
Eric Christopher7300ac12007-10-26 04:00:13 +0000195 FR< 0x00,
196 func,
Evan Chengb783fa32007-07-19 01:14:50 +0000197 (outs CPURegs:$dst),
198 (ins CPURegs:$b, CPURegs:$c),
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +0000199 !strconcat(instr_asm, "\t$dst, $b, $c"),
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000200 [(set CPURegs:$dst, (OpNode CPURegs:$b, CPURegs:$c))], IIAlu>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000201
202// Load Upper Imediate
203class LoadUpper<bits<6> op, string instr_asm>:
204 FI< op,
Evan Chengb783fa32007-07-19 01:14:50 +0000205 (outs CPURegs:$dst),
206 (ins uimm16:$imm),
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +0000207 !strconcat(instr_asm, "\t$dst, $imm"),
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000208 [], IIAlu>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000209
Eric Christopher7300ac12007-10-26 04:00:13 +0000210// Memory Load/Store
Chris Lattner1a1932c2008-01-06 23:38:27 +0000211let isSimpleLoad = 1, hasDelaySlot = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000212class LoadM<bits<6> op, string instr_asm, PatFrag OpNode>:
213 FI< op,
Evan Chengb783fa32007-07-19 01:14:50 +0000214 (outs CPURegs:$dst),
215 (ins mem:$addr),
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +0000216 !strconcat(instr_asm, "\t$dst, $addr"),
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000217 [(set CPURegs:$dst, (OpNode addr:$addr))], IILoad>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000218
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000219class StoreM<bits<6> op, string instr_asm, PatFrag OpNode>:
220 FI< op,
Evan Chengb783fa32007-07-19 01:14:50 +0000221 (outs),
222 (ins CPURegs:$dst, mem:$addr),
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +0000223 !strconcat(instr_asm, "\t$dst, $addr"),
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000224 [(OpNode CPURegs:$dst, addr:$addr)], IIStore>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000225
226// Conditional Branch
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000227let isBranch = 1, isTerminator=1, hasDelaySlot = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000228class CBranch<bits<6> op, string instr_asm, PatFrag cond_op>:
229 FI< op,
Evan Chengb783fa32007-07-19 01:14:50 +0000230 (outs),
231 (ins CPURegs:$a, CPURegs:$b, brtarget:$offset),
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +0000232 !strconcat(instr_asm, "\t$a, $b, $offset"),
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000233 [(brcond (cond_op CPURegs:$a, CPURegs:$b), bb:$offset)],
234 IIBranch>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000235
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000236
237class CBranchZero<bits<6> op, string instr_asm, PatFrag cond_op>:
238 FI< op,
239 (outs),
240 (ins CPURegs:$src, brtarget:$offset),
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +0000241 !strconcat(instr_asm, "\t$src, $offset"),
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000242 [(brcond (cond_op CPURegs:$src, 0), bb:$offset)],
243 IIBranch>;
Eric Christopher7300ac12007-10-26 04:00:13 +0000244}
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000245
Eric Christopher7300ac12007-10-26 04:00:13 +0000246// SetCC
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000247class SetCC_R<bits<6> op, bits<6> func, string instr_asm,
248 PatFrag cond_op>:
249 FR< op,
250 func,
Evan Chengb783fa32007-07-19 01:14:50 +0000251 (outs CPURegs:$dst),
252 (ins CPURegs:$b, CPURegs:$c),
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +0000253 !strconcat(instr_asm, "\t$dst, $b, $c"),
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000254 [(set CPURegs:$dst, (cond_op CPURegs:$b, CPURegs:$c))],
255 IIAlu>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000256
257class SetCC_I<bits<6> op, string instr_asm, PatFrag cond_op,
258 Operand Od, PatLeaf imm_type>:
259 FI< op,
Evan Chengb783fa32007-07-19 01:14:50 +0000260 (outs CPURegs:$dst),
261 (ins CPURegs:$b, Od:$c),
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +0000262 !strconcat(instr_asm, "\t$dst, $b, $c"),
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000263 [(set CPURegs:$dst, (cond_op CPURegs:$b, imm_type:$c))],
264 IIAlu>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000265
266// Unconditional branch
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000267let isBranch=1, isTerminator=1, isBarrier=1, hasDelaySlot = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000268class JumpFJ<bits<6> op, string instr_asm>:
269 FJ< op,
Evan Chengb783fa32007-07-19 01:14:50 +0000270 (outs),
271 (ins brtarget:$target),
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +0000272 !strconcat(instr_asm, "\t$target"),
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000273 [(br bb:$target)], IIBranch>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000274
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000275let isBranch=1, isTerminator=1, isBarrier=1, rd=0, hasDelaySlot = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000276class JumpFR<bits<6> op, bits<6> func, string instr_asm>:
277 FR< op,
278 func,
Evan Chengb783fa32007-07-19 01:14:50 +0000279 (outs),
280 (ins CPURegs:$target),
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +0000281 !strconcat(instr_asm, "\t$target"),
Bruno Cardoso Lopesea377302007-11-12 19:49:57 +0000282 [(brind CPURegs:$target)], IIBranch>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000283
284// Jump and Link (Call)
Eric Christopher7300ac12007-10-26 04:00:13 +0000285let isCall=1, hasDelaySlot=1,
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000286 // All calls clobber the non-callee saved registers...
Eric Christopher7300ac12007-10-26 04:00:13 +0000287 Defs = [AT, V0, V1, A0, A1, A2, A3, T0, T1, T2,
Bruno Cardoso Lopesea377302007-11-12 19:49:57 +0000288 T3, T4, T5, T6, T7, T8, T9, K0, K1], Uses = [GP] in {
Eric Christopher7300ac12007-10-26 04:00:13 +0000289 class JumpLink<bits<6> op, string instr_asm>:
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000290 FJ< op,
291 (outs),
292 (ins calltarget:$target),
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +0000293 !strconcat(instr_asm, "\t$target"),
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000294 [(MipsJmpLink imm:$target)], IIBranch>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000295
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000296 let rd=31 in
297 class JumpLinkReg<bits<6> op, bits<6> func, string instr_asm>:
298 FR< op,
299 func,
300 (outs),
301 (ins CPURegs:$rs),
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +0000302 !strconcat(instr_asm, "\t$rs"),
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000303 [(MipsJmpLink CPURegs:$rs)], IIBranch>;
304
305 class BranchLink<string instr_asm>:
306 FI< 0x1,
307 (outs),
308 (ins CPURegs:$rs, brtarget:$target),
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +0000309 !strconcat(instr_asm, "\t$rs, $target"),
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000310 [], IIBranch>;
311}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000312
Eric Christopher7300ac12007-10-26 04:00:13 +0000313// Mul, Div
314class MulDiv<bits<6> func, string instr_asm, InstrItinClass itin>:
315 FR< 0x00,
316 func,
Evan Chengb783fa32007-07-19 01:14:50 +0000317 (outs),
Eric Christopher7300ac12007-10-26 04:00:13 +0000318 (ins CPURegs:$a, CPURegs:$b),
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +0000319 !strconcat(instr_asm, "\t$a, $b"),
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000320 [], itin>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000321
Eric Christopher7300ac12007-10-26 04:00:13 +0000322// Move from Hi/Lo
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000323class MoveFromTo<bits<6> func, string instr_asm>:
Eric Christopher7300ac12007-10-26 04:00:13 +0000324 FR< 0x00,
325 func,
326 (outs CPURegs:$dst),
Evan Chengb783fa32007-07-19 01:14:50 +0000327 (ins),
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +0000328 !strconcat(instr_asm, "\t$dst"),
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000329 [], IIHiLo>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000330
331// Count Leading Ones/Zeros in Word
332class CountLeading<bits<6> func, string instr_asm>:
Eric Christopher7300ac12007-10-26 04:00:13 +0000333 FR< 0x1c,
334 func,
335 (outs CPURegs:$dst),
336 (ins CPURegs:$src),
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +0000337 !strconcat(instr_asm, "\t$dst, $src"),
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000338 [], IIAlu>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000339
Eric Christopher7300ac12007-10-26 04:00:13 +0000340class EffectiveAddress<string instr_asm> :
341 FI<0x09,
342 (outs CPURegs:$dst),
Bruno Cardoso Lopes96433662007-09-24 20:15:11 +0000343 (ins mem:$addr),
344 instr_asm,
345 [(set CPURegs:$dst, addr:$addr)], IIAlu>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000346
Bruno Cardoso Lopes4fb1f542008-07-05 19:05:21 +0000347class SignExtInReg<bits<6> func, string instr_asm, ValueType vt>:
348 FR< 0x3f, func, (outs CPURegs:$dst), (ins CPURegs:$src),
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +0000349 !strconcat(instr_asm, "\t$dst, $src"),
Bruno Cardoso Lopes4fb1f542008-07-05 19:05:21 +0000350 [(set CPURegs:$dst, (sext_inreg CPURegs:$src, vt))], NoItinerary>;
351
352
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000353//===----------------------------------------------------------------------===//
354// Pseudo instructions
355//===----------------------------------------------------------------------===//
356
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000357// As stack alignment is always done with addiu, we need a 16-bit immediate
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000358let Defs = [SP], Uses = [SP] in {
Bruno Cardoso Lopesed7723d2008-06-06 00:58:26 +0000359def ADJCALLSTACKDOWN : MipsPseudo<(outs), (ins uimm16:$amt),
Bruno Cardoso Lopes4fb1f542008-07-05 19:05:21 +0000360 "!ADJCALLSTACKDOWN $amt",
361 [(callseq_start imm:$amt)]>;
Bruno Cardoso Lopesed7723d2008-06-06 00:58:26 +0000362def ADJCALLSTACKUP : MipsPseudo<(outs), (ins uimm16:$amt1, uimm16:$amt2),
Bruno Cardoso Lopes4fb1f542008-07-05 19:05:21 +0000363 "!ADJCALLSTACKUP $amt1",
364 [(callseq_end imm:$amt1, imm:$amt2)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000365}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000366
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +0000367// Some assembly macros need to avoid pseudoinstructions and assembler
368// automatic reodering, we should reorder ourselves.
369def MACRO : MipsPseudo<(outs), (ins), ".set\tmacro", []>;
370def REORDER : MipsPseudo<(outs), (ins), ".set\treorder", []>;
371def NOMACRO : MipsPseudo<(outs), (ins), ".set\tnomacro", []>;
372def NOREORDER : MipsPseudo<(outs), (ins), ".set\tnoreorder", []>;
373
Eric Christopher7300ac12007-10-26 04:00:13 +0000374// When handling PIC code the assembler needs .cpload and .cprestore
375// directives. If the real instructions corresponding these directives
376// are used, we have the same behavior, but get also a bunch of warnings
Bruno Cardoso Lopes2cacce92007-10-09 02:55:31 +0000377// from the assembler.
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +0000378def CPLOAD : MipsPseudo<(outs), (ins CPURegs:$picreg), ".cpload\t$picreg", []>;
379def CPRESTORE : MipsPseudo<(outs), (ins uimm16:$loc), ".cprestore\t$loc\n", []>;
Bruno Cardoso Lopesed7723d2008-06-06 00:58:26 +0000380
381// The supported Mips ISAs dont have any instruction close to the SELECT_CC
382// operation. The solution is to create a Mips pseudo SELECT_CC instruction
383// (MipsSelectCC), use LowerSELECT_CC to generate this instruction and finally
384// replace it for real supported nodes into EmitInstrWithCustomInserter
385let usesCustomDAGSchedInserter = 1 in {
386 def Select_CC : MipsPseudo<(outs CPURegs:$dst),
387 (ins CPURegs:$CmpRes, CPURegs:$T, CPURegs:$F), "# MipsSelect_CC",
388 [(set CPURegs:$dst, (MipsSelectCC CPURegs:$CmpRes,
389 CPURegs:$T, CPURegs:$F))]>;
390}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000391
392//===----------------------------------------------------------------------===//
393// Instruction definition
394//===----------------------------------------------------------------------===//
395
396//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000397// MipsI Instructions
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000398//===----------------------------------------------------------------------===//
399
400// Arithmetic
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000401
402// ADDiu just accept 16-bit immediates but we handle this on Pat's.
403// immZExt32 is used here so it can match GlobalAddress immediates.
Bruno Cardoso Lopesf2377552008-06-06 06:37:31 +0000404// MUL is a assembly macro in the current used ISAs.
Bruno Cardoso Lopes218d5822007-11-05 03:02:32 +0000405def ADDiu : ArithI<0x09, "addiu", add, uimm16, immZExt16>;
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000406def ADDi : ArithI<0x08, "addi", add, simm16, immSExt16>;
Bruno Cardoso Lopesf2377552008-06-06 06:37:31 +0000407//def MUL : ArithR<0x1c, 0x02, "mul", mul, IIImul>;
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000408def ADDu : ArithR<0x00, 0x21, "addu", add, IIAlu>;
409def SUBu : ArithR<0x00, 0x23, "subu", sub, IIAlu>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000410def ADD : ArithOverflowR<0x00, 0x20, "add">;
411def SUB : ArithOverflowR<0x00, 0x22, "sub">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000412
413// Logical
414def AND : LogicR<0x24, "and", and>;
415def OR : LogicR<0x25, "or", or>;
416def XOR : LogicR<0x26, "xor", xor>;
417def ANDi : LogicI<0x0c, "andi", and>;
418def ORi : LogicI<0x0d, "ori", or>;
419def XORi : LogicI<0x0e, "xori", xor>;
420def NOR : LogicNOR<0x00, 0x27, "nor">;
421
Eric Christopher7300ac12007-10-26 04:00:13 +0000422// Shifts
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000423def SLL : LogicR_shift_imm<0x00, "sll", shl>;
424def SRL : LogicR_shift_imm<0x02, "srl", srl>;
425def SRA : LogicR_shift_imm<0x03, "sra", sra>;
426def SLLV : LogicR_shift_reg<0x04, "sllv", shl>;
427def SRLV : LogicR_shift_reg<0x06, "srlv", srl>;
428def SRAV : LogicR_shift_reg<0x07, "srav", sra>;
429
430// Load Upper Immediate
431def LUi : LoadUpper<0x0f, "lui">;
432
433// Load/Store
434def LB : LoadM<0x20, "lb", sextloadi8>;
435def LBu : LoadM<0x24, "lbu", zextloadi8>;
436def LH : LoadM<0x21, "lh", sextloadi16>;
437def LHu : LoadM<0x25, "lhu", zextloadi16>;
438def LW : LoadM<0x23, "lw", load>;
439def SB : StoreM<0x28, "sb", truncstorei8>;
440def SH : StoreM<0x29, "sh", truncstorei16>;
441def SW : StoreM<0x2b, "sw", store>;
442
443// Conditional Branch
444def BEQ : CBranch<0x04, "beq", seteq>;
445def BNE : CBranch<0x05, "bne", setne>;
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000446
Eric Christopher7300ac12007-10-26 04:00:13 +0000447let rt=1 in
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000448def BGEZ : CBranchZero<0x01, "bgez", setge>;
449
450let rt=0 in {
451def BGTZ : CBranchZero<0x07, "bgtz", setgt>;
452def BLEZ : CBranchZero<0x07, "blez", setle>;
453def BLTZ : CBranchZero<0x01, "bltz", setlt>;
454}
455
456// Set Condition Code
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000457def SLT : SetCC_R<0x00, 0x2a, "slt", setlt>;
458def SLTu : SetCC_R<0x00, 0x2b, "sltu", setult>;
459def SLTi : SetCC_I<0x0a, "slti", setlt, simm16, immSExt16>;
460def SLTiu : SetCC_I<0x0b, "sltiu", setult, uimm16, immZExt16>;
461
462// Unconditional jump
463def J : JumpFJ<0x02, "j">;
464def JR : JumpFR<0x00, 0x08, "jr">;
465
466// Jump and Link (Call)
467def JAL : JumpLink<0x03, "jal">;
468def JALR : JumpLinkReg<0x00, 0x09, "jalr">;
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000469def BGEZAL : BranchLink<"bgezal">;
470def BLTZAL : BranchLink<"bltzal">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000471
472// MulDiv and Move From Hi/Lo operations, have
473// their correpondent SDNodes created on ISelDAG.
474// Special Mul, Div operations
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000475def MULT : MulDiv<0x18, "mult", IIImul>;
476def MULTu : MulDiv<0x19, "multu", IIImul>;
477def DIV : MulDiv<0x1a, "div", IIIdiv>;
478def DIVu : MulDiv<0x1b, "divu", IIIdiv>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000479
Eric Christopher7300ac12007-10-26 04:00:13 +0000480// Move From Hi/Lo
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000481def MFHI : MoveFromTo<0x10, "mfhi">;
482def MFLO : MoveFromTo<0x12, "mflo">;
483def MTHI : MoveFromTo<0x11, "mthi">;
484def MTLO : MoveFromTo<0x13, "mtlo">;
485
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000486// No operation
487let addr=0 in
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000488def NOP : FJ<0, (outs), (ins), "nop", [], IIAlu>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000489
Eric Christopher7300ac12007-10-26 04:00:13 +0000490// Ret instruction - as mips does not have "ret" a
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000491// jr $ra must be generated.
Evan Cheng37e7c752007-07-21 00:34:19 +0000492let isReturn=1, isTerminator=1, hasDelaySlot=1,
Eric Christopher7300ac12007-10-26 04:00:13 +0000493 isBarrier=1, hasCtrlDep=1, rs=0, rt=0, shamt=0 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000494{
Evan Chengb783fa32007-07-19 01:14:50 +0000495 def RET : FR <0x00, 0x02, (outs), (ins CPURegs:$target),
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +0000496 "jr\t$target", [(MipsRet CPURegs:$target)], IIBranch>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000497}
498
Eric Christopher7300ac12007-10-26 04:00:13 +0000499// FrameIndexes are legalized when they are operands from load/store
Bruno Cardoso Lopes96433662007-09-24 20:15:11 +0000500// instructions. The same not happens for stack address copies, so an
501// add op with mem ComplexPattern is used and the stack address copy
502// can be matched. It's similar to Sparc LEA_ADDRi
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +0000503def LEA_ADDiu : EffectiveAddress<"addiu\t$dst, ${addr:stackloc}">;
Bruno Cardoso Lopes96433662007-09-24 20:15:11 +0000504
Bruno Cardoso Lopes4fb1f542008-07-05 19:05:21 +0000505// Count Leading
506// CLO/CLZ are part of the newer MIPS32(tm) instruction
507// set and not older Mips I keep this for future use
508// though.
509//def CLO : CountLeading<0x21, "clo">;
510//def CLZ : CountLeading<0x20, "clz">;
511
512// MADD*/MSUB* are not part of MipsI either.
513//def MADD : MArithR<0x00, "madd">;
514//def MADDU : MArithR<0x01, "maddu">;
515//def MSUB : MArithR<0x04, "msub">;
516//def MSUBU : MArithR<0x05, "msubu">;
517
Bruno Cardoso Lopesdfd657f2008-07-09 05:32:22 +0000518let Predicates = [HasSEInReg] in {
Bruno Cardoso Lopes4fb1f542008-07-05 19:05:21 +0000519 let shamt = 0x10, rs = 0 in
520 def SEB : SignExtInReg<0x21, "seb", i8>;
521
522 let shamt = 0x18, rs = 0 in
523 def SEH : SignExtInReg<0x20, "seh", i16>;
524}
525
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000526//===----------------------------------------------------------------------===//
527// Arbitrary patterns that map to one or more instructions
528//===----------------------------------------------------------------------===//
529
530// Small immediates
Eric Christopher7300ac12007-10-26 04:00:13 +0000531def : Pat<(i32 immSExt16:$in),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000532 (ADDiu ZERO, imm:$in)>;
Eric Christopher7300ac12007-10-26 04:00:13 +0000533def : Pat<(i32 immZExt16:$in),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000534 (ORi ZERO, imm:$in)>;
535
536// Arbitrary immediates
537def : Pat<(i32 imm:$imm),
538 (ORi (LUi (HI16 imm:$imm)), (LO16 imm:$imm))>;
539
Bruno Cardoso Lopesed7723d2008-06-06 00:58:26 +0000540// Carry patterns
541def : Pat<(subc CPURegs:$lhs, CPURegs:$rhs),
542 (SUBu CPURegs:$lhs, CPURegs:$rhs)>;
543def : Pat<(addc CPURegs:$lhs, CPURegs:$rhs),
544 (ADDu CPURegs:$lhs, CPURegs:$rhs)>;
545def : Pat<(addc CPURegs:$src, imm:$imm),
546 (ADDiu CPURegs:$src, imm:$imm)>;
547
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000548// Call
549def : Pat<(MipsJmpLink (i32 tglobaladdr:$dst)),
550 (JAL tglobaladdr:$dst)>;
551def : Pat<(MipsJmpLink (i32 texternalsym:$dst)),
552 (JAL texternalsym:$dst)>;
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000553def : Pat<(MipsJmpLink CPURegs:$dst),
554 (JALR CPURegs:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000555
556// GlobalAddress, Constant Pool, ExternalSymbol, and JumpTable
557def : Pat<(MipsHi tglobaladdr:$in), (LUi tglobaladdr:$in)>;
Bruno Cardoso Lopes12355a82008-07-21 18:52:34 +0000558//def : Pat<(MipsLo tglobaladdr:$in), (ADDiu ZERO, tglobaladdr:$in)>;
Bruno Cardoso Lopes218d5822007-11-05 03:02:32 +0000559def : Pat<(add CPURegs:$hi, (MipsLo tglobaladdr:$lo)),
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000560 (ADDiu CPURegs:$hi, tglobaladdr:$lo)>;
Bruno Cardoso Lopesea377302007-11-12 19:49:57 +0000561def : Pat<(MipsHi tjumptable:$in), (LUi tjumptable:$in)>;
Bruno Cardoso Lopes12355a82008-07-21 18:52:34 +0000562//def : Pat<(MipsLo tjumptable:$in), (ADDiu ZERO, tjumptable:$in)>;
Bruno Cardoso Lopesea377302007-11-12 19:49:57 +0000563def : Pat<(add CPURegs:$hi, (MipsLo tjumptable:$lo)),
564 (ADDiu CPURegs:$hi, tjumptable:$lo)>;
Bruno Cardoso Lopes12355a82008-07-21 18:52:34 +0000565def : Pat<(add CPURegs:$gp, (MipsGPRel tglobaladdr:$in)),
566 (ADDiu CPURegs:$gp, tglobaladdr:$in)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000567
Bruno Cardoso Lopes4fb1f542008-07-05 19:05:21 +0000568// Mips does not have "not", so we expand our way
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000569def : Pat<(not CPURegs:$in),
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000570 (NOR CPURegs:$in, ZERO)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000571
Eric Christopher7300ac12007-10-26 04:00:13 +0000572// extended load and stores
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000573def : Pat<(i32 (extloadi1 addr:$src)), (LBu addr:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000574def : Pat<(i32 (extloadi8 addr:$src)), (LBu addr:$src)>;
575def : Pat<(i32 (extloadi16 addr:$src)), (LHu addr:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000576
Bruno Cardoso Lopesed7723d2008-06-06 00:58:26 +0000577// peepholes
Bruno Cardoso Lopes218d5822007-11-05 03:02:32 +0000578def : Pat<(store (i32 0), addr:$dst), (SW ZERO, addr:$dst)>;
579
Bruno Cardoso Lopes4fb1f542008-07-05 19:05:21 +0000580// brcond patterns
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000581// direct match equal/notequal zero branches
582def : Pat<(brcond (setne CPURegs:$lhs, 0), bb:$dst),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000583 (BNE CPURegs:$lhs, ZERO, bb:$dst)>;
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000584def : Pat<(brcond (seteq CPURegs:$lhs, 0), bb:$dst),
585 (BEQ CPURegs:$lhs, ZERO, bb:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000586
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000587def : Pat<(brcond (setge CPURegs:$lhs, CPURegs:$rhs), bb:$dst),
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000588 (BGEZ (SUB CPURegs:$lhs, CPURegs:$rhs), bb:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000589def : Pat<(brcond (setuge CPURegs:$lhs, CPURegs:$rhs), bb:$dst),
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000590 (BGEZ (SUBu CPURegs:$lhs, CPURegs:$rhs), bb:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000591
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000592def : Pat<(brcond (setgt CPURegs:$lhs, CPURegs:$rhs), bb:$dst),
593 (BGTZ (SUB CPURegs:$lhs, CPURegs:$rhs), bb:$dst)>;
594def : Pat<(brcond (setugt CPURegs:$lhs, CPURegs:$rhs), bb:$dst),
595 (BGTZ (SUBu CPURegs:$lhs, CPURegs:$rhs), bb:$dst)>;
596
597def : Pat<(brcond (setle CPURegs:$lhs, CPURegs:$rhs), bb:$dst),
598 (BLEZ (SUB CPURegs:$lhs, CPURegs:$rhs), bb:$dst)>;
599def : Pat<(brcond (setule CPURegs:$lhs, CPURegs:$rhs), bb:$dst),
600 (BLEZ (SUBu CPURegs:$lhs, CPURegs:$rhs), bb:$dst)>;
601
602def : Pat<(brcond (setlt CPURegs:$lhs, immSExt16:$rhs), bb:$dst),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000603 (BNE (SLTi CPURegs:$lhs, immSExt16:$rhs), ZERO, bb:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000604def : Pat<(brcond (setult CPURegs:$lhs, immZExt16:$rhs), bb:$dst),
605 (BNE (SLTiu CPURegs:$lhs, immZExt16:$rhs), ZERO, bb:$dst)>;
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000606def : Pat<(brcond (setlt CPURegs:$lhs, CPURegs:$rhs), bb:$dst),
607 (BNE (SLT CPURegs:$lhs, CPURegs:$rhs), ZERO, bb:$dst)>;
608def : Pat<(brcond (setult CPURegs:$lhs, CPURegs:$rhs), bb:$dst),
609 (BNE (SLTu CPURegs:$lhs, CPURegs:$rhs), ZERO, bb:$dst)>;
610
611def : Pat<(brcond (setlt CPURegs:$lhs, CPURegs:$rhs), bb:$dst),
612 (BLTZ (SUB CPURegs:$lhs, CPURegs:$rhs), bb:$dst)>;
613def : Pat<(brcond (setult CPURegs:$lhs, CPURegs:$rhs), bb:$dst),
614 (BLTZ (SUBu CPURegs:$lhs, CPURegs:$rhs), bb:$dst)>;
615
616// generic brcond pattern
617def : Pat<(brcond CPURegs:$cond, bb:$dst),
618 (BNE CPURegs:$cond, ZERO, bb:$dst)>;
619
Eric Christopher7300ac12007-10-26 04:00:13 +0000620/// setcc patterns, only matched when there
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000621/// is no brcond following a setcc operation
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000622def : Pat<(setle CPURegs:$lhs, CPURegs:$rhs),
623 (XORi (SLT CPURegs:$rhs, CPURegs:$lhs), 1)>;
624def : Pat<(setule CPURegs:$lhs, CPURegs:$rhs),
625 (XORi (SLTu CPURegs:$rhs, CPURegs:$lhs), 1)>;
626
627def : Pat<(setgt CPURegs:$lhs, CPURegs:$rhs),
628 (SLT CPURegs:$rhs, CPURegs:$lhs)>;
629def : Pat<(setugt CPURegs:$lhs, CPURegs:$rhs),
630 (SLTu CPURegs:$rhs, CPURegs:$lhs)>;
631
632def : Pat<(setge CPURegs:$lhs, CPURegs:$rhs),
633 (XORi (SLT CPURegs:$lhs, CPURegs:$rhs), 1)>;
634def : Pat<(setuge CPURegs:$lhs, CPURegs:$rhs),
635 (XORi (SLTu CPURegs:$lhs, CPURegs:$rhs), 1)>;
636
637def : Pat<(setne CPURegs:$lhs, CPURegs:$rhs),
Eric Christopher7300ac12007-10-26 04:00:13 +0000638 (OR (SLT CPURegs:$lhs, CPURegs:$rhs),
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000639 (SLT CPURegs:$rhs, CPURegs:$lhs))>;
640
641def : Pat<(seteq CPURegs:$lhs, CPURegs:$rhs),
Eric Christopher7300ac12007-10-26 04:00:13 +0000642 (XORi (OR (SLT CPURegs:$lhs, CPURegs:$rhs),
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000643 (SLT CPURegs:$rhs, CPURegs:$lhs)), 1)>;
Eric Christopher7300ac12007-10-26 04:00:13 +0000644
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000645def : Pat<(setge CPURegs:$lhs, immSExt16:$rhs),
646 (XORi (SLTi CPURegs:$lhs, immSExt16:$rhs), 1)>;
647def : Pat<(setuge CPURegs:$lhs, immZExt16:$rhs),
648 (XORi (SLTiu CPURegs:$lhs, immZExt16:$rhs), 1)>;
Bruno Cardoso Lopes4fb1f542008-07-05 19:05:21 +0000649
650//===----------------------------------------------------------------------===//
651// Floating Point Support
652//===----------------------------------------------------------------------===//
653
654include "MipsInstrFPU.td"
655