@@ -282,7 +282,7 @@ def _FI32m : FPI<0xDA, fp, (outs), (ins i32mem:$src),
282
282
!strconcat("fi", asmstring, "{l}\t$src")>;
283
283
}
284
284
285
- let Defs = [FPSW ], Uses = [FPCW] in {
285
+ let Uses = [FPCW ], mayRaiseFPException = 1 in {
286
286
// FPBinary_rr just defines pseudo-instructions, no need to set a scheduling
287
287
// resources.
288
288
let hasNoSchedulingInfo = 1 in {
@@ -307,7 +307,7 @@ let SchedRW = [WriteFDivLd] in {
307
307
defm DIV : FPBinary<fdiv, MRM6m, "div">;
308
308
defm DIVR: FPBinary<fdiv, MRM7m, "divr", 0>;
309
309
}
310
- } // Defs = [FPSW]
310
+ } // Uses = [FPCW], mayRaiseFPException = 1
311
311
312
312
class FPST0rInst<Format fp, string asm>
313
313
: FPI<0xD8, fp, (outs), (ins RSTi:$op), asm>;
@@ -319,7 +319,7 @@ class FPrST0PInst<Format fp, string asm>
319
319
// NOTE: GAS and apparently all other AT&T style assemblers have a broken notion
320
320
// of some of the 'reverse' forms of the fsub and fdiv instructions. As such,
321
321
// we have to put some 'r's in and take them out of weird places.
322
- let SchedRW = [WriteFAdd], Defs = [FPSW ], Uses = [FPCW] in {
322
+ let SchedRW = [WriteFAdd], Uses = [FPCW ], mayRaiseFPException = 1 in {
323
323
def ADD_FST0r : FPST0rInst <MRM0r, "fadd\t{$op, %st|st, $op}">;
324
324
def ADD_FrST0 : FPrST0Inst <MRM0r, "fadd\t{%st, $op|$op, st}">;
325
325
def ADD_FPrST0 : FPrST0PInst<MRM0r, "faddp\t{%st, $op|$op, st}">;
@@ -330,16 +330,16 @@ def SUB_FST0r : FPST0rInst <MRM4r, "fsub\t{$op, %st|st, $op}">;
330
330
def SUBR_FrST0 : FPrST0Inst <MRM4r, "fsub{|r}\t{%st, $op|$op, st}">;
331
331
def SUBR_FPrST0 : FPrST0PInst<MRM4r, "fsub{|r}p\t{%st, $op|$op, st}">;
332
332
} // SchedRW
333
- let SchedRW = [WriteFCom], Defs = [FPSW ], Uses = [FPCW] in {
333
+ let SchedRW = [WriteFCom], Uses = [FPCW ], mayRaiseFPException = 1 in {
334
334
def COM_FST0r : FPST0rInst <MRM2r, "fcom\t$op">;
335
335
def COMP_FST0r : FPST0rInst <MRM3r, "fcomp\t$op">;
336
336
} // SchedRW
337
- let SchedRW = [WriteFMul], Defs = [FPSW ], Uses = [FPCW] in {
337
+ let SchedRW = [WriteFMul], Uses = [FPCW ], mayRaiseFPException = 1 in {
338
338
def MUL_FST0r : FPST0rInst <MRM1r, "fmul\t{$op, %st|st, $op}">;
339
339
def MUL_FrST0 : FPrST0Inst <MRM1r, "fmul\t{%st, $op|$op, st}">;
340
340
def MUL_FPrST0 : FPrST0PInst<MRM1r, "fmulp\t{%st, $op|$op, st}">;
341
341
} // SchedRW
342
- let SchedRW = [WriteFDiv], Defs = [FPSW ], Uses = [FPCW] in {
342
+ let SchedRW = [WriteFDiv], Uses = [FPCW ], mayRaiseFPException = 1 in {
343
343
def DIVR_FST0r : FPST0rInst <MRM7r, "fdivr\t{$op, %st|st, $op}">;
344
344
def DIV_FrST0 : FPrST0Inst <MRM7r, "fdiv{r}\t{%st, $op|$op, st}">;
345
345
def DIV_FPrST0 : FPrST0PInst<MRM7r, "fdiv{r}p\t{%st, $op|$op, st}">;
@@ -359,13 +359,12 @@ def _Fp80 : FpI_<(outs RFP80:$dst), (ins RFP80:$src), OneArgFPRW,
359
359
def _F : FPI<0xD9, fp, (outs), (ins), asmstring>;
360
360
}
361
361
362
- let Defs = [FPSW], Uses = [FPCW] in {
363
-
364
362
let SchedRW = [WriteFSign] in {
365
363
defm CHS : FPUnary<fneg, MRM_E0, "fchs">;
366
364
defm ABS : FPUnary<fabs, MRM_E1, "fabs">;
367
365
}
368
366
367
+ let Uses = [FPCW], mayRaiseFPException = 1 in {
369
368
let SchedRW = [WriteFSqrt80] in
370
369
defm SQRT: FPUnary<fsqrt,MRM_FA, "fsqrt">;
371
370
@@ -378,11 +377,11 @@ def TST_Fp80 : FpI_<(outs), (ins RFP80:$src), OneArgFP, []>;
378
377
379
378
def TST_F : FPI<0xD9, MRM_E4, (outs), (ins), "ftst">;
380
379
} // SchedRW
381
- } // Defs = [FPSW]
380
+ } // Uses = [FPCW], mayRaiseFPException = 1
382
381
383
382
// Versions of FP instructions that take a single memory operand. Added for the
384
383
// disassembler; remove as they are included with patterns elsewhere.
385
- let SchedRW = [WriteFComLd], Defs = [FPSW ], Uses = [FPCW] in {
384
+ let SchedRW = [WriteFComLd], Uses = [FPCW ], mayRaiseFPException = 1 in {
386
385
def FCOM32m : FPI<0xD8, MRM2m, (outs), (ins f32mem:$src), "fcom{s}\t$src">;
387
386
def FCOMP32m : FPI<0xD8, MRM3m, (outs), (ins f32mem:$src), "fcomp{s}\t$src">;
388
387
@@ -397,14 +396,21 @@ def FICOMP32m: FPI<0xDA, MRM3m, (outs), (ins i32mem:$src), "ficomp{l}\t$src">;
397
396
} // SchedRW
398
397
399
398
let SchedRW = [WriteMicrocoded] in {
399
+ let Defs = [FPSW, FPCW] in {
400
400
def FLDENVm : FPI<0xD9, MRM4m, (outs), (ins f32mem:$src), "fldenv\t$src">;
401
- def FSTENVm : FPI<0xD9, MRM6m, (outs), (ins f32mem:$dst), "fnstenv\t$dst">;
402
-
403
401
def FRSTORm : FPI<0xDD, MRM4m, (outs), (ins f32mem:$dst), "frstor\t$dst">;
402
+ }
403
+
404
+ let Defs = [FPSW, FPCW], Uses = [FPSW, FPCW] in {
405
+ def FSTENVm : FPI<0xD9, MRM6m, (outs), (ins f32mem:$dst), "fnstenv\t$dst">;
404
406
def FSAVEm : FPI<0xDD, MRM6m, (outs), (ins f32mem:$dst), "fnsave\t$dst">;
407
+ }
408
+
409
+ let Uses = [FPSW] in
405
410
def FNSTSWm : FPI<0xDD, MRM7m, (outs), (ins i16mem:$dst), "fnstsw\t$dst">;
406
411
407
412
def FBLDm : FPI<0xDF, MRM4m, (outs), (ins f80mem:$src), "fbld\t$src">;
413
+ let Uses = [FPCW] ,mayRaiseFPException = 1 in
408
414
def FBSTPm : FPI<0xDF, MRM6m, (outs), (ins f80mem:$dst), "fbstp\t$dst">;
409
415
} // SchedRW
410
416
@@ -430,7 +436,6 @@ multiclass FPCMov<PatLeaf cc> {
430
436
Requires<[HasCMov]>;
431
437
}
432
438
433
- let Defs = [FPSW] in {
434
439
let SchedRW = [WriteFCMOV] in {
435
440
let Uses = [EFLAGS], Constraints = "$src1 = $dst" in {
436
441
defm CMOVB : FPCMov<X86_COND_B>;
@@ -464,6 +469,7 @@ def CMOVNP_F : FPI<0xDB, MRM3r, (outs), (ins RSTi:$op),
464
469
} // Predicates = [HasCMov]
465
470
} // SchedRW
466
471
472
+ let mayRaiseFPException = 1 in {
467
473
// Floating point loads & stores.
468
474
let SchedRW = [WriteLoad], Uses = [FPCW] in {
469
475
let canFoldAsLoad = 1 in {
@@ -480,6 +486,7 @@ def LD_Fp64m80 : FpI_<(outs RFP80:$dst), (ins f64mem:$src), ZeroArgFP,
480
486
[(set RFP80:$dst, (f80 (extloadf64 addr:$src)))]>;
481
487
def LD_Fp32m80 : FpI_<(outs RFP80:$dst), (ins f32mem:$src), ZeroArgFP,
482
488
[(set RFP80:$dst, (f80 (extloadf32 addr:$src)))]>;
489
+ let mayRaiseFPException = 0 in {
483
490
def ILD_Fp16m32: FpIf32<(outs RFP32:$dst), (ins i16mem:$src), ZeroArgFP,
484
491
[(set RFP32:$dst, (X86fild16 addr:$src))]>;
485
492
def ILD_Fp32m32: FpIf32<(outs RFP32:$dst), (ins i32mem:$src), ZeroArgFP,
@@ -498,6 +505,7 @@ def ILD_Fp32m80: FpI_<(outs RFP80:$dst), (ins i32mem:$src), ZeroArgFP,
498
505
[(set RFP80:$dst, (X86fild32 addr:$src))]>;
499
506
def ILD_Fp64m80: FpI_<(outs RFP80:$dst), (ins i64mem:$src), ZeroArgFP,
500
507
[(set RFP80:$dst, (X86fild64 addr:$src))]>;
508
+ } // mayRaiseFPException = 0
501
509
} // SchedRW
502
510
503
511
let SchedRW = [WriteStore], Uses = [FPCW] in {
@@ -541,10 +549,12 @@ let mayLoad = 1, SchedRW = [WriteLoad], Uses = [FPCW] in {
541
549
def LD_F32m : FPI<0xD9, MRM0m, (outs), (ins f32mem:$src), "fld{s}\t$src">;
542
550
def LD_F64m : FPI<0xDD, MRM0m, (outs), (ins f64mem:$src), "fld{l}\t$src">;
543
551
def LD_F80m : FPI<0xDB, MRM5m, (outs), (ins f80mem:$src), "fld{t}\t$src">;
552
+ let mayRaiseFPException = 0 in {
544
553
def ILD_F16m : FPI<0xDF, MRM0m, (outs), (ins i16mem:$src), "fild{s}\t$src">;
545
554
def ILD_F32m : FPI<0xDB, MRM0m, (outs), (ins i32mem:$src), "fild{l}\t$src">;
546
555
def ILD_F64m : FPI<0xDF, MRM5m, (outs), (ins i64mem:$src), "fild{ll}\t$src">;
547
556
}
557
+ }
548
558
let mayStore = 1, SchedRW = [WriteStore], Uses = [FPCW] in {
549
559
def ST_F32m : FPI<0xD9, MRM2m, (outs), (ins f32mem:$dst), "fst{s}\t$dst">;
550
560
def ST_F64m : FPI<0xDD, MRM2m, (outs), (ins f64mem:$dst), "fst{l}\t$dst">;
@@ -616,7 +626,7 @@ def LD_F0 : FPI<0xD9, MRM_EE, (outs), (ins), "fldz">;
616
626
let SchedRW = [WriteFLD1], Uses = [FPCW] in
617
627
def LD_F1 : FPI<0xD9, MRM_E8, (outs), (ins), "fld1">;
618
628
619
- let SchedRW = [WriteFLDC], Uses = [FPCW] in {
629
+ let SchedRW = [WriteFLDC], Defs = [FPSW], Uses = [FPCW] in {
620
630
def FLDL2T : I<0xD9, MRM_E9, (outs), (ins), "fldl2t", []>;
621
631
def FLDL2E : I<0xD9, MRM_EA, (outs), (ins), "fldl2e", []>;
622
632
def FLDPI : I<0xD9, MRM_EB, (outs), (ins), "fldpi", []>;
@@ -633,11 +643,11 @@ def UCOM_Fpr64 : FpIf64<(outs), (ins RFP64:$lhs, RFP64:$rhs), CompareFP,
633
643
def UCOM_Fpr80 : FpI_ <(outs), (ins RFP80:$lhs, RFP80:$rhs), CompareFP,
634
644
[(set FPSW, (trunc (X86cmp RFP80:$lhs, RFP80:$rhs)))]>;
635
645
} // SchedRW
636
- } // Defs = [FPSW]
646
+ } // mayRaiseFPException = 1
637
647
638
- let SchedRW = [WriteFCom] in {
648
+ let SchedRW = [WriteFCom], mayRaiseFPException = 1 in {
639
649
// CC = ST(0) cmp ST(i)
640
- let Defs = [EFLAGS, FPSW ], Uses = [FPCW] in {
650
+ let Defs = [EFLAGS, FPCW ], Uses = [FPCW] in {
641
651
def UCOM_FpIr32: FpI_<(outs), (ins RFP32:$lhs, RFP32:$rhs), CompareFP,
642
652
[(set EFLAGS, (X86cmp RFP32:$lhs, RFP32:$rhs))]>,
643
653
Requires<[FPStackf32, HasCMov]>;
@@ -649,7 +659,7 @@ def UCOM_FpIr80: FpI_<(outs), (ins RFP80:$lhs, RFP80:$rhs), CompareFP,
649
659
Requires<[HasCMov]>;
650
660
}
651
661
652
- let Defs = [FPSW], Uses = [ST0, FPCW] in {
662
+ let Uses = [ST0, FPCW] in {
653
663
def UCOM_Fr : FPI<0xDD, MRM4r, // FPSW = cmp ST(0) with ST(i)
654
664
(outs), (ins RSTi:$reg), "fucom\t$reg">;
655
665
def UCOM_FPr : FPI<0xDD, MRM5r, // FPSW = cmp ST(0) with ST(i), pop
@@ -673,7 +683,7 @@ def COM_FIPr : FPI<0xDF, MRM6r, (outs), (ins RSTi:$reg),
673
683
674
684
// Floating point flag ops.
675
685
let SchedRW = [WriteALU] in {
676
- let Defs = [AX], Uses = [FPSW] in
686
+ let Defs = [AX, FPSW ], Uses = [FPSW] in
677
687
def FNSTSW16r : I<0xDF, MRM_E0, // AX = fp flags
678
688
(outs), (ins), "fnstsw\t{%ax|ax}",
679
689
[(set AX, (X86fp_stsw FPSW))]>;
@@ -689,31 +699,33 @@ def FLDCW16m : I<0xD9, MRM5m, // X87 control world = [mem16]
689
699
690
700
// FPU control instructions
691
701
let SchedRW = [WriteMicrocoded] in {
692
- let Defs = [FPSW] in {
693
- def FNINIT : I<0xDB, MRM_E3, (outs), (ins), "fninit", []>;
694
702
def FFREE : FPI<0xDD, MRM0r, (outs), (ins RSTi:$reg), "ffree\t$reg">;
695
703
def FFREEP : FPI<0xDF, MRM0r, (outs), (ins RSTi:$reg), "ffreep\t$reg">;
696
704
705
+ let Defs = [FPSW, FPCW] in
706
+ def FNINIT : I<0xDB, MRM_E3, (outs), (ins), "fninit", []>;
697
707
// Clear exceptions
708
+ let Defs = [FPSW] in
698
709
def FNCLEX : I<0xDB, MRM_E2, (outs), (ins), "fnclex", []>;
699
- } // Defs = [FPSW]
700
710
} // SchedRW
701
711
702
712
// Operand-less floating-point instructions for the disassembler.
713
+ let Defs = [FPSW] in
703
714
def FNOP : I<0xD9, MRM_D0, (outs), (ins), "fnop", []>, Sched<[WriteNop]>;
704
715
705
716
let SchedRW = [WriteMicrocoded] in {
706
717
let Defs = [FPSW] in {
707
718
def WAIT : I<0x9B, RawFrm, (outs), (ins), "wait", []>;
708
719
def FXAM : I<0xD9, MRM_E5, (outs), (ins), "fxam", []>;
720
+ def FDECSTP : I<0xD9, MRM_F6, (outs), (ins), "fdecstp", []>;
721
+ def FINCSTP : I<0xD9, MRM_F7, (outs), (ins), "fincstp", []>;
722
+ let Uses = [FPCW], mayRaiseFPException = 1 in {
709
723
def F2XM1 : I<0xD9, MRM_F0, (outs), (ins), "f2xm1", []>;
710
724
def FYL2X : I<0xD9, MRM_F1, (outs), (ins), "fyl2x", []>;
711
725
def FPTAN : I<0xD9, MRM_F2, (outs), (ins), "fptan", []>;
712
726
def FPATAN : I<0xD9, MRM_F3, (outs), (ins), "fpatan", []>;
713
727
def FXTRACT : I<0xD9, MRM_F4, (outs), (ins), "fxtract", []>;
714
728
def FPREM1 : I<0xD9, MRM_F5, (outs), (ins), "fprem1", []>;
715
- def FDECSTP : I<0xD9, MRM_F6, (outs), (ins), "fdecstp", []>;
716
- def FINCSTP : I<0xD9, MRM_F7, (outs), (ins), "fincstp", []>;
717
729
def FPREM : I<0xD9, MRM_F8, (outs), (ins), "fprem", []>;
718
730
def FYL2XP1 : I<0xD9, MRM_F9, (outs), (ins), "fyl2xp1", []>;
719
731
def FSIN : I<0xD9, MRM_FE, (outs), (ins), "fsin", []>;
@@ -722,20 +734,26 @@ def FSINCOS : I<0xD9, MRM_FB, (outs), (ins), "fsincos", []>;
722
734
def FRNDINT : I<0xD9, MRM_FC, (outs), (ins), "frndint", []>;
723
735
def FSCALE : I<0xD9, MRM_FD, (outs), (ins), "fscale", []>;
724
736
def FCOMPP : I<0xDE, MRM_D9, (outs), (ins), "fcompp", []>;
737
+ } // Uses = [FPCW], mayRaiseFPException = 1
725
738
} // Defs = [FPSW]
726
739
740
+ let Uses = [FPSW, FPCW] in {
727
741
def FXSAVE : I<0xAE, MRM0m, (outs), (ins opaquemem:$dst),
728
742
"fxsave\t$dst", [(int_x86_fxsave addr:$dst)]>, TB,
729
743
Requires<[HasFXSR]>;
730
744
def FXSAVE64 : RI<0xAE, MRM0m, (outs), (ins opaquemem:$dst),
731
745
"fxsave64\t$dst", [(int_x86_fxsave64 addr:$dst)]>,
732
746
TB, Requires<[HasFXSR, In64BitMode]>;
747
+ } // Uses = [FPSW, FPCW]
748
+
749
+ let Defs = [FPSW, FPCW] in {
733
750
def FXRSTOR : I<0xAE, MRM1m, (outs), (ins opaquemem:$src),
734
751
"fxrstor\t$src", [(int_x86_fxrstor addr:$src)]>,
735
752
TB, Requires<[HasFXSR]>;
736
753
def FXRSTOR64 : RI<0xAE, MRM1m, (outs), (ins opaquemem:$src),
737
754
"fxrstor64\t$src", [(int_x86_fxrstor64 addr:$src)]>,
738
755
TB, Requires<[HasFXSR, In64BitMode]>;
756
+ } // Defs = [FPSW, FPCW]
739
757
} // SchedRW
740
758
741
759
//===----------------------------------------------------------------------===//
0 commit comments