Skip to content

Commit b772538

Browse files
authored
[Clang][XTHeadVector] Implement 17.4-17.6 vmv/vfmv/vslide/vrgather/vcompress (llvm#106)
* [Clang][XTHeadVector] Implement 17.4-17.6 `vmv/vfmv/vslide/vrgather/vcompress` * [Clang][XTHeadVector] Test 17.4-17.6 `vmv/vfmv/vslide/vrgather/vcompress` * [Clang][XTHeadVector] Implement wrappers for 17.4-17.6 `vmv/vfmv/vslide/vrgather/vcompress` * [NFC] fix format
1 parent 660c32c commit b772538

File tree

14 files changed

+11204
-0
lines changed

14 files changed

+11204
-0
lines changed

clang/include/clang/Basic/riscv_vector_xtheadv.td

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,11 @@ multiclass RVVIntReductionBuiltinSet
284284
: RVVSignedReductionBuiltin,
285285
RVVUnsignedReductionBuiltin;
286286

287+
multiclass RVVSlideOneBuiltinSet
288+
: RVVOutOp1BuiltinSet<NAME, "csil",
289+
[["vx", "v", "vve"],
290+
["vx", "Uv", "UvUvUe"]]>;
291+
287292
//===----------------------------------------------------------------------===//
288293
// 6. Configuration-Setting and Utility
289294
//===----------------------------------------------------------------------===//
@@ -1494,5 +1499,93 @@ let UnMaskedPolicyScheme = HasPassthruOperand,
14941499
["v", "Uv", "Uv"]]>;
14951500
}
14961501

1502+
// 17.4. Vector Slide Operations
1503+
let UnMaskedPolicyScheme = NonePolicy,
1504+
MaskedPolicyScheme = HasPassthruOperand,
1505+
HasMaskedOffOperand = false,
1506+
ManualCodegen = [{
1507+
if (IsMasked) {
1508+
std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1509+
}
1510+
1511+
// TODO: no policy in LLVM side for masked intrinsics.
1512+
// Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1513+
IntrinsicTypes = {ResultType, Ops.back()->getType()};
1514+
}]
1515+
in {
1516+
multiclass RVVSlideUpBuiltinSet {
1517+
defm "" : RVVOutBuiltinSet<NAME, "csilxfd",
1518+
[["vx","v", "vvvz"]]>;
1519+
defm "" : RVVOutBuiltinSet<NAME, "csil",
1520+
[["vx","Uv", "UvUvUvz"]]>;
1521+
}
1522+
}
1523+
1524+
let UnMaskedPolicyScheme = NonePolicy,
1525+
MaskedPolicyScheme = HasPassthruOperand,
1526+
HasMaskedOffOperand = false,
1527+
ManualCodegen = [{
1528+
if (IsMasked) {
1529+
std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1530+
if ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA))
1531+
Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
1532+
} else {
1533+
if (PolicyAttrs & RVV_VTA)
1534+
Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
1535+
}
1536+
1537+
// TODO: no policy in LLVM side for masked intrinsics.
1538+
// Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1539+
IntrinsicTypes = {ResultType, Ops.back()->getType()};
1540+
}] in {
1541+
multiclass RVVSlideDownBuiltinSet {
1542+
defm "" : RVVOutBuiltinSet<NAME, "csilxfd",
1543+
[["vx","v", "vvz"]]>;
1544+
defm "" : RVVOutBuiltinSet<NAME, "csil",
1545+
[["vx","Uv", "UvUvz"]]>;
1546+
}
1547+
}
1548+
1549+
defm th_vslideup : RVVSlideUpBuiltinSet;
1550+
defm th_vslidedown : RVVSlideDownBuiltinSet;
1551+
1552+
let UnMaskedPolicyScheme = HasPassthruOperand,
1553+
MaskedPolicyScheme = HasPassthruOperand in {
1554+
defm th_vslide1up : RVVSlideOneBuiltinSet;
1555+
defm th_vslide1down : RVVSlideOneBuiltinSet;
1556+
}
1557+
1558+
// 17.5. Vector Register Gather Operations
1559+
let UnMaskedPolicyScheme = HasPassthruOperand,
1560+
MaskedPolicyScheme = HasPassthruOperand in {
1561+
// signed and floating type
1562+
defm th_vrgather : RVVOutBuiltinSet<"th_vrgather_vv", "csilxfd",
1563+
[["vv", "v", "vvUv"]]>;
1564+
defm th_vrgather : RVVOutBuiltinSet<"th_vrgather_vx", "csilxfd",
1565+
[["vx", "v", "vvz"]]>;
1566+
// unsigned type
1567+
defm th_vrgather : RVVOutBuiltinSet<"th_vrgather_vv", "csil",
1568+
[["vv", "Uv", "UvUvUv"]]>;
1569+
defm th_vrgather : RVVOutBuiltinSet<"th_vrgather_vx", "csil",
1570+
[["vx", "Uv", "UvUvz"]]>;
1571+
}
1572+
1573+
// 17.6. Vector Compress Operations
1574+
let HasMasked = false,
1575+
UnMaskedPolicyScheme = HasPassthruOperand,
1576+
MaskedPolicyScheme = NonePolicy,
1577+
ManualCodegen = [{
1578+
// insert poison passthru
1579+
if (PolicyAttrs & RVV_VTA)
1580+
Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
1581+
IntrinsicTypes = {ResultType, Ops.back()->getType()};
1582+
}] in {
1583+
// signed and floating type
1584+
defm th_vcompress : RVVOutBuiltinSet<"th_vcompress", "csilxfd",
1585+
[["vm", "v", "vvm"]]>;
1586+
// unsigned type
1587+
defm th_vcompress : RVVOutBuiltinSet<"th_vcompress", "csil",
1588+
[["vm", "Uv", "UvUvm"]]>;
1589+
}
14971590

