blob: 61626bda1a331f7e5e53461203442c50d5f1b352 [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
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 {
Bruno Cardoso Lopesda54c7d2008-07-29 19:05:28 +0000386 class PseudoSelCC<RegisterClass RC, string asmstr>:
387 MipsPseudo<(outs RC:$dst), (ins CPURegs:$CmpRes, RC:$T, RC:$F), asmstr,
388 [(set RC:$dst, (MipsSelectCC CPURegs:$CmpRes, RC:$T, RC:$F))]>;
Bruno Cardoso Lopesed7723d2008-06-06 00:58:26 +0000389}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000390
Bruno Cardoso Lopesda54c7d2008-07-29 19:05:28 +0000391def Select_CC : PseudoSelCC<CPURegs, "# MipsSelect_CC_i32">;
392
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000393//===----------------------------------------------------------------------===//
394// Instruction definition
395//===----------------------------------------------------------------------===//
396
397//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000398// MipsI Instructions
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000399//===----------------------------------------------------------------------===//
400
401// Arithmetic
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000402
403// ADDiu just accept 16-bit immediates but we handle this on Pat's.
404// immZExt32 is used here so it can match GlobalAddress immediates.
Bruno Cardoso Lopesf2377552008-06-06 06:37:31 +0000405// MUL is a assembly macro in the current used ISAs.
Bruno Cardoso Lopes218d5822007-11-05 03:02:32 +0000406def ADDiu : ArithI<0x09, "addiu", add, uimm16, immZExt16>;
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000407def ADDi : ArithI<0x08, "addi", add, simm16, immSExt16>;
Bruno Cardoso Lopesf2377552008-06-06 06:37:31 +0000408//def MUL : ArithR<0x1c, 0x02, "mul", mul, IIImul>;
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000409def ADDu : ArithR<0x00, 0x21, "addu", add, IIAlu>;
410def SUBu : ArithR<0x00, 0x23, "subu", sub, IIAlu>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000411def ADD : ArithOverflowR<0x00, 0x20, "add">;
412def SUB : ArithOverflowR<0x00, 0x22, "sub">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000413
414// Logical
415def AND : LogicR<0x24, "and", and>;
416def OR : LogicR<0x25, "or", or>;
417def XOR : LogicR<0x26, "xor", xor>;
418def ANDi : LogicI<0x0c, "andi", and>;
419def ORi : LogicI<0x0d, "ori", or>;
420def XORi : LogicI<0x0e, "xori", xor>;
421def NOR : LogicNOR<0x00, 0x27, "nor">;
422
Eric Christopher7300ac12007-10-26 04:00:13 +0000423// Shifts
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000424def SLL : LogicR_shift_imm<0x00, "sll", shl>;
425def SRL : LogicR_shift_imm<0x02, "srl", srl>;
426def SRA : LogicR_shift_imm<0x03, "sra", sra>;
427def SLLV : LogicR_shift_reg<0x04, "sllv", shl>;
428def SRLV : LogicR_shift_reg<0x06, "srlv", srl>;
429def SRAV : LogicR_shift_reg<0x07, "srav", sra>;
430
431// Load Upper Immediate
432def LUi : LoadUpper<0x0f, "lui">;
433
434// Load/Store
435def LB : LoadM<0x20, "lb", sextloadi8>;
436def LBu : LoadM<0x24, "lbu", zextloadi8>;
437def LH : LoadM<0x21, "lh", sextloadi16>;
438def LHu : LoadM<0x25, "lhu", zextloadi16>;
439def LW : LoadM<0x23, "lw", load>;
440def SB : StoreM<0x28, "sb", truncstorei8>;
441def SH : StoreM<0x29, "sh", truncstorei16>;
442def SW : StoreM<0x2b, "sw", store>;
443
444// Conditional Branch
445def BEQ : CBranch<0x04, "beq", seteq>;
446def BNE : CBranch<0x05, "bne", setne>;
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000447
Eric Christopher7300ac12007-10-26 04:00:13 +0000448let rt=1 in
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000449def BGEZ : CBranchZero<0x01, "bgez", setge>;
450
451let rt=0 in {
452def BGTZ : CBranchZero<0x07, "bgtz", setgt>;
453def BLEZ : CBranchZero<0x07, "blez", setle>;
454def BLTZ : CBranchZero<0x01, "bltz", setlt>;
455}
456
457// Set Condition Code
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000458def SLT : SetCC_R<0x00, 0x2a, "slt", setlt>;
459def SLTu : SetCC_R<0x00, 0x2b, "sltu", setult>;
460def SLTi : SetCC_I<0x0a, "slti", setlt, simm16, immSExt16>;
461def SLTiu : SetCC_I<0x0b, "sltiu", setult, uimm16, immZExt16>;
462
463// Unconditional jump
464def J : JumpFJ<0x02, "j">;
465def JR : JumpFR<0x00, 0x08, "jr">;
466
467// Jump and Link (Call)
468def JAL : JumpLink<0x03, "jal">;
469def JALR : JumpLinkReg<0x00, 0x09, "jalr">;
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000470def BGEZAL : BranchLink<"bgezal">;
471def BLTZAL : BranchLink<"bltzal">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000472
473// MulDiv and Move From Hi/Lo operations, have
474// their correpondent SDNodes created on ISelDAG.
475// Special Mul, Div operations
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000476def MULT : MulDiv<0x18, "mult", IIImul>;
477def MULTu : MulDiv<0x19, "multu", IIImul>;
478def DIV : MulDiv<0x1a, "div", IIIdiv>;
479def DIVu : MulDiv<0x1b, "divu", IIIdiv>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000480
Eric Christopher7300ac12007-10-26 04:00:13 +0000481// Move From Hi/Lo
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000482def MFHI : MoveFromTo<0x10, "mfhi">;
483def MFLO : MoveFromTo<0x12, "mflo">;
484def MTHI : MoveFromTo<0x11, "mthi">;
485def MTLO : MoveFromTo<0x13, "mtlo">;
486
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000487// No operation
488let addr=0 in
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000489def NOP : FJ<0, (outs), (ins), "nop", [], IIAlu>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000490
Eric Christopher7300ac12007-10-26 04:00:13 +0000491// Ret instruction - as mips does not have "ret" a
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000492// jr $ra must be generated.
Evan Cheng37e7c752007-07-21 00:34:19 +0000493let isReturn=1, isTerminator=1, hasDelaySlot=1,
Eric Christopher7300ac12007-10-26 04:00:13 +0000494 isBarrier=1, hasCtrlDep=1, rs=0, rt=0, shamt=0 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000495{
Evan Chengb783fa32007-07-19 01:14:50 +0000496 def RET : FR <0x00, 0x02, (outs), (ins CPURegs:$target),
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +0000497 "jr\t$target", [(MipsRet CPURegs:$target)], IIBranch>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000498}
499
Eric Christopher7300ac12007-10-26 04:00:13 +0000500// FrameIndexes are legalized when they are operands from load/store
Bruno Cardoso Lopes96433662007-09-24 20:15:11 +0000501// instructions. The same not happens for stack address copies, so an
502// add op with mem ComplexPattern is used and the stack address copy
503// can be matched. It's similar to Sparc LEA_ADDRi
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +0000504def LEA_ADDiu : EffectiveAddress<"addiu\t$dst, ${addr:stackloc}">;
Bruno Cardoso Lopes96433662007-09-24 20:15:11 +0000505
Bruno Cardoso Lopes4fb1f542008-07-05 19:05:21 +0000506// Count Leading
507// CLO/CLZ are part of the newer MIPS32(tm) instruction
508// set and not older Mips I keep this for future use
509// though.
510//def CLO : CountLeading<0x21, "clo">;
511//def CLZ : CountLeading<0x20, "clz">;
512
513// MADD*/MSUB* are not part of MipsI either.
514//def MADD : MArithR<0x00, "madd">;
515//def MADDU : MArithR<0x01, "maddu">;
516//def MSUB : MArithR<0x04, "msub">;
517//def MSUBU : MArithR<0x05, "msubu">;
518
Bruno Cardoso Lopesdfd657f2008-07-09 05:32:22 +0000519let Predicates = [HasSEInReg] in {
Bruno Cardoso Lopes4fb1f542008-07-05 19:05:21 +0000520 let shamt = 0x10, rs = 0 in
521 def SEB : SignExtInReg<0x21, "seb", i8>;
522
523 let shamt = 0x18, rs = 0 in
524 def SEH : SignExtInReg<0x20, "seh", i16>;
525}
526
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000527//===----------------------------------------------------------------------===//
528// Arbitrary patterns that map to one or more instructions
529//===----------------------------------------------------------------------===//
530
531// Small immediates
Eric Christopher7300ac12007-10-26 04:00:13 +0000532def : Pat<(i32 immSExt16:$in),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000533 (ADDiu ZERO, imm:$in)>;
Eric Christopher7300ac12007-10-26 04:00:13 +0000534def : Pat<(i32 immZExt16:$in),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000535 (ORi ZERO, imm:$in)>;
536
537// Arbitrary immediates
538def : Pat<(i32 imm:$imm),
539 (ORi (LUi (HI16 imm:$imm)), (LO16 imm:$imm))>;
540
Bruno Cardoso Lopesed7723d2008-06-06 00:58:26 +0000541// Carry patterns
542def : Pat<(subc CPURegs:$lhs, CPURegs:$rhs),
543 (SUBu CPURegs:$lhs, CPURegs:$rhs)>;
544def : Pat<(addc CPURegs:$lhs, CPURegs:$rhs),
545 (ADDu CPURegs:$lhs, CPURegs:$rhs)>;
546def : Pat<(addc CPURegs:$src, imm:$imm),
547 (ADDiu CPURegs:$src, imm:$imm)>;
548
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000549// Call
550def : Pat<(MipsJmpLink (i32 tglobaladdr:$dst)),
551 (JAL tglobaladdr:$dst)>;
552def : Pat<(MipsJmpLink (i32 texternalsym:$dst)),
553 (JAL texternalsym:$dst)>;
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000554def : Pat<(MipsJmpLink CPURegs:$dst),
555 (JALR CPURegs:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000556
Bruno Cardoso Lopes69ca2ca2008-07-23 16:01:50 +0000557// hi/lo relocs
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000558def : Pat<(MipsHi tglobaladdr:$in), (LUi 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 Lopes69ca2ca2008-07-23 16:01:50 +0000561
Bruno Cardoso Lopesea377302007-11-12 19:49:57 +0000562def : Pat<(MipsHi tjumptable:$in), (LUi 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 Lopes69ca2ca2008-07-23 16:01:50 +0000565
566def : Pat<(MipsHi tconstpool:$in), (LUi tconstpool:$in)>;
567def : Pat<(add CPURegs:$hi, (MipsLo tconstpool:$lo)),
568 (ADDiu CPURegs:$hi, tconstpool:$lo)>;
569
570// gp_rel relocs
Bruno Cardoso Lopes12355a82008-07-21 18:52:34 +0000571def : Pat<(add CPURegs:$gp, (MipsGPRel tglobaladdr:$in)),
572 (ADDiu CPURegs:$gp, tglobaladdr:$in)>;
Bruno Cardoso Lopes69ca2ca2008-07-23 16:01:50 +0000573def : Pat<(add CPURegs:$gp, (MipsGPRel tconstpool:$in)),
574 (ADDiu CPURegs:$gp, tconstpool:$in)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000575
Bruno Cardoso Lopes4fb1f542008-07-05 19:05:21 +0000576// Mips does not have "not", so we expand our way
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000577def : Pat<(not CPURegs:$in),
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000578 (NOR CPURegs:$in, ZERO)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000579
Eric Christopher7300ac12007-10-26 04:00:13 +0000580// extended load and stores
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000581def : Pat<(i32 (extloadi1 addr:$src)), (LBu addr:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000582def : Pat<(i32 (extloadi8 addr:$src)), (LBu addr:$src)>;
583def : Pat<(i32 (extloadi16 addr:$src)), (LHu addr:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000584
Bruno Cardoso Lopesed7723d2008-06-06 00:58:26 +0000585// peepholes
Bruno Cardoso Lopes218d5822007-11-05 03:02:32 +0000586def : Pat<(store (i32 0), addr:$dst), (SW ZERO, addr:$dst)>;
587
Bruno Cardoso Lopes4fb1f542008-07-05 19:05:21 +0000588// brcond patterns
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000589// direct match equal/notequal zero branches
590def : Pat<(brcond (setne CPURegs:$lhs, 0), bb:$dst),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000591 (BNE CPURegs:$lhs, ZERO, bb:$dst)>;
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000592def : Pat<(brcond (seteq CPURegs:$lhs, 0), bb:$dst),
593 (BEQ CPURegs:$lhs, ZERO, bb:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000594
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000595def : Pat<(brcond (setge CPURegs:$lhs, CPURegs:$rhs), bb:$dst),
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000596 (BGEZ (SUB CPURegs:$lhs, CPURegs:$rhs), bb:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000597def : Pat<(brcond (setuge CPURegs:$lhs, CPURegs:$rhs), bb:$dst),
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000598 (BGEZ (SUBu CPURegs:$lhs, CPURegs:$rhs), bb:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000599
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000600def : Pat<(brcond (setgt CPURegs:$lhs, CPURegs:$rhs), bb:$dst),
601 (BGTZ (SUB CPURegs:$lhs, CPURegs:$rhs), bb:$dst)>;
602def : Pat<(brcond (setugt CPURegs:$lhs, CPURegs:$rhs), bb:$dst),
603 (BGTZ (SUBu CPURegs:$lhs, CPURegs:$rhs), bb:$dst)>;
604
605def : Pat<(brcond (setle CPURegs:$lhs, CPURegs:$rhs), bb:$dst),
606 (BLEZ (SUB CPURegs:$lhs, CPURegs:$rhs), bb:$dst)>;
607def : Pat<(brcond (setule CPURegs:$lhs, CPURegs:$rhs), bb:$dst),
608 (BLEZ (SUBu CPURegs:$lhs, CPURegs:$rhs), bb:$dst)>;
609
610def : Pat<(brcond (setlt CPURegs:$lhs, immSExt16:$rhs), bb:$dst),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000611 (BNE (SLTi CPURegs:$lhs, immSExt16:$rhs), ZERO, bb:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000612def : Pat<(brcond (setult CPURegs:$lhs, immZExt16:$rhs), bb:$dst),
613 (BNE (SLTiu CPURegs:$lhs, immZExt16:$rhs), ZERO, bb:$dst)>;
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000614def : Pat<(brcond (setlt CPURegs:$lhs, CPURegs:$rhs), bb:$dst),
615 (BNE (SLT CPURegs:$lhs, CPURegs:$rhs), ZERO, bb:$dst)>;
616def : Pat<(brcond (setult CPURegs:$lhs, CPURegs:$rhs), bb:$dst),
617 (BNE (SLTu CPURegs:$lhs, CPURegs:$rhs), ZERO, bb:$dst)>;
618
619def : Pat<(brcond (setlt CPURegs:$lhs, CPURegs:$rhs), bb:$dst),
620 (BLTZ (SUB CPURegs:$lhs, CPURegs:$rhs), bb:$dst)>;
621def : Pat<(brcond (setult CPURegs:$lhs, CPURegs:$rhs), bb:$dst),
622 (BLTZ (SUBu CPURegs:$lhs, CPURegs:$rhs), bb:$dst)>;
623
624// generic brcond pattern
625def : Pat<(brcond CPURegs:$cond, bb:$dst),
626 (BNE CPURegs:$cond, ZERO, bb:$dst)>;
627
Eric Christopher7300ac12007-10-26 04:00:13 +0000628/// setcc patterns, only matched when there
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000629/// is no brcond following a setcc operation
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000630def : Pat<(setle CPURegs:$lhs, CPURegs:$rhs),
631 (XORi (SLT CPURegs:$rhs, CPURegs:$lhs), 1)>;
632def : Pat<(setule CPURegs:$lhs, CPURegs:$rhs),
633 (XORi (SLTu CPURegs:$rhs, CPURegs:$lhs), 1)>;
634
635def : Pat<(setgt CPURegs:$lhs, CPURegs:$rhs),
636 (SLT CPURegs:$rhs, CPURegs:$lhs)>;
637def : Pat<(setugt CPURegs:$lhs, CPURegs:$rhs),
638 (SLTu CPURegs:$rhs, CPURegs:$lhs)>;
639
640def : Pat<(setge CPURegs:$lhs, CPURegs:$rhs),
641 (XORi (SLT CPURegs:$lhs, CPURegs:$rhs), 1)>;
642def : Pat<(setuge CPURegs:$lhs, CPURegs:$rhs),
643 (XORi (SLTu CPURegs:$lhs, CPURegs:$rhs), 1)>;
644
645def : Pat<(setne CPURegs:$lhs, CPURegs:$rhs),
Eric Christopher7300ac12007-10-26 04:00:13 +0000646 (OR (SLT CPURegs:$lhs, CPURegs:$rhs),
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000647 (SLT CPURegs:$rhs, CPURegs:$lhs))>;
648
649def : Pat<(seteq CPURegs:$lhs, CPURegs:$rhs),
Eric Christopher7300ac12007-10-26 04:00:13 +0000650 (XORi (OR (SLT CPURegs:$lhs, CPURegs:$rhs),
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000651 (SLT CPURegs:$rhs, CPURegs:$lhs)), 1)>;
Eric Christopher7300ac12007-10-26 04:00:13 +0000652
Bruno Cardoso Lopes34190552007-08-18 02:37:46 +0000653def : Pat<(setge CPURegs:$lhs, immSExt16:$rhs),
654 (XORi (SLTi CPURegs:$lhs, immSExt16:$rhs), 1)>;
655def : Pat<(setuge CPURegs:$lhs, immZExt16:$rhs),
656 (XORi (SLTiu CPURegs:$lhs, immZExt16:$rhs), 1)>;
Bruno Cardoso Lopes4fb1f542008-07-05 19:05:21 +0000657
658//===----------------------------------------------------------------------===//
659// Floating Point Support
660//===----------------------------------------------------------------------===//
661
662include "MipsInstrFPU.td"
663