blob: 78846a2bbc265e00d491a19564651c6299a0e15d [file] [log] [blame]
Akira Hatanaka4552c9a2011-04-15 21:51:11 +00001//===- MipsInstrFPU.td - Mips FPU Instruction Information --*- tablegen -*-===//
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +00002//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
Akira Hatanaka4552c9a2011-04-15 21:51:11 +00008//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +00009//
Eric Christopher49ac3d72011-05-09 18:16:46 +000010// This file describes the Mips FPU instruction set.
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000011//
Akira Hatanaka4552c9a2011-04-15 21:51:11 +000012//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000013
Akira Hatanaka4552c9a2011-04-15 21:51:11 +000014//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes7b76da12008-07-09 04:45:36 +000015// Floating Point Instructions
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000016// ------------------------
17// * 64bit fp:
18// - 32 64-bit registers (default mode)
19// - 16 even 32-bit registers (32-bit compatible mode) for
20// single and double access.
21// * 32bit fp:
22// - 16 even 32-bit registers - single and double (aliased)
23// - 32 32-bit registers (within single-only mode)
Akira Hatanaka4552c9a2011-04-15 21:51:11 +000024//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000025
Bruno Cardoso Lopes7b76da12008-07-09 04:45:36 +000026// Floating Point Compare and Branch
Akira Hatanaka1d6b38d2011-03-31 18:26:17 +000027def SDT_MipsFPBrcond : SDTypeProfile<0, 2, [SDTCisInt<0>,
28 SDTCisVT<1, OtherVT>]>;
29def SDT_MipsFPCmp : SDTypeProfile<0, 3, [SDTCisSameAs<0, 1>, SDTCisFP<1>,
Akira Hatanaka40eda462011-09-22 23:31:54 +000030 SDTCisVT<2, i32>]>;
Akira Hatanaka1d6b38d2011-03-31 18:26:17 +000031def SDT_MipsCMovFP : SDTypeProfile<1, 2, [SDTCisSameAs<0, 1>,
32 SDTCisSameAs<1, 2>]>;
Akira Hatanaka99a2e982011-04-15 19:52:08 +000033def SDT_MipsBuildPairF64 : SDTypeProfile<1, 2, [SDTCisVT<0, f64>,
34 SDTCisVT<1, i32>,
35 SDTCisSameAs<1, 2>]>;
36def SDT_MipsExtractElementF64 : SDTypeProfile<1, 2, [SDTCisVT<0, i32>,
37 SDTCisVT<1, f64>,
Akira Hatanaka40eda462011-09-22 23:31:54 +000038 SDTCisVT<2, i32>]>;
Bruno Cardoso Lopesd3bdf192009-05-27 17:23:44 +000039
Akira Hatanaka1d6b38d2011-03-31 18:26:17 +000040def MipsFPCmp : SDNode<"MipsISD::FPCmp", SDT_MipsFPCmp, [SDNPOutGlue]>;
41def MipsCMovFP_T : SDNode<"MipsISD::CMovFP_T", SDT_MipsCMovFP, [SDNPInGlue]>;
42def MipsCMovFP_F : SDNode<"MipsISD::CMovFP_F", SDT_MipsCMovFP, [SDNPInGlue]>;
Bruno Cardoso Lopes81092dc2011-03-04 17:51:39 +000043def MipsFPBrcond : SDNode<"MipsISD::FPBrcond", SDT_MipsFPBrcond,
Akira Hatanaka1d6b38d2011-03-31 18:26:17 +000044 [SDNPHasChain, SDNPOptInGlue]>;
Akira Hatanaka99a2e982011-04-15 19:52:08 +000045def MipsBuildPairF64 : SDNode<"MipsISD::BuildPairF64", SDT_MipsBuildPairF64>;
46def MipsExtractElementF64 : SDNode<"MipsISD::ExtractElementF64",
47 SDT_MipsExtractElementF64>;
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000048
49// Operand for printing out a condition code.
50let PrintMethod = "printFCCOperand" in
51 def condcode : Operand<i32>;
52
Akira Hatanaka4552c9a2011-04-15 21:51:11 +000053//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000054// Feature predicates.
Akira Hatanaka4552c9a2011-04-15 21:51:11 +000055//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000056
Akira Hatanakaaa757902011-09-28 18:11:19 +000057def IsFP64bit : Predicate<"Subtarget.isFP64bit()">;
58def NotFP64bit : Predicate<"!Subtarget.isFP64bit()">;
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000059def IsSingleFloat : Predicate<"Subtarget.isSingleFloat()">;
60def IsNotSingleFloat : Predicate<"!Subtarget.isSingleFloat()">;
61
Akira Hatanaka4552c9a2011-04-15 21:51:11 +000062//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000063// Instruction Class Templates
64//
Bruno Cardoso Lopes81092dc2011-03-04 17:51:39 +000065// A set of multiclasses is used to address the register usage.
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000066//
Jakob Stoklund Olesen5cd4ee72011-09-28 23:59:28 +000067// S32 - single precision in 16 32bit even fp registers
Bruno Cardoso Lopesbdfbb742009-03-21 00:05:07 +000068// single precision in 32 32bit fp registers in SingleOnly mode
Jakob Stoklund Olesen5cd4ee72011-09-28 23:59:28 +000069// S64 - single precision in 32 64bit fp registers (In64BitMode)
Bruno Cardoso Lopesbdfbb742009-03-21 00:05:07 +000070// D32 - double precision in 16 32bit even fp registers
71// D64 - double precision in 32 64bit fp registers (In64BitMode)
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000072//
Jakob Stoklund Olesen5cd4ee72011-09-28 23:59:28 +000073// Only S32 and D32 are supported right now.
Akira Hatanaka4552c9a2011-04-15 21:51:11 +000074//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000075
Akira Hatanaka1acb7df2011-10-11 01:12:52 +000076// FP load.
77class FPLoad<bits<6> op, string opstr, PatFrag FOp, RegisterClass RC,
78 Operand MemOpnd>:
79 FFI<op, (outs RC:$ft), (ins MemOpnd:$base),
80 !strconcat(opstr, "\t$ft, $base"), [(set RC:$ft, (FOp addr:$base))]>;
81
82// FP store.
83class FPStore<bits<6> op, string opstr, PatFrag FOp, RegisterClass RC,
84 Operand MemOpnd>:
85 FFI<op, (outs), (ins RC:$ft, MemOpnd:$base),
86 !strconcat(opstr, "\t$ft, $base"), [(store RC:$ft, addr:$base)]>;
87
Akira Hatanakaa8de1c12011-10-08 03:19:38 +000088// Instructions that convert an FP value to 32-bit fixed point.
89multiclass FFR1_W_M<bits<6> funct, string opstr> {
90 def _S : FFR1<funct, 16, opstr, "w.s", FGR32, FGR32>;
91 def _D32 : FFR1<funct, 17, opstr, "w.d", FGR32, AFGR64>,
92 Requires<[NotFP64bit]>;
93 def _D64 : FFR1<funct, 17, opstr, "w.d", FGR32, FGR64>,
94 Requires<[IsFP64bit]>;
95}
Jakob Stoklund Olesen5cd4ee72011-09-28 23:59:28 +000096
Akira Hatanakaa8de1c12011-10-08 03:19:38 +000097// Instructions that convert an FP value to 64-bit fixed point.
98let Predicates = [IsFP64bit] in
99multiclass FFR1_L_M<bits<6> funct, string opstr> {
100 def _S : FFR1<funct, 16, opstr, "l.s", FGR64, FGR32>;
101 def _D64 : FFR1<funct, 17, opstr, "l.d", FGR64, FGR64>;
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +0000102}
103
Akira Hatanakabfca0792011-10-08 03:29:22 +0000104// FP-to-FP conversion instructions.
105multiclass FFR1P_M<bits<6> funct, string opstr, SDNode OpNode> {
106 def _S : FFR1P<funct, 16, opstr, "s", FGR32, FGR32, OpNode>;
107 def _D32 : FFR1P<funct, 17, opstr, "d", AFGR64, AFGR64, OpNode>,
108 Requires<[NotFP64bit]>;
109 def _D64 : FFR1P<funct, 17, opstr, "d", FGR64, FGR64, OpNode>,
110 Requires<[IsFP64bit]>;
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +0000111}
112
Akira Hatanakac9289f62011-10-08 03:38:41 +0000113multiclass FFR2P_M<bits<6> funct, string opstr, SDNode OpNode, bit isComm = 0> {
Jakob Stoklund Olesen5cd4ee72011-09-28 23:59:28 +0000114 let isCommutable = isComm in {
Akira Hatanakac9289f62011-10-08 03:38:41 +0000115 def _S : FFR2P<funct, 16, opstr, "s", FGR32, OpNode>;
116 def _D32 : FFR2P<funct, 17, opstr, "d", AFGR64, OpNode>,
117 Requires<[NotFP64bit]>;
118 def _D64 : FFR2P<funct, 17, opstr, "d", FGR64, OpNode>,
119 Requires<[IsFP64bit]>;
Jakob Stoklund Olesen5cd4ee72011-09-28 23:59:28 +0000120 }
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +0000121}
122
Akira Hatanaka4552c9a2011-04-15 21:51:11 +0000123//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes7b76da12008-07-09 04:45:36 +0000124// Floating Point Instructions
Akira Hatanaka4552c9a2011-04-15 21:51:11 +0000125//===----------------------------------------------------------------------===//
Akira Hatanakaa8de1c12011-10-08 03:19:38 +0000126defm ROUND_W : FFR1_W_M<0xc, "round">;
127defm ROUND_L : FFR1_L_M<0x8, "round">;
128defm TRUNC_W : FFR1_W_M<0xd, "trunc">;
129defm TRUNC_L : FFR1_L_M<0x9, "trunc">;
130defm CEIL_W : FFR1_W_M<0xe, "ceil">;
131defm CEIL_L : FFR1_L_M<0xa, "ceil">;
132defm FLOOR_W : FFR1_W_M<0xf, "floor">;
133defm FLOOR_L : FFR1_L_M<0xb, "floor">;
134defm CVT_W : FFR1_W_M<0x24, "cvt">;
135defm CVT_L : FFR1_L_M<0x25, "cvt">;
136
137def CVT_S_W : FFR1<0x20, 20, "cvt", "s.w", FGR32, FGR32>;
138
139let Predicates = [NotFP64bit] in {
140 def CVT_S_D32 : FFR1<0x20, 17, "cvt", "s.d", FGR32, AFGR64>;
141 def CVT_D32_W : FFR1<0x21, 20, "cvt", "d.w", AFGR64, FGR32>;
142 def CVT_D32_S : FFR1<0x21, 16, "cvt", "d.s", AFGR64, FGR32>;
143}
144
145let Predicates = [IsFP64bit] in {
146 def CVT_S_D64 : FFR1<0x20, 17, "cvt", "s.d", FGR32, FGR64>;
147 def CVT_S_L : FFR1<0x20, 21, "cvt", "s.l", FGR32, FGR64>;
148 def CVT_D64_W : FFR1<0x21, 20, "cvt", "d.w", FGR64, FGR32>;
149 def CVT_D64_S : FFR1<0x21, 16, "cvt", "d.s", FGR64, FGR32>;
150 def CVT_D64_L : FFR1<0x21, 21, "cvt", "d.l", FGR64, FGR64>;
151}
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +0000152
Akira Hatanakabfca0792011-10-08 03:29:22 +0000153defm FABS : FFR1P_M<0x5, "abs", fabs>;
154defm FNEG : FFR1P_M<0x7, "neg", fneg>;
155defm FSQRT : FFR1P_M<0x4, "sqrt", fsqrt>;
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +0000156
157// The odd-numbered registers are only referenced when doing loads,
158// stores, and moves between floating-point and integer registers.
Bruno Cardoso Lopes81092dc2011-03-04 17:51:39 +0000159// When defining instructions, we reference all 32-bit registers,
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +0000160// regardless of register aliasing.
161let fd = 0 in {
162 /// Move Control Registers From/To CPU Registers
Bruno Cardoso Lopesd3bdf192009-05-27 17:23:44 +0000163 def CFC1 : FFR<0x11, 0x0, 0x2, (outs CPURegs:$rt), (ins CCR:$fs),
Akira Hatanakaffe9a712011-06-07 18:16:51 +0000164 "cfc1\t$rt, $fs", []>;
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +0000165
Bruno Cardoso Lopesd3bdf192009-05-27 17:23:44 +0000166 def CTC1 : FFR<0x11, 0x0, 0x6, (outs CCR:$rt), (ins CPURegs:$fs),
Akira Hatanakaffe9a712011-06-07 18:16:51 +0000167 "ctc1\t$fs, $rt", []>;
Bruno Cardoso Lopes81092dc2011-03-04 17:51:39 +0000168
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +0000169 def MFC1 : FFR<0x11, 0x00, 0x00, (outs CPURegs:$rt), (ins FGR32:$fs),
Akira Hatanaka8eea4612011-09-27 22:01:01 +0000170 "mfc1\t$rt, $fs",
171 [(set CPURegs:$rt, (bitconvert FGR32:$fs))]>;
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +0000172
173 def MTC1 : FFR<0x11, 0x00, 0x04, (outs FGR32:$fs), (ins CPURegs:$rt),
Akira Hatanaka8eea4612011-09-27 22:01:01 +0000174 "mtc1\t$rt, $fs",
175 [(set FGR32:$fs, (bitconvert CPURegs:$rt))]>;
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +0000176}
177
Akira Hatanaka4391bb72011-10-08 03:50:18 +0000178def FMOV_S : FFR1<0x6, 16, "mov", "s", FGR32, FGR32>;
179def FMOV_D32 : FFR1<0x6, 17, "mov", "d", AFGR64, AFGR64>,
180 Requires<[NotFP64bit]>;
181def FMOV_D64 : FFR1<0x6, 17, "mov", "d", FGR64, FGR64>,
182 Requires<[IsFP64bit]>;
Bruno Cardoso Lopes5e194602010-01-30 18:29:19 +0000183
Bruno Cardoso Lopes7b76da12008-07-09 04:45:36 +0000184/// Floating Point Memory Instructions
Akira Hatanaka1acb7df2011-10-11 01:12:52 +0000185let Predicates = [IsN64] in {
186 def LWC1_P8 : FPLoad<0x31, "lwc1", load, FGR32, mem64>;
187 def SWC1_P8 : FPStore<0x39, "swc1", store, FGR32, mem64>;
188 def LDC164_P8 : FPLoad<0x35, "ldc1", load, FGR64, mem64>;
189 def SDC164_P8 : FPStore<0x3d, "sdc1", store, FGR64, mem64>;
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +0000190}
191
Akira Hatanaka1acb7df2011-10-11 01:12:52 +0000192let Predicates = [NotN64] in {
193 def LWC1 : FPLoad<0x31, "lwc1", load, FGR32, mem>;
194 def SWC1 : FPStore<0x39, "swc1", store, FGR32, mem>;
195 let Predicates = [HasMips64] in {
196 def LDC164 : FPLoad<0x35, "ldc1", load, FGR64, mem>;
197 def SDC164 : FPStore<0x3d, "sdc1", store, FGR64, mem>;
198 }
199 let Predicates = [NotMips64] in {
200 def LDC1 : FPLoad<0x35, "ldc1", load, AFGR64, mem>;
201 def SDC1 : FPStore<0x3d, "sdc1", store, AFGR64, mem>;
202 }
203}
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +0000204
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +0000205/// Floating-point Aritmetic
Akira Hatanakac9289f62011-10-08 03:38:41 +0000206defm FADD : FFR2P_M<0x10, "add", fadd, 1>;
207defm FDIV : FFR2P_M<0x03, "div", fdiv>;
208defm FMUL : FFR2P_M<0x02, "mul", fmul, 1>;
209defm FSUB : FFR2P_M<0x01, "sub", fsub>;
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +0000210
Akira Hatanaka4552c9a2011-04-15 21:51:11 +0000211//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes7b76da12008-07-09 04:45:36 +0000212// Floating Point Branch Codes
Akira Hatanaka4552c9a2011-04-15 21:51:11 +0000213//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes81092dc2011-03-04 17:51:39 +0000214// Mips branch codes. These correspond to condcode in MipsInstrInfo.h.
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +0000215// They must be kept in synch.
216def MIPS_BRANCH_F : PatLeaf<(i32 0)>;
217def MIPS_BRANCH_T : PatLeaf<(i32 1)>;
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +0000218
Bruno Cardoso Lopes7b76da12008-07-09 04:45:36 +0000219/// Floating Point Branch of False/True (Likely)
Akira Hatanaka1d6b38d2011-03-31 18:26:17 +0000220let isBranch=1, isTerminator=1, hasDelaySlot=1, base=0x8, Uses=[FCR31] in
Bruno Cardoso Lopes81092dc2011-03-04 17:51:39 +0000221 class FBRANCH<PatLeaf op, string asmstr> : FFI<0x11, (outs),
Akira Hatanakaffe9a712011-06-07 18:16:51 +0000222 (ins brtarget:$dst), !strconcat(asmstr, "\t$dst"),
Akira Hatanaka1d6b38d2011-03-31 18:26:17 +0000223 [(MipsFPBrcond op, bb:$dst)]>;
224
Bruno Cardoso Lopes85e31e32008-07-28 19:11:24 +0000225def BC1F : FBRANCH<MIPS_BRANCH_F, "bc1f">;
226def BC1T : FBRANCH<MIPS_BRANCH_T, "bc1t">;
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +0000227
Akira Hatanaka4552c9a2011-04-15 21:51:11 +0000228//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes7b76da12008-07-09 04:45:36 +0000229// Floating Point Flag Conditions
Akira Hatanaka4552c9a2011-04-15 21:51:11 +0000230//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes81092dc2011-03-04 17:51:39 +0000231// Mips condition codes. They must correspond to condcode in MipsInstrInfo.h.
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +0000232// They must be kept in synch.
233def MIPS_FCOND_F : PatLeaf<(i32 0)>;
234def MIPS_FCOND_UN : PatLeaf<(i32 1)>;
Akira Hatanaka1d6b38d2011-03-31 18:26:17 +0000235def MIPS_FCOND_OEQ : PatLeaf<(i32 2)>;
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +0000236def MIPS_FCOND_UEQ : PatLeaf<(i32 3)>;
237def MIPS_FCOND_OLT : PatLeaf<(i32 4)>;
238def MIPS_FCOND_ULT : PatLeaf<(i32 5)>;
239def MIPS_FCOND_OLE : PatLeaf<(i32 6)>;
240def MIPS_FCOND_ULE : PatLeaf<(i32 7)>;
241def MIPS_FCOND_SF : PatLeaf<(i32 8)>;
242def MIPS_FCOND_NGLE : PatLeaf<(i32 9)>;
243def MIPS_FCOND_SEQ : PatLeaf<(i32 10)>;
244def MIPS_FCOND_NGL : PatLeaf<(i32 11)>;
245def MIPS_FCOND_LT : PatLeaf<(i32 12)>;
246def MIPS_FCOND_NGE : PatLeaf<(i32 13)>;
247def MIPS_FCOND_LE : PatLeaf<(i32 14)>;
248def MIPS_FCOND_NGT : PatLeaf<(i32 15)>;
249
250/// Floating Point Compare
Akira Hatanaka8ddf6532011-09-09 20:45:50 +0000251let Defs=[FCR31] in {
Jakob Stoklund Olesen5cd4ee72011-09-28 23:59:28 +0000252 def FCMP_S32 : FCC<0x0, (outs), (ins FGR32:$fs, FGR32:$ft, condcode:$cc),
Akira Hatanakaffe9a712011-06-07 18:16:51 +0000253 "c.$cc.s\t$fs, $ft",
Akira Hatanaka1d6b38d2011-03-31 18:26:17 +0000254 [(MipsFPCmp FGR32:$fs, FGR32:$ft, imm:$cc)]>;
Bruno Cardoso Lopes81092dc2011-03-04 17:51:39 +0000255
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +0000256 def FCMP_D32 : FCC<0x1, (outs), (ins AFGR64:$fs, AFGR64:$ft, condcode:$cc),
Akira Hatanakaffe9a712011-06-07 18:16:51 +0000257 "c.$cc.d\t$fs, $ft",
Akira Hatanaka1d6b38d2011-03-31 18:26:17 +0000258 [(MipsFPCmp AFGR64:$fs, AFGR64:$ft, imm:$cc)]>,
Akira Hatanakaaa757902011-09-28 18:11:19 +0000259 Requires<[NotFP64bit]>;
Akira Hatanaka1d6b38d2011-03-31 18:26:17 +0000260}
261
Akira Hatanaka4552c9a2011-04-15 21:51:11 +0000262//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes6d399bd2008-07-29 19:05:28 +0000263// Floating Point Pseudo-Instructions
Akira Hatanaka4552c9a2011-04-15 21:51:11 +0000264//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes81092dc2011-03-04 17:51:39 +0000265def MOVCCRToCCR : MipsPseudo<(outs CCR:$dst), (ins CCR:$src),
266 "# MOVCCRToCCR", []>;
Bruno Cardoso Lopesd3bdf192009-05-27 17:23:44 +0000267
Akira Hatanaka99a2e982011-04-15 19:52:08 +0000268// This pseudo instr gets expanded into 2 mtc1 instrs after register
269// allocation.
270def BuildPairF64 :
271 MipsPseudo<(outs AFGR64:$dst),
272 (ins CPURegs:$lo, CPURegs:$hi), "",
273 [(set AFGR64:$dst, (MipsBuildPairF64 CPURegs:$lo, CPURegs:$hi))]>;
274
275// This pseudo instr gets expanded into 2 mfc1 instrs after register
276// allocation.
277// if n is 0, lower part of src is extracted.
278// if n is 1, higher part of src is extracted.
279def ExtractElementF64 :
280 MipsPseudo<(outs CPURegs:$dst),
281 (ins AFGR64:$src, i32imm:$n), "",
282 [(set CPURegs:$dst,
283 (MipsExtractElementF64 AFGR64:$src, imm:$n))]>;
284
Akira Hatanaka4552c9a2011-04-15 21:51:11 +0000285//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes7b76da12008-07-09 04:45:36 +0000286// Floating Point Patterns
Akira Hatanaka4552c9a2011-04-15 21:51:11 +0000287//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes7030ae72008-07-30 19:00:31 +0000288def fpimm0 : PatLeaf<(fpimm), [{
Bruno Cardoso Lopes9089ba82009-11-11 23:09:33 +0000289 return N->isExactlyValue(+0.0);
290}]>;
291
292def fpimm0neg : PatLeaf<(fpimm), [{
293 return N->isExactlyValue(-0.0);
Bruno Cardoso Lopes7030ae72008-07-30 19:00:31 +0000294}]>;
295
Bruno Cardoso Lopesbdfbb742009-03-21 00:05:07 +0000296def : Pat<(f32 fpimm0), (MTC1 ZERO)>;
Akira Hatanakabfca0792011-10-08 03:29:22 +0000297def : Pat<(f32 fpimm0neg), (FNEG_S (MTC1 ZERO))>;
Bruno Cardoso Lopes7030ae72008-07-30 19:00:31 +0000298
Akira Hatanakaa8de1c12011-10-08 03:19:38 +0000299def : Pat<(f32 (sint_to_fp CPURegs:$src)), (CVT_S_W (MTC1 CPURegs:$src))>;
300def : Pat<(f64 (sint_to_fp CPURegs:$src)), (CVT_D32_W (MTC1 CPURegs:$src))>;
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +0000301
Akira Hatanakaa8de1c12011-10-08 03:19:38 +0000302def : Pat<(i32 (fp_to_sint FGR32:$src)), (MFC1 (TRUNC_W_S FGR32:$src))>;
Akira Hatanakaf89532f2011-05-23 22:16:43 +0000303def : Pat<(i32 (fp_to_sint AFGR64:$src)), (MFC1 (TRUNC_W_D32 AFGR64:$src))>;
Bruno Cardoso Lopes7030ae72008-07-30 19:00:31 +0000304
Akira Hatanakaaa757902011-09-28 18:11:19 +0000305let Predicates = [NotFP64bit] in {
Akira Hatanakaa8de1c12011-10-08 03:19:38 +0000306 def : Pat<(f32 (fround AFGR64:$src)), (CVT_S_D32 AFGR64:$src)>;
307 def : Pat<(f64 (fextend FGR32:$src)), (CVT_D32_S FGR32:$src)>;
Bruno Cardoso Lopesd3bdf192009-05-27 17:23:44 +0000308}
309