|
51 | 51 | ;; `i64` and smaller |
52 | 52 |
|
53 | 53 | ;; Base case, simply adding things in registers. |
54 | | -(rule iadd_base_case -1 (lower (has_type (fits_in_64 (ty_int ty)) (iadd x y))) |
| 54 | +(rule iadd_base_case -1 (lower (has_type (ty_int_ref_scalar_64 ty) (iadd x y))) |
55 | 55 | (add ty x y)) |
56 | 56 |
|
57 | 57 | ;; Special cases for when one operand is an immediate that fits in 12 bits. |
58 | | -(rule iadd_imm12_right 4 (lower (has_type (fits_in_64 (ty_int ty)) (iadd x (imm12_from_value y)))) |
| 58 | +(rule iadd_imm12_right 4 (lower (has_type (ty_int_ref_scalar_64 ty) (iadd x (imm12_from_value y)))) |
59 | 59 | (add_imm ty x y)) |
60 | 60 |
|
61 | | -(rule iadd_imm12_left 5 (lower (has_type (fits_in_64 (ty_int ty)) (iadd (imm12_from_value x) y))) |
| 61 | +(rule iadd_imm12_left 5 (lower (has_type (ty_int_ref_scalar_64 ty) (iadd (imm12_from_value x) y))) |
62 | 62 | (add_imm ty y x)) |
63 | 63 |
|
64 | 64 | ;; Same as the previous special cases, except we can switch the addition to a |
65 | 65 | ;; subtraction if the negated immediate fits in 12 bits. |
66 | | -(rule iadd_imm12_neg_right 2 (lower (has_type (fits_in_64 (ty_int ty)) (iadd x y))) |
| 66 | +(rule iadd_imm12_neg_right 2 (lower (has_type (ty_int_ref_scalar_64 ty) (iadd x y))) |
67 | 67 | (if-let imm12_neg (imm12_from_negated_value y)) |
68 | 68 | (sub_imm ty x imm12_neg)) |
69 | 69 |
|
70 | | -(rule iadd_imm12_neg_left 3 (lower (has_type (fits_in_64 (ty_int ty)) (iadd x y))) |
| 70 | +(rule iadd_imm12_neg_left 3 (lower (has_type (ty_int_ref_scalar_64 ty) (iadd x y))) |
71 | 71 | (if-let imm12_neg (imm12_from_negated_value x)) |
72 | 72 | (sub_imm ty y imm12_neg)) |
73 | 73 |
|
74 | 74 | ;; Special cases for when we're adding an extended register where the extending |
75 | 75 | ;; operation can get folded into the add itself. |
76 | | -(rule iadd_extend_right 0 (lower (has_type (fits_in_64 (ty_int ty)) (iadd x (extended_value_from_value y)))) |
| 76 | +(rule iadd_extend_right 0 (lower (has_type (ty_int_ref_scalar_64 ty) (iadd x (extended_value_from_value y)))) |
77 | 77 | (add_extend ty x y)) |
78 | 78 |
|
79 | | -(rule iadd_extend_left 1 (lower (has_type (fits_in_64 (ty_int ty)) (iadd (extended_value_from_value x) y))) |
| 79 | +(rule iadd_extend_left 1 (lower (has_type (ty_int_ref_scalar_64 ty) (iadd (extended_value_from_value x) y))) |
80 | 80 | (add_extend ty y x)) |
81 | 81 |
|
82 | 82 | ;; Special cases for when we're adding the shift of a different |
83 | 83 | ;; register by a constant amount and the shift can get folded into the add. |
84 | | -(rule iadd_ishl_right 7 (lower (has_type (fits_in_64 (ty_int ty)) |
| 84 | +(rule iadd_ishl_right 7 (lower (has_type (ty_int_ref_scalar_64 ty) |
85 | 85 | (iadd x (ishl y (iconst k))))) |
86 | 86 | (if-let amt (lshl_from_imm64 ty k)) |
87 | 87 | (add_shift ty x y amt)) |
88 | 88 |
|
89 | | -(rule iadd_ishl_left 6 (lower (has_type (fits_in_64 (ty_int ty)) |
| 89 | +(rule iadd_ishl_left 6 (lower (has_type (ty_int_ref_scalar_64 ty) |
90 | 90 | (iadd (ishl x (iconst k)) y))) |
91 | 91 | (if-let amt (lshl_from_imm64 ty k)) |
92 | 92 | (add_shift ty y x amt)) |
93 | 93 |
|
94 | 94 | ;; Fold an `iadd` and `imul` combination into a `madd` instruction. |
95 | | -(rule iadd_imul_right 7 (lower (has_type (fits_in_64 (ty_int ty)) (iadd x (imul y z)))) |
| 95 | +(rule iadd_imul_right 7 (lower (has_type (ty_int_ref_scalar_64 ty) (iadd x (imul y z)))) |
96 | 96 | (madd ty y z x)) |
97 | 97 |
|
98 | | -(rule iadd_imul_left 6 (lower (has_type (fits_in_64 (ty_int ty)) (iadd (imul x y) z))) |
| 98 | +(rule iadd_imul_left 6 (lower (has_type (ty_int_ref_scalar_64 ty) (iadd (imul x y) z))) |
99 | 99 | (madd ty x y z)) |
100 | 100 |
|
101 | 101 | ;; Fold an `isub` and `imul` combination into a `msub` instruction. |
102 | | -(rule isub_imul (lower (has_type (fits_in_64 (ty_int ty)) (isub x (imul y z)))) |
| 102 | +(rule isub_imul (lower (has_type (ty_int_ref_scalar_64 ty) (isub x (imul y z)))) |
103 | 103 | (msub ty y z x)) |
104 | 104 |
|
105 | 105 | ;; vectors |
|
720 | 720 | ;; `i64` and smaller |
721 | 721 |
|
722 | 722 | ;; Base case, simply subtracting things in registers. |
723 | | -(rule isub_base_case -4 (lower (has_type (fits_in_64 (ty_int ty)) (isub x y))) |
| 723 | +(rule isub_base_case -4 (lower (has_type (ty_int_ref_scalar_64 ty) (isub x y))) |
724 | 724 | (sub ty x y)) |
725 | 725 |
|
726 | 726 | ;; Special case for when one operand is an immediate that fits in 12 bits. |
727 | | -(rule isub_imm12 0 (lower (has_type (fits_in_64 (ty_int ty)) (isub x (imm12_from_value y)))) |
| 727 | +(rule isub_imm12 0 (lower (has_type (ty_int_ref_scalar_64 ty) (isub x (imm12_from_value y)))) |
728 | 728 | (sub_imm ty x y)) |
729 | 729 |
|
730 | 730 | ;; Same as the previous special case, except we can switch the subtraction to an |
731 | 731 | ;; addition if the negated immediate fits in 12 bits. |
732 | | -(rule isub_imm12_neg 2 (lower (has_type (fits_in_64 (ty_int ty)) (isub x y))) |
| 732 | +(rule isub_imm12_neg 2 (lower (has_type (ty_int_ref_scalar_64 ty) (isub x y))) |
733 | 733 | (if-let imm12_neg (imm12_from_negated_value y)) |
734 | 734 | (add_imm ty x imm12_neg)) |
735 | 735 |
|
736 | 736 | ;; Special cases for when we're subtracting an extended register where the |
737 | 737 | ;; extending operation can get folded into the sub itself. |
738 | | -(rule isub_extend 1 (lower (has_type (fits_in_64 (ty_int ty)) (isub x (extended_value_from_value y)))) |
| 738 | +(rule isub_extend 1 (lower (has_type (ty_int_ref_scalar_64 ty) (isub x (extended_value_from_value y)))) |
739 | 739 | (sub_extend ty x y)) |
740 | 740 |
|
741 | 741 | ;; Finally a special case for when we're subtracting the shift of a different |
742 | 742 | ;; register by a constant amount and the shift can get folded into the sub. |
743 | | -(rule isub_ishl -3 (lower (has_type (fits_in_64 (ty_int ty)) |
| 743 | +(rule isub_ishl -3 (lower (has_type (ty_int_ref_scalar_64 ty) |
744 | 744 | (isub x (ishl y (iconst k))))) |
745 | 745 | (if-let amt (lshl_from_imm64 ty k)) |
746 | 746 | (sub_shift ty x y amt)) |
|
790 | 790 | ;;;; Rules for `imul` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
791 | 791 |
|
792 | 792 | ;; `i64` and smaller. |
793 | | -(rule imul_base_case -3 (lower (has_type (fits_in_64 (ty_int ty)) (imul x y))) |
| 793 | +(rule imul_base_case -3 (lower (has_type (ty_int_ref_scalar_64 ty) (imul x y))) |
794 | 794 | (madd ty x y (zero_reg))) |
795 | 795 |
|
796 | 796 | ;; `i128`. |
|
0 commit comments