llvm.org GIT mirror llvm / 1e93249
ptx: add floating-point comparison to setp Patched by Dan Bailey git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129847 91177308-0d34-0410-b5e6-96231b3b80d8 Che-Liang Chiou 9 years ago
1 changed file(s) with 234 addition(s) and 14 deletion(s). Raw diff Collapse all Expand all
322322 [(set RRegu64:$d, (opnode imm:$a, RRegu64:$b))]>;
323323 }
324324
325 multiclass PTX_SETP
325 multiclass PTX_SETP_I
326326 CondCode cmp, string cmpstr> {
327 // TODO 1. support floating-point 2. support 5-operand format: p|q, a, b, c
327 // TODO support 5-operand format: p|q, a, b, c
328328
329329 def rr
330330 : InstPTX<(outs Preds:$p), (ins RC:$a, RC:$b),
384384 : InstPTX<(outs Preds:$p), (ins RC:$a, immcls:$b, Preds:$c),
385385 !strconcat("setp.", cmpstr, ".xor.", regclsname, "\t$p, $a, $b, !$c"),
386386 [(set Preds:$p, (xor (setcc RC:$a, imm:$b, cmp), (not Preds:$c)))]>;
387 }
388
389 multiclass PTX_SETP_FP
390 CondCode ucmp, CondCode ocmp, string cmpstr> {
391 // TODO support 5-operand format: p|q, a, b, c
392
393 def rr_u
394 : InstPTX<(outs Preds:$p), (ins RC:$a, RC:$b),
395 !strconcat("setp.", cmpstr, "u.", regclsname, "\t$p, $a, $b"),
396 [(set Preds:$p, (setcc RC:$a, RC:$b, ucmp))]>;
397 def rr_o
398 : InstPTX<(outs Preds:$p), (ins RC:$a, RC:$b),
399 !strconcat("setp.", cmpstr, ".", regclsname, "\t$p, $a, $b"),
400 [(set Preds:$p, (setcc RC:$a, RC:$b, ocmp))]>;
401
402 def rr_and_r_u
403 : InstPTX<(outs Preds:$p), (ins RC:$a, RC:$b, Preds:$c),
404 !strconcat("setp.", cmpstr, "u.and.", regclsname, "\t$p, $a, $b, $c"),
405 [(set Preds:$p, (and (setcc RC:$a, RC:$b, ucmp), Preds:$c))]>;
406 def rr_and_r_o
407 : InstPTX<(outs Preds:$p), (ins RC:$a, RC:$b, Preds:$c),
408 !strconcat("setp.", cmpstr, ".and.", regclsname, "\t$p, $a, $b, $c"),
409 [(set Preds:$p, (and (setcc RC:$a, RC:$b, ocmp), Preds:$c))]>;
410
411 def rr_or_r_u
412 : InstPTX<(outs Preds:$p), (ins RC:$a, RC:$b, Preds:$c),
413 !strconcat("setp.", cmpstr, "u.or.", regclsname, "\t$p, $a, $b, $c"),
414 [(set Preds:$p, (or (setcc RC:$a, RC:$b, ucmp), Preds:$c))]>;
415 def rr_or_r_o
416 : InstPTX<(outs Preds:$p), (ins RC:$a, RC:$b, Preds:$c),
417 !strconcat("setp.", cmpstr, ".or.", regclsname, "\t$p, $a, $b, $c"),
418 [(set Preds:$p, (or (setcc RC:$a, RC:$b, ocmp), Preds:$c))]>;
419
420 def rr_xor_r_u
421 : InstPTX<(outs Preds:$p), (ins RC:$a, RC:$b, Preds:$c),
422 !strconcat("setp.", cmpstr, "u.xor.", regclsname, "\t$p, $a, $b, $c"),
423 [(set Preds:$p, (xor (setcc RC:$a, RC:$b, ucmp), Preds:$c))]>;
424 def rr_xor_r_o
425 : InstPTX<(outs Preds:$p), (ins RC:$a, RC:$b, Preds:$c),
426 !strconcat("setp.", cmpstr, ".xor.", regclsname, "\t$p, $a, $b, $c"),
427 [(set Preds:$p, (xor (setcc RC:$a, RC:$b, ocmp), Preds:$c))]>;
428
429 def rr_and_not_r_u
430 : InstPTX<(outs Preds:$p), (ins RC:$a, RC:$b, Preds:$c),
431 !strconcat("setp.", cmpstr, "u.and.", regclsname, "\t$p, $a, $b, !$c"),
432 [(set Preds:$p, (and (setcc RC:$a, RC:$b, ucmp), (not Preds:$c)))]>;
433 def rr_and_not_r_o
434 : InstPTX<(outs Preds:$p), (ins RC:$a, RC:$b, Preds:$c),
435 !strconcat("setp.", cmpstr, ".and.", regclsname, "\t$p, $a, $b, !$c"),
436 [(set Preds:$p, (and (setcc RC:$a, RC:$b, ocmp), (not Preds:$c)))]>;
437
438 def rr_or_not_r_u
439 : InstPTX<(outs Preds:$p), (ins RC:$a, RC:$b, Preds:$c),
440 !strconcat("setp.", cmpstr, "u.or.", regclsname, "\t$p, $a, $b, !$c"),
441 [(set Preds:$p, (or (setcc RC:$a, RC:$b, ucmp), (not Preds:$c)))]>;
442 def rr_or_not_r_o
443 : InstPTX<(outs Preds:$p), (ins RC:$a, RC:$b, Preds:$c),
444 !strconcat("setp.", cmpstr, ".or.", regclsname, "\t$p, $a, $b, !$c"),
445 [(set Preds:$p, (or (setcc RC:$a, RC:$b, ocmp), (not Preds:$c)))]>;
446
447 def rr_xor_not_r_u
448 : InstPTX<(outs Preds:$p), (ins RC:$a, RC:$b, Preds:$c),
449 !strconcat("setp.", cmpstr, "u.xor.", regclsname, "\t$p, $a, $b, !$c"),
450 [(set Preds:$p, (xor (setcc RC:$a, RC:$b, ucmp), (not Preds:$c)))]>;
451 def rr_xor_not_r_o
452 : InstPTX<(outs Preds:$p), (ins RC:$a, RC:$b, Preds:$c),
453 !strconcat("setp.", cmpstr, ".xor.", regclsname, "\t$p, $a, $b, !$c"),
454 [(set Preds:$p, (xor (setcc RC:$a, RC:$b, ocmp), (not Preds:$c)))]>;
387455 }
388456
389457 multiclass PTX_LD {
556624
557625 ///===- Comparison and Selection Instructions -----------------------------===//
558626
559 defm SETPEQu32 : PTX_SETP;
560 defm SETPNEu32 : PTX_SETP;
561 defm SETPLTu32 : PTX_SETP;
562 defm SETPLEu32 : PTX_SETP;
563 defm SETPGTu32 : PTX_SETP;
564 defm SETPGEu32 : PTX_SETP;
565 defm SETPEQu64 : PTX_SETP;
566 defm SETPNEu64 : PTX_SETP;
567 defm SETPLTu64 : PTX_SETP;
568 defm SETPLEu64 : PTX_SETP;
569 defm SETPGTu64 : PTX_SETP;
570 defm SETPGEu64 : PTX_SETP;
627 // Compare u16
628
629 defm SETPEQu16 : PTX_SETP_I;
630 defm SETPNEu16 : PTX_SETP_I;
631 defm SETPLTu16 : PTX_SETP_I;
632 defm SETPLEu16 : PTX_SETP_I;
633 defm SETPGTu16 : PTX_SETP_I;
634 defm SETPGEu16 : PTX_SETP_I;
635
636 // Compare u32
637
638 defm SETPEQu32 : PTX_SETP_I;
639 defm SETPNEu32 : PTX_SETP_I;
640 defm SETPLTu32 : PTX_SETP_I;
641 defm SETPLEu32 : PTX_SETP_I;
642 defm SETPGTu32 : PTX_SETP_I;
643 defm SETPGEu32 : PTX_SETP_I;
644
645 // Compare u64
646
647 defm SETPEQu64 : PTX_SETP_I;
648 defm SETPNEu64 : PTX_SETP_I;
649 defm SETPLTu64 : PTX_SETP_I;
650 defm SETPLEu64 : PTX_SETP_I;
651 defm SETPGTu64 : PTX_SETP_I;
652 defm SETPGEu64 : PTX_SETP_I;
653
654 // Compare f32
655
656 defm SETPEQf32 : PTX_SETP_FP;
657 defm SETPNEf32 : PTX_SETP_FP;
658 defm SETPLTf32 : PTX_SETP_FP;
659 defm SETPLEf32 : PTX_SETP_FP;
660 defm SETPGTf32 : PTX_SETP_FP;
661 defm SETPGEf32 : PTX_SETP_FP;
662
663 // Compare f64
664
665 defm SETPEQf64 : PTX_SETP_FP;
666 defm SETPNEf64 : PTX_SETP_FP;
667 defm SETPLTf64 : PTX_SETP_FP;
668 defm SETPLEf64 : PTX_SETP_FP;
669 defm SETPGTf64 : PTX_SETP_FP;
670 defm SETPGEf64 : PTX_SETP_FP;
571671
572672 ///===- Logic and Shift Instructions --------------------------------------===//
573673
653753 // defm LDp : PTX_LD_ALL<"ld.param", load_parameter>;
654754 // TODO: Do something with st.param if/when it is needed.
655755
756 // Conversion to pred
757
758 def CVT_pred_u16
759 : InstPTX<(outs Preds:$d), (ins RRegu16:$a), "cvt.pred.u16\t$d, $a",
760 [(set Preds:$d, (trunc RRegu16:$a))]>;
761
656762 def CVT_pred_u32
657763 : InstPTX<(outs Preds:$d), (ins RRegu32:$a), "cvt.pred.u32\t$d, $a",
658764 [(set Preds:$d, (trunc RRegu32:$a))]>;
659765
766 def CVT_pred_u64
767 : InstPTX<(outs Preds:$d), (ins RRegu64:$a), "cvt.pred.u64\t$d, $a",
768 [(set Preds:$d, (trunc RRegu64:$a))]>;
769
770 def CVT_pred_f32
771 : InstPTX<(outs Preds:$d), (ins RRegf32:$a), "cvt.pred.f32\t$d, $a",
772 [(set Preds:$d, (fp_to_uint RRegf32:$a))]>;
773
774 def CVT_pred_f64
775 : InstPTX<(outs Preds:$d), (ins RRegf64:$a), "cvt.pred.f64\t$d, $a",
776 [(set Preds:$d, (fp_to_uint RRegf64:$a))]>;
777
778 // Conversion to u16
779
780 def CVT_u16_pred
781 : InstPTX<(outs RRegu16:$d), (ins Preds:$a), "cvt.u16.pred\t$d, $a",
782 [(set RRegu16:$d, (zext Preds:$a))]>;
783
784 def CVT_u16_u32
785 : InstPTX<(outs RRegu16:$d), (ins RRegu32:$a), "cvt.u16.u32\t$d, $a",
786 [(set RRegu16:$d, (trunc RRegu32:$a))]>;
787
788 def CVT_u16_u64
789 : InstPTX<(outs RRegu16:$d), (ins RRegu64:$a), "cvt.u16.u64\t$d, $a",
790 [(set RRegu16:$d, (trunc RRegu64:$a))]>;
791
792 def CVT_u16_f32
793 : InstPTX<(outs RRegu16:$d), (ins RRegf32:$a), "cvt.u16.f32\t$d, $a",
794 [(set RRegu16:$d, (fp_to_uint RRegf32:$a))]>;
795
796 def CVT_u16_f64
797 : InstPTX<(outs RRegu16:$d), (ins RRegf64:$a), "cvt.u16.f64\t$d, $a",
798 [(set RRegu16:$d, (fp_to_uint RRegf64:$a))]>;
799
800 // Conversion to u32
801
660802 def CVT_u32_pred
661803 : InstPTX<(outs RRegu32:$d), (ins Preds:$a), "cvt.u32.pred\t$d, $a",
662804 [(set RRegu32:$d, (zext Preds:$a))]>;
663805
806 def CVT_u32_u16
807 : InstPTX<(outs RRegu32:$d), (ins RRegu16:$a), "cvt.u32.u16\t$d, $a",
808 [(set RRegu32:$d, (zext RRegu16:$a))]>;
809
810 def CVT_u32_u64
811 : InstPTX<(outs RRegu32:$d), (ins RRegu64:$a), "cvt.u32.u64\t$d, $a",
812 [(set RRegu32:$d, (trunc RRegu64:$a))]>;
813
814 def CVT_u32_f32
815 : InstPTX<(outs RRegu32:$d), (ins RRegf32:$a), "cvt.u32.f32\t$d, $a",
816 [(set RRegu32:$d, (fp_to_uint RRegf32:$a))]>;
817
818 def CVT_u32_f64
819 : InstPTX<(outs RRegu32:$d), (ins RRegf64:$a), "cvt.u32.f64\t$d, $a",
820 [(set RRegu32:$d, (fp_to_uint RRegf64:$a))]>;
821
822 // Conversion to u64
823
824 def CVT_u64_pred
825 : InstPTX<(outs RRegu64:$d), (ins Preds:$a), "cvt.u64.pred\t$d, $a",
826 [(set RRegu64:$d, (zext Preds:$a))]>;
827
828 def CVT_u64_u16
829 : InstPTX<(outs RRegu64:$d), (ins RRegu16:$a), "cvt.u64.u16\t$d, $a",
830 [(set RRegu64:$d, (zext RRegu16:$a))]>;
831
664832 def CVT_u64_u32
665833 : InstPTX<(outs RRegu64:$d), (ins RRegu32:$a), "cvt.u64.u32\t$d, $a",
666834 [(set RRegu64:$d, (zext RRegu32:$a))]>;
835
836 def CVT_u64_f32
837 : InstPTX<(outs RRegu64:$d), (ins RRegf32:$a), "cvt.u64.f32\t$d, $a",
838 [(set RRegu64:$d, (fp_to_uint RRegf32:$a))]>;
839
840 def CVT_u64_f64
841 : InstPTX<(outs RRegu64:$d), (ins RRegf64:$a), "cvt.u64.f32\t$d, $a",
842 [(set RRegu64:$d, (fp_to_uint RRegf64:$a))]>;
843
844 // Conversion to f32
845
846 def CVT_f32_pred
847 : InstPTX<(outs RRegf32:$d), (ins Preds:$a), "cvt.f32.pred\t$d, $a",
848 [(set RRegf32:$d, (uint_to_fp Preds:$a))]>;
849
850 def CVT_f32_u16
851 : InstPTX<(outs RRegf32:$d), (ins RRegu16:$a), "cvt.f32.u16\t$d, $a",
852 [(set RRegf32:$d, (uint_to_fp RRegu16:$a))]>;
853
854 def CVT_f32_u32
855 : InstPTX<(outs RRegf32:$d), (ins RRegu32:$a), "cvt.f32.u32\t$d, $a",
856 [(set RRegf32:$d, (uint_to_fp RRegu32:$a))]>;
857
858 def CVT_f32_u64
859 : InstPTX<(outs RRegf32:$d), (ins RRegu64:$a), "cvt.f32.u64\t$d, $a",
860 [(set RRegf32:$d, (uint_to_fp RRegu64:$a))]>;
861
862 def CVT_f32_f64
863 : InstPTX<(outs RRegf32:$d), (ins RRegf64:$a), "cvt.f32.f64\t$d, $a",
864 [(set RRegf32:$d, (fround RRegf64:$a))]>;
865
866 // Conversion to f64
867
868 def CVT_f64_pred
869 : InstPTX<(outs RRegf64:$d), (ins Preds:$a), "cvt.f64.pred\t$d, $a",
870 [(set RRegf64:$d, (uint_to_fp Preds:$a))]>;
871
872 def CVT_f64_u16
873 : InstPTX<(outs RRegf64:$d), (ins RRegu16:$a), "cvt.f64.u16\t$d, $a",
874 [(set RRegf64:$d, (uint_to_fp RRegu16:$a))]>;
875
876 def CVT_f64_u32
877 : InstPTX<(outs RRegf64:$d), (ins RRegu32:$a), "cvt.f64.u32\t$d, $a",
878 [(set RRegf64:$d, (uint_to_fp RRegu32:$a))]>;
879
880 def CVT_f64_u64
881 : InstPTX<(outs RRegf64:$d), (ins RRegu64:$a), "cvt.f64.u64\t$d, $a",
882 [(set RRegf64:$d, (uint_to_fp RRegu64:$a))]>;
883
884 def CVT_f64_f32
885 : InstPTX<(outs RRegf64:$d), (ins RRegf32:$a), "cvt.f64.f32\t$d, $a",
886 [(set RRegf64:$d, (fextend RRegf32:$a))]>;
667887
668888 ///===- Control Flow Instructions -----------------------------------------===//
669889