|
531 | 531 | (RemU) |
532 | 532 |
|
533 | 533 | ;; RV64M Standard Extension (in addition to RV32M) |
534 | | - |
535 | 534 | (Mulw) |
536 | 535 | (Divw) |
537 | 536 | (Divuw) |
538 | 537 | (Remw) |
539 | 538 | (Remuw) |
540 | 539 |
|
541 | | - ;; bitmapip |
| 540 | + ;; Zba: Address Generation Instructions |
542 | 541 | (Adduw) |
| 542 | + (Sh1add) |
| 543 | + (Sh1adduw) |
| 544 | + (Sh2add) |
| 545 | + (Sh2adduw) |
| 546 | + (Sh3add) |
| 547 | + (Sh3adduw) |
| 548 | + |
| 549 | + ;; Zbb: Bit Manipulation Instructions |
543 | 550 | (Andn) |
544 | | - (Bclr) |
545 | | - (Bext) |
546 | | - (Binv) |
547 | | - (Bset) |
548 | | - (Clmul) |
549 | | - (Clmulh) |
550 | | - (Clmulr) |
| 551 | + (Orn) |
| 552 | + (Xnor) |
551 | 553 | (Max) |
552 | 554 | (Maxu) |
553 | 555 | (Min) |
554 | 556 | (Minu) |
555 | | - (Orn) |
556 | 557 | (Rol) |
557 | 558 | (Rolw) |
558 | 559 | (Ror) |
559 | 560 | (Rorw) |
560 | | - (Sh1add) |
561 | | - (Sh1adduw) |
562 | | - (Sh2add) |
563 | | - (Sh2adduw) |
564 | | - (Sh3add) |
565 | | - (Sh3adduw) |
566 | | - (Xnor) |
| 561 | + |
| 562 | + ;; Zbs: Single-bit instructions |
| 563 | + (Bclr) |
| 564 | + (Bext) |
| 565 | + (Binv) |
| 566 | + (Bset) |
| 567 | + |
| 568 | + ;; Zbc: Carry-less multiplication |
| 569 | + (Clmul) |
| 570 | + (Clmulh) |
| 571 | + (Clmulr) |
567 | 572 | )) |
568 | 573 |
|
569 | 574 |
|
|
601 | 606 |
|
602 | 607 |
|
603 | 608 | (type AluOPRRI (enum |
| 609 | + ;; Base ISA |
604 | 610 | (Addi) |
605 | 611 | (Slti) |
606 | 612 | (SltiU) |
|
614 | 620 | (Slliw) |
615 | 621 | (SrliW) |
616 | 622 | (Sraiw) |
617 | | - (Bclri) |
618 | | - (Bexti) |
619 | | - (Binvi) |
620 | | - (Bseti) |
621 | | - (Rori) |
622 | | - (Roriw) |
| 623 | + |
| 624 | + ;; Zba: Address Generation Instructions |
623 | 625 | (SlliUw) |
| 626 | + |
| 627 | + ;; Zbb: Bit Manipulation Instructions |
624 | 628 | (Clz) |
625 | 629 | (Clzw) |
626 | | - (Cpop) |
627 | | - (Cpopw) |
628 | 630 | (Ctz) |
629 | 631 | (Ctzw) |
630 | | - (Rev8) |
| 632 | + (Cpop) |
| 633 | + (Cpopw) |
631 | 634 | (Sextb) |
632 | 635 | (Sexth) |
633 | 636 | (Zexth) |
634 | | - (Orcb) |
| 637 | + (Rori) |
| 638 | + (Roriw) |
| 639 | + (Rev8) |
635 | 640 | (Brev8) |
| 641 | + (Orcb) |
| 642 | + |
| 643 | + ;; Zbs: Single-bit instructions |
| 644 | + (Bclri) |
| 645 | + (Bexti) |
| 646 | + (Binvi) |
| 647 | + (Bseti) |
636 | 648 | )) |
637 | 649 |
|
638 | 650 |
|
|
695 | 707 | (type AMO (primitive AMO)) |
696 | 708 | (type VecMachLabel extern (enum)) |
697 | 709 |
|
| 710 | +;; ISA Extension helpers |
| 711 | + |
| 712 | +(decl pure has_zbkb () bool) |
| 713 | +(extern constructor has_zbkb has_zbkb) |
| 714 | + |
| 715 | +(decl pure has_zba () bool) |
| 716 | +(extern constructor has_zba has_zba) |
| 717 | + |
| 718 | +(decl pure has_zbb () bool) |
| 719 | +(extern constructor has_zbb has_zbb) |
| 720 | + |
| 721 | +(decl pure has_zbc () bool) |
| 722 | +(extern constructor has_zbc has_zbc) |
| 723 | + |
| 724 | +(decl pure has_zbs () bool) |
| 725 | +(extern constructor has_zbs has_zbs) |
| 726 | + |
698 | 727 | ;; Helper for creating the zero register. |
699 | 728 | (decl zero_reg () Reg) |
700 | 729 | (extern constructor zero_reg zero_reg) |
|
908 | 937 | (decl lower_ctz (Type Reg) Reg) |
909 | 938 | (rule |
910 | 939 | (lower_ctz ty x) |
911 | | - (if-let $false (has_b)) |
| 940 | + (if-let $false (has_zbb)) |
912 | 941 | (gen_cltz $false x ty)) |
913 | 942 |
|
914 | 943 | (rule 2 |
915 | 944 | (lower_ctz $I64 x) |
916 | | - (if-let $true (has_b)) |
| 945 | + (if-let $true (has_zbb)) |
917 | 946 | (alu_rr_funct12 (AluOPRRI.Ctz) x)) |
918 | 947 |
|
919 | 948 | (rule 2 |
920 | 949 | (lower_ctz $I32 x) |
921 | | - (if-let $true (has_b)) |
| 950 | + (if-let $true (has_zbb)) |
922 | 951 | (alu_rr_funct12 (AluOPRRI.Ctzw) x)) |
| 952 | + |
923 | 953 | ;;;; for I8 and I16 |
924 | 954 | (rule 1 |
925 | 955 | (lower_ctz ty x) |
926 | | - (if-let $true (has_b)) |
| 956 | + (if-let $true (has_zbb)) |
| 957 | + (if-let $true (has_zbs)) |
927 | 958 | (let |
928 | 959 | ((tmp Reg (alu_rr_imm12 (AluOPRRI.Bseti) x (imm12_const (ty_bits ty))))) |
929 | 960 | (alu_rr_funct12 (AluOPRRI.Ctzw) x))) |
|
954 | 985 | (decl lower_clz (Type Reg) Reg) |
955 | 986 | (rule |
956 | 987 | (lower_clz ty rs) |
957 | | - (if-let $false (has_b)) |
| 988 | + (if-let $false (has_zbb)) |
958 | 989 | (gen_cltz $true rs ty)) |
959 | 990 | (rule 2 |
960 | 991 | (lower_clz $I64 r) |
961 | | - (if-let $true (has_b)) |
| 992 | + (if-let $true (has_zbb)) |
962 | 993 | (alu_rr_funct12 (AluOPRRI.Clz) r)) |
963 | 994 | (rule 2 |
964 | 995 | (lower_clz $I32 r) |
965 | | - (if-let $true (has_b)) |
| 996 | + (if-let $true (has_zbb)) |
966 | 997 | (alu_rr_funct12 (AluOPRRI.Clzw) r)) |
967 | 998 |
|
968 | 999 | ;;; for I8 and I16 |
969 | 1000 | (rule 1 |
970 | 1001 | (lower_clz ty r) |
971 | | - (if-let $true (has_b)) |
| 1002 | + (if-let $true (has_zbb)) |
972 | 1003 | (let |
973 | 1004 | ( ;; narrow int make all upper bits are zeros. |
974 | 1005 | (tmp Reg (ext_int_if_need $false r ty )) |
|
1078 | 1109 | (alu_rr_imm12 (AluOPRRI.Srli) tmp (imm12_const (ty_bits ty))))) |
1079 | 1110 |
|
1080 | 1111 |
|
1081 | | -;;; has extension B?? |
1082 | | -(decl pure has_b () bool) |
1083 | | -(extern constructor has_b has_b) |
1084 | | - |
1085 | 1112 | (decl lower_rotl (Type Reg Reg) Reg) |
1086 | 1113 |
|
1087 | 1114 | (rule 1 |
1088 | 1115 | (lower_rotl $I64 rs amount) |
1089 | | - (if-let $true (has_b)) |
| 1116 | + (if-let $true (has_zbb)) |
1090 | 1117 | (alu_rrr (AluOPRRR.Rol) rs amount)) |
1091 | 1118 |
|
1092 | 1119 | (rule |
1093 | 1120 | (lower_rotl $I64 rs amount) |
1094 | | - (if-let $false (has_b)) |
| 1121 | + (if-let $false (has_zbb)) |
1095 | 1122 | (lower_rotl_shift $I64 rs amount)) |
1096 | 1123 |
|
1097 | 1124 | (rule 1 |
1098 | 1125 | (lower_rotl $I32 rs amount) |
1099 | | - (if-let $true (has_b)) |
| 1126 | + (if-let $true (has_zbb)) |
1100 | 1127 | (alu_rrr (AluOPRRR.Rolw) rs amount)) |
1101 | 1128 |
|
1102 | 1129 | (rule |
1103 | 1130 | (lower_rotl $I32 rs amount) |
1104 | | - (if-let $false (has_b)) |
| 1131 | + (if-let $false (has_zbb)) |
1105 | 1132 | (lower_rotl_shift $I32 rs amount)) |
1106 | 1133 |
|
1107 | 1134 | (rule -1 |
|
1136 | 1163 |
|
1137 | 1164 | (rule 1 |
1138 | 1165 | (lower_rotr $I64 rs amount) |
1139 | | - (if-let $true (has_b)) |
| 1166 | + (if-let $true (has_zbb)) |
1140 | 1167 | (alu_rrr (AluOPRRR.Ror) rs amount)) |
1141 | 1168 | (rule |
1142 | 1169 | (lower_rotr $I64 rs amount) |
1143 | | - (if-let $false (has_b)) |
| 1170 | + (if-let $false (has_zbb)) |
1144 | 1171 | (lower_rotr_shift $I64 rs amount)) |
1145 | 1172 |
|
1146 | 1173 | (rule 1 |
1147 | 1174 | (lower_rotr $I32 rs amount) |
1148 | | - (if-let $true (has_b)) |
| 1175 | + (if-let $true (has_zbb)) |
1149 | 1176 | (alu_rrr (AluOPRRR.Rorw) rs amount)) |
1150 | 1177 |
|
1151 | 1178 | (rule |
1152 | 1179 | (lower_rotr $I32 rs amount) |
1153 | | - (if-let $false (has_b)) |
| 1180 | + (if-let $false (has_zbb)) |
1154 | 1181 | (lower_rotr_shift $I32 rs amount)) |
1155 | 1182 |
|
1156 | 1183 | (rule -1 |
|
1208 | 1235 |
|
1209 | 1236 | (decl lower_popcnt (Reg Type) Reg) |
1210 | 1237 | (rule 1 (lower_popcnt rs ty ) |
1211 | | - (if-let $true (has_b)) |
| 1238 | + (if-let $true (has_zbb)) |
1212 | 1239 | (alu_rr_funct12 (AluOPRRI.Cpop) (ext_int_if_need $false rs ty))) |
1213 | 1240 | (rule (lower_popcnt rs ty) |
1214 | | - (if-let $false (has_b)) |
| 1241 | + (if-let $false (has_zbb)) |
1215 | 1242 | (gen_popcnt rs ty)) |
1216 | 1243 |
|
1217 | 1244 | (decl lower_popcnt_i128 (ValueRegs) ValueRegs) |
|
1962 | 1989 | (decl gen_rev8 (Reg) Reg) |
1963 | 1990 | (rule 1 |
1964 | 1991 | (gen_rev8 rs) |
1965 | | - (if-let $true (has_b)) |
| 1992 | + (if-let $true (has_zbb)) |
1966 | 1993 | (alu_rr_funct12 (AluOPRRI.Rev8) rs)) |
1967 | 1994 |
|
1968 | 1995 | (rule |
1969 | 1996 | (gen_rev8 rs) |
1970 | | - (if-let $false (has_b)) |
| 1997 | + (if-let $false (has_zbb)) |
1971 | 1998 | (let |
1972 | 1999 | ((rd WritableReg (temp_writable_reg $I64)) |
1973 | 2000 | (tmp WritableReg (temp_writable_reg $I64)) |
1974 | 2001 | (step WritableReg (temp_writable_reg $I64)) |
1975 | 2002 | (_ Unit (emit (MInst.Rev8 rs step tmp rd)))) |
1976 | 2003 | (writable_reg_to_reg rd))) |
1977 | 2004 |
|
1978 | | -(decl pure has_zbkb () bool) |
1979 | | -(extern constructor has_zbkb has_zbkb) |
1980 | | - |
1981 | | -(decl pure has_zbb () bool) |
1982 | | -(extern constructor has_zbb has_zbb) |
1983 | 2005 |
|
1984 | 2006 | (decl gen_brev8 (Reg Type) Reg) |
1985 | 2007 | (rule 1 |
|
0 commit comments