14981591
include "riscv_vector_xtheadv_wrappers.td"

clang/include/clang/Basic/riscv_vector_xtheadv_wrappers.td

Lines changed: 531 additions & 0 deletions
Large diffs are not rendered by default.

clang/test/CodeGen/RISCV/rvv0p71-intrinsics-handcrafted/vector-permutation/thead/vcompress.c

Lines changed: 449 additions & 0 deletions
Large diffs are not rendered by default.

clang/test/CodeGen/RISCV/rvv0p71-intrinsics-handcrafted/vector-permutation/thead/vrgather.c

Lines changed: 1769 additions & 0 deletions
Large diffs are not rendered by default.

clang/test/CodeGen/RISCV/rvv0p71-intrinsics-handcrafted/vector-permutation/thead/vslide1down.c

Lines changed: 648 additions & 0 deletions
Large diffs are not rendered by default.

clang/test/CodeGen/RISCV/rvv0p71-intrinsics-handcrafted/vector-permutation/thead/vslide1up.c

Lines changed: 648 additions & 0 deletions
Large diffs are not rendered by default.

clang/test/CodeGen/RISCV/rvv0p71-intrinsics-handcrafted/vector-permutation/thead/vslidedown.c

Lines changed: 888 additions & 0 deletions
Large diffs are not rendered by default.

clang/test/CodeGen/RISCV/rvv0p71-intrinsics-handcrafted/vector-permutation/thead/vslideup.c

Lines changed: 888 additions & 0 deletions
Large diffs are not rendered by default.

clang/test/CodeGen/RISCV/rvv0p71-intrinsics-handcrafted/vector-permutation/wrappers/vcompress.c

Lines changed: 449 additions & 0 deletions
Large diffs are not rendered by default.

clang/test/CodeGen/RISCV/rvv0p71-intrinsics-handcrafted/vector-permutation/wrappers/vrgather.c

Lines changed: 1769 additions & 0 deletions
Large diffs are not rendered by default.

clang/test/CodeGen/RISCV/rvv0p71-intrinsics-handcrafted/vector-permutation/wrappers/vslide1down.c

Lines changed: 648 additions & 0 deletions
Large diffs are not rendered by default.

clang/test/CodeGen/RISCV/rvv0p71-intrinsics-handcrafted/vector-permutation/wrappers/vslide1up.c

Lines changed: 648 additions & 0 deletions
Large diffs are not rendered by default.

clang/test/CodeGen/RISCV/rvv0p71-intrinsics-handcrafted/vector-permutation/wrappers/vslidedown.c

Lines changed: 888 additions & 0 deletions
Large diffs are not rendered by default.

clang/test/CodeGen/RISCV/rvv0p71-intrinsics-handcrafted/vector-permutation/wrappers/vslideup.c

Lines changed: 888 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)