@@ -1451,7 +1451,7 @@ def : PatGpcrUimm12<int_cheri_bounded_stack_cap, CSetBoundsImm>;
1451
1451
def : PatGpcrGpr<int_cheri_bounded_stack_cap_dynamic, CSetBounds>;
1452
1452
def : PatGpcrUimm12<int_cheri_bounded_stack_cap_dynamic, CSetBoundsImm>;
1453
1453
1454
- def : Pat<(CapFrameAddrRegImm(cPTR GPCR:$rs1) , simm12:$imm12),
1454
+ def : Pat<(CapFrameAddrRegImm GPCR:$rs1, simm12:$imm12),
1455
1455
(CIncOffsetImm GPCR:$rs1, simm12:$imm12)>;
1456
1456
1457
1457
/// Pointer-Arithmetic Instructions
@@ -1463,15 +1463,14 @@ def : Pat<(XLenVT (int_cheri_cap_diff GPCR:$cs1, GPCR:$cs2)),
1463
1463
(XLenVT (EXTRACT_SUBREG GPCR:$cs2, sub_cap_addr)))>;
1464
1464
1465
1465
let Predicates = [IsPureCapABI] in {
1466
- def : Pat<(inttoptr(XLenVT GPR:$rs2)), (cPTR(CIncOffset(cPTR C0), GPR:$rs2))>;
1467
- def : Pat<(inttoptr simm12:$imm12), (cPTR(CIncOffsetImm(cPTR C0),
1468
- simm12:$imm12))>;
1469
- def : Pat<(XLenVT(ptrtoint(cPTR GPCR:$rs1))), (PseudoCGetAddr GPCR:$rs1)>;
1466
+ def : Pat<(inttoptr (XLenVT GPR:$rs2)), (CIncOffset C0, GPR:$rs2)>;
1467
+ def : Pat<(inttoptr simm12:$imm12), (CIncOffsetImm C0, simm12:$imm12)>;
1468
+ def : Pat<(XLenVT (ptrtoint GPCR:$rs1)), (PseudoCGetAddr GPCR:$rs1)>;
1470
1469
}
1471
1470
1472
1471
/// Null Capability Patterns
1473
1472
1474
- def : Pat<(inttoptr(XLenVT 0)), (CLenVT(COPY(cPTR C0) ))>;
1473
+ def : Pat<(inttoptr (XLenVT 0)), (CLenVT (COPY C0))>;
1475
1474
def : Pat<(ptrtoint (CLenVT (inttoptr (XLenVT 0)))),
1476
1475
(XLenVT (COPY (XLenVT X0)))>;
1477
1476
@@ -1482,31 +1481,26 @@ def : Pat<(ptrtoint (CLenVT (inttoptr (XLenVT 0)))),
1482
1481
// * Break untagged < tagged semantics
1483
1482
// * Can't implement exact equality
1484
1483
class CheriSetCCPatGpcrGpcr<PatFrag CondOp, dag GprGprDag>
1485
- : Pat<(XLenVT(CondOp(cPTR GPCR:$cs1), (cPTR GPCR:$cs2) )),
1486
- (OutPatFrag<(ops node:$rs1, node:$rs2), GprGprDag>(XLenVT
1487
- (EXTRACT_SUBREG GPCR:$cs1, sub_cap_addr)),
1488
- (XLenVT(EXTRACT_SUBREG GPCR:$cs2, sub_cap_addr)))>;
1484
+ : Pat<(XLenVT (CondOp GPCR:$cs1, GPCR:$cs2)),
1485
+ (OutPatFrag<(ops node:$rs1, node:$rs2), GprGprDag>
1486
+ (XLenVT (EXTRACT_SUBREG GPCR:$cs1, sub_cap_addr)),
1487
+ (XLenVT (EXTRACT_SUBREG GPCR:$cs2, sub_cap_addr)))>;
1489
1488
1490
1489
multiclass CheriSetCCPatGpcrImm<PatFrag CondOp, Operand ImmTy, dag GprImmDag> {
1491
- def : Pat<(XLenVT(CondOp(cPTR GPCR:$cs1), (inttoptr ImmTy:$imm12))),
1492
- (OutPatFrag<(ops node:$rs1, node:$imm12), GprImmDag>(XLenVT
1493
- (EXTRACT_SUBREG GPCR:$cs1, sub_cap_addr)),
1494
- ImmTy:$imm12)>;
1495
- def : Pat<(XLenVT(CondOp(cPTR GPCR:$cs1), (cptradd(inttoptr(XLenVT 0)),
1496
- ImmTy:$imm12))),
1497
- (OutPatFrag<(ops node:$rs1, node:$imm12), GprImmDag>(XLenVT
1498
- (EXTRACT_SUBREG GPCR:$cs1, sub_cap_addr)),
1499
- ImmTy:$imm12)>;
1500
- def : Pat<(XLenVT(CondOp(cPTR GPCR:$cs1),
1501
- (int_cheri_cap_offset_set(inttoptr(XLenVT 0)), ImmTy:$imm12))),
1502
- (OutPatFrag<(ops node:$rs1, node:$imm12), GprImmDag>(XLenVT
1503
- (EXTRACT_SUBREG GPCR:$cs1, sub_cap_addr)),
1504
- ImmTy:$imm12)>;
1505
- def : Pat<(XLenVT(CondOp(cPTR GPCR:$cs1),
1506
- (int_cheri_cap_address_set(inttoptr(XLenVT 0)), ImmTy:$imm12))),
1507
- (OutPatFrag<(ops node:$rs1, node:$imm12), GprImmDag>(XLenVT
1508
- (EXTRACT_SUBREG GPCR:$cs1, sub_cap_addr)),
1509
- ImmTy:$imm12)>;
1490
+ def : Pat<(XLenVT (CondOp GPCR:$cs1, (inttoptr ImmTy:$imm12))),
1491
+ (OutPatFrag<(ops node:$rs1, node:$imm12), GprImmDag>
1492
+ (XLenVT (EXTRACT_SUBREG GPCR:$cs1, sub_cap_addr)), ImmTy:$imm12)>;
1493
+ def : Pat<(XLenVT (CondOp GPCR:$cs1, (cptradd (inttoptr (XLenVT 0)), ImmTy:$imm12))),
1494
+ (OutPatFrag<(ops node:$rs1, node:$imm12), GprImmDag>
1495
+ (XLenVT (EXTRACT_SUBREG GPCR:$cs1, sub_cap_addr)), ImmTy:$imm12)>;
1496
+ def : Pat<(XLenVT (CondOp GPCR:$cs1,
1497
+ (int_cheri_cap_offset_set (inttoptr (XLenVT 0)), ImmTy:$imm12))),
1498
+ (OutPatFrag<(ops node:$rs1, node:$imm12), GprImmDag>
1499
+ (XLenVT (EXTRACT_SUBREG GPCR:$cs1, sub_cap_addr)), ImmTy:$imm12)>;
1500
+ def : Pat<(XLenVT (CondOp GPCR:$cs1,
1501
+ (int_cheri_cap_address_set (inttoptr (XLenVT 0)), ImmTy:$imm12))),
1502
+ (OutPatFrag<(ops node:$rs1, node:$imm12), GprImmDag>
1503
+ (XLenVT (EXTRACT_SUBREG GPCR:$cs1, sub_cap_addr)), ImmTy:$imm12)>;
1510
1504
}
1511
1505
1512
1506
multiclass CheriSetCCPatGpcrSimm12<PatFrag CondOp, dag GprImmDag>
@@ -1516,9 +1510,9 @@ multiclass CheriSetCCPatGpcrSimm12Plus1<PatFrag CondOp, dag GprImmDag>
1516
1510
: CheriSetCCPatGpcrImm<CondOp, simm12_plus1, GprImmDag>;
1517
1511
1518
1512
class CheriSetCCPatGpcrNull<PatFrag CondOp, dag GprDag>
1519
- : Pat<(XLenVT(CondOp(cPTR GPCR:$cs1) , (inttoptr(XLenVT 0)))),
1520
- (OutPatFrag<(ops node:$rs1), GprDag>(XLenVT(EXTRACT_SUBREG GPCR:$cs1,
1521
- sub_cap_addr)))>;
1513
+ : Pat<(XLenVT (CondOp GPCR:$cs1, (inttoptr (XLenVT 0)))),
1514
+ (OutPatFrag<(ops node:$rs1), GprDag>
1515
+ (XLenVT (EXTRACT_SUBREG GPCR:$cs1, sub_cap_addr)))>;
1522
1516
1523
1517
class Swap<PatFrag BinFrag>
1524
1518
: PatFrag<(ops node:$a, node:$b), (BinFrag $b, $a)>;
@@ -1561,10 +1555,11 @@ defm Select_GPCR : SelectCC_GPR_rrirr<GPCR, CLenVT>;
1561
1555
// No dedicated instructions; see above
1562
1556
1563
1557
class CheriBccPat<PatFrag CondOp, RVInstB Inst>
1564
- : Pat<(brcond(XLenVT(CondOp(cPTR GPCR:$rs1), (cPTR GPCR:$rs2))), bb:$imm12),
1565
- (Inst(XLenVT(EXTRACT_SUBREG GPCR:$rs1, sub_cap_addr)),
1566
- (XLenVT(EXTRACT_SUBREG GPCR:$rs2, sub_cap_addr)),
1567
- simm13_lsb0:$imm12)>;
1558
+ : Pat<(brcond (XLenVT (CondOp GPCR:$rs1, GPCR:$rs2)), bb:$imm12),
1559
+ (Inst
1560
+ (XLenVT (EXTRACT_SUBREG GPCR:$rs1, sub_cap_addr)),
1561
+ (XLenVT (EXTRACT_SUBREG GPCR:$rs2, sub_cap_addr)),
1562
+ simm13_lsb0:$imm12)>;
1568
1563
1569
1564
def : CheriBccPat<seteq, BEQ>;
1570
1565
def : CheriBccPat<setne, BNE>;
@@ -1574,10 +1569,11 @@ def : CheriBccPat<setult, BLTU>;
1574
1569
def : CheriBccPat<setuge, BGEU>;
1575
1570
1576
1571
class CheriBccSwapPat<PatFrag CondOp, RVInst InstBcc>
1577
- : Pat<(brcond(XLenVT(CondOp(cPTR GPCR:$rs1), (cPTR GPCR:$rs2))), bb:$imm12),
1578
- (InstBcc(XLenVT(EXTRACT_SUBREG GPCR:$rs2, sub_cap_addr)),
1579
- (XLenVT(EXTRACT_SUBREG GPCR:$rs1, sub_cap_addr)),
1580
- simm13_lsb0:$imm12)>;
1572
+ : Pat<(brcond (XLenVT (CondOp GPCR:$rs1, GPCR:$rs2)), bb:$imm12),
1573
+ (InstBcc
1574
+ (XLenVT (EXTRACT_SUBREG GPCR:$rs2, sub_cap_addr)),
1575
+ (XLenVT (EXTRACT_SUBREG GPCR:$rs1, sub_cap_addr)),
1576
+ simm13_lsb0:$imm12)>;
1581
1577
1582
1578
def : CheriBccSwapPat<setgt, BLT>;
1583
1579
def : CheriBccSwapPat<setle, BGE>;
@@ -1591,18 +1587,15 @@ def : PatGpcrGpcr<riscv_cap_equal_exact, CSEQX, XLenVT>;
1591
1587
1592
1588
/// Special Capability Register Access Instructions
1593
1589
1594
- def : Pat<(int_cheri_ddc_get), (CSpecialRW SCR_DDC.Encoding, (cPTR C0))>;
1595
- let Predicates = [HasCheri,
1596
- IsPureCapABI] in def : Pat<(int_cheri_stack_cap_get),
1597
- (CLenVT(COPY(cPTR C2)))>;
1590
+ def : Pat<(int_cheri_ddc_get), (CSpecialRW SCR_DDC.Encoding, C0)>;
1591
+ let Predicates = [HasCheri, IsPureCapABI] in
1592
+ def : Pat<(int_cheri_stack_cap_get), (CLenVT (COPY C2))>;
1598
1593
1599
1594
let Predicates = [HasCheri, IsCapMode] in
1600
1595
def : Pat<(int_cheri_pcc_get), (AUIPCC 0)>;
1601
1596
1602
- let Predicates = [HasCheri,
1603
- NotCapMode] in def : Pat<(int_cheri_pcc_get),
1604
- (CSpecialRW SCR_PCC.Encoding,
1605
- (cPTR C0))>;
1597
+ let Predicates = [HasCheri, NotCapMode] in
1598
+ def : Pat<(int_cheri_pcc_get), (CSpecialRW SCR_PCC.Encoding, C0)>;
1606
1599
1607
1600
/// Fast Register-Clearing Instructions
1608
1601
@@ -1831,14 +1824,13 @@ defm : PseudoCmpXchgPat<"atomic_cmp_swap_cap", PseudoCmpXchgCap, CLenVT, GPCR>;
1831
1824
/// Capability Mode Instructions
1832
1825
1833
1826
multiclass CheriLdPat<PatFrag LoadOp, RVInst Inst, ValueType ReturnVt = XLenVT> {
1834
- def : Pat<(ReturnVt(LoadOp(CapRegImm(cPTR GPCR:$rs1) , simm12:$imm12))),
1827
+ def : Pat<(ReturnVt (LoadOp (CapRegImm GPCR:$rs1, simm12:$imm12))),
1835
1828
(Inst GPCR:$rs1, simm12:$imm12)>;
1836
1829
}
1837
1830
1838
1831
multiclass CheriStPat<PatFrag StoreOp, RVInst Inst, RegisterClass StTy, ValueType StoreVt = XLenVT> {
1839
- def : Pat<(StoreOp(StoreVt StTy:$rs2), (CapRegImm(cPTR GPCR:$rs1),
1840
- simm12:$imm12)),
1841
- (Inst(StoreVt StTy:$rs2), GPCR:$rs1, simm12:$imm12)>;
1832
+ def : Pat<(StoreOp (StoreVt StTy:$rs2), (CapRegImm GPCR:$rs1, simm12:$imm12)),
1833
+ (Inst (StoreVt StTy:$rs2), GPCR:$rs1, simm12:$imm12)>;
1842
1834
}
1843
1835
1844
1836
multiclass CheriAtomicStPat<PatFrag StoreOp, RVInst Inst, RegisterClass StTy, ValueType StoreVt>
@@ -2295,11 +2287,6 @@ defm : CheriLdPat<load, CLC_128, CLenVT>;
2295
2287
defm : CheriStPat<store, CSC_128, GPCR, CLenVT>;
2296
2288
} // Predicates = [HasCheri, IsRV64, IsCapMode]
2297
2289
2298
- let Predicates = [HasCheri, HasCheriot, IsRV32, IsCapMode] in {
2299
- defm : CheriLdPat<load, CLC_64, f64>;
2300
- defm : CheriStPat<store, CSC_64, GPCR, f64>;
2301
- } // Predicates = [HasCheri, HasCheriot, IsRV32, IsCapMode]
2302
-
2303
2290
//===----------------------------------------------------------------------===//
2304
2291
// Compress Instruction tablegen backend.
2305
2292
//===----------------------------------------------------------------------===//
@@ -2442,17 +2429,7 @@ let Predicates = [HasCheri, IsRV32, IsCapMode, IsRVE] in {
2442
2429
let mayLoad = true, mayStore = false, hasSideEffects = false in
2443
2430
def PseudoCLLW : Pseudo<(outs GPCR:$dst), (ins bare_symbol:$src), [],
2444
2431
"cllc", "$dst, $src">;
2445
- def : Pat<(c64(load(cPTR(load(iPTR globaladdr:$src))))),
2446
- (PseudoCLLW bare_symbol:$src)>;
2447
- def : Pat<(f64(load(cPTR(load(iPTR globaladdr:$src))))),
2432
+ def : Pat<(load (cPTR (load (iPTR globaladdr:$src)))),
2448
2433
(PseudoCLLW bare_symbol:$src)>;
2449
2434
} // Predicates = [HasCheri, IsRV32, IsCapMode, IsRVE]
2450
-
2451
- // Cheriot stores f64 in cap registers, so bitcasting between f64 and c64
2452
- // is a no-op.
2453
- multiclass NopCapRegCast<ValueType Ty1, ValueType Ty2> {
2454
- def : Pat<(Ty1(bitconvert(Ty2 GPCR:$Val))), (Ty1 GPCR:$Val)>;
2455
- def : Pat<(Ty2(bitconvert(Ty1 GPCR:$Val))), (Ty2 GPCR:$Val)>;
2456
- }
2457
-
2458
- let Predicates = [HasCheri, HasCheriot] in { defm : NopCapRegCast<c64, f64>; }
2435
+
0 commit comments