diff --git a/clang/include/clang/Basic/riscv_vector.td b/clang/include/clang/Basic/riscv_vector.td --- a/clang/include/clang/Basic/riscv_vector.td +++ b/clang/include/clang/Basic/riscv_vector.td @@ -629,12 +629,12 @@ if (IsMasked) { // Move mask to right before vl. std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1); - if (DefaultPolicy == TAIL_AGNOSTIC_MASK_AGNOSTIC) + if (PolicyAttrs == TAIL_AGNOSTIC_MASK_AGNOSTIC) Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType)); - Ops.push_back(ConstantInt::get(Ops.back()->getType(), DefaultPolicy)); + Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs)); IntrinsicTypes = {ResultType, Ops[4]->getType()}; } else { - if (DefaultPolicy == TAIL_AGNOSTIC) + if (PolicyAttrs == TAIL_AGNOSTIC) Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType)); IntrinsicTypes = {ResultType, Ops[3]->getType()}; } @@ -847,7 +847,7 @@ // TAMA builtin: (val0 address, ..., mask, ptr, vl) // builtin: (val0 address, ..., mask, maskedoff0, ..., ptr, vl) // intrinsic: (maskedoff0, ..., ptr, mask, vl) - if (DefaultPolicy == TAIL_AGNOSTIC_MASK_AGNOSTIC) { + if (PolicyAttrs == TAIL_AGNOSTIC_MASK_AGNOSTIC) { for (unsigned I = 0; I < NF; ++I) Operands.push_back(llvm::PoisonValue::get(ResultType)); Operands.push_back(Ops[NF + 1]); @@ -860,13 +860,13 @@ Operands.push_back(Ops[NF]); Operands.push_back(Ops[2 * NF + 2]); } - Operands.push_back(ConstantInt::get(Ops.back()->getType(), DefaultPolicy)); + Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs)); assert(Operands.size() == NF + 4); } else { // TA builtin: (val0 address, val1 address, ..., ptr, vl) // TU builtin: (val0 address, ..., passthru0, ..., ptr, vl) // intrinsic: (passthru0, passthru1, ..., ptr, vl) - if (DefaultPolicy == TAIL_AGNOSTIC) { + if (PolicyAttrs == TAIL_AGNOSTIC) { for (unsigned I = 0; I < NF; ++I) Operands.push_back(llvm::PoisonValue::get(ResultType)); Operands.push_back(Ops[NF]); @@ -926,7 +926,7 @@ // TAMA builtin: (val0 address, ..., mask, ptr, new_vl, vl) // builtin: (val0 address, ..., mask, maskedoff0, ..., ptr, new_vl, vl) // intrinsic: (maskedoff0, ..., ptr, mask, vl) - if (DefaultPolicy == TAIL_AGNOSTIC_MASK_AGNOSTIC) { + if (PolicyAttrs == TAIL_AGNOSTIC_MASK_AGNOSTIC) { for (unsigned I = 0; I < NF; ++I) Operands.push_back(llvm::PoisonValue::get(ResultType)); Operands.push_back(Ops[NF + 1]); @@ -941,13 +941,13 @@ Operands.push_back(Ops[2 * NF + 3]); NewVL = Ops[2 * NF + 2]; } - Operands.push_back(ConstantInt::get(Ops.back()->getType(), DefaultPolicy)); + Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs)); assert(Operands.size() == NF + 4); } else { // TA builtin: (val0 address, val1 address, ..., ptr, new_vl, vl) // TU builtin: (val0 address, ..., passthru0, ..., ptr, new_vl, vl) // intrinsic: (passthru0, passthru1, ..., ptr, vl) - if (DefaultPolicy == TAIL_AGNOSTIC) { + if (PolicyAttrs == TAIL_AGNOSTIC) { for (unsigned I = 0; I < NF; ++I) Operands.push_back(llvm::PoisonValue::get(ResultType)); Operands.push_back(Ops[NF]); @@ -1009,7 +1009,7 @@ // TAMA builtin: (val0 address, ..., mask, ptr, stride, vl) // builtin: (val0 address, ..., mask, maskedoff0, ..., ptr, stride, vl) // intrinsic: (maskedoff0, ..., ptr, stride, mask, vl) - if (DefaultPolicy == TAIL_AGNOSTIC_MASK_AGNOSTIC) { + if (PolicyAttrs == TAIL_AGNOSTIC_MASK_AGNOSTIC) { for (unsigned I = 0; I < NF; ++I) Operands.push_back(llvm::PoisonValue::get(ResultType)); Operands.push_back(Ops[NF + 1]); @@ -1024,13 +1024,13 @@ Operands.push_back(Ops[NF]); Operands.push_back(Ops[2 * NF + 3]); } - Operands.push_back(ConstantInt::get(Ops.back()->getType(), DefaultPolicy)); + Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs)); assert(Operands.size() == NF + 5); } else { // TA builtin: (val0 address, val1 address, ..., ptr, stride, vl) // TU builtin: (val0 address, ..., passthru0, ..., ptr, stride, vl) // intrinsic: (passthru0, passthru1, ..., ptr, stride, vl) - if (DefaultPolicy == TAIL_AGNOSTIC) { + if (PolicyAttrs == TAIL_AGNOSTIC) { for (unsigned I = 0; I < NF; ++I) Operands.push_back(llvm::PoisonValue::get(ResultType)); Operands.push_back(Ops[NF]); @@ -1085,7 +1085,7 @@ // TAMA builtin: (val0 address, ..., mask, ptr, index, vl) // builtin: (val0 address, ..., mask, maskedoff0, ..., ptr, index, vl) // intrinsic: (maskedoff0, ..., ptr, index, mask, vl) - if (DefaultPolicy == TAIL_AGNOSTIC_MASK_AGNOSTIC) { + if (PolicyAttrs == TAIL_AGNOSTIC_MASK_AGNOSTIC) { for (unsigned I = 0; I < NF; ++I) Operands.push_back(llvm::PoisonValue::get(ResultType)); Operands.push_back(Ops[NF + 1]); @@ -1102,13 +1102,13 @@ Operands.push_back(Ops[2 * NF + 3]); IntrinsicTypes = {ResultType, Ops[2 * NF + 2]->getType(), Ops.back()->getType()}; } - Operands.push_back(ConstantInt::get(Ops.back()->getType(), DefaultPolicy)); + Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs)); assert(Operands.size() == NF + 5); } else { // TA builtin: (val0 address, val1 address, ..., ptr, index, vl) // TU builtin: (val0 address, ..., passthru0, ..., ptr, index, vl) // intrinsic: (passthru0, passthru1, ..., ptr, index, vl) - if (DefaultPolicy == TAIL_AGNOSTIC) { + if (PolicyAttrs == TAIL_AGNOSTIC) { for (unsigned I = 0; I < NF; ++I) Operands.push_back(llvm::PoisonValue::get(ResultType)); Operands.push_back(Ops[NF]); @@ -1300,17 +1300,17 @@ { if (IsMasked) { std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1); - if (DefaultPolicy == TAIL_AGNOSTIC_MASK_AGNOSTIC) + if (PolicyAttrs == TAIL_AGNOSTIC_MASK_AGNOSTIC) Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType)); } else { - if (DefaultPolicy == TAIL_AGNOSTIC) + if (PolicyAttrs == TAIL_AGNOSTIC) Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType)); } auto ElemTy = cast(ResultType)->getElementType(); Ops.insert(Ops.begin() + 2, llvm::Constant::getNullValue(ElemTy)); if (IsMasked) { - Ops.push_back(ConstantInt::get(Ops.back()->getType(), DefaultPolicy)); + Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs)); // maskedoff, op1, op2, mask, vl, policy IntrinsicTypes = {ResultType, ElemTy, Ops[4]->getType()}; } else { @@ -1333,17 +1333,17 @@ { if (IsMasked) { std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1); - if (DefaultPolicy == TAIL_AGNOSTIC_MASK_AGNOSTIC) + if (PolicyAttrs == TAIL_AGNOSTIC_MASK_AGNOSTIC) Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType)); } else { - if (DefaultPolicy == TAIL_AGNOSTIC) + if (PolicyAttrs == TAIL_AGNOSTIC) Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType)); } auto ElemTy = cast(ResultType)->getElementType(); Ops.insert(Ops.begin() + 2, llvm::Constant::getAllOnesValue(ElemTy)); if (IsMasked) { - Ops.push_back(ConstantInt::get(Ops.back()->getType(), DefaultPolicy)); + Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs)); // maskedoff, op1, po2, mask, vl, policy IntrinsicTypes = {ResultType, ElemTy, @@ -1388,16 +1388,16 @@ { if (IsMasked) { std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1); - if (DefaultPolicy == TAIL_AGNOSTIC_MASK_AGNOSTIC) + if (PolicyAttrs == TAIL_AGNOSTIC_MASK_AGNOSTIC) Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType)); Ops.insert(Ops.begin() + 2, Ops[1]); - Ops.push_back(ConstantInt::get(Ops.back()->getType(), DefaultPolicy)); + Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs)); // maskedoff, op1, op2, mask, vl IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()}; } else { - if (DefaultPolicy == TAIL_AGNOSTIC) + if (PolicyAttrs == TAIL_AGNOSTIC) Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType)); // op1, po2, vl IntrinsicTypes = {ResultType, @@ -1423,16 +1423,16 @@ { if (IsMasked) { std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1); - if (DefaultPolicy == TAIL_AGNOSTIC_MASK_AGNOSTIC) + if (PolicyAttrs == TAIL_AGNOSTIC_MASK_AGNOSTIC) Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType)); } else { - if (DefaultPolicy == TAIL_AGNOSTIC) + if (PolicyAttrs == TAIL_AGNOSTIC) Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType)); } auto ElemTy = cast(ResultType)->getElementType(); Ops.insert(Ops.begin() + 2, llvm::Constant::getNullValue(ElemTy)); if (IsMasked) { - Ops.push_back(ConstantInt::get(Ops.back()->getType(), DefaultPolicy)); + Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs)); // maskedoff, op1, op2, mask, vl, policy IntrinsicTypes = {ResultType, Ops[1]->getType(), @@ -1465,15 +1465,15 @@ { if (IsMasked) { std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1); - if (DefaultPolicy == TAIL_AGNOSTIC_MASK_AGNOSTIC) + if (PolicyAttrs == TAIL_AGNOSTIC_MASK_AGNOSTIC) Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType)); } else { - if (DefaultPolicy == TAIL_AGNOSTIC) + if (PolicyAttrs == TAIL_AGNOSTIC) Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType)); } Ops.insert(Ops.begin() + 2, llvm::Constant::getNullValue(Ops.back()->getType())); if (IsMasked) { - Ops.push_back(ConstantInt::get(Ops.back()->getType(), DefaultPolicy)); + Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs)); // maskedoff, op1, xlen, mask, vl IntrinsicTypes = {ResultType, Ops[1]->getType(), @@ -1844,7 +1844,7 @@ ManualCodegen = [{ std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1); // insert poison passthru - if (DefaultPolicy == TAIL_AGNOSTIC) + if (PolicyAttrs == TAIL_AGNOSTIC) Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType)); IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()}; }] in { @@ -1988,7 +1988,7 @@ ManualCodegen = [{ std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1); // insert poison passthru - if (DefaultPolicy == TAIL_AGNOSTIC) + if (PolicyAttrs == TAIL_AGNOSTIC) Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType)); IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()}; }] in { @@ -2188,7 +2188,7 @@ ManualCodegen = [{ std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1); // insert poison passthru - if (DefaultPolicy == TAIL_AGNOSTIC) + if (PolicyAttrs == TAIL_AGNOSTIC) Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType)); IntrinsicTypes = {ResultType, Ops.back()->getType()}; }] in { diff --git a/clang/include/clang/Support/RISCVVIntrinsicUtils.h b/clang/include/clang/Support/RISCVVIntrinsicUtils.h --- a/clang/include/clang/Support/RISCVVIntrinsicUtils.h +++ b/clang/include/clang/Support/RISCVVIntrinsicUtils.h @@ -394,7 +394,7 @@ // InputTypes. -1 means the return type. std::vector IntrinsicTypes; unsigned NF = 1; - Policy DefaultPolicy; + Policy PolicyAttrs; public: RVVIntrinsic(llvm::StringRef Name, llvm::StringRef Suffix, @@ -405,7 +405,7 @@ const RVVTypes &Types, const std::vector &IntrinsicTypes, const std::vector &RequiredFeatures, - unsigned NF, Policy DefaultPolicy, bool IsPrototypeDefaultTU); + unsigned NF, Policy PolicyAttrs, bool IsPrototypeDefaultTU); ~RVVIntrinsic() = default; RVVTypePtr getOutputType() const { return OutputType; } @@ -433,30 +433,30 @@ const std::vector &getIntrinsicTypes() const { return IntrinsicTypes; } - Policy getDefaultPolicy() const { - assert(DefaultPolicy.PolicyNone == false); - return DefaultPolicy; + Policy getPolicyAttrs() const { + assert(PolicyAttrs.PolicyNone == false); + return PolicyAttrs; } - unsigned getDefaultPolicyBits() const { + unsigned getPolicyAttrsBits() const { // Return following value. // constexpr unsigned TAIL_UNDISTURBED = 0; // constexpr unsigned TAIL_AGNOSTIC = 1; // constexpr unsigned TAIL_AGNOSTIC_MASK_AGNOSTIC = 3; // FIXME: how about value 2 - // int DefaultPolicy = TAIL_UNDISTURBED; - assert(DefaultPolicy.PolicyNone == false); + // int PolicyAttrs = TAIL_UNDISTURBED; + assert(PolicyAttrs.PolicyNone == false); - if (DefaultPolicy.isTUMAPolicy()) + if (PolicyAttrs.isTUMAPolicy()) return 2; - if (DefaultPolicy.isTAMAPolicy()) + if (PolicyAttrs.isTAMAPolicy()) return 3; - if (DefaultPolicy.isTUMUPolicy()) + if (PolicyAttrs.isTUMUPolicy()) return 0; - if (DefaultPolicy.isTAMUPolicy()) + if (PolicyAttrs.isTAMUPolicy()) return 1; - if (DefaultPolicy.isTUPolicy()) + if (PolicyAttrs.isTUPolicy()) return 0; - if (DefaultPolicy.isTAPolicy()) + if (PolicyAttrs.isTAPolicy()) return 1; llvm_unreachable("unsupport policy"); @@ -471,11 +471,10 @@ llvm::ArrayRef PrototypeDescriptors); static llvm::SmallVector - computeBuiltinTypes(llvm::ArrayRef Prototype, - bool IsMasked, bool HasMaskedOffOperand, bool HasVL, - unsigned NF, bool IsPrototypeDefaultTU, - PolicyScheme DefaultScheme, - Policy DefaultPolicy); + computeBuiltinTypes(llvm::ArrayRef Prototype, + bool IsMasked, bool HasMaskedOffOperand, bool HasVL, + unsigned NF, bool IsPrototypeDefaultTU, + PolicyScheme DefaultScheme, Policy PolicyAttrs); static llvm::SmallVector getSupportedMaskedPolicies(bool HasTailPolicy, bool HasMaskPolicy); @@ -483,7 +482,7 @@ bool IsPrototypeDefaultTU, std::string &Name, std::string &BuiltinName, std::string &OverloadedName, - Policy &DefaultPolicy); + Policy &PolicyAttrs); }; // RVVRequire should be sync'ed with target features, but only diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -19441,7 +19441,7 @@ constexpr unsigned TAIL_UNDISTURBED = 0; constexpr unsigned TAIL_AGNOSTIC = 1; constexpr unsigned TAIL_AGNOSTIC_MASK_AGNOSTIC = 3; - int DefaultPolicy = TAIL_UNDISTURBED; + int PolicyAttrs = TAIL_UNDISTURBED; bool IsMasked = false; // Required for overloaded intrinsics. diff --git a/clang/lib/Sema/SemaRISCVVectorLookup.cpp b/clang/lib/Sema/SemaRISCVVectorLookup.cpp --- a/clang/lib/Sema/SemaRISCVVectorLookup.cpp +++ b/clang/lib/Sema/SemaRISCVVectorLookup.cpp @@ -147,7 +147,7 @@ // Create RVVIntrinsicDef. void InitRVVIntrinsic(const RVVIntrinsicRecord &Record, StringRef SuffixStr, StringRef OverloadedSuffixStr, bool IsMask, - RVVTypes &Types, bool HasPolicy, Policy DefaultPolicy, + RVVTypes &Types, bool HasPolicy, Policy PolicyAttrs, bool IsPrototypeDefaultTU); // Create FunctionDecl for a vector intrinsic. @@ -314,7 +314,7 @@ void RISCVIntrinsicManagerImpl::InitRVVIntrinsic( const RVVIntrinsicRecord &Record, StringRef SuffixStr, StringRef OverloadedSuffixStr, bool IsMasked, RVVTypes &Signature, - bool HasPolicy, Policy DefaultPolicy, bool IsPrototypeDefaultTU) { + bool HasPolicy, Policy PolicyAttrs, bool IsPrototypeDefaultTU) { // Function name, e.g. vadd_vv_i32m1. std::string Name = Record.Name; if (!SuffixStr.empty()) @@ -334,7 +334,7 @@ RVVIntrinsic::updateNamesAndPolicy(IsMasked, HasPolicy, IsPrototypeDefaultTU, Name, BuiltinName, OverloadedName, - DefaultPolicy); + PolicyAttrs); // Put into IntrinsicList. size_t Index = IntrinsicList.size(); diff --git a/clang/lib/Support/RISCVVIntrinsicUtils.cpp b/clang/lib/Support/RISCVVIntrinsicUtils.cpp --- a/clang/lib/Support/RISCVVIntrinsicUtils.cpp +++ b/clang/lib/Support/RISCVVIntrinsicUtils.cpp @@ -848,12 +848,11 @@ bool SupportOverloading, bool HasBuiltinAlias, StringRef ManualCodegen, const RVVTypes &OutInTypes, const std::vector &NewIntrinsicTypes, const std::vector &RequiredFeatures, unsigned NF, - Policy NewDefaultPolicy, bool IsPrototypeDefaultTU) + Policy NewPolicyAttrs, bool IsPrototypeDefaultTU) : IRName(IRName), IsMasked(IsMasked), HasMaskedOffOperand(HasMaskedOffOperand), HasVL(HasVL), Scheme(Scheme), SupportOverloading(SupportOverloading), HasBuiltinAlias(HasBuiltinAlias), - ManualCodegen(ManualCodegen.str()), NF(NF), - DefaultPolicy(NewDefaultPolicy) { + ManualCodegen(ManualCodegen.str()), NF(NF), PolicyAttrs(NewPolicyAttrs) { // Init BuiltinName, Name and OverloadedName BuiltinName = NewName.str(); @@ -868,7 +867,7 @@ OverloadedName += "_" + OverloadedSuffix.str(); updateNamesAndPolicy(IsMasked, hasPolicy(), IsPrototypeDefaultTU, Name, - BuiltinName, OverloadedName, DefaultPolicy); + BuiltinName, OverloadedName, PolicyAttrs); // Init OutputType and InputTypes OutputType = OutInTypes[0]; @@ -909,27 +908,26 @@ llvm::SmallVector RVVIntrinsic::computeBuiltinTypes( llvm::ArrayRef Prototype, bool IsMasked, bool HasMaskedOffOperand, bool HasVL, unsigned NF, - bool IsPrototypeDefaultTU, PolicyScheme DefaultScheme, - Policy DefaultPolicy) { + bool IsPrototypeDefaultTU, PolicyScheme DefaultScheme, Policy PolicyAttrs) { SmallVector NewPrototype(Prototype.begin(), Prototype.end()); - // Update DefaultPolicy if need (TA or TAMA) for compute builtin types. - if (DefaultPolicy.isMAPolicy()) - DefaultPolicy.TailPolicy = Policy::PolicyType::Agnostic; // TAMA - if (DefaultPolicy.isPolicyNonePolicy()) { + // Update PolicyAttrs if need (TA or TAMA) for compute builtin types. + if (PolicyAttrs.isMAPolicy()) + PolicyAttrs.TailPolicy = Policy::PolicyType::Agnostic; // TAMA + if (PolicyAttrs.isPolicyNonePolicy()) { if (!IsMasked) { - DefaultPolicy.PolicyNone = false; + PolicyAttrs.PolicyNone = false; if (IsPrototypeDefaultTU) - DefaultPolicy.TailPolicy = Policy::PolicyType::Undisturbed; // TU + PolicyAttrs.TailPolicy = Policy::PolicyType::Undisturbed; // TU else - DefaultPolicy.TailPolicy = Policy::PolicyType::Agnostic; // TA + PolicyAttrs.TailPolicy = Policy::PolicyType::Agnostic; // TA } } bool HasPassthruOp = DefaultScheme == PolicyScheme::HasPassthruOperand; if (IsMasked) { // If HasMaskedOffOperand, insert result type as first input operand if // need. - if (HasMaskedOffOperand && !DefaultPolicy.isTAMAPolicy()) { + if (HasMaskedOffOperand && !PolicyAttrs.isTAMAPolicy()) { if (NF == 1) { NewPrototype.insert(NewPrototype.begin() + 1, NewPrototype[0]); } else if (NF > 1) { @@ -944,7 +942,7 @@ } } // Erase passthru operand for TAM - if (NF == 1 && IsPrototypeDefaultTU && DefaultPolicy.isTAMAPolicy() && + if (NF == 1 && IsPrototypeDefaultTU && PolicyAttrs.isTAMAPolicy() && HasPassthruOp && !HasMaskedOffOperand) NewPrototype.erase(NewPrototype.begin() + 1); if (HasMaskedOffOperand && NF > 1) { @@ -961,21 +959,21 @@ } } else { if (NF == 1) { - if (DefaultPolicy.isTUPolicy() && HasPassthruOp && !IsPrototypeDefaultTU) + if (PolicyAttrs.isTUPolicy() && HasPassthruOp && !IsPrototypeDefaultTU) NewPrototype.insert(NewPrototype.begin(), NewPrototype[0]); - else if (DefaultPolicy.isTAPolicy() && HasPassthruOp && + else if (PolicyAttrs.isTAPolicy() && HasPassthruOp && IsPrototypeDefaultTU) NewPrototype.erase(NewPrototype.begin() + 1); if (DefaultScheme == PolicyScheme::HasPassthruOperandAtIdx1) { - if (DefaultPolicy.isTUPolicy() && !IsPrototypeDefaultTU) { + if (PolicyAttrs.isTUPolicy() && !IsPrototypeDefaultTU) { // Insert undisturbed output to index 1 NewPrototype.insert(NewPrototype.begin() + 2, NewPrototype[0]); - } else if (DefaultPolicy.isTAPolicy() && IsPrototypeDefaultTU) { + } else if (PolicyAttrs.isTAPolicy() && IsPrototypeDefaultTU) { // Erase passthru for TA policy NewPrototype.erase(NewPrototype.begin() + 2); } } - } else if (DefaultPolicy.isTUPolicy() && HasPassthruOp) { + } else if (PolicyAttrs.isTUPolicy() && HasPassthruOp) { // NF > 1 cases for segment load operations. // Convert // (void, op0 address, op1 address, ...) @@ -1023,7 +1021,7 @@ std::string &Name, std::string &BuiltinName, std::string &OverloadedName, - Policy &DefaultPolicy) { + Policy &PolicyAttrs) { auto appendPolicySuffix = [&](const std::string &suffix) { Name += suffix; @@ -1031,50 +1029,50 @@ OverloadedName += suffix; }; - if (DefaultPolicy.isPolicyNonePolicy()) { - DefaultPolicy.PolicyNone = false; + if (PolicyAttrs.isPolicyNonePolicy()) { + PolicyAttrs.PolicyNone = false; if (IsMasked) { Name += "_m"; // FIXME: Currently _m default policy implementation is different with // RVV intrinsic spec (TUMA) - DefaultPolicy.TailPolicy = Policy::PolicyType::Undisturbed; - DefaultPolicy.MaskPolicy = Policy::PolicyType::Undisturbed; + PolicyAttrs.TailPolicy = Policy::PolicyType::Undisturbed; + PolicyAttrs.MaskPolicy = Policy::PolicyType::Undisturbed; if (HasPolicy) BuiltinName += "_tumu"; else BuiltinName += "_m"; } else if (IsPrototypeDefaultTU) { - DefaultPolicy.TailPolicy = Policy::PolicyType::Undisturbed; + PolicyAttrs.TailPolicy = Policy::PolicyType::Undisturbed; if (HasPolicy) BuiltinName += "_tu"; } else { - DefaultPolicy.TailPolicy = Policy::PolicyType::Agnostic; + PolicyAttrs.TailPolicy = Policy::PolicyType::Agnostic; if (HasPolicy) BuiltinName += "_ta"; } } else { - if (DefaultPolicy.isTUMPolicy()) + if (PolicyAttrs.isTUMPolicy()) appendPolicySuffix("_tum"); - else if (DefaultPolicy.isTAMPolicy()) + else if (PolicyAttrs.isTAMPolicy()) appendPolicySuffix("_tam"); - else if (DefaultPolicy.isTUMUPolicy()) + else if (PolicyAttrs.isTUMUPolicy()) appendPolicySuffix("_tumu"); - else if (DefaultPolicy.isTAMUPolicy()) + else if (PolicyAttrs.isTAMUPolicy()) appendPolicySuffix("_tamu"); - else if (DefaultPolicy.isTUMAPolicy()) + else if (PolicyAttrs.isTUMAPolicy()) appendPolicySuffix("_tuma"); - else if (DefaultPolicy.isTAMAPolicy()) + else if (PolicyAttrs.isTAMAPolicy()) appendPolicySuffix("_tama"); - else if (DefaultPolicy.isTUPolicy()) + else if (PolicyAttrs.isTUPolicy()) appendPolicySuffix("_tu"); - else if (DefaultPolicy.isTAPolicy()) + else if (PolicyAttrs.isTAPolicy()) appendPolicySuffix("_ta"); - else if (DefaultPolicy.isMUPolicy()) { + else if (PolicyAttrs.isMUPolicy()) { appendPolicySuffix("_mu"); - DefaultPolicy.TailPolicy = Policy::PolicyType::Agnostic; - } else if (DefaultPolicy.isMAPolicy()) { + PolicyAttrs.TailPolicy = Policy::PolicyType::Agnostic; + } else if (PolicyAttrs.isMAPolicy()) { appendPolicySuffix("_ma"); - DefaultPolicy.TailPolicy = Policy::PolicyType::Agnostic; + PolicyAttrs.TailPolicy = Policy::PolicyType::Agnostic; } } } diff --git a/clang/utils/TableGen/RISCVVEmitter.cpp b/clang/utils/TableGen/RISCVVEmitter.cpp --- a/clang/utils/TableGen/RISCVVEmitter.cpp +++ b/clang/utils/TableGen/RISCVVEmitter.cpp @@ -163,14 +163,14 @@ OS << " ID = Intrinsic::riscv_" + RVVI->getIRName() + ";\n"; if (RVVI->getNF() >= 2) OS << " NF = " + utostr(RVVI->getNF()) + ";\n"; - // We had initialized DefaultPolicy as TU/TUMU in CodeGen function. - if (!RVVI->getDefaultPolicy().isTUPolicy() && - !RVVI->getDefaultPolicy().isTUMUPolicy() && !RVVI->hasPassthruOperand() && + // We had initialized PolicyAttrs as TU/TUMU in CodeGen function. + if (!RVVI->getPolicyAttrs().isTUPolicy() && + !RVVI->getPolicyAttrs().isTUMUPolicy() && !RVVI->hasPassthruOperand() && !RVVI->hasManualCodegen() && RVVI->hasVL()) - OS << " DefaultPolicy = " << RVVI->getDefaultPolicyBits() << ";\n"; + OS << " PolicyAttrs = " << RVVI->getPolicyAttrsBits() << ";\n"; if (RVVI->hasManualCodegen()) { - OS << " DefaultPolicy = " << RVVI->getDefaultPolicyBits() << ";\n"; + OS << " PolicyAttrs = " << RVVI->getPolicyAttrsBits() << ";\n"; if (RVVI->isMasked()) OS << "IsMasked = true;\n"; else @@ -195,13 +195,12 @@ OS << " std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);\n"; if (RVVI->hasPolicyOperand()) OS << " Ops.push_back(ConstantInt::get(Ops.back()->getType()," - " DefaultPolicy));\n"; - if (RVVI->hasMaskedOffOperand() && - RVVI->getDefaultPolicy().isTAMAPolicy()) + " PolicyAttrs));\n"; + if (RVVI->hasMaskedOffOperand() && RVVI->getPolicyAttrs().isTAMAPolicy()) OS << " Ops.insert(Ops.begin(), llvm::UndefValue::get(ResultType));\n"; // Masked reduction cases. if (!RVVI->hasMaskedOffOperand() && RVVI->hasPassthruOperand() && - RVVI->getDefaultPolicy().isTAMAPolicy()) + RVVI->getPolicyAttrs().isTAMAPolicy()) OS << " Ops.insert(Ops.begin(), llvm::UndefValue::get(ResultType));\n"; } else { OS << " std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end());\n"; @@ -209,9 +208,8 @@ } else { if (RVVI->hasPolicyOperand()) OS << " Ops.push_back(ConstantInt::get(Ops.back()->getType(), " - "DefaultPolicy));\n"; - else if (RVVI->hasPassthruOperand() && - RVVI->getDefaultPolicy().isTAPolicy()) + "PolicyAttrs));\n"; + else if (RVVI->hasPassthruOperand() && RVVI->getPolicyAttrs().isTAPolicy()) OS << " Ops.insert(Ops.begin(), llvm::UndefValue::get(ResultType));\n"; } @@ -448,7 +446,7 @@ llvm::stable_sort(Defs, [](const std::unique_ptr &A, const std::unique_ptr &B) { if (A->getIRName() == B->getIRName()) - return (A->getDefaultPolicy() < B->getDefaultPolicy()); + return (A->getPolicyAttrs() < B->getPolicyAttrs()); return (A->getIRName() < B->getIRName()); }); @@ -462,7 +460,7 @@ StringRef CurIRName = Def->getIRName(); if (CurIRName != PrevDef->getIRName() || (Def->getManualCodegen() != PrevDef->getManualCodegen()) || - (Def->getDefaultPolicy() != PrevDef->getDefaultPolicy())) { + (Def->getPolicyAttrs() != PrevDef->getPolicyAttrs())) { emitCodeGenSwitchBody(PrevDef, OS); } PrevDef = Def.get();