1*0b57cec5SDimitry Andric//===- X86InstrFPStack.td - FPU Instruction Set ------------*- tablegen -*-===// 2*0b57cec5SDimitry Andric// 3*0b57cec5SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*0b57cec5SDimitry Andric// See https://llvm.org/LICENSE.txt for license information. 5*0b57cec5SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*0b57cec5SDimitry Andric// 7*0b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 8*0b57cec5SDimitry Andric// 9*0b57cec5SDimitry Andric// This file describes the X86 x87 FPU instruction set, defining the 10*0b57cec5SDimitry Andric// instructions, and properties of the instructions which are needed for code 11*0b57cec5SDimitry Andric// generation, machine code emission, and analysis. 12*0b57cec5SDimitry Andric// 13*0b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 14*0b57cec5SDimitry Andric 15*0b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 16*0b57cec5SDimitry Andric// FPStack specific DAG Nodes. 17*0b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 18*0b57cec5SDimitry Andric 19*0b57cec5SDimitry Andricdef SDTX86Fld : SDTypeProfile<1, 1, [SDTCisFP<0>, 20*0b57cec5SDimitry Andric SDTCisPtrTy<1>]>; 21*0b57cec5SDimitry Andricdef SDTX86Fst : SDTypeProfile<0, 2, [SDTCisFP<0>, 22*0b57cec5SDimitry Andric SDTCisPtrTy<1>]>; 23*0b57cec5SDimitry Andricdef SDTX86Fild : SDTypeProfile<1, 1, [SDTCisFP<0>, SDTCisPtrTy<1>]>; 24*0b57cec5SDimitry Andricdef SDTX86Fist : SDTypeProfile<0, 2, [SDTCisFP<0>, SDTCisPtrTy<1>]>; 25*0b57cec5SDimitry Andricdef SDTX86Fnstsw : SDTypeProfile<1, 1, [SDTCisVT<0, i16>, SDTCisVT<1, i16>]>; 26*0b57cec5SDimitry Andric 27*0b57cec5SDimitry Andricdef SDTX86CwdStore : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>; 28*0b57cec5SDimitry Andric 29*0b57cec5SDimitry Andricdef X86fld : SDNode<"X86ISD::FLD", SDTX86Fld, 30*0b57cec5SDimitry Andric [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>; 31*0b57cec5SDimitry Andricdef X86fst : SDNode<"X86ISD::FST", SDTX86Fst, 32*0b57cec5SDimitry Andric [SDNPHasChain, SDNPInGlue, SDNPMayStore, 33*0b57cec5SDimitry Andric SDNPMemOperand]>; 34*0b57cec5SDimitry Andricdef X86fild : SDNode<"X86ISD::FILD", SDTX86Fild, 35*0b57cec5SDimitry Andric [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>; 36*0b57cec5SDimitry Andricdef X86fildflag : SDNode<"X86ISD::FILD_FLAG", SDTX86Fild, 37*0b57cec5SDimitry Andric [SDNPHasChain, SDNPOutGlue, SDNPMayLoad, 38*0b57cec5SDimitry Andric SDNPMemOperand]>; 39*0b57cec5SDimitry Andricdef X86fist : SDNode<"X86ISD::FIST", SDTX86Fist, 40*0b57cec5SDimitry Andric [SDNPHasChain, SDNPInGlue, SDNPMayStore, 41*0b57cec5SDimitry Andric SDNPMemOperand]>; 42*0b57cec5SDimitry Andricdef X86fp_stsw : SDNode<"X86ISD::FNSTSW16r", SDTX86Fnstsw>; 43*0b57cec5SDimitry Andricdef X86fp_to_mem : SDNode<"X86ISD::FP_TO_INT_IN_MEM", SDTX86Fst, 44*0b57cec5SDimitry Andric [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>; 45*0b57cec5SDimitry Andricdef X86fp_cwd_get16 : SDNode<"X86ISD::FNSTCW16m", SDTX86CwdStore, 46*0b57cec5SDimitry Andric [SDNPHasChain, SDNPMayStore, SDNPSideEffect, 47*0b57cec5SDimitry Andric SDNPMemOperand]>; 48*0b57cec5SDimitry Andric 49*0b57cec5SDimitry Andricdef X86fstf32 : PatFrag<(ops node:$val, node:$ptr), 50*0b57cec5SDimitry Andric (X86fst node:$val, node:$ptr), [{ 51*0b57cec5SDimitry Andric return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::f32; 52*0b57cec5SDimitry Andric}]>; 53*0b57cec5SDimitry Andricdef X86fstf64 : PatFrag<(ops node:$val, node:$ptr), 54*0b57cec5SDimitry Andric (X86fst node:$val, node:$ptr), [{ 55*0b57cec5SDimitry Andric return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::f64; 56*0b57cec5SDimitry Andric}]>; 57*0b57cec5SDimitry Andricdef X86fstf80 : PatFrag<(ops node:$val, node:$ptr), 58*0b57cec5SDimitry Andric (X86fst node:$val, node:$ptr), [{ 59*0b57cec5SDimitry Andric return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::f80; 60*0b57cec5SDimitry Andric}]>; 61*0b57cec5SDimitry Andric 62*0b57cec5SDimitry Andricdef X86fldf32 : PatFrag<(ops node:$ptr), (X86fld node:$ptr), [{ 63*0b57cec5SDimitry Andric return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::f32; 64*0b57cec5SDimitry Andric}]>; 65*0b57cec5SDimitry Andricdef X86fldf64 : PatFrag<(ops node:$ptr), (X86fld node:$ptr), [{ 66*0b57cec5SDimitry Andric return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::f64; 67*0b57cec5SDimitry Andric}]>; 68*0b57cec5SDimitry Andricdef X86fldf80 : PatFrag<(ops node:$ptr), (X86fld node:$ptr), [{ 69*0b57cec5SDimitry Andric return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::f80; 70*0b57cec5SDimitry Andric}]>; 71*0b57cec5SDimitry Andric 72*0b57cec5SDimitry Andricdef X86fild16 : PatFrag<(ops node:$ptr), (X86fild node:$ptr), [{ 73*0b57cec5SDimitry Andric return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i16; 74*0b57cec5SDimitry Andric}]>; 75*0b57cec5SDimitry Andricdef X86fild32 : PatFrag<(ops node:$ptr), (X86fild node:$ptr), [{ 76*0b57cec5SDimitry Andric return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i32; 77*0b57cec5SDimitry Andric}]>; 78*0b57cec5SDimitry Andricdef X86fild64 : PatFrag<(ops node:$ptr), (X86fild node:$ptr), [{ 79*0b57cec5SDimitry Andric return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i64; 80*0b57cec5SDimitry Andric}]>; 81*0b57cec5SDimitry Andric 82*0b57cec5SDimitry Andricdef X86fildflag64 : PatFrag<(ops node:$ptr), (X86fildflag node:$ptr), [{ 83*0b57cec5SDimitry Andric return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i64; 84*0b57cec5SDimitry Andric}]>; 85*0b57cec5SDimitry Andric 86*0b57cec5SDimitry Andricdef X86fist64 : PatFrag<(ops node:$val, node:$ptr), 87*0b57cec5SDimitry Andric (X86fist node:$val, node:$ptr), [{ 88*0b57cec5SDimitry Andric return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i64; 89*0b57cec5SDimitry Andric}]>; 90*0b57cec5SDimitry Andric 91*0b57cec5SDimitry Andricdef X86fp_to_i16mem : PatFrag<(ops node:$val, node:$ptr), 92*0b57cec5SDimitry Andric (X86fp_to_mem node:$val, node:$ptr), [{ 93*0b57cec5SDimitry Andric return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i16; 94*0b57cec5SDimitry Andric}]>; 95*0b57cec5SDimitry Andricdef X86fp_to_i32mem : PatFrag<(ops node:$val, node:$ptr), 96*0b57cec5SDimitry Andric (X86fp_to_mem node:$val, node:$ptr), [{ 97*0b57cec5SDimitry Andric return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i32; 98*0b57cec5SDimitry Andric}]>; 99*0b57cec5SDimitry Andricdef X86fp_to_i64mem : PatFrag<(ops node:$val, node:$ptr), 100*0b57cec5SDimitry Andric (X86fp_to_mem node:$val, node:$ptr), [{ 101*0b57cec5SDimitry Andric return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i64; 102*0b57cec5SDimitry Andric}]>; 103*0b57cec5SDimitry Andric 104*0b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 105*0b57cec5SDimitry Andric// FPStack pattern fragments 106*0b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 107*0b57cec5SDimitry Andric 108*0b57cec5SDimitry Andricdef fpimm0 : FPImmLeaf<fAny, [{ 109*0b57cec5SDimitry Andric return Imm.isExactlyValue(+0.0); 110*0b57cec5SDimitry Andric}]>; 111*0b57cec5SDimitry Andric 112*0b57cec5SDimitry Andricdef fpimmneg0 : FPImmLeaf<fAny, [{ 113*0b57cec5SDimitry Andric return Imm.isExactlyValue(-0.0); 114*0b57cec5SDimitry Andric}]>; 115*0b57cec5SDimitry Andric 116*0b57cec5SDimitry Andricdef fpimm1 : FPImmLeaf<fAny, [{ 117*0b57cec5SDimitry Andric return Imm.isExactlyValue(+1.0); 118*0b57cec5SDimitry Andric}]>; 119*0b57cec5SDimitry Andric 120*0b57cec5SDimitry Andricdef fpimmneg1 : FPImmLeaf<fAny, [{ 121*0b57cec5SDimitry Andric return Imm.isExactlyValue(-1.0); 122*0b57cec5SDimitry Andric}]>; 123*0b57cec5SDimitry Andric 124*0b57cec5SDimitry Andric// Some 'special' instructions - expanded after instruction selection. 125*0b57cec5SDimitry Andric// Clobbers EFLAGS due to OR instruction used internally. 126*0b57cec5SDimitry Andric// FIXME: Can we model this in SelectionDAG? 127*0b57cec5SDimitry Andriclet usesCustomInserter = 1, hasNoSchedulingInfo = 1, Defs = [EFLAGS] in { 128*0b57cec5SDimitry Andric def FP32_TO_INT16_IN_MEM : PseudoI<(outs), (ins i16mem:$dst, RFP32:$src), 129*0b57cec5SDimitry Andric [(X86fp_to_i16mem RFP32:$src, addr:$dst)]>; 130*0b57cec5SDimitry Andric def FP32_TO_INT32_IN_MEM : PseudoI<(outs), (ins i32mem:$dst, RFP32:$src), 131*0b57cec5SDimitry Andric [(X86fp_to_i32mem RFP32:$src, addr:$dst)]>; 132*0b57cec5SDimitry Andric def FP32_TO_INT64_IN_MEM : PseudoI<(outs), (ins i64mem:$dst, RFP32:$src), 133*0b57cec5SDimitry Andric [(X86fp_to_i64mem RFP32:$src, addr:$dst)]>; 134*0b57cec5SDimitry Andric def FP64_TO_INT16_IN_MEM : PseudoI<(outs), (ins i16mem:$dst, RFP64:$src), 135*0b57cec5SDimitry Andric [(X86fp_to_i16mem RFP64:$src, addr:$dst)]>; 136*0b57cec5SDimitry Andric def FP64_TO_INT32_IN_MEM : PseudoI<(outs), (ins i32mem:$dst, RFP64:$src), 137*0b57cec5SDimitry Andric [(X86fp_to_i32mem RFP64:$src, addr:$dst)]>; 138*0b57cec5SDimitry Andric def FP64_TO_INT64_IN_MEM : PseudoI<(outs), (ins i64mem:$dst, RFP64:$src), 139*0b57cec5SDimitry Andric [(X86fp_to_i64mem RFP64:$src, addr:$dst)]>; 140*0b57cec5SDimitry Andric def FP80_TO_INT16_IN_MEM : PseudoI<(outs), (ins i16mem:$dst, RFP80:$src), 141*0b57cec5SDimitry Andric [(X86fp_to_i16mem RFP80:$src, addr:$dst)]>; 142*0b57cec5SDimitry Andric def FP80_TO_INT32_IN_MEM : PseudoI<(outs), (ins i32mem:$dst, RFP80:$src), 143*0b57cec5SDimitry Andric [(X86fp_to_i32mem RFP80:$src, addr:$dst)]>; 144*0b57cec5SDimitry Andric def FP80_TO_INT64_IN_MEM : PseudoI<(outs), (ins i64mem:$dst, RFP80:$src), 145*0b57cec5SDimitry Andric [(X86fp_to_i64mem RFP80:$src, addr:$dst)]>; 146*0b57cec5SDimitry Andric} 147*0b57cec5SDimitry Andric 148*0b57cec5SDimitry Andric// All FP Stack operations are represented with four instructions here. The 149*0b57cec5SDimitry Andric// first three instructions, generated by the instruction selector, use "RFP32" 150*0b57cec5SDimitry Andric// "RFP64" or "RFP80" registers: traditional register files to reference 32-bit, 151*0b57cec5SDimitry Andric// 64-bit or 80-bit floating point values. These sizes apply to the values, 152*0b57cec5SDimitry Andric// not the registers, which are always 80 bits; RFP32, RFP64 and RFP80 can be 153*0b57cec5SDimitry Andric// copied to each other without losing information. These instructions are all 154*0b57cec5SDimitry Andric// pseudo instructions and use the "_Fp" suffix. 155*0b57cec5SDimitry Andric// In some cases there are additional variants with a mixture of different 156*0b57cec5SDimitry Andric// register sizes. 157*0b57cec5SDimitry Andric// The second instruction is defined with FPI, which is the actual instruction 158*0b57cec5SDimitry Andric// emitted by the assembler. These use "RST" registers, although frequently 159*0b57cec5SDimitry Andric// the actual register(s) used are implicit. These are always 80 bits. 160*0b57cec5SDimitry Andric// The FP stackifier pass converts one to the other after register allocation 161*0b57cec5SDimitry Andric// occurs. 162*0b57cec5SDimitry Andric// 163*0b57cec5SDimitry Andric// Note that the FpI instruction should have instruction selection info (e.g. 164*0b57cec5SDimitry Andric// a pattern) and the FPI instruction should have emission info (e.g. opcode 165*0b57cec5SDimitry Andric// encoding and asm printing info). 166*0b57cec5SDimitry Andric 167*0b57cec5SDimitry Andric// FpIf32, FpIf64 - Floating Point Pseudo Instruction template. 168*0b57cec5SDimitry Andric// f32 instructions can use SSE1 and are predicated on FPStackf32 == !SSE1. 169*0b57cec5SDimitry Andric// f64 instructions can use SSE2 and are predicated on FPStackf64 == !SSE2. 170*0b57cec5SDimitry Andric// f80 instructions cannot use SSE and use neither of these. 171*0b57cec5SDimitry Andricclass FpIf32<dag outs, dag ins, FPFormat fp, list<dag> pattern> : 172*0b57cec5SDimitry Andric FpI_<outs, ins, fp, pattern>, Requires<[FPStackf32]>; 173*0b57cec5SDimitry Andricclass FpIf64<dag outs, dag ins, FPFormat fp, list<dag> pattern> : 174*0b57cec5SDimitry Andric FpI_<outs, ins, fp, pattern>, Requires<[FPStackf64]>; 175*0b57cec5SDimitry Andric 176*0b57cec5SDimitry Andric// Factoring for arithmetic. 177*0b57cec5SDimitry Andricmulticlass FPBinary_rr<SDNode OpNode> { 178*0b57cec5SDimitry Andric// Register op register -> register 179*0b57cec5SDimitry Andric// These are separated out because they have no reversed form. 180*0b57cec5SDimitry Andricdef _Fp32 : FpIf32<(outs RFP32:$dst), (ins RFP32:$src1, RFP32:$src2), TwoArgFP, 181*0b57cec5SDimitry Andric [(set RFP32:$dst, (OpNode RFP32:$src1, RFP32:$src2))]>; 182*0b57cec5SDimitry Andricdef _Fp64 : FpIf64<(outs RFP64:$dst), (ins RFP64:$src1, RFP64:$src2), TwoArgFP, 183*0b57cec5SDimitry Andric [(set RFP64:$dst, (OpNode RFP64:$src1, RFP64:$src2))]>; 184*0b57cec5SDimitry Andricdef _Fp80 : FpI_<(outs RFP80:$dst), (ins RFP80:$src1, RFP80:$src2), TwoArgFP, 185*0b57cec5SDimitry Andric [(set RFP80:$dst, (OpNode RFP80:$src1, RFP80:$src2))]>; 186*0b57cec5SDimitry Andric} 187*0b57cec5SDimitry Andric// The FopST0 series are not included here because of the irregularities 188*0b57cec5SDimitry Andric// in where the 'r' goes in assembly output. 189*0b57cec5SDimitry Andric// These instructions cannot address 80-bit memory. 190*0b57cec5SDimitry Andricmulticlass FPBinary<SDNode OpNode, Format fp, string asmstring, 191*0b57cec5SDimitry Andric bit Forward = 1> { 192*0b57cec5SDimitry Andric// ST(0) = ST(0) + [mem] 193*0b57cec5SDimitry Andricdef _Fp32m : FpIf32<(outs RFP32:$dst), 194*0b57cec5SDimitry Andric (ins RFP32:$src1, f32mem:$src2), OneArgFPRW, 195*0b57cec5SDimitry Andric [!if(Forward, 196*0b57cec5SDimitry Andric (set RFP32:$dst, 197*0b57cec5SDimitry Andric (OpNode RFP32:$src1, (loadf32 addr:$src2))), 198*0b57cec5SDimitry Andric (set RFP32:$dst, 199*0b57cec5SDimitry Andric (OpNode (loadf32 addr:$src2), RFP32:$src1)))]>; 200*0b57cec5SDimitry Andricdef _Fp64m : FpIf64<(outs RFP64:$dst), 201*0b57cec5SDimitry Andric (ins RFP64:$src1, f64mem:$src2), OneArgFPRW, 202*0b57cec5SDimitry Andric [!if(Forward, 203*0b57cec5SDimitry Andric (set RFP64:$dst, 204*0b57cec5SDimitry Andric (OpNode RFP64:$src1, (loadf64 addr:$src2))), 205*0b57cec5SDimitry Andric (set RFP64:$dst, 206*0b57cec5SDimitry Andric (OpNode (loadf64 addr:$src2), RFP64:$src1)))]>; 207*0b57cec5SDimitry Andricdef _Fp64m32: FpIf64<(outs RFP64:$dst), 208*0b57cec5SDimitry Andric (ins RFP64:$src1, f32mem:$src2), OneArgFPRW, 209*0b57cec5SDimitry Andric [!if(Forward, 210*0b57cec5SDimitry Andric (set RFP64:$dst, 211*0b57cec5SDimitry Andric (OpNode RFP64:$src1, (f64 (extloadf32 addr:$src2)))), 212*0b57cec5SDimitry Andric (set RFP64:$dst, 213*0b57cec5SDimitry Andric (OpNode (f64 (extloadf32 addr:$src2)), RFP64:$src1)))]>; 214*0b57cec5SDimitry Andricdef _Fp80m32: FpI_<(outs RFP80:$dst), 215*0b57cec5SDimitry Andric (ins RFP80:$src1, f32mem:$src2), OneArgFPRW, 216*0b57cec5SDimitry Andric [!if(Forward, 217*0b57cec5SDimitry Andric (set RFP80:$dst, 218*0b57cec5SDimitry Andric (OpNode RFP80:$src1, (f80 (extloadf32 addr:$src2)))), 219*0b57cec5SDimitry Andric (set RFP80:$dst, 220*0b57cec5SDimitry Andric (OpNode (f80 (extloadf32 addr:$src2)), RFP80:$src1)))]>; 221*0b57cec5SDimitry Andricdef _Fp80m64: FpI_<(outs RFP80:$dst), 222*0b57cec5SDimitry Andric (ins RFP80:$src1, f64mem:$src2), OneArgFPRW, 223*0b57cec5SDimitry Andric [!if(Forward, 224*0b57cec5SDimitry Andric (set RFP80:$dst, 225*0b57cec5SDimitry Andric (OpNode RFP80:$src1, (f80 (extloadf64 addr:$src2)))), 226*0b57cec5SDimitry Andric (set RFP80:$dst, 227*0b57cec5SDimitry Andric (OpNode (f80 (extloadf64 addr:$src2)), RFP80:$src1)))]>; 228*0b57cec5SDimitry Andriclet mayLoad = 1 in 229*0b57cec5SDimitry Andricdef _F32m : FPI<0xD8, fp, (outs), (ins f32mem:$src), 230*0b57cec5SDimitry Andric !strconcat("f", asmstring, "{s}\t$src")>; 231*0b57cec5SDimitry Andriclet mayLoad = 1 in 232*0b57cec5SDimitry Andricdef _F64m : FPI<0xDC, fp, (outs), (ins f64mem:$src), 233*0b57cec5SDimitry Andric !strconcat("f", asmstring, "{l}\t$src")>; 234*0b57cec5SDimitry Andric// ST(0) = ST(0) + [memint] 235*0b57cec5SDimitry Andricdef _FpI16m32 : FpIf32<(outs RFP32:$dst), (ins RFP32:$src1, i16mem:$src2), 236*0b57cec5SDimitry Andric OneArgFPRW, 237*0b57cec5SDimitry Andric [!if(Forward, 238*0b57cec5SDimitry Andric (set RFP32:$dst, 239*0b57cec5SDimitry Andric (OpNode RFP32:$src1, (X86fild16 addr:$src2))), 240*0b57cec5SDimitry Andric (set RFP32:$dst, 241*0b57cec5SDimitry Andric (OpNode (X86fild16 addr:$src2), RFP32:$src1)))]>; 242*0b57cec5SDimitry Andricdef _FpI32m32 : FpIf32<(outs RFP32:$dst), (ins RFP32:$src1, i32mem:$src2), 243*0b57cec5SDimitry Andric OneArgFPRW, 244*0b57cec5SDimitry Andric [!if(Forward, 245*0b57cec5SDimitry Andric (set RFP32:$dst, 246*0b57cec5SDimitry Andric (OpNode RFP32:$src1, (X86fild32 addr:$src2))), 247*0b57cec5SDimitry Andric (set RFP32:$dst, 248*0b57cec5SDimitry Andric (OpNode (X86fild32 addr:$src2), RFP32:$src1)))]>; 249*0b57cec5SDimitry Andricdef _FpI16m64 : FpIf64<(outs RFP64:$dst), (ins RFP64:$src1, i16mem:$src2), 250*0b57cec5SDimitry Andric OneArgFPRW, 251*0b57cec5SDimitry Andric [!if(Forward, 252*0b57cec5SDimitry Andric (set RFP64:$dst, 253*0b57cec5SDimitry Andric (OpNode RFP64:$src1, (X86fild16 addr:$src2))), 254*0b57cec5SDimitry Andric (set RFP64:$dst, 255*0b57cec5SDimitry Andric (OpNode (X86fild16 addr:$src2), RFP64:$src1)))]>; 256*0b57cec5SDimitry Andricdef _FpI32m64 : FpIf64<(outs RFP64:$dst), (ins RFP64:$src1, i32mem:$src2), 257*0b57cec5SDimitry Andric OneArgFPRW, 258*0b57cec5SDimitry Andric [!if(Forward, 259*0b57cec5SDimitry Andric (set RFP64:$dst, 260*0b57cec5SDimitry Andric (OpNode RFP64:$src1, (X86fild32 addr:$src2))), 261*0b57cec5SDimitry Andric (set RFP64:$dst, 262*0b57cec5SDimitry Andric (OpNode (X86fild32 addr:$src2), RFP64:$src1)))]>; 263*0b57cec5SDimitry Andricdef _FpI16m80 : FpI_<(outs RFP80:$dst), (ins RFP80:$src1, i16mem:$src2), 264*0b57cec5SDimitry Andric OneArgFPRW, 265*0b57cec5SDimitry Andric [!if(Forward, 266*0b57cec5SDimitry Andric (set RFP80:$dst, 267*0b57cec5SDimitry Andric (OpNode RFP80:$src1, (X86fild16 addr:$src2))), 268*0b57cec5SDimitry Andric (set RFP80:$dst, 269*0b57cec5SDimitry Andric (OpNode (X86fild16 addr:$src2), RFP80:$src1)))]>; 270*0b57cec5SDimitry Andricdef _FpI32m80 : FpI_<(outs RFP80:$dst), (ins RFP80:$src1, i32mem:$src2), 271*0b57cec5SDimitry Andric OneArgFPRW, 272*0b57cec5SDimitry Andric [!if(Forward, 273*0b57cec5SDimitry Andric (set RFP80:$dst, 274*0b57cec5SDimitry Andric (OpNode RFP80:$src1, (X86fild32 addr:$src2))), 275*0b57cec5SDimitry Andric (set RFP80:$dst, 276*0b57cec5SDimitry Andric (OpNode (X86fild32 addr:$src2), RFP80:$src1)))]>; 277*0b57cec5SDimitry Andriclet mayLoad = 1 in 278*0b57cec5SDimitry Andricdef _FI16m : FPI<0xDE, fp, (outs), (ins i16mem:$src), 279*0b57cec5SDimitry Andric !strconcat("fi", asmstring, "{s}\t$src")>; 280*0b57cec5SDimitry Andriclet mayLoad = 1 in 281*0b57cec5SDimitry Andricdef _FI32m : FPI<0xDA, fp, (outs), (ins i32mem:$src), 282*0b57cec5SDimitry Andric !strconcat("fi", asmstring, "{l}\t$src")>; 283*0b57cec5SDimitry Andric} 284*0b57cec5SDimitry Andric 285*0b57cec5SDimitry Andriclet Defs = [FPSW], Uses = [FPCW] in { 286*0b57cec5SDimitry Andric// FPBinary_rr just defines pseudo-instructions, no need to set a scheduling 287*0b57cec5SDimitry Andric// resources. 288*0b57cec5SDimitry Andriclet hasNoSchedulingInfo = 1 in { 289*0b57cec5SDimitry Andricdefm ADD : FPBinary_rr<fadd>; 290*0b57cec5SDimitry Andricdefm SUB : FPBinary_rr<fsub>; 291*0b57cec5SDimitry Andricdefm MUL : FPBinary_rr<fmul>; 292*0b57cec5SDimitry Andricdefm DIV : FPBinary_rr<fdiv>; 293*0b57cec5SDimitry Andric} 294*0b57cec5SDimitry Andric 295*0b57cec5SDimitry Andric// Sets the scheduling resources for the actual NAME#_F<size>m defintions. 296*0b57cec5SDimitry Andriclet SchedRW = [WriteFAddLd] in { 297*0b57cec5SDimitry Andricdefm ADD : FPBinary<fadd, MRM0m, "add">; 298*0b57cec5SDimitry Andricdefm SUB : FPBinary<fsub, MRM4m, "sub">; 299*0b57cec5SDimitry Andricdefm SUBR: FPBinary<fsub ,MRM5m, "subr", 0>; 300*0b57cec5SDimitry Andric} 301*0b57cec5SDimitry Andric 302*0b57cec5SDimitry Andriclet SchedRW = [WriteFMulLd] in { 303*0b57cec5SDimitry Andricdefm MUL : FPBinary<fmul, MRM1m, "mul">; 304*0b57cec5SDimitry Andric} 305*0b57cec5SDimitry Andric 306*0b57cec5SDimitry Andriclet SchedRW = [WriteFDivLd] in { 307*0b57cec5SDimitry Andricdefm DIV : FPBinary<fdiv, MRM6m, "div">; 308*0b57cec5SDimitry Andricdefm DIVR: FPBinary<fdiv, MRM7m, "divr", 0>; 309*0b57cec5SDimitry Andric} 310*0b57cec5SDimitry Andric} // Defs = [FPSW] 311*0b57cec5SDimitry Andric 312*0b57cec5SDimitry Andricclass FPST0rInst<Format fp, string asm> 313*0b57cec5SDimitry Andric : FPI<0xD8, fp, (outs), (ins RSTi:$op), asm>; 314*0b57cec5SDimitry Andricclass FPrST0Inst<Format fp, string asm> 315*0b57cec5SDimitry Andric : FPI<0xDC, fp, (outs), (ins RSTi:$op), asm>; 316*0b57cec5SDimitry Andricclass FPrST0PInst<Format fp, string asm> 317*0b57cec5SDimitry Andric : FPI<0xDE, fp, (outs), (ins RSTi:$op), asm>; 318*0b57cec5SDimitry Andric 319*0b57cec5SDimitry Andric// NOTE: GAS and apparently all other AT&T style assemblers have a broken notion 320*0b57cec5SDimitry Andric// of some of the 'reverse' forms of the fsub and fdiv instructions. As such, 321*0b57cec5SDimitry Andric// we have to put some 'r's in and take them out of weird places. 322*0b57cec5SDimitry Andriclet SchedRW = [WriteFAdd], Defs = [FPSW], Uses = [FPCW] in { 323*0b57cec5SDimitry Andricdef ADD_FST0r : FPST0rInst <MRM0r, "fadd\t{$op, %st|st, $op}">; 324*0b57cec5SDimitry Andricdef ADD_FrST0 : FPrST0Inst <MRM0r, "fadd\t{%st, $op|$op, st}">; 325*0b57cec5SDimitry Andricdef ADD_FPrST0 : FPrST0PInst<MRM0r, "faddp\t{%st, $op|$op, st}">; 326*0b57cec5SDimitry Andricdef SUBR_FST0r : FPST0rInst <MRM5r, "fsubr\t{$op, %st|st, $op}">; 327*0b57cec5SDimitry Andricdef SUB_FrST0 : FPrST0Inst <MRM5r, "fsub{r}\t{%st, $op|$op, st}">; 328*0b57cec5SDimitry Andricdef SUB_FPrST0 : FPrST0PInst<MRM5r, "fsub{r}p\t{%st, $op|$op, st}">; 329*0b57cec5SDimitry Andricdef SUB_FST0r : FPST0rInst <MRM4r, "fsub\t{$op, %st|st, $op}">; 330*0b57cec5SDimitry Andricdef SUBR_FrST0 : FPrST0Inst <MRM4r, "fsub{|r}\t{%st, $op|$op, st}">; 331*0b57cec5SDimitry Andricdef SUBR_FPrST0 : FPrST0PInst<MRM4r, "fsub{|r}p\t{%st, $op|$op, st}">; 332*0b57cec5SDimitry Andric} // SchedRW 333*0b57cec5SDimitry Andriclet SchedRW = [WriteFCom], Defs = [FPSW], Uses = [FPCW] in { 334*0b57cec5SDimitry Andricdef COM_FST0r : FPST0rInst <MRM2r, "fcom\t$op">; 335*0b57cec5SDimitry Andricdef COMP_FST0r : FPST0rInst <MRM3r, "fcomp\t$op">; 336*0b57cec5SDimitry Andric} // SchedRW 337*0b57cec5SDimitry Andriclet SchedRW = [WriteFMul], Defs = [FPSW], Uses = [FPCW] in { 338*0b57cec5SDimitry Andricdef MUL_FST0r : FPST0rInst <MRM1r, "fmul\t{$op, %st|st, $op}">; 339*0b57cec5SDimitry Andricdef MUL_FrST0 : FPrST0Inst <MRM1r, "fmul\t{%st, $op|$op, st}">; 340*0b57cec5SDimitry Andricdef MUL_FPrST0 : FPrST0PInst<MRM1r, "fmulp\t{%st, $op|$op, st}">; 341*0b57cec5SDimitry Andric} // SchedRW 342*0b57cec5SDimitry Andriclet SchedRW = [WriteFDiv], Defs = [FPSW], Uses = [FPCW] in { 343*0b57cec5SDimitry Andricdef DIVR_FST0r : FPST0rInst <MRM7r, "fdivr\t{$op, %st|st, $op}">; 344*0b57cec5SDimitry Andricdef DIV_FrST0 : FPrST0Inst <MRM7r, "fdiv{r}\t{%st, $op|$op, st}">; 345*0b57cec5SDimitry Andricdef DIV_FPrST0 : FPrST0PInst<MRM7r, "fdiv{r}p\t{%st, $op|$op, st}">; 346*0b57cec5SDimitry Andricdef DIV_FST0r : FPST0rInst <MRM6r, "fdiv\t{$op, %st|st, $op}">; 347*0b57cec5SDimitry Andricdef DIVR_FrST0 : FPrST0Inst <MRM6r, "fdiv{|r}\t{%st, $op|$op, st}">; 348*0b57cec5SDimitry Andricdef DIVR_FPrST0 : FPrST0PInst<MRM6r, "fdiv{|r}p\t{%st, $op|$op, st}">; 349*0b57cec5SDimitry Andric} // SchedRW 350*0b57cec5SDimitry Andric 351*0b57cec5SDimitry Andric// Unary operations. 352*0b57cec5SDimitry Andricmulticlass FPUnary<SDNode OpNode, Format fp, string asmstring> { 353*0b57cec5SDimitry Andricdef _Fp32 : FpIf32<(outs RFP32:$dst), (ins RFP32:$src), OneArgFPRW, 354*0b57cec5SDimitry Andric [(set RFP32:$dst, (OpNode RFP32:$src))]>; 355*0b57cec5SDimitry Andricdef _Fp64 : FpIf64<(outs RFP64:$dst), (ins RFP64:$src), OneArgFPRW, 356*0b57cec5SDimitry Andric [(set RFP64:$dst, (OpNode RFP64:$src))]>; 357*0b57cec5SDimitry Andricdef _Fp80 : FpI_<(outs RFP80:$dst), (ins RFP80:$src), OneArgFPRW, 358*0b57cec5SDimitry Andric [(set RFP80:$dst, (OpNode RFP80:$src))]>; 359*0b57cec5SDimitry Andricdef _F : FPI<0xD9, fp, (outs), (ins), asmstring>; 360*0b57cec5SDimitry Andric} 361*0b57cec5SDimitry Andric 362*0b57cec5SDimitry Andriclet Defs = [FPSW], Uses = [FPCW] in { 363*0b57cec5SDimitry Andric 364*0b57cec5SDimitry Andriclet SchedRW = [WriteFSign] in { 365*0b57cec5SDimitry Andricdefm CHS : FPUnary<fneg, MRM_E0, "fchs">; 366*0b57cec5SDimitry Andricdefm ABS : FPUnary<fabs, MRM_E1, "fabs">; 367*0b57cec5SDimitry Andric} 368*0b57cec5SDimitry Andric 369*0b57cec5SDimitry Andriclet SchedRW = [WriteFSqrt80] in 370*0b57cec5SDimitry Andricdefm SQRT: FPUnary<fsqrt,MRM_FA, "fsqrt">; 371*0b57cec5SDimitry Andric 372*0b57cec5SDimitry Andriclet SchedRW = [WriteMicrocoded] in { 373*0b57cec5SDimitry Andricdefm SIN : FPUnary<fsin, MRM_FE, "fsin">; 374*0b57cec5SDimitry Andricdefm COS : FPUnary<fcos, MRM_FF, "fcos">; 375*0b57cec5SDimitry Andric} 376*0b57cec5SDimitry Andric 377*0b57cec5SDimitry Andriclet SchedRW = [WriteFCom] in { 378*0b57cec5SDimitry Andriclet hasSideEffects = 0 in { 379*0b57cec5SDimitry Andricdef TST_Fp32 : FpIf32<(outs), (ins RFP32:$src), OneArgFP, []>; 380*0b57cec5SDimitry Andricdef TST_Fp64 : FpIf64<(outs), (ins RFP64:$src), OneArgFP, []>; 381*0b57cec5SDimitry Andricdef TST_Fp80 : FpI_<(outs), (ins RFP80:$src), OneArgFP, []>; 382*0b57cec5SDimitry Andric} // hasSideEffects 383*0b57cec5SDimitry Andric 384*0b57cec5SDimitry Andricdef TST_F : FPI<0xD9, MRM_E4, (outs), (ins), "ftst">; 385*0b57cec5SDimitry Andric} // SchedRW 386*0b57cec5SDimitry Andric} // Defs = [FPSW] 387*0b57cec5SDimitry Andric 388*0b57cec5SDimitry Andric// Versions of FP instructions that take a single memory operand. Added for the 389*0b57cec5SDimitry Andric// disassembler; remove as they are included with patterns elsewhere. 390*0b57cec5SDimitry Andriclet SchedRW = [WriteFComLd], Defs = [FPSW], Uses = [FPCW] in { 391*0b57cec5SDimitry Andricdef FCOM32m : FPI<0xD8, MRM2m, (outs), (ins f32mem:$src), "fcom{s}\t$src">; 392*0b57cec5SDimitry Andricdef FCOMP32m : FPI<0xD8, MRM3m, (outs), (ins f32mem:$src), "fcomp{s}\t$src">; 393*0b57cec5SDimitry Andric 394*0b57cec5SDimitry Andricdef FCOM64m : FPI<0xDC, MRM2m, (outs), (ins f64mem:$src), "fcom{l}\t$src">; 395*0b57cec5SDimitry Andricdef FCOMP64m : FPI<0xDC, MRM3m, (outs), (ins f64mem:$src), "fcomp{l}\t$src">; 396*0b57cec5SDimitry Andric 397*0b57cec5SDimitry Andricdef FICOM16m : FPI<0xDE, MRM2m, (outs), (ins i16mem:$src), "ficom{s}\t$src">; 398*0b57cec5SDimitry Andricdef FICOMP16m: FPI<0xDE, MRM3m, (outs), (ins i16mem:$src), "ficomp{s}\t$src">; 399*0b57cec5SDimitry Andric 400*0b57cec5SDimitry Andricdef FICOM32m : FPI<0xDA, MRM2m, (outs), (ins i32mem:$src), "ficom{l}\t$src">; 401*0b57cec5SDimitry Andricdef FICOMP32m: FPI<0xDA, MRM3m, (outs), (ins i32mem:$src), "ficomp{l}\t$src">; 402*0b57cec5SDimitry Andric} // SchedRW 403*0b57cec5SDimitry Andric 404*0b57cec5SDimitry Andriclet SchedRW = [WriteMicrocoded] in { 405*0b57cec5SDimitry Andricdef FLDENVm : FPI<0xD9, MRM4m, (outs), (ins f32mem:$src), "fldenv\t$src">; 406*0b57cec5SDimitry Andricdef FSTENVm : FPI<0xD9, MRM6m, (outs), (ins f32mem:$dst), "fnstenv\t$dst">; 407*0b57cec5SDimitry Andric 408*0b57cec5SDimitry Andricdef FRSTORm : FPI<0xDD, MRM4m, (outs), (ins f32mem:$dst), "frstor\t$dst">; 409*0b57cec5SDimitry Andricdef FSAVEm : FPI<0xDD, MRM6m, (outs), (ins f32mem:$dst), "fnsave\t$dst">; 410*0b57cec5SDimitry Andricdef FNSTSWm : FPI<0xDD, MRM7m, (outs), (ins i16mem:$dst), "fnstsw\t$dst">; 411*0b57cec5SDimitry Andric 412*0b57cec5SDimitry Andricdef FBLDm : FPI<0xDF, MRM4m, (outs), (ins f80mem:$src), "fbld\t$src">; 413*0b57cec5SDimitry Andricdef FBSTPm : FPI<0xDF, MRM6m, (outs), (ins f80mem:$dst), "fbstp\t$dst">; 414*0b57cec5SDimitry Andric} // SchedRW 415*0b57cec5SDimitry Andric 416*0b57cec5SDimitry Andric// Floating point cmovs. 417*0b57cec5SDimitry Andricclass FpIf32CMov<dag outs, dag ins, FPFormat fp, list<dag> pattern> : 418*0b57cec5SDimitry Andric FpI_<outs, ins, fp, pattern>, Requires<[FPStackf32, HasCMov]>; 419*0b57cec5SDimitry Andricclass FpIf64CMov<dag outs, dag ins, FPFormat fp, list<dag> pattern> : 420*0b57cec5SDimitry Andric FpI_<outs, ins, fp, pattern>, Requires<[FPStackf64, HasCMov]>; 421*0b57cec5SDimitry Andric 422*0b57cec5SDimitry Andricmulticlass FPCMov<PatLeaf cc> { 423*0b57cec5SDimitry Andric def _Fp32 : FpIf32CMov<(outs RFP32:$dst), (ins RFP32:$src1, RFP32:$src2), 424*0b57cec5SDimitry Andric CondMovFP, 425*0b57cec5SDimitry Andric [(set RFP32:$dst, (X86cmov RFP32:$src1, RFP32:$src2, 426*0b57cec5SDimitry Andric cc, EFLAGS))]>; 427*0b57cec5SDimitry Andric def _Fp64 : FpIf64CMov<(outs RFP64:$dst), (ins RFP64:$src1, RFP64:$src2), 428*0b57cec5SDimitry Andric CondMovFP, 429*0b57cec5SDimitry Andric [(set RFP64:$dst, (X86cmov RFP64:$src1, RFP64:$src2, 430*0b57cec5SDimitry Andric cc, EFLAGS))]>; 431*0b57cec5SDimitry Andric def _Fp80 : FpI_<(outs RFP80:$dst), (ins RFP80:$src1, RFP80:$src2), 432*0b57cec5SDimitry Andric CondMovFP, 433*0b57cec5SDimitry Andric [(set RFP80:$dst, (X86cmov RFP80:$src1, RFP80:$src2, 434*0b57cec5SDimitry Andric cc, EFLAGS))]>, 435*0b57cec5SDimitry Andric Requires<[HasCMov]>; 436*0b57cec5SDimitry Andric} 437*0b57cec5SDimitry Andric 438*0b57cec5SDimitry Andriclet Defs = [FPSW] in { 439*0b57cec5SDimitry Andriclet SchedRW = [WriteFCMOV] in { 440*0b57cec5SDimitry Andriclet Uses = [EFLAGS], Constraints = "$src1 = $dst" in { 441*0b57cec5SDimitry Andricdefm CMOVB : FPCMov<X86_COND_B>; 442*0b57cec5SDimitry Andricdefm CMOVBE : FPCMov<X86_COND_BE>; 443*0b57cec5SDimitry Andricdefm CMOVE : FPCMov<X86_COND_E>; 444*0b57cec5SDimitry Andricdefm CMOVP : FPCMov<X86_COND_P>; 445*0b57cec5SDimitry Andricdefm CMOVNB : FPCMov<X86_COND_AE>; 446*0b57cec5SDimitry Andricdefm CMOVNBE: FPCMov<X86_COND_A>; 447*0b57cec5SDimitry Andricdefm CMOVNE : FPCMov<X86_COND_NE>; 448*0b57cec5SDimitry Andricdefm CMOVNP : FPCMov<X86_COND_NP>; 449*0b57cec5SDimitry Andric} // Uses = [EFLAGS], Constraints = "$src1 = $dst" 450*0b57cec5SDimitry Andric 451*0b57cec5SDimitry Andriclet Predicates = [HasCMov] in { 452*0b57cec5SDimitry Andric// These are not factored because there's no clean way to pass DA/DB. 453*0b57cec5SDimitry Andricdef CMOVB_F : FPI<0xDA, MRM0r, (outs), (ins RSTi:$op), 454*0b57cec5SDimitry Andric "fcmovb\t{$op, %st|st, $op}">; 455*0b57cec5SDimitry Andricdef CMOVBE_F : FPI<0xDA, MRM2r, (outs), (ins RSTi:$op), 456*0b57cec5SDimitry Andric "fcmovbe\t{$op, %st|st, $op}">; 457*0b57cec5SDimitry Andricdef CMOVE_F : FPI<0xDA, MRM1r, (outs), (ins RSTi:$op), 458*0b57cec5SDimitry Andric "fcmove\t{$op, %st|st, $op}">; 459*0b57cec5SDimitry Andricdef CMOVP_F : FPI<0xDA, MRM3r, (outs), (ins RSTi:$op), 460*0b57cec5SDimitry Andric "fcmovu\t{$op, %st|st, $op}">; 461*0b57cec5SDimitry Andricdef CMOVNB_F : FPI<0xDB, MRM0r, (outs), (ins RSTi:$op), 462*0b57cec5SDimitry Andric "fcmovnb\t{$op, %st|st, $op}">; 463*0b57cec5SDimitry Andricdef CMOVNBE_F: FPI<0xDB, MRM2r, (outs), (ins RSTi:$op), 464*0b57cec5SDimitry Andric "fcmovnbe\t{$op, %st|st, $op}">; 465*0b57cec5SDimitry Andricdef CMOVNE_F : FPI<0xDB, MRM1r, (outs), (ins RSTi:$op), 466*0b57cec5SDimitry Andric "fcmovne\t{$op, %st|st, $op}">; 467*0b57cec5SDimitry Andricdef CMOVNP_F : FPI<0xDB, MRM3r, (outs), (ins RSTi:$op), 468*0b57cec5SDimitry Andric "fcmovnu\t{$op, %st|st, $op}">; 469*0b57cec5SDimitry Andric} // Predicates = [HasCMov] 470*0b57cec5SDimitry Andric} // SchedRW 471*0b57cec5SDimitry Andric 472*0b57cec5SDimitry Andric// Floating point loads & stores. 473*0b57cec5SDimitry Andriclet SchedRW = [WriteLoad], Uses = [FPCW] in { 474*0b57cec5SDimitry Andriclet canFoldAsLoad = 1 in { 475*0b57cec5SDimitry Andricdef LD_Fp32m : FpIf32<(outs RFP32:$dst), (ins f32mem:$src), ZeroArgFP, 476*0b57cec5SDimitry Andric [(set RFP32:$dst, (loadf32 addr:$src))]>; 477*0b57cec5SDimitry Andricdef LD_Fp64m : FpIf64<(outs RFP64:$dst), (ins f64mem:$src), ZeroArgFP, 478*0b57cec5SDimitry Andric [(set RFP64:$dst, (loadf64 addr:$src))]>; 479*0b57cec5SDimitry Andricdef LD_Fp80m : FpI_<(outs RFP80:$dst), (ins f80mem:$src), ZeroArgFP, 480*0b57cec5SDimitry Andric [(set RFP80:$dst, (loadf80 addr:$src))]>; 481*0b57cec5SDimitry Andric} // canFoldAsLoad 482*0b57cec5SDimitry Andricdef LD_Fp32m64 : FpIf64<(outs RFP64:$dst), (ins f32mem:$src), ZeroArgFP, 483*0b57cec5SDimitry Andric [(set RFP64:$dst, (f64 (extloadf32 addr:$src)))]>; 484*0b57cec5SDimitry Andricdef LD_Fp64m80 : FpI_<(outs RFP80:$dst), (ins f64mem:$src), ZeroArgFP, 485*0b57cec5SDimitry Andric [(set RFP80:$dst, (f80 (extloadf64 addr:$src)))]>; 486*0b57cec5SDimitry Andricdef LD_Fp32m80 : FpI_<(outs RFP80:$dst), (ins f32mem:$src), ZeroArgFP, 487*0b57cec5SDimitry Andric [(set RFP80:$dst, (f80 (extloadf32 addr:$src)))]>; 488*0b57cec5SDimitry Andricdef ILD_Fp16m32: FpIf32<(outs RFP32:$dst), (ins i16mem:$src), ZeroArgFP, 489*0b57cec5SDimitry Andric [(set RFP32:$dst, (X86fild16 addr:$src))]>; 490*0b57cec5SDimitry Andricdef ILD_Fp32m32: FpIf32<(outs RFP32:$dst), (ins i32mem:$src), ZeroArgFP, 491*0b57cec5SDimitry Andric [(set RFP32:$dst, (X86fild32 addr:$src))]>; 492*0b57cec5SDimitry Andricdef ILD_Fp64m32: FpIf32<(outs RFP32:$dst), (ins i64mem:$src), ZeroArgFP, 493*0b57cec5SDimitry Andric [(set RFP32:$dst, (X86fild64 addr:$src))]>; 494*0b57cec5SDimitry Andricdef ILD_Fp16m64: FpIf64<(outs RFP64:$dst), (ins i16mem:$src), ZeroArgFP, 495*0b57cec5SDimitry Andric [(set RFP64:$dst, (X86fild16 addr:$src))]>; 496*0b57cec5SDimitry Andricdef ILD_Fp32m64: FpIf64<(outs RFP64:$dst), (ins i32mem:$src), ZeroArgFP, 497*0b57cec5SDimitry Andric [(set RFP64:$dst, (X86fild32 addr:$src))]>; 498*0b57cec5SDimitry Andricdef ILD_Fp64m64: FpIf64<(outs RFP64:$dst), (ins i64mem:$src), ZeroArgFP, 499*0b57cec5SDimitry Andric [(set RFP64:$dst, (X86fild64 addr:$src))]>; 500*0b57cec5SDimitry Andricdef ILD_Fp16m80: FpI_<(outs RFP80:$dst), (ins i16mem:$src), ZeroArgFP, 501*0b57cec5SDimitry Andric [(set RFP80:$dst, (X86fild16 addr:$src))]>; 502*0b57cec5SDimitry Andricdef ILD_Fp32m80: FpI_<(outs RFP80:$dst), (ins i32mem:$src), ZeroArgFP, 503*0b57cec5SDimitry Andric [(set RFP80:$dst, (X86fild32 addr:$src))]>; 504*0b57cec5SDimitry Andricdef ILD_Fp64m80: FpI_<(outs RFP80:$dst), (ins i64mem:$src), ZeroArgFP, 505*0b57cec5SDimitry Andric [(set RFP80:$dst, (X86fild64 addr:$src))]>; 506*0b57cec5SDimitry Andric} // SchedRW 507*0b57cec5SDimitry Andric 508*0b57cec5SDimitry Andriclet SchedRW = [WriteStore], Uses = [FPCW] in { 509*0b57cec5SDimitry Andricdef ST_Fp32m : FpIf32<(outs), (ins f32mem:$op, RFP32:$src), OneArgFP, 510*0b57cec5SDimitry Andric [(store RFP32:$src, addr:$op)]>; 511*0b57cec5SDimitry Andricdef ST_Fp64m32 : FpIf64<(outs), (ins f32mem:$op, RFP64:$src), OneArgFP, 512*0b57cec5SDimitry Andric [(truncstoref32 RFP64:$src, addr:$op)]>; 513*0b57cec5SDimitry Andricdef ST_Fp64m : FpIf64<(outs), (ins f64mem:$op, RFP64:$src), OneArgFP, 514*0b57cec5SDimitry Andric [(store RFP64:$src, addr:$op)]>; 515*0b57cec5SDimitry Andricdef ST_Fp80m32 : FpI_<(outs), (ins f32mem:$op, RFP80:$src), OneArgFP, 516*0b57cec5SDimitry Andric [(truncstoref32 RFP80:$src, addr:$op)]>; 517*0b57cec5SDimitry Andricdef ST_Fp80m64 : FpI_<(outs), (ins f64mem:$op, RFP80:$src), OneArgFP, 518*0b57cec5SDimitry Andric [(truncstoref64 RFP80:$src, addr:$op)]>; 519*0b57cec5SDimitry Andric// FST does not support 80-bit memory target; FSTP must be used. 520*0b57cec5SDimitry Andric 521*0b57cec5SDimitry Andriclet mayStore = 1, hasSideEffects = 0 in { 522*0b57cec5SDimitry Andricdef ST_FpP32m : FpIf32<(outs), (ins f32mem:$op, RFP32:$src), OneArgFP, []>; 523*0b57cec5SDimitry Andricdef ST_FpP64m32 : FpIf64<(outs), (ins f32mem:$op, RFP64:$src), OneArgFP, []>; 524*0b57cec5SDimitry Andricdef ST_FpP64m : FpIf64<(outs), (ins f64mem:$op, RFP64:$src), OneArgFP, []>; 525*0b57cec5SDimitry Andricdef ST_FpP80m32 : FpI_<(outs), (ins f32mem:$op, RFP80:$src), OneArgFP, []>; 526*0b57cec5SDimitry Andricdef ST_FpP80m64 : FpI_<(outs), (ins f64mem:$op, RFP80:$src), OneArgFP, []>; 527*0b57cec5SDimitry Andric} // mayStore 528*0b57cec5SDimitry Andric 529*0b57cec5SDimitry Andricdef ST_FpP80m : FpI_<(outs), (ins f80mem:$op, RFP80:$src), OneArgFP, 530*0b57cec5SDimitry Andric [(store RFP80:$src, addr:$op)]>; 531*0b57cec5SDimitry Andric 532*0b57cec5SDimitry Andriclet mayStore = 1, hasSideEffects = 0 in { 533*0b57cec5SDimitry Andricdef IST_Fp16m32 : FpIf32<(outs), (ins i16mem:$op, RFP32:$src), OneArgFP, []>; 534*0b57cec5SDimitry Andricdef IST_Fp32m32 : FpIf32<(outs), (ins i32mem:$op, RFP32:$src), OneArgFP, []>; 535*0b57cec5SDimitry Andricdef IST_Fp64m32 : FpIf32<(outs), (ins i64mem:$op, RFP32:$src), OneArgFP, []>; 536*0b57cec5SDimitry Andricdef IST_Fp16m64 : FpIf64<(outs), (ins i16mem:$op, RFP64:$src), OneArgFP, []>; 537*0b57cec5SDimitry Andricdef IST_Fp32m64 : FpIf64<(outs), (ins i32mem:$op, RFP64:$src), OneArgFP, []>; 538*0b57cec5SDimitry Andricdef IST_Fp64m64 : FpIf64<(outs), (ins i64mem:$op, RFP64:$src), OneArgFP, []>; 539*0b57cec5SDimitry Andricdef IST_Fp16m80 : FpI_<(outs), (ins i16mem:$op, RFP80:$src), OneArgFP, []>; 540*0b57cec5SDimitry Andricdef IST_Fp32m80 : FpI_<(outs), (ins i32mem:$op, RFP80:$src), OneArgFP, []>; 541*0b57cec5SDimitry Andricdef IST_Fp64m80 : FpI_<(outs), (ins i64mem:$op, RFP80:$src), OneArgFP, []>; 542*0b57cec5SDimitry Andric} // mayStore 543*0b57cec5SDimitry Andric} // SchedRW, Uses = [FPCW] 544*0b57cec5SDimitry Andric 545*0b57cec5SDimitry Andriclet mayLoad = 1, SchedRW = [WriteLoad], Uses = [FPCW] in { 546*0b57cec5SDimitry Andricdef LD_F32m : FPI<0xD9, MRM0m, (outs), (ins f32mem:$src), "fld{s}\t$src">; 547*0b57cec5SDimitry Andricdef LD_F64m : FPI<0xDD, MRM0m, (outs), (ins f64mem:$src), "fld{l}\t$src">; 548*0b57cec5SDimitry Andricdef LD_F80m : FPI<0xDB, MRM5m, (outs), (ins f80mem:$src), "fld{t}\t$src">; 549*0b57cec5SDimitry Andricdef ILD_F16m : FPI<0xDF, MRM0m, (outs), (ins i16mem:$src), "fild{s}\t$src">; 550*0b57cec5SDimitry Andricdef ILD_F32m : FPI<0xDB, MRM0m, (outs), (ins i32mem:$src), "fild{l}\t$src">; 551*0b57cec5SDimitry Andricdef ILD_F64m : FPI<0xDF, MRM5m, (outs), (ins i64mem:$src), "fild{ll}\t$src">; 552*0b57cec5SDimitry Andric} 553*0b57cec5SDimitry Andriclet mayStore = 1, SchedRW = [WriteStore], Uses = [FPCW] in { 554*0b57cec5SDimitry Andricdef ST_F32m : FPI<0xD9, MRM2m, (outs), (ins f32mem:$dst), "fst{s}\t$dst">; 555*0b57cec5SDimitry Andricdef ST_F64m : FPI<0xDD, MRM2m, (outs), (ins f64mem:$dst), "fst{l}\t$dst">; 556*0b57cec5SDimitry Andricdef ST_FP32m : FPI<0xD9, MRM3m, (outs), (ins f32mem:$dst), "fstp{s}\t$dst">; 557*0b57cec5SDimitry Andricdef ST_FP64m : FPI<0xDD, MRM3m, (outs), (ins f64mem:$dst), "fstp{l}\t$dst">; 558*0b57cec5SDimitry Andricdef ST_FP80m : FPI<0xDB, MRM7m, (outs), (ins f80mem:$dst), "fstp{t}\t$dst">; 559*0b57cec5SDimitry Andricdef IST_F16m : FPI<0xDF, MRM2m, (outs), (ins i16mem:$dst), "fist{s}\t$dst">; 560*0b57cec5SDimitry Andricdef IST_F32m : FPI<0xDB, MRM2m, (outs), (ins i32mem:$dst), "fist{l}\t$dst">; 561*0b57cec5SDimitry Andricdef IST_FP16m : FPI<0xDF, MRM3m, (outs), (ins i16mem:$dst), "fistp{s}\t$dst">; 562*0b57cec5SDimitry Andricdef IST_FP32m : FPI<0xDB, MRM3m, (outs), (ins i32mem:$dst), "fistp{l}\t$dst">; 563*0b57cec5SDimitry Andricdef IST_FP64m : FPI<0xDF, MRM7m, (outs), (ins i64mem:$dst), "fistp{ll}\t$dst">; 564*0b57cec5SDimitry Andric} 565*0b57cec5SDimitry Andric 566*0b57cec5SDimitry Andric// FISTTP requires SSE3 even though it's a FPStack op. 567*0b57cec5SDimitry Andriclet Predicates = [HasSSE3], SchedRW = [WriteStore], Uses = [FPCW] in { 568*0b57cec5SDimitry Andricdef ISTT_Fp16m32 : FpI_<(outs), (ins i16mem:$op, RFP32:$src), OneArgFP, 569*0b57cec5SDimitry Andric [(X86fp_to_i16mem RFP32:$src, addr:$op)]>; 570*0b57cec5SDimitry Andricdef ISTT_Fp32m32 : FpI_<(outs), (ins i32mem:$op, RFP32:$src), OneArgFP, 571*0b57cec5SDimitry Andric [(X86fp_to_i32mem RFP32:$src, addr:$op)]>; 572*0b57cec5SDimitry Andricdef ISTT_Fp64m32 : FpI_<(outs), (ins i64mem:$op, RFP32:$src), OneArgFP, 573*0b57cec5SDimitry Andric [(X86fp_to_i64mem RFP32:$src, addr:$op)]>; 574*0b57cec5SDimitry Andricdef ISTT_Fp16m64 : FpI_<(outs), (ins i16mem:$op, RFP64:$src), OneArgFP, 575*0b57cec5SDimitry Andric [(X86fp_to_i16mem RFP64:$src, addr:$op)]>; 576*0b57cec5SDimitry Andricdef ISTT_Fp32m64 : FpI_<(outs), (ins i32mem:$op, RFP64:$src), OneArgFP, 577*0b57cec5SDimitry Andric [(X86fp_to_i32mem RFP64:$src, addr:$op)]>; 578*0b57cec5SDimitry Andricdef ISTT_Fp64m64 : FpI_<(outs), (ins i64mem:$op, RFP64:$src), OneArgFP, 579*0b57cec5SDimitry Andric [(X86fp_to_i64mem RFP64:$src, addr:$op)]>; 580*0b57cec5SDimitry Andricdef ISTT_Fp16m80 : FpI_<(outs), (ins i16mem:$op, RFP80:$src), OneArgFP, 581*0b57cec5SDimitry Andric [(X86fp_to_i16mem RFP80:$src, addr:$op)]>; 582*0b57cec5SDimitry Andricdef ISTT_Fp32m80 : FpI_<(outs), (ins i32mem:$op, RFP80:$src), OneArgFP, 583*0b57cec5SDimitry Andric [(X86fp_to_i32mem RFP80:$src, addr:$op)]>; 584*0b57cec5SDimitry Andricdef ISTT_Fp64m80 : FpI_<(outs), (ins i64mem:$op, RFP80:$src), OneArgFP, 585*0b57cec5SDimitry Andric [(X86fp_to_i64mem RFP80:$src, addr:$op)]>; 586*0b57cec5SDimitry Andric} // Predicates = [HasSSE3] 587*0b57cec5SDimitry Andric 588*0b57cec5SDimitry Andriclet mayStore = 1, SchedRW = [WriteStore], Uses = [FPCW] in { 589*0b57cec5SDimitry Andricdef ISTT_FP16m : FPI<0xDF, MRM1m, (outs), (ins i16mem:$dst), "fisttp{s}\t$dst">; 590*0b57cec5SDimitry Andricdef ISTT_FP32m : FPI<0xDB, MRM1m, (outs), (ins i32mem:$dst), "fisttp{l}\t$dst">; 591*0b57cec5SDimitry Andricdef ISTT_FP64m : FPI<0xDD, MRM1m, (outs), (ins i64mem:$dst), "fisttp{ll}\t$dst">; 592*0b57cec5SDimitry Andric} 593*0b57cec5SDimitry Andric 594*0b57cec5SDimitry Andric// FP Stack manipulation instructions. 595*0b57cec5SDimitry Andriclet SchedRW = [WriteMove], Uses = [FPCW] in { 596*0b57cec5SDimitry Andricdef LD_Frr : FPI<0xD9, MRM0r, (outs), (ins RSTi:$op), "fld\t$op">; 597*0b57cec5SDimitry Andricdef ST_Frr : FPI<0xDD, MRM2r, (outs), (ins RSTi:$op), "fst\t$op">; 598*0b57cec5SDimitry Andricdef ST_FPrr : FPI<0xDD, MRM3r, (outs), (ins RSTi:$op), "fstp\t$op">; 599*0b57cec5SDimitry Andricdef XCH_F : FPI<0xD9, MRM1r, (outs), (ins RSTi:$op), "fxch\t$op">; 600*0b57cec5SDimitry Andric} 601*0b57cec5SDimitry Andric 602*0b57cec5SDimitry Andric// Floating point constant loads. 603*0b57cec5SDimitry Andriclet SchedRW = [WriteZero], Uses = [FPCW] in { 604*0b57cec5SDimitry Andricdef LD_Fp032 : FpIf32<(outs RFP32:$dst), (ins), ZeroArgFP, 605*0b57cec5SDimitry Andric [(set RFP32:$dst, fpimm0)]>; 606*0b57cec5SDimitry Andricdef LD_Fp132 : FpIf32<(outs RFP32:$dst), (ins), ZeroArgFP, 607*0b57cec5SDimitry Andric [(set RFP32:$dst, fpimm1)]>; 608*0b57cec5SDimitry Andricdef LD_Fp064 : FpIf64<(outs RFP64:$dst), (ins), ZeroArgFP, 609*0b57cec5SDimitry Andric [(set RFP64:$dst, fpimm0)]>; 610*0b57cec5SDimitry Andricdef LD_Fp164 : FpIf64<(outs RFP64:$dst), (ins), ZeroArgFP, 611*0b57cec5SDimitry Andric [(set RFP64:$dst, fpimm1)]>; 612*0b57cec5SDimitry Andricdef LD_Fp080 : FpI_<(outs RFP80:$dst), (ins), ZeroArgFP, 613*0b57cec5SDimitry Andric [(set RFP80:$dst, fpimm0)]>; 614*0b57cec5SDimitry Andricdef LD_Fp180 : FpI_<(outs RFP80:$dst), (ins), ZeroArgFP, 615*0b57cec5SDimitry Andric [(set RFP80:$dst, fpimm1)]>; 616*0b57cec5SDimitry Andric} 617*0b57cec5SDimitry Andric 618*0b57cec5SDimitry Andriclet SchedRW = [WriteFLD0], Uses = [FPCW] in 619*0b57cec5SDimitry Andricdef LD_F0 : FPI<0xD9, MRM_EE, (outs), (ins), "fldz">; 620*0b57cec5SDimitry Andric 621*0b57cec5SDimitry Andriclet SchedRW = [WriteFLD1], Uses = [FPCW] in 622*0b57cec5SDimitry Andricdef LD_F1 : FPI<0xD9, MRM_E8, (outs), (ins), "fld1">; 623*0b57cec5SDimitry Andric 624*0b57cec5SDimitry Andriclet SchedRW = [WriteFLDC], Uses = [FPCW] in { 625*0b57cec5SDimitry Andricdef FLDL2T : I<0xD9, MRM_E9, (outs), (ins), "fldl2t", []>; 626*0b57cec5SDimitry Andricdef FLDL2E : I<0xD9, MRM_EA, (outs), (ins), "fldl2e", []>; 627*0b57cec5SDimitry Andricdef FLDPI : I<0xD9, MRM_EB, (outs), (ins), "fldpi", []>; 628*0b57cec5SDimitry Andricdef FLDLG2 : I<0xD9, MRM_EC, (outs), (ins), "fldlg2", []>; 629*0b57cec5SDimitry Andricdef FLDLN2 : I<0xD9, MRM_ED, (outs), (ins), "fldln2", []>; 630*0b57cec5SDimitry Andric} // SchedRW 631*0b57cec5SDimitry Andric 632*0b57cec5SDimitry Andric// Floating point compares. 633*0b57cec5SDimitry Andriclet SchedRW = [WriteFCom], Uses = [FPCW] in { 634*0b57cec5SDimitry Andricdef UCOM_Fpr32 : FpIf32<(outs), (ins RFP32:$lhs, RFP32:$rhs), CompareFP, 635*0b57cec5SDimitry Andric [(set FPSW, (trunc (X86cmp RFP32:$lhs, RFP32:$rhs)))]>; 636*0b57cec5SDimitry Andricdef UCOM_Fpr64 : FpIf64<(outs), (ins RFP64:$lhs, RFP64:$rhs), CompareFP, 637*0b57cec5SDimitry Andric [(set FPSW, (trunc (X86cmp RFP64:$lhs, RFP64:$rhs)))]>; 638*0b57cec5SDimitry Andricdef UCOM_Fpr80 : FpI_ <(outs), (ins RFP80:$lhs, RFP80:$rhs), CompareFP, 639*0b57cec5SDimitry Andric [(set FPSW, (trunc (X86cmp RFP80:$lhs, RFP80:$rhs)))]>; 640*0b57cec5SDimitry Andric} // SchedRW 641*0b57cec5SDimitry Andric} // Defs = [FPSW] 642*0b57cec5SDimitry Andric 643*0b57cec5SDimitry Andriclet SchedRW = [WriteFCom] in { 644*0b57cec5SDimitry Andric// CC = ST(0) cmp ST(i) 645*0b57cec5SDimitry Andriclet Defs = [EFLAGS, FPSW], Uses = [FPCW] in { 646*0b57cec5SDimitry Andricdef UCOM_FpIr32: FpI_<(outs), (ins RFP32:$lhs, RFP32:$rhs), CompareFP, 647*0b57cec5SDimitry Andric [(set EFLAGS, (X86cmp RFP32:$lhs, RFP32:$rhs))]>, 648*0b57cec5SDimitry Andric Requires<[FPStackf32, HasCMov]>; 649*0b57cec5SDimitry Andricdef UCOM_FpIr64: FpI_<(outs), (ins RFP64:$lhs, RFP64:$rhs), CompareFP, 650*0b57cec5SDimitry Andric [(set EFLAGS, (X86cmp RFP64:$lhs, RFP64:$rhs))]>, 651*0b57cec5SDimitry Andric Requires<[FPStackf64, HasCMov]>; 652*0b57cec5SDimitry Andricdef UCOM_FpIr80: FpI_<(outs), (ins RFP80:$lhs, RFP80:$rhs), CompareFP, 653*0b57cec5SDimitry Andric [(set EFLAGS, (X86cmp RFP80:$lhs, RFP80:$rhs))]>, 654*0b57cec5SDimitry Andric Requires<[HasCMov]>; 655*0b57cec5SDimitry Andric} 656*0b57cec5SDimitry Andric 657*0b57cec5SDimitry Andriclet Defs = [FPSW], Uses = [ST0, FPCW] in { 658*0b57cec5SDimitry Andricdef UCOM_Fr : FPI<0xDD, MRM4r, // FPSW = cmp ST(0) with ST(i) 659*0b57cec5SDimitry Andric (outs), (ins RSTi:$reg), "fucom\t$reg">; 660*0b57cec5SDimitry Andricdef UCOM_FPr : FPI<0xDD, MRM5r, // FPSW = cmp ST(0) with ST(i), pop 661*0b57cec5SDimitry Andric (outs), (ins RSTi:$reg), "fucomp\t$reg">; 662*0b57cec5SDimitry Andricdef UCOM_FPPr : FPI<0xDA, MRM_E9, // cmp ST(0) with ST(1), pop, pop 663*0b57cec5SDimitry Andric (outs), (ins), "fucompp">; 664*0b57cec5SDimitry Andric} 665*0b57cec5SDimitry Andric 666*0b57cec5SDimitry Andriclet Defs = [EFLAGS, FPSW], Uses = [ST0, FPCW] in { 667*0b57cec5SDimitry Andricdef UCOM_FIr : FPI<0xDB, MRM5r, // CC = cmp ST(0) with ST(i) 668*0b57cec5SDimitry Andric (outs), (ins RSTi:$reg), "fucomi\t{$reg, %st|st, $reg}">; 669*0b57cec5SDimitry Andricdef UCOM_FIPr : FPI<0xDF, MRM5r, // CC = cmp ST(0) with ST(i), pop 670*0b57cec5SDimitry Andric (outs), (ins RSTi:$reg), "fucompi\t{$reg, %st|st, $reg}">; 671*0b57cec5SDimitry Andric 672*0b57cec5SDimitry Andricdef COM_FIr : FPI<0xDB, MRM6r, (outs), (ins RSTi:$reg), 673*0b57cec5SDimitry Andric "fcomi\t{$reg, %st|st, $reg}">; 674*0b57cec5SDimitry Andricdef COM_FIPr : FPI<0xDF, MRM6r, (outs), (ins RSTi:$reg), 675*0b57cec5SDimitry Andric "fcompi\t{$reg, %st|st, $reg}">; 676*0b57cec5SDimitry Andric} 677*0b57cec5SDimitry Andric} // SchedRW 678*0b57cec5SDimitry Andric 679*0b57cec5SDimitry Andric// Floating point flag ops. 680*0b57cec5SDimitry Andriclet SchedRW = [WriteALU] in { 681*0b57cec5SDimitry Andriclet Defs = [AX], Uses = [FPSW] in 682*0b57cec5SDimitry Andricdef FNSTSW16r : I<0xDF, MRM_E0, // AX = fp flags 683*0b57cec5SDimitry Andric (outs), (ins), "fnstsw\t{%ax|ax}", 684*0b57cec5SDimitry Andric [(set AX, (X86fp_stsw FPSW))]>; 685*0b57cec5SDimitry Andriclet Defs = [FPSW], Uses = [FPCW] in 686*0b57cec5SDimitry Andricdef FNSTCW16m : I<0xD9, MRM7m, // [mem16] = X87 control world 687*0b57cec5SDimitry Andric (outs), (ins i16mem:$dst), "fnstcw\t$dst", 688*0b57cec5SDimitry Andric [(X86fp_cwd_get16 addr:$dst)]>; 689*0b57cec5SDimitry Andric} // SchedRW 690*0b57cec5SDimitry Andriclet Defs = [FPSW,FPCW], mayLoad = 1 in 691*0b57cec5SDimitry Andricdef FLDCW16m : I<0xD9, MRM5m, // X87 control world = [mem16] 692*0b57cec5SDimitry Andric (outs), (ins i16mem:$dst), "fldcw\t$dst", []>, 693*0b57cec5SDimitry Andric Sched<[WriteLoad]>; 694*0b57cec5SDimitry Andric 695*0b57cec5SDimitry Andric// FPU control instructions 696*0b57cec5SDimitry Andriclet SchedRW = [WriteMicrocoded] in { 697*0b57cec5SDimitry Andriclet Defs = [FPSW] in { 698*0b57cec5SDimitry Andricdef FNINIT : I<0xDB, MRM_E3, (outs), (ins), "fninit", []>; 699*0b57cec5SDimitry Andricdef FFREE : FPI<0xDD, MRM0r, (outs), (ins RSTi:$reg), "ffree\t$reg">; 700*0b57cec5SDimitry Andricdef FFREEP : FPI<0xDF, MRM0r, (outs), (ins RSTi:$reg), "ffreep\t$reg">; 701*0b57cec5SDimitry Andric 702*0b57cec5SDimitry Andric// Clear exceptions 703*0b57cec5SDimitry Andricdef FNCLEX : I<0xDB, MRM_E2, (outs), (ins), "fnclex", []>; 704*0b57cec5SDimitry Andric} // Defs = [FPSW] 705*0b57cec5SDimitry Andric} // SchedRW 706*0b57cec5SDimitry Andric 707*0b57cec5SDimitry Andric// Operand-less floating-point instructions for the disassembler. 708*0b57cec5SDimitry Andricdef FNOP : I<0xD9, MRM_D0, (outs), (ins), "fnop", []>, Sched<[WriteNop]>; 709*0b57cec5SDimitry Andric 710*0b57cec5SDimitry Andriclet SchedRW = [WriteMicrocoded] in { 711*0b57cec5SDimitry Andriclet Defs = [FPSW] in { 712*0b57cec5SDimitry Andricdef WAIT : I<0x9B, RawFrm, (outs), (ins), "wait", []>; 713*0b57cec5SDimitry Andricdef FXAM : I<0xD9, MRM_E5, (outs), (ins), "fxam", []>; 714*0b57cec5SDimitry Andricdef F2XM1 : I<0xD9, MRM_F0, (outs), (ins), "f2xm1", []>; 715*0b57cec5SDimitry Andricdef FYL2X : I<0xD9, MRM_F1, (outs), (ins), "fyl2x", []>; 716*0b57cec5SDimitry Andricdef FPTAN : I<0xD9, MRM_F2, (outs), (ins), "fptan", []>; 717*0b57cec5SDimitry Andricdef FPATAN : I<0xD9, MRM_F3, (outs), (ins), "fpatan", []>; 718*0b57cec5SDimitry Andricdef FXTRACT : I<0xD9, MRM_F4, (outs), (ins), "fxtract", []>; 719*0b57cec5SDimitry Andricdef FPREM1 : I<0xD9, MRM_F5, (outs), (ins), "fprem1", []>; 720*0b57cec5SDimitry Andricdef FDECSTP : I<0xD9, MRM_F6, (outs), (ins), "fdecstp", []>; 721*0b57cec5SDimitry Andricdef FINCSTP : I<0xD9, MRM_F7, (outs), (ins), "fincstp", []>; 722*0b57cec5SDimitry Andricdef FPREM : I<0xD9, MRM_F8, (outs), (ins), "fprem", []>; 723*0b57cec5SDimitry Andricdef FYL2XP1 : I<0xD9, MRM_F9, (outs), (ins), "fyl2xp1", []>; 724*0b57cec5SDimitry Andricdef FSINCOS : I<0xD9, MRM_FB, (outs), (ins), "fsincos", []>; 725*0b57cec5SDimitry Andricdef FRNDINT : I<0xD9, MRM_FC, (outs), (ins), "frndint", []>; 726*0b57cec5SDimitry Andricdef FSCALE : I<0xD9, MRM_FD, (outs), (ins), "fscale", []>; 727*0b57cec5SDimitry Andricdef FCOMPP : I<0xDE, MRM_D9, (outs), (ins), "fcompp", []>; 728*0b57cec5SDimitry Andric} // Defs = [FPSW] 729*0b57cec5SDimitry Andric 730*0b57cec5SDimitry Andricdef FXSAVE : I<0xAE, MRM0m, (outs), (ins opaquemem:$dst), 731*0b57cec5SDimitry Andric "fxsave\t$dst", [(int_x86_fxsave addr:$dst)]>, TB, 732*0b57cec5SDimitry Andric Requires<[HasFXSR]>; 733*0b57cec5SDimitry Andricdef FXSAVE64 : RI<0xAE, MRM0m, (outs), (ins opaquemem:$dst), 734*0b57cec5SDimitry Andric "fxsave64\t$dst", [(int_x86_fxsave64 addr:$dst)]>, 735*0b57cec5SDimitry Andric TB, Requires<[HasFXSR, In64BitMode]>; 736*0b57cec5SDimitry Andricdef FXRSTOR : I<0xAE, MRM1m, (outs), (ins opaquemem:$src), 737*0b57cec5SDimitry Andric "fxrstor\t$src", [(int_x86_fxrstor addr:$src)]>, 738*0b57cec5SDimitry Andric TB, Requires<[HasFXSR]>; 739*0b57cec5SDimitry Andricdef FXRSTOR64 : RI<0xAE, MRM1m, (outs), (ins opaquemem:$src), 740*0b57cec5SDimitry Andric "fxrstor64\t$src", [(int_x86_fxrstor64 addr:$src)]>, 741*0b57cec5SDimitry Andric TB, Requires<[HasFXSR, In64BitMode]>; 742*0b57cec5SDimitry Andric} // SchedRW 743*0b57cec5SDimitry Andric 744*0b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 745*0b57cec5SDimitry Andric// Non-Instruction Patterns 746*0b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 747*0b57cec5SDimitry Andric 748*0b57cec5SDimitry Andric// Required for RET of f32 / f64 / f80 values. 749*0b57cec5SDimitry Andricdef : Pat<(X86fldf32 addr:$src), (LD_Fp32m addr:$src)>; 750*0b57cec5SDimitry Andricdef : Pat<(X86fldf64 addr:$src), (LD_Fp64m addr:$src)>; 751*0b57cec5SDimitry Andricdef : Pat<(X86fldf80 addr:$src), (LD_Fp80m addr:$src)>; 752*0b57cec5SDimitry Andric 753*0b57cec5SDimitry Andric// Required for CALL which return f32 / f64 / f80 values. 754*0b57cec5SDimitry Andricdef : Pat<(X86fstf32 RFP32:$src, addr:$op), (ST_Fp32m addr:$op, RFP32:$src)>; 755*0b57cec5SDimitry Andricdef : Pat<(X86fstf32 RFP64:$src, addr:$op), (ST_Fp64m32 addr:$op, RFP64:$src)>; 756*0b57cec5SDimitry Andricdef : Pat<(X86fstf64 RFP64:$src, addr:$op), (ST_Fp64m addr:$op, RFP64:$src)>; 757*0b57cec5SDimitry Andricdef : Pat<(X86fstf32 RFP80:$src, addr:$op), (ST_Fp80m32 addr:$op, RFP80:$src)>; 758*0b57cec5SDimitry Andricdef : Pat<(X86fstf64 RFP80:$src, addr:$op), (ST_Fp80m64 addr:$op, RFP80:$src)>; 759*0b57cec5SDimitry Andricdef : Pat<(X86fstf80 RFP80:$src, addr:$op), (ST_FpP80m addr:$op, RFP80:$src)>; 760*0b57cec5SDimitry Andric 761*0b57cec5SDimitry Andric// Floating point constant -0.0 and -1.0 762*0b57cec5SDimitry Andricdef : Pat<(f32 fpimmneg0), (CHS_Fp32 (LD_Fp032))>, Requires<[FPStackf32]>; 763*0b57cec5SDimitry Andricdef : Pat<(f32 fpimmneg1), (CHS_Fp32 (LD_Fp132))>, Requires<[FPStackf32]>; 764*0b57cec5SDimitry Andricdef : Pat<(f64 fpimmneg0), (CHS_Fp64 (LD_Fp064))>, Requires<[FPStackf64]>; 765*0b57cec5SDimitry Andricdef : Pat<(f64 fpimmneg1), (CHS_Fp64 (LD_Fp164))>, Requires<[FPStackf64]>; 766*0b57cec5SDimitry Andricdef : Pat<(f80 fpimmneg0), (CHS_Fp80 (LD_Fp080))>; 767*0b57cec5SDimitry Andricdef : Pat<(f80 fpimmneg1), (CHS_Fp80 (LD_Fp180))>; 768*0b57cec5SDimitry Andric 769*0b57cec5SDimitry Andric// Used to conv. i64 to f64 since there isn't a SSE version. 770*0b57cec5SDimitry Andricdef : Pat<(X86fildflag64 addr:$src), (ILD_Fp64m64 addr:$src)>; 771*0b57cec5SDimitry Andric 772*0b57cec5SDimitry Andric// Used to conv. between f80 and i64 for i64 atomic loads. 773*0b57cec5SDimitry Andricdef : Pat<(X86fildflag64 addr:$src), (ILD_Fp64m80 addr:$src)>; 774*0b57cec5SDimitry Andricdef : Pat<(X86fist64 RFP80:$src, addr:$op), (IST_Fp64m80 addr:$op, RFP80:$src)>; 775*0b57cec5SDimitry Andric 776*0b57cec5SDimitry Andric// FP extensions map onto simple pseudo-value conversions if they are to/from 777*0b57cec5SDimitry Andric// the FP stack. 778*0b57cec5SDimitry Andricdef : Pat<(f64 (fpextend RFP32:$src)), (COPY_TO_REGCLASS RFP32:$src, RFP64)>, 779*0b57cec5SDimitry Andric Requires<[FPStackf32]>; 780*0b57cec5SDimitry Andricdef : Pat<(f80 (fpextend RFP32:$src)), (COPY_TO_REGCLASS RFP32:$src, RFP80)>, 781*0b57cec5SDimitry Andric Requires<[FPStackf32]>; 782*0b57cec5SDimitry Andricdef : Pat<(f80 (fpextend RFP64:$src)), (COPY_TO_REGCLASS RFP64:$src, RFP80)>, 783*0b57cec5SDimitry Andric Requires<[FPStackf64]>; 784*0b57cec5SDimitry Andric 785*0b57cec5SDimitry Andric// FP truncations map onto simple pseudo-value conversions if they are to/from 786*0b57cec5SDimitry Andric// the FP stack. We have validated that only value-preserving truncations make 787*0b57cec5SDimitry Andric// it through isel. 788*0b57cec5SDimitry Andricdef : Pat<(f32 (fpround RFP64:$src)), (COPY_TO_REGCLASS RFP64:$src, RFP32)>, 789*0b57cec5SDimitry Andric Requires<[FPStackf32]>; 790*0b57cec5SDimitry Andricdef : Pat<(f32 (fpround RFP80:$src)), (COPY_TO_REGCLASS RFP80:$src, RFP32)>, 791*0b57cec5SDimitry Andric Requires<[FPStackf32]>; 792*0b57cec5SDimitry Andricdef : Pat<(f64 (fpround RFP80:$src)), (COPY_TO_REGCLASS RFP80:$src, RFP64)>, 793*0b57cec5SDimitry Andric Requires<[FPStackf64]>; 794