Skip to content

Commit 2532aa5

Browse files
committed
[Clang][RISCV] Update operand order for vmerge and vcompress
From: vint32m1_t vmerge_vvm_i32m1 (vbool32_t mask, vint32m1_t op1, vint32m1_t op2, size_t vl); vint32m1_t vcompress_vm_i32m1 (vbool32_t mask, vint32m1_t src, size_t vl); To: vint32m1_t vmerge_vvm_i32m1 (vint32m1_t op1, vint32m1_t op2, vbool32_t selector, size_t vl); vint32m1_t vcompress_vm_i32m1 (vint32m1_t src, vbool32_t selector, size_t vl); Address issues: riscv-non-isa/rvv-intrinsic-doc#140 riscv-non-isa/rvv-intrinsic-doc#167 Pull request: riscv-non-isa/rvv-intrinsic-doc#185 Reviewed By: craig.topper Differential Revision: https://reviews.llvm.org/D140686
1 parent f3a2443 commit 2532aa5

File tree

15 files changed

+2135
-2152
lines changed

15 files changed

+2135
-2152
lines changed

clang/include/clang/Basic/riscv_vector.td

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,6 @@ class PolicyScheme<int val>{
137137
def NonePolicy : PolicyScheme<0>;
138138
def HasPassthruOperand : PolicyScheme<1>;
139139
def HasPolicyOperand : PolicyScheme<2>;
140-
// Specail case for passthru operand which is not a first opeand.
141-
def HasPassthruOperandAtIdx1 : PolicyScheme<3>;
142140

143141
class RVVBuiltin<string suffix, string prototype, string type_range,
144142
string overloaded_suffix = ""> {
@@ -1878,20 +1876,19 @@ defm vwmaccus : RVVOutOp1Op2BuiltinSet<"vwmaccus", "csi",
18781876
// 12.15. Vector Integer Merge Instructions
18791877
// C/C++ Operand: (mask, op1, op2, vl), Intrinsic: (passthru, op1, op2, mask, vl)
18801878
let HasMasked = false,
1881-
UnMaskedPolicyScheme = HasPassthruOperandAtIdx1,
1879+
UnMaskedPolicyScheme = HasPassthruOperand,
18821880
MaskedPolicyScheme = NonePolicy,
18831881
ManualCodegen = [{
1884-
std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
18851882
// insert poison passthru
18861883
if (PolicyAttrs == TAIL_AGNOSTIC)
18871884
Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
18881885
IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
18891886
}] in {
18901887
defm vmerge : RVVOutOp1BuiltinSet<"vmerge", "csil",
1891-
[["vvm", "v", "vmvv"],
1892-
["vxm", "v", "vmve"],
1893-
["vvm", "Uv", "UvmUvUv"],
1894-
["vxm", "Uv", "UvmUvUe"]]>;
1888+
[["vvm", "v", "vvvm"],
1889+
["vxm", "v", "vvem"],
1890+
["vvm", "Uv", "UvUvUvm"],
1891+
["vxm", "Uv", "UvUvUem"]]>;
18951892
}
18961893

18971894
// 12.16. Vector Integer Move Instructions
@@ -2022,19 +2019,18 @@ let Name = "vfclass_v", UnMaskedPolicyScheme = HasPassthruOperand in
20222019
// 14.15. Vector Floating-Point Merge Instructio
20232020
// C/C++ Operand: (mask, op1, op2, vl), Builtin: (op1, op2, mask, vl)
20242021
let HasMasked = false,
2025-
UnMaskedPolicyScheme = HasPassthruOperandAtIdx1,
2022+
UnMaskedPolicyScheme = HasPassthruOperand,
20262023
MaskedPolicyScheme = NonePolicy,
20272024
ManualCodegen = [{
2028-
std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
20292025
// insert poison passthru
20302026
if (PolicyAttrs == TAIL_AGNOSTIC)
20312027
Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
20322028
IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
20332029
}] in {
20342030
defm vmerge : RVVOutOp1BuiltinSet<"vmerge", "xfd",
2035-
[["vvm", "v", "vmvv"]]>;
2031+
[["vvm", "v", "vvvm"]]>;
20362032
defm vfmerge : RVVOutOp1BuiltinSet<"vfmerge", "xfd",
2037-
[["vfm", "v", "vmve"]]>;
2033+
[["vfm", "v", "vvem"]]>;
20382034
}
20392035

20402036
// 14.16. Vector Floating-Point Move Instruction
@@ -2222,21 +2218,20 @@ defm vrgatherei16 : RVVOutBuiltinSet<"vrgatherei16_vv", "csil",
22222218
// 17.5. Vector Compress Instruction
22232219
let IsPrototypeDefaultTU = true,
22242220
HasMasked = false,
2225-
UnMaskedPolicyScheme = HasPassthruOperandAtIdx1,
2221+
UnMaskedPolicyScheme = HasPassthruOperand,
22262222
MaskedPolicyScheme = NonePolicy,
22272223
ManualCodegen = [{
2228-
std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
22292224
// insert poison passthru
22302225
if (PolicyAttrs == TAIL_AGNOSTIC)
22312226
Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
22322227
IntrinsicTypes = {ResultType, Ops.back()->getType()};
22332228
}] in {
22342229
// signed and floating type
22352230
defm vcompress : RVVOutBuiltinSet<"vcompress", "csilxfd",
2236-
[["vm", "v", "vmvv"]]>;
2231+
[["vm", "v", "vvvm"]]>;
22372232
// unsigned type
22382233
defm vcompress : RVVOutBuiltinSet<"vcompress", "csil",
2239-
[["vm", "Uv", "UvmUvUv"]]>;
2234+
[["vm", "Uv", "UvUvUvm"]]>;
22402235
}
22412236

22422237
// Miscellaneous

clang/include/clang/Support/RISCVVIntrinsicUtils.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -366,9 +366,6 @@ enum PolicyScheme : uint8_t {
366366
// Passthru operand is at first parameter in C builtin.
367367
HasPassthruOperand,
368368
HasPolicyOperand,
369-
// Special case for vmerge, the passthru operand is second
370-
// parameter in C builtin.
371-
HasPassthruOperandAtIdx1,
372369
};
373370

374371
// TODO refactor RVVIntrinsic class design after support all intrinsic

clang/lib/Support/RISCVVIntrinsicUtils.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -964,15 +964,6 @@ llvm::SmallVector<PrototypeDescriptor> RVVIntrinsic::computeBuiltinTypes(
964964
else if (PolicyAttrs.isTAPolicy() && HasPassthruOp &&
965965
IsPrototypeDefaultTU)
966966
NewPrototype.erase(NewPrototype.begin() + 1);
967-
if (DefaultScheme == PolicyScheme::HasPassthruOperandAtIdx1) {
968-
if (PolicyAttrs.isTUPolicy() && !IsPrototypeDefaultTU) {
969-
// Insert undisturbed output to index 1
970-
NewPrototype.insert(NewPrototype.begin() + 2, NewPrototype[0]);
971-
} else if (PolicyAttrs.isTAPolicy() && IsPrototypeDefaultTU) {
972-
// Erase passthru for TA policy
973-
NewPrototype.erase(NewPrototype.begin() + 2);
974-
}
975-
}
976967
} else if (PolicyAttrs.isTUPolicy() && HasPassthruOp) {
977968
// NF > 1 cases for segment load operations.
978969
// Convert

0 commit comments

Comments
 (0)