@@ -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 GPCR:$rs1, simm12:$imm12),
1454
+ def : Pat<(CapFrameAddrRegImm(cPTR GPCR:$rs1) , simm12:$imm12),
1455
1455
(CIncOffsetImm GPCR:$rs1, simm12:$imm12)>;
1456
1456
1457
1457
/// Pointer-Arithmetic Instructions
@@ -1463,14 +1463,15 @@ 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)), (CIncOffset C0, GPR:$rs2)>;
1467
- def : Pat<(inttoptr simm12:$imm12), (CIncOffsetImm C0, simm12:$imm12)>;
1468
- def : Pat<(XLenVT (ptrtoint GPCR:$rs1)), (PseudoCGetAddr GPCR:$rs1)>;
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)>;
1469
1470
}
1470
1471
1471
1472
/// Null Capability Patterns
1472
1473
1473
- def : Pat<(inttoptr (XLenVT 0)), (CLenVT (COPY C0))>;
1474
+ def : Pat<(inttoptr(XLenVT 0)), (CLenVT(COPY(cPTR C0) ))>;
1474
1475
def : Pat<(ptrtoint (CLenVT (inttoptr (XLenVT 0)))),
1475
1476
(XLenVT (COPY (XLenVT X0)))>;
1476
1477
@@ -1481,26 +1482,31 @@ def : Pat<(ptrtoint (CLenVT (inttoptr (XLenVT 0)))),
1481
1482
// * Break untagged < tagged semantics
1482
1483
// * Can't implement exact equality
1483
1484
class CheriSetCCPatGpcrGpcr<PatFrag CondOp, dag GprGprDag>
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)))>;
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)))>;
1488
1489
1489
1490
multiclass CheriSetCCPatGpcrImm<PatFrag CondOp, Operand ImmTy, dag GprImmDag> {
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)>;
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)>;
1504
1510
}
1505
1511
1506
1512
multiclass CheriSetCCPatGpcrSimm12<PatFrag CondOp, dag GprImmDag>
@@ -1510,9 +1516,9 @@ multiclass CheriSetCCPatGpcrSimm12Plus1<PatFrag CondOp, dag GprImmDag>
1510
1516
: CheriSetCCPatGpcrImm<CondOp, simm12_plus1, GprImmDag>;
1511
1517
1512
1518
class CheriSetCCPatGpcrNull<PatFrag CondOp, dag GprDag>
1513
- : Pat<(XLenVT (CondOp GPCR:$cs1, (inttoptr (XLenVT 0)))),
1514
- (OutPatFrag<(ops node:$rs1), GprDag>
1515
- (XLenVT (EXTRACT_SUBREG GPCR:$cs1, sub_cap_addr)))>;
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)))>;
1516
1522
1517
1523
class Swap<PatFrag BinFrag>
1518
1524
: PatFrag<(ops node:$a, node:$b), (BinFrag $b, $a)>;
@@ -1555,11 +1561,10 @@ defm Select_GPCR : SelectCC_GPR_rrirr<GPCR, CLenVT>;
1555
1561
// No dedicated instructions; see above
1556
1562
1557
1563
class CheriBccPat<PatFrag CondOp, RVInstB Inst>
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)>;
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)>;
1563
1568
1564
1569
def : CheriBccPat<seteq, BEQ>;
1565
1570
def : CheriBccPat<setne, BNE>;
@@ -1569,11 +1574,10 @@ def : CheriBccPat<setult, BLTU>;
1569
1574
def : CheriBccPat<setuge, BGEU>;
1570
1575
1571
1576
class CheriBccSwapPat<PatFrag CondOp, RVInst InstBcc>
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)>;
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)>;
1577
1581
1578
1582
def : CheriBccSwapPat<setgt, BLT>;
1579
1583
def : CheriBccSwapPat<setle, BGE>;
@@ -1587,15 +1591,18 @@ def : PatGpcrGpcr<riscv_cap_equal_exact, CSEQX, XLenVT>;
1587
1591
1588
1592
/// Special Capability Register Access Instructions
1589
1593
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))>;
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)))>;
1593
1598
1594
1599
let Predicates = [HasCheri, IsCapMode] in
1595
1600
def : Pat<(int_cheri_pcc_get), (AUIPCC 0)>;
1596
1601
1597
- let Predicates = [HasCheri, NotCapMode] in
1598
- def : Pat<(int_cheri_pcc_get), (CSpecialRW SCR_PCC.Encoding, C0)>;
1602
+ let Predicates = [HasCheri,
1603
+ NotCapMode] in def : Pat<(int_cheri_pcc_get),
1604
+ (CSpecialRW SCR_PCC.Encoding,
1605
+ (cPTR C0))>;
1599
1606
1600
1607
/// Fast Register-Clearing Instructions
1601
1608
@@ -1824,13 +1831,14 @@ defm : PseudoCmpXchgPat<"atomic_cmp_swap_cap", PseudoCmpXchgCap, CLenVT, GPCR>;
1824
1831
/// Capability Mode Instructions
1825
1832
1826
1833
multiclass CheriLdPat<PatFrag LoadOp, RVInst Inst, ValueType ReturnVt = XLenVT> {
1827
- def : Pat<(ReturnVt (LoadOp (CapRegImm GPCR:$rs1, simm12:$imm12))),
1834
+ def : Pat<(ReturnVt(LoadOp(CapRegImm(cPTR GPCR:$rs1) , simm12:$imm12))),
1828
1835
(Inst GPCR:$rs1, simm12:$imm12)>;
1829
1836
}
1830
1837
1831
1838
multiclass CheriStPat<PatFrag StoreOp, RVInst Inst, RegisterClass StTy, ValueType StoreVt = XLenVT> {
1832
- def : Pat<(StoreOp (StoreVt StTy:$rs2), (CapRegImm GPCR:$rs1, simm12:$imm12)),
1833
- (Inst (StoreVt StTy:$rs2), GPCR:$rs1, simm12:$imm12)>;
1839
+ def : Pat<(StoreOp(StoreVt StTy:$rs2), (CapRegImm(cPTR GPCR:$rs1),
1840
+ simm12:$imm12)),
1841
+ (Inst(StoreVt StTy:$rs2), GPCR:$rs1, simm12:$imm12)>;
1834
1842
}
1835
1843
1836
1844
multiclass CheriAtomicStPat<PatFrag StoreOp, RVInst Inst, RegisterClass StTy, ValueType StoreVt>
@@ -2287,6 +2295,11 @@ defm : CheriLdPat<load, CLC_128, CLenVT>;
2287
2295
defm : CheriStPat<store, CSC_128, GPCR, CLenVT>;
2288
2296
} // Predicates = [HasCheri, IsRV64, IsCapMode]
2289
2297
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
+
2290
2303
//===----------------------------------------------------------------------===//
2291
2304
// Compress Instruction tablegen backend.
2292
2305
//===----------------------------------------------------------------------===//
@@ -2429,7 +2442,17 @@ let Predicates = [HasCheri, IsRV32, IsCapMode, IsRVE] in {
2429
2442
let mayLoad = true, mayStore = false, hasSideEffects = false in
2430
2443
def PseudoCLLW : Pseudo<(outs GPCR:$dst), (ins bare_symbol:$src), [],
2431
2444
"cllc", "$dst, $src">;
2432
- def : Pat<(load (cPTR (load (iPTR globaladdr:$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))))),
2433
2448
(PseudoCLLW bare_symbol:$src)>;
2434
2449
} // Predicates = [HasCheri, IsRV32, IsCapMode, IsRVE]
2435
-
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>; }
0 commit comments