blob: 9b1b930163c558883959afe8686ff2beca1d5358 [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>]>;
Bruno Cardoso Lopesda54c7d2008-07-29 19:05:28 +000022def SDT_MipsSelectCC : SDTypeProfile<1, 3, [SDTCisSameAs<0, 2>,
23 SDTCisSameAs<2, 3>, SDTCisInt<1>]>;
Bruno Cardoso Lopes4fb1f542008-07-05 19:05:21 +000024def 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
103// shamt field must fit in 5 bits.
104def immZExt5 : PatLeaf<(imm), [{
105 return N->getValue() == ((N->getValue()) & 0x1f) ;
106}]>;
107
Eric Christopher7300ac12007-10-26 04:00:13 +0000108// Mips Address Mode! SDNode frameindex could possibily be a match
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000109// since load and store instructions from stack used it.
110def addr : ComplexPattern<i32, 2, "SelectAddr", [frameindex], []>;
111
112//===----------------------------------------------------------------------===//
113// Instructions specific format
114//===----------------------------------------------------------------------===//
115
116// Arithmetic 3 register operands
Eric Christopher7300ac12007-10-26 04:00:13 +0000117let isCommutable = 1 in
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000118class ArithR<bits<6> op, bits<6> func, string instr_asm, SDNode OpNode,
Eric Christopher7300ac12007-10-26 04:00:13 +0000119 InstrItinClass itin>:
120 FR< op,
121 func,
122 (outs CPURegs:$dst),
123 (ins CPURegs:$b, CPURegs:$c),
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +0000124 !strconcat(instr_asm, "\t$dst, $b, $c"),
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000125 [(set CPURegs:$dst, (OpNode CPURegs:$b, CPURegs:$c))], itin>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000126
Eric Christopher7300ac12007-10-26 04:00:13 +0000127let isCommutable = 1 in
128class ArithOverflowR<bits<6> op, bits<6> func, string instr_asm>:
129 FR< op,
130 func,
131 (outs CPURegs:$dst),
132 (ins CPURegs:$b, CPURegs:$c),
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +0000133 !strconcat(instr_asm, "\t$dst, $b, $c"),
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000134 [], IIAlu>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000135
136// Arithmetic 2 register operands
Eric Christopher7300ac12007-10-26 04:00:13 +0000137class ArithI<bits<6> op, string instr_asm, SDNode OpNode,
138 Operand Od, PatLeaf imm_type> :
139 FI< op,
140 (outs CPURegs:$dst),
141 (ins CPURegs:$b, Od:$c),
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +0000142 !strconcat(instr_asm, "\t$dst, $b, $c"),
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000143 [(set CPURegs:$dst, (OpNode CPURegs:$b, imm_type:$c))], IIAlu>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000144
145// Arithmetic Multiply ADD/SUB
146let rd=0 in
Eric Christopher7300ac12007-10-26 04:00:13 +0000147class MArithR<bits<6> func, string instr_asm> :
148 FR< 0x1c,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000149 func,
Eric Christopher7300ac12007-10-26 04:00:13 +0000150 (outs CPURegs:$rs),
151 (ins CPURegs:$rt),
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +0000152 !strconcat(instr_asm, "\t$rs, $rt"),
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000153 [], IIImul>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000154
155// Logical
156class LogicR<bits<6> func, string instr_asm, SDNode OpNode>:
Eric Christopher7300ac12007-10-26 04:00:13 +0000157 FR< 0x00,
158 func,
159 (outs CPURegs:$dst),
160 (ins CPURegs:$b, CPURegs:$c),
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +0000161 !strconcat(instr_asm, "\t$dst, $b, $c"),
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000162 [(set CPURegs:$dst, (OpNode CPURegs:$b, CPURegs:$c))], IIAlu>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000163
164class LogicI<bits<6> op, string instr_asm, SDNode OpNode>:
165 FI< op,
Evan Chengb783fa32007-07-19 01:14:50 +0000166 (outs CPURegs:$dst),
167 (ins CPURegs:$b, uimm16:$c),
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +0000168 !strconcat(instr_asm, "\t$dst, $b, $c"),
Bruno Cardoso Lopesf2377552008-06-06 06:37:31 +0000169 [(set CPURegs:$dst, (OpNode CPURegs:$b, immZExt16:$c))], IIAlu>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000170
171class LogicNOR<bits<6> op, bits<6> func, string instr_asm>:
Eric Christopher7300ac12007-10-26 04:00:13 +0000172 FR< op,
173 func,
174 (outs CPURegs:$dst),
175 (ins CPURegs:$b, CPURegs:$c),
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +0000176 !strconcat(instr_asm, "\t$dst, $b, $c"),
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000177 [(set CPURegs:$dst, (not (or CPURegs:$b, CPURegs:$c)))], IIAlu>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000178
179// Shifts
180let rt = 0 in
181class LogicR_shift_imm<bits<6> func, string instr_asm, SDNode OpNode>:
Eric Christopher7300ac12007-10-26 04:00:13 +0000182 FR< 0x00,
183 func,
Evan Chengb783fa32007-07-19 01:14:50 +0000184 (outs CPURegs:$dst),
185 (ins CPURegs:$b, shamt:$c),
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +0000186 !strconcat(instr_asm, "\t$dst, $b, $c"),
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000187 [(set CPURegs:$dst, (OpNode CPURegs:$b, immZExt5:$c))], IIAlu>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000188
189class LogicR_shift_reg<bits<6> func, string instr_asm, SDNode OpNode>:
Eric Christopher7300ac12007-10-26 04:00:13 +0000190 FR< 0x00,
191 func,
Evan Chengb783fa32007-07-19 01:14:50 +0000192 (outs CPURegs:$dst),
193 (ins CPURegs:$b, CPURegs:$c),
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +0000194 !strconcat(instr_asm, "\t$dst, $b, $c"),
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000195 [(set CPURegs:$dst, (OpNode CPURegs:$b, CPURegs:$c))], IIAlu>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000196
197// Load Upper Imediate
198class LoadUpper<bits<6> op, string instr_asm>:
199 FI< op,
Evan Chengb783fa32007-07-19 01:14:50 +0000200 (outs CPURegs:$dst),
201 (ins uimm16:$imm),
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +0000202 !strconcat(instr_asm, "\t$dst, $imm"),
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000203 [], IIAlu>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000204
Eric Christopher7300ac12007-10-26 04:00:13 +0000205// Memory Load/Store
Chris Lattner1a1932c2008-01-06 23:38:27 +0000206let isSimpleLoad = 1, hasDelaySlot = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000207class LoadM<bits<6> op, string instr_asm, PatFrag OpNode>:
208 FI< op,
Evan Chengb783fa32007-07-19 01:14:50 +0000209 (outs CPURegs:$dst),
210 (ins mem:$addr),
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +0000211 !strconcat(instr_asm, "\t$dst, $addr"),
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000212 [(set CPURegs:$dst, (OpNode addr:$addr))], IILoad>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000213
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000214class StoreM<bits<6> op, string instr_asm, PatFrag OpNode>:
215 FI< op,
Evan Chengb783fa32007-07-19 01:14:50 +0000216 (outs),
217 (ins CPURegs:$dst, mem:$addr),
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +0000218 !strconcat(instr_asm, "\t$dst, $addr"),
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000219 [(OpNode CPURegs:$dst, addr:$addr)], IIStore>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000220
221// Conditional Branch
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000222let isBranch = 1, isTerminator=1, hasDelaySlot = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000223class CBranch<bits<6> op, string instr_asm, PatFrag cond_op>:
224 FI< op,
Evan Chengb783fa32007-07-19 01:14:50 +0000225 (outs),
226 (ins CPURegs:$a, CPURegs:$b, brtarget:$offset),
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +0000227 !strconcat(instr_asm, "\t$a, $b, $offset"),
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000228 [(brcond (cond_op CPURegs:$a, CPURegs:$b), bb:$offset)],
229 IIBranch>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000230
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000231
232class CBranchZero<bits<6> op, string instr_asm, PatFrag cond_op>:
233 FI< op,
234 (outs),
235 (ins CPURegs:$src, brtarget:$offset),
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +0000236 !strconcat(instr_asm, "\t$src, $offset"),
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000237 [(brcond (cond_op CPURegs:$src, 0), bb:$offset)],
238 IIBranch>;
Eric Christopher7300ac12007-10-26 04:00:13 +0000239}
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000240
Eric Christopher7300ac12007-10-26 04:00:13 +0000241// SetCC
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000242class SetCC_R<bits<6> op, bits<6> func, string instr_asm,
243 PatFrag cond_op>:
244 FR< op,
245 func,
Evan Chengb783fa32007-07-19 01:14:50 +0000246 (outs CPURegs:$dst),
247 (ins CPURegs:$b, CPURegs:$c),
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +0000248 !strconcat(instr_asm, "\t$dst, $b, $c"),
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000249 [(set CPURegs:$dst, (cond_op CPURegs:$b, CPURegs:$c))],
250 IIAlu>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000251
252class SetCC_I<bits<6> op, string instr_asm, PatFrag cond_op,
253 Operand Od, PatLeaf imm_type>:
254 FI< op,
Evan Chengb783fa32007-07-19 01:14:50 +0000255 (outs CPURegs:$dst),
256 (ins CPURegs:$b, Od:$c),
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +0000257 !strconcat(instr_asm, "\t$dst, $b, $c"),
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000258 [(set CPURegs:$dst, (cond_op CPURegs:$b, imm_type:$c))],
259 IIAlu>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000260
261// Unconditional branch
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000262let isBranch=1, isTerminator=1, isBarrier=1, hasDelaySlot = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000263class JumpFJ<bits<6> op, string instr_asm>:
264 FJ< op,
Evan Chengb783fa32007-07-19 01:14:50 +0000265 (outs),
266 (ins brtarget:$target),
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +0000267 !strconcat(instr_asm, "\t$target"),
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000268 [(br bb:$target)], IIBranch>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000269
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000270let isBranch=1, isTerminator=1, isBarrier=1, rd=0, hasDelaySlot = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000271class JumpFR<bits<6> op, bits<6> func, string instr_asm>:
272 FR< op,
273 func,
Evan Chengb783fa32007-07-19 01:14:50 +0000274 (outs),
275 (ins CPURegs:$target),
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +0000276 !strconcat(instr_asm, "\t$target"),
Bruno Cardoso Lopesea377302007-11-12 19:49:57 +0000277 [(brind CPURegs:$target)], IIBranch>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000278
279// Jump and Link (Call)
Eric Christopher7300ac12007-10-26 04:00:13 +0000280let isCall=1, hasDelaySlot=1,
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000281 // All calls clobber the non-callee saved registers...
Eric Christopher7300ac12007-10-26 04:00:13 +0000282 Defs = [AT, V0, V1, A0, A1, A2, A3, T0, T1, T2,
Bruno Cardoso Lopesea377302007-11-12 19:49:57 +0000283 T3, T4, T5, T6, T7, T8, T9, K0, K1], Uses = [GP] in {
Eric Christopher7300ac12007-10-26 04:00:13 +0000284 class JumpLink<bits<6> op, string instr_asm>:
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000285 FJ< op,
286 (outs),
287 (ins calltarget:$target),
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +0000288 !strconcat(instr_asm, "\t$target"),
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000289 [(MipsJmpLink imm:$target)], IIBranch>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000290
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000291 let rd=31 in
292 class JumpLinkReg<bits<6> op, bits<6> func, string instr_asm>:
293 FR< op,
294 func,
295 (outs),
296 (ins CPURegs:$rs),
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +0000297 !strconcat(instr_asm, "\t$rs"),
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000298 [(MipsJmpLink CPURegs:$rs)], IIBranch>;
299
300 class BranchLink<string instr_asm>:
301 FI< 0x1,
302 (outs),
303 (ins CPURegs:$rs, brtarget:$target),
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +0000304 !strconcat(instr_asm, "\t$rs, $target"),
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000305 [], IIBranch>;
306}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000307
Eric Christopher7300ac12007-10-26 04:00:13 +0000308// Mul, Div
309class MulDiv<bits<6> func, string instr_asm, InstrItinClass itin>:
310 FR< 0x00,
311 func,
Evan Chengb783fa32007-07-19 01:14:50 +0000312 (outs),
Eric Christopher7300ac12007-10-26 04:00:13 +0000313 (ins CPURegs:$a, CPURegs:$b),
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +0000314 !strconcat(instr_asm, "\t$a, $b"),
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000315 [], itin>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000316
Eric Christopher7300ac12007-10-26 04:00:13 +0000317// Move from Hi/Lo
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000318class MoveFromTo<bits<6> func, string instr_asm>:
Eric Christopher7300ac12007-10-26 04:00:13 +0000319 FR< 0x00,
320 func,
321 (outs CPURegs:$dst),
Evan Chengb783fa32007-07-19 01:14:50 +0000322 (ins),
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +0000323 !strconcat(instr_asm, "\t$dst"),
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000324 [], IIHiLo>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000325
326// Count Leading Ones/Zeros in Word
327class CountLeading<bits<6> func, string instr_asm>:
Eric Christopher7300ac12007-10-26 04:00:13 +0000328 FR< 0x1c,
329 func,
330 (outs CPURegs:$dst),
331 (ins CPURegs:$src),
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +0000332 !strconcat(instr_asm, "\t$dst, $src"),
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000333 [], IIAlu>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000334
Eric Christopher7300ac12007-10-26 04:00:13 +0000335class EffectiveAddress<string instr_asm> :
336 FI<0x09,
337 (outs CPURegs:$dst),
Bruno Cardoso Lopes96433662007-09-24 20:15:11 +0000338 (ins mem:$addr),
339 instr_asm,
340 [(set CPURegs:$dst, addr:$addr)], IIAlu>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000341
Bruno Cardoso Lopes4fb1f542008-07-05 19:05:21 +0000342class SignExtInReg<bits<6> func, string instr_asm, ValueType vt>:
343 FR< 0x3f, func, (outs CPURegs:$dst), (ins CPURegs:$src),
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +0000344 !strconcat(instr_asm, "\t$dst, $src"),
Bruno Cardoso Lopes4fb1f542008-07-05 19:05:21 +0000345 [(set CPURegs:$dst, (sext_inreg CPURegs:$src, vt))], NoItinerary>;
346
347
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000348//===----------------------------------------------------------------------===//
349// Pseudo instructions
350//===----------------------------------------------------------------------===//
351
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000352// As stack alignment is always done with addiu, we need a 16-bit immediate
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000353let Defs = [SP], Uses = [SP] in {
Bruno Cardoso Lopesed7723d2008-06-06 00:58:26 +0000354def ADJCALLSTACKDOWN : MipsPseudo<(outs), (ins uimm16:$amt),
Bruno Cardoso Lopes4fb1f542008-07-05 19:05:21 +0000355 "!ADJCALLSTACKDOWN $amt",
356 [(callseq_start imm:$amt)]>;
Bruno Cardoso Lopesed7723d2008-06-06 00:58:26 +0000357def ADJCALLSTACKUP : MipsPseudo<(outs), (ins uimm16:$amt1, uimm16:$amt2),
Bruno Cardoso Lopes4fb1f542008-07-05 19:05:21 +0000358 "!ADJCALLSTACKUP $amt1",
359 [(callseq_end imm:$amt1, imm:$amt2)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000360}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000361
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +0000362// Some assembly macros need to avoid pseudoinstructions and assembler
363// automatic reodering, we should reorder ourselves.
364def MACRO : MipsPseudo<(outs), (ins), ".set\tmacro", []>;
365def REORDER : MipsPseudo<(outs), (ins), ".set\treorder", []>;
366def NOMACRO : MipsPseudo<(outs), (ins), ".set\tnomacro", []>;
367def NOREORDER : MipsPseudo<(outs), (ins), ".set\tnoreorder", []>;
368
Eric Christopher7300ac12007-10-26 04:00:13 +0000369// When handling PIC code the assembler needs .cpload and .cprestore
370// directives. If the real instructions corresponding these directives
371// are used, we have the same behavior, but get also a bunch of warnings
Bruno Cardoso Lopes2cacce92007-10-09 02:55:31 +0000372// from the assembler.
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +0000373def CPLOAD : MipsPseudo<(outs), (ins CPURegs:$picreg), ".cpload\t$picreg", []>;
374def CPRESTORE : MipsPseudo<(outs), (ins uimm16:$loc), ".cprestore\t$loc\n", []>;
Bruno Cardoso Lopesed7723d2008-06-06 00:58:26 +0000375
376// The supported Mips ISAs dont have any instruction close to the SELECT_CC
377// operation. The solution is to create a Mips pseudo SELECT_CC instruction
378// (MipsSelectCC), use LowerSELECT_CC to generate this instruction and finally
379// replace it for real supported nodes into EmitInstrWithCustomInserter
380let usesCustomDAGSchedInserter = 1 in {
Bruno Cardoso Lopesda54c7d2008-07-29 19:05:28 +0000381 class PseudoSelCC<RegisterClass RC, string asmstr>:
382 MipsPseudo<(outs RC:$dst), (ins CPURegs:$CmpRes, RC:$T, RC:$F), asmstr,
383 [(set RC:$dst, (MipsSelectCC CPURegs:$CmpRes, RC:$T, RC:$F))]>;
Bruno Cardoso Lopesed7723d2008-06-06 00:58:26 +0000384}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000385
Bruno Cardoso Lopesda54c7d2008-07-29 19:05:28 +0000386def Select_CC : PseudoSelCC<CPURegs, "# MipsSelect_CC_i32">;
387
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000388//===----------------------------------------------------------------------===//
389// Instruction definition
390//===----------------------------------------------------------------------===//
391
392//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000393// MipsI Instructions
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000394//===----------------------------------------------------------------------===//
395
Bruno Cardoso Lopes062ac062008-07-30 16:58:59 +0000396/// Arithmetic Instructions (ALU Immediate)
Bruno Cardoso Lopes218d5822007-11-05 03:02:32 +0000397def ADDiu : ArithI<0x09, "addiu", add, uimm16, immZExt16>;
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000398def ADDi : ArithI<0x08, "addi", add, simm16, immSExt16>;
Bruno Cardoso Lopes062ac062008-07-30 16:58:59 +0000399def SLTi : SetCC_I<0x0a, "slti", setlt, simm16, immSExt16>;
400def SLTiu : SetCC_I<0x0b, "sltiu", setult, uimm16, immZExt16>;
401def ANDi : LogicI<0x0c, "andi", and>;
402def ORi : LogicI<0x0d, "ori", or>;
403def XORi : LogicI<0x0e, "xori", xor>;
404def LUi : LoadUpper<0x0f, "lui">;
405
406/// Arithmetic Instructions (3-Operand, R-Type)
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000407def ADDu : ArithR<0x00, 0x21, "addu", add, IIAlu>;
408def SUBu : ArithR<0x00, 0x23, "subu", sub, IIAlu>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000409def ADD : ArithOverflowR<0x00, 0x20, "add">;
410def SUB : ArithOverflowR<0x00, 0x22, "sub">;
Bruno Cardoso Lopes062ac062008-07-30 16:58:59 +0000411def SLT : SetCC_R<0x00, 0x2a, "slt", setlt>;
412def SLTu : SetCC_R<0x00, 0x2b, "sltu", setult>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000413def AND : LogicR<0x24, "and", and>;
414def OR : LogicR<0x25, "or", or>;
415def XOR : LogicR<0x26, "xor", xor>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000416def NOR : LogicNOR<0x00, 0x27, "nor">;
417
Bruno Cardoso Lopes062ac062008-07-30 16:58:59 +0000418/// Shift Instructions
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000419def SLL : LogicR_shift_imm<0x00, "sll", shl>;
420def SRL : LogicR_shift_imm<0x02, "srl", srl>;
421def SRA : LogicR_shift_imm<0x03, "sra", sra>;
422def SLLV : LogicR_shift_reg<0x04, "sllv", shl>;
423def SRLV : LogicR_shift_reg<0x06, "srlv", srl>;
424def SRAV : LogicR_shift_reg<0x07, "srav", sra>;
425
Bruno Cardoso Lopes062ac062008-07-30 16:58:59 +0000426/// Load and Store Instructions
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000427def LB : LoadM<0x20, "lb", sextloadi8>;
428def LBu : LoadM<0x24, "lbu", zextloadi8>;
429def LH : LoadM<0x21, "lh", sextloadi16>;
430def LHu : LoadM<0x25, "lhu", zextloadi16>;
431def LW : LoadM<0x23, "lw", load>;
432def SB : StoreM<0x28, "sb", truncstorei8>;
433def SH : StoreM<0x29, "sh", truncstorei16>;
434def SW : StoreM<0x2b, "sw", store>;
435
Bruno Cardoso Lopes062ac062008-07-30 16:58:59 +0000436/// Jump and Branch Instructions
437def J : JumpFJ<0x02, "j">;
438def JR : JumpFR<0x00, 0x08, "jr">;
439def JAL : JumpLink<0x03, "jal">;
440def JALR : JumpLinkReg<0x00, 0x09, "jalr">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000441def BEQ : CBranch<0x04, "beq", seteq>;
442def BNE : CBranch<0x05, "bne", setne>;
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000443
Eric Christopher7300ac12007-10-26 04:00:13 +0000444let rt=1 in
Bruno Cardoso Lopes062ac062008-07-30 16:58:59 +0000445 def BGEZ : CBranchZero<0x01, "bgez", setge>;
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000446
447let rt=0 in {
Bruno Cardoso Lopes062ac062008-07-30 16:58:59 +0000448 def BGTZ : CBranchZero<0x07, "bgtz", setgt>;
449 def BLEZ : CBranchZero<0x07, "blez", setle>;
450 def BLTZ : CBranchZero<0x01, "bltz", setlt>;
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000451}
452
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000453def BGEZAL : BranchLink<"bgezal">;
454def BLTZAL : BranchLink<"bltzal">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000455
Bruno Cardoso Lopes062ac062008-07-30 16:58:59 +0000456let isReturn=1, isTerminator=1, hasDelaySlot=1,
457 isBarrier=1, hasCtrlDep=1, rs=0, rt=0, shamt=0 in
458 def RET : FR <0x00, 0x02, (outs), (ins CPURegs:$target),
459 "jr\t$target", [(MipsRet CPURegs:$target)], IIBranch>;
460
461/// Multiply and Divide Instructions.
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000462def MULT : MulDiv<0x18, "mult", IIImul>;
463def MULTu : MulDiv<0x19, "multu", IIImul>;
464def DIV : MulDiv<0x1a, "div", IIIdiv>;
465def DIVu : MulDiv<0x1b, "divu", IIIdiv>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000466def MFHI : MoveFromTo<0x10, "mfhi">;
467def MFLO : MoveFromTo<0x12, "mflo">;
468def MTHI : MoveFromTo<0x11, "mthi">;
469def MTLO : MoveFromTo<0x13, "mtlo">;
470
Bruno Cardoso Lopes062ac062008-07-30 16:58:59 +0000471/// Sign Ext In Register Instructions.
472let Predicates = [HasSEInReg] in {
473 let shamt = 0x10, rs = 0 in
474 def SEB : SignExtInReg<0x21, "seb", i8>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000475
Bruno Cardoso Lopes062ac062008-07-30 16:58:59 +0000476 let shamt = 0x18, rs = 0 in
477 def SEH : SignExtInReg<0x20, "seh", i16>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000478}
479
Bruno Cardoso Lopes062ac062008-07-30 16:58:59 +0000480/// No operation
481let addr=0 in
482 def NOP : FJ<0, (outs), (ins), "nop", [], IIAlu>;
483
Eric Christopher7300ac12007-10-26 04:00:13 +0000484// FrameIndexes are legalized when they are operands from load/store
Bruno Cardoso Lopes96433662007-09-24 20:15:11 +0000485// instructions. The same not happens for stack address copies, so an
486// add op with mem ComplexPattern is used and the stack address copy
487// can be matched. It's similar to Sparc LEA_ADDRi
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +0000488def LEA_ADDiu : EffectiveAddress<"addiu\t$dst, ${addr:stackloc}">;
Bruno Cardoso Lopes96433662007-09-24 20:15:11 +0000489
Bruno Cardoso Lopes4fb1f542008-07-05 19:05:21 +0000490// Count Leading
491// CLO/CLZ are part of the newer MIPS32(tm) instruction
492// set and not older Mips I keep this for future use
493// though.
494//def CLO : CountLeading<0x21, "clo">;
495//def CLZ : CountLeading<0x20, "clz">;
496
497// MADD*/MSUB* are not part of MipsI either.
498//def MADD : MArithR<0x00, "madd">;
499//def MADDU : MArithR<0x01, "maddu">;
500//def MSUB : MArithR<0x04, "msub">;
501//def MSUBU : MArithR<0x05, "msubu">;
502
Bruno Cardoso Lopes062ac062008-07-30 16:58:59 +0000503// MUL is a assembly macro in the current used ISAs. In recent ISA's
504// it is a real instruction.
505//def MUL : ArithR<0x1c, 0x02, "mul", mul, IIImul>;
Bruno Cardoso Lopes4fb1f542008-07-05 19:05:21 +0000506
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000507//===----------------------------------------------------------------------===//
508// Arbitrary patterns that map to one or more instructions
509//===----------------------------------------------------------------------===//
510
511// Small immediates
Eric Christopher7300ac12007-10-26 04:00:13 +0000512def : Pat<(i32 immSExt16:$in),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000513 (ADDiu ZERO, imm:$in)>;
Eric Christopher7300ac12007-10-26 04:00:13 +0000514def : Pat<(i32 immZExt16:$in),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000515 (ORi ZERO, imm:$in)>;
516
517// Arbitrary immediates
518def : Pat<(i32 imm:$imm),
519 (ORi (LUi (HI16 imm:$imm)), (LO16 imm:$imm))>;
520
Bruno Cardoso Lopesed7723d2008-06-06 00:58:26 +0000521// Carry patterns
522def : Pat<(subc CPURegs:$lhs, CPURegs:$rhs),
523 (SUBu CPURegs:$lhs, CPURegs:$rhs)>;
524def : Pat<(addc CPURegs:$lhs, CPURegs:$rhs),
525 (ADDu CPURegs:$lhs, CPURegs:$rhs)>;
526def : Pat<(addc CPURegs:$src, imm:$imm),
527 (ADDiu CPURegs:$src, imm:$imm)>;
528
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000529// Call
530def : Pat<(MipsJmpLink (i32 tglobaladdr:$dst)),
531 (JAL tglobaladdr:$dst)>;
532def : Pat<(MipsJmpLink (i32 texternalsym:$dst)),
533 (JAL texternalsym:$dst)>;
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000534def : Pat<(MipsJmpLink CPURegs:$dst),
535 (JALR CPURegs:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000536
Bruno Cardoso Lopes69ca2ca2008-07-23 16:01:50 +0000537// hi/lo relocs
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000538def : Pat<(MipsHi tglobaladdr:$in), (LUi tglobaladdr:$in)>;
Bruno Cardoso Lopes218d5822007-11-05 03:02:32 +0000539def : Pat<(add CPURegs:$hi, (MipsLo tglobaladdr:$lo)),
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000540 (ADDiu CPURegs:$hi, tglobaladdr:$lo)>;
Bruno Cardoso Lopes69ca2ca2008-07-23 16:01:50 +0000541
Bruno Cardoso Lopesea377302007-11-12 19:49:57 +0000542def : Pat<(MipsHi tjumptable:$in), (LUi tjumptable:$in)>;
Bruno Cardoso Lopesea377302007-11-12 19:49:57 +0000543def : Pat<(add CPURegs:$hi, (MipsLo tjumptable:$lo)),
544 (ADDiu CPURegs:$hi, tjumptable:$lo)>;
Bruno Cardoso Lopes69ca2ca2008-07-23 16:01:50 +0000545
546def : Pat<(MipsHi tconstpool:$in), (LUi tconstpool:$in)>;
547def : Pat<(add CPURegs:$hi, (MipsLo tconstpool:$lo)),
548 (ADDiu CPURegs:$hi, tconstpool:$lo)>;
549
550// gp_rel relocs
Bruno Cardoso Lopes12355a82008-07-21 18:52:34 +0000551def : Pat<(add CPURegs:$gp, (MipsGPRel tglobaladdr:$in)),
552 (ADDiu CPURegs:$gp, tglobaladdr:$in)>;
Bruno Cardoso Lopes69ca2ca2008-07-23 16:01:50 +0000553def : Pat<(add CPURegs:$gp, (MipsGPRel tconstpool:$in)),
554 (ADDiu CPURegs:$gp, tconstpool:$in)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000555
Bruno Cardoso Lopes4fb1f542008-07-05 19:05:21 +0000556// Mips does not have "not", so we expand our way
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000557def : Pat<(not CPURegs:$in),
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000558 (NOR CPURegs:$in, ZERO)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000559
Eric Christopher7300ac12007-10-26 04:00:13 +0000560// extended load and stores
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000561def : Pat<(i32 (extloadi1 addr:$src)), (LBu addr:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000562def : Pat<(i32 (extloadi8 addr:$src)), (LBu addr:$src)>;
563def : Pat<(i32 (extloadi16 addr:$src)), (LHu addr:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000564
Bruno Cardoso Lopesed7723d2008-06-06 00:58:26 +0000565// peepholes
Bruno Cardoso Lopes218d5822007-11-05 03:02:32 +0000566def : Pat<(store (i32 0), addr:$dst), (SW ZERO, addr:$dst)>;
567
Bruno Cardoso Lopes4fb1f542008-07-05 19:05:21 +0000568// brcond patterns
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000569// direct match equal/notequal zero branches
570def : Pat<(brcond (setne CPURegs:$lhs, 0), bb:$dst),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000571 (BNE CPURegs:$lhs, ZERO, bb:$dst)>;
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000572def : Pat<(brcond (seteq CPURegs:$lhs, 0), bb:$dst),
573 (BEQ CPURegs:$lhs, ZERO, bb:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000574
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000575def : Pat<(brcond (setge CPURegs:$lhs, CPURegs:$rhs), bb:$dst),
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000576 (BGEZ (SUB CPURegs:$lhs, CPURegs:$rhs), bb:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000577def : Pat<(brcond (setuge CPURegs:$lhs, CPURegs:$rhs), bb:$dst),
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000578 (BGEZ (SUBu CPURegs:$lhs, CPURegs:$rhs), bb:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000579
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000580def : Pat<(brcond (setgt CPURegs:$lhs, CPURegs:$rhs), bb:$dst),
581 (BGTZ (SUB CPURegs:$lhs, CPURegs:$rhs), bb:$dst)>;
582def : Pat<(brcond (setugt CPURegs:$lhs, CPURegs:$rhs), bb:$dst),
583 (BGTZ (SUBu CPURegs:$lhs, CPURegs:$rhs), bb:$dst)>;
584
585def : Pat<(brcond (setle CPURegs:$lhs, CPURegs:$rhs), bb:$dst),
586 (BLEZ (SUB CPURegs:$lhs, CPURegs:$rhs), bb:$dst)>;
587def : Pat<(brcond (setule CPURegs:$lhs, CPURegs:$rhs), bb:$dst),
588 (BLEZ (SUBu CPURegs:$lhs, CPURegs:$rhs), bb:$dst)>;
589
590def : Pat<(brcond (setlt CPURegs:$lhs, immSExt16:$rhs), bb:$dst),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000591 (BNE (SLTi CPURegs:$lhs, immSExt16:$rhs), ZERO, bb:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000592def : Pat<(brcond (setult CPURegs:$lhs, immZExt16:$rhs), bb:$dst),
593 (BNE (SLTiu CPURegs:$lhs, immZExt16:$rhs), ZERO, bb:$dst)>;
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000594def : Pat<(brcond (setlt CPURegs:$lhs, CPURegs:$rhs), bb:$dst),
595 (BNE (SLT CPURegs:$lhs, CPURegs:$rhs), ZERO, bb:$dst)>;
596def : Pat<(brcond (setult CPURegs:$lhs, CPURegs:$rhs), bb:$dst),
597 (BNE (SLTu CPURegs:$lhs, CPURegs:$rhs), ZERO, bb:$dst)>;
598
599def : Pat<(brcond (setlt CPURegs:$lhs, CPURegs:$rhs), bb:$dst),
600 (BLTZ (SUB CPURegs:$lhs, CPURegs:$rhs), bb:$dst)>;
601def : Pat<(brcond (setult CPURegs:$lhs, CPURegs:$rhs), bb:$dst),
602 (BLTZ (SUBu CPURegs:$lhs, CPURegs:$rhs), bb:$dst)>;
603
604// generic brcond pattern
605def : Pat<(brcond CPURegs:$cond, bb:$dst),
606 (BNE CPURegs:$cond, ZERO, bb:$dst)>;
607
Bruno Cardoso Lopes062ac062008-07-30 16:58:59 +0000608// setcc patterns, only matched when there
609// is no brcond following a setcc operation
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000610def : Pat<(setle CPURegs:$lhs, CPURegs:$rhs),
611 (XORi (SLT CPURegs:$rhs, CPURegs:$lhs), 1)>;
612def : Pat<(setule CPURegs:$lhs, CPURegs:$rhs),
613 (XORi (SLTu CPURegs:$rhs, CPURegs:$lhs), 1)>;
614
615def : Pat<(setgt CPURegs:$lhs, CPURegs:$rhs),
616 (SLT CPURegs:$rhs, CPURegs:$lhs)>;
617def : Pat<(setugt CPURegs:$lhs, CPURegs:$rhs),
618 (SLTu CPURegs:$rhs, CPURegs:$lhs)>;
619
620def : Pat<(setge CPURegs:$lhs, CPURegs:$rhs),
621 (XORi (SLT CPURegs:$lhs, CPURegs:$rhs), 1)>;
622def : Pat<(setuge CPURegs:$lhs, CPURegs:$rhs),
623 (XORi (SLTu CPURegs:$lhs, CPURegs:$rhs), 1)>;
624
625def : Pat<(setne CPURegs:$lhs, CPURegs:$rhs),
Eric Christopher7300ac12007-10-26 04:00:13 +0000626 (OR (SLT CPURegs:$lhs, CPURegs:$rhs),
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000627 (SLT CPURegs:$rhs, CPURegs:$lhs))>;
628
629def : Pat<(seteq CPURegs:$lhs, CPURegs:$rhs),
Eric Christopher7300ac12007-10-26 04:00:13 +0000630 (XORi (OR (SLT CPURegs:$lhs, CPURegs:$rhs),
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000631 (SLT CPURegs:$rhs, CPURegs:$lhs)), 1)>;
Eric Christopher7300ac12007-10-26 04:00:13 +0000632
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000633def : Pat<(setge CPURegs:$lhs, immSExt16:$rhs),
634 (XORi (SLTi CPURegs:$lhs, immSExt16:$rhs), 1)>;
635def : Pat<(setuge CPURegs:$lhs, immZExt16:$rhs),
636 (XORi (SLTiu CPURegs:$lhs, immZExt16:$rhs), 1)>;
Bruno Cardoso Lopes4fb1f542008-07-05 19:05:21 +0000637
638//===----------------------------------------------------------------------===//
639// Floating Point Support
640//===----------------------------------------------------------------------===//
641
642include "MipsInstrFPU.td"
643