[PATCH] D126740: [RISCV][Clang] Refactor and rename rvv intrinsic related stuff. (NFC)
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rGbc4eef509b21: [RISCV][Clang] Refactor and rename rvv intrinsic related stuff. (NFC) (authored by khchen). Changed prior to commit: https://reviews.llvm.org/D126740?vs=433256=447630#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D126740/new/ https://reviews.llvm.org/D126740 Files: clang/include/clang/Basic/riscv_vector.td clang/include/clang/Support/RISCVVIntrinsicUtils.h clang/lib/Support/RISCVVIntrinsicUtils.cpp clang/utils/TableGen/RISCVVEmitter.cpp Index: clang/utils/TableGen/RISCVVEmitter.cpp === --- clang/utils/TableGen/RISCVVEmitter.cpp +++ clang/utils/TableGen/RISCVVEmitter.cpp @@ -479,12 +479,12 @@ bool HasMasked = R->getValueAsBit("HasMasked"); bool HasMaskedOffOperand = R->getValueAsBit("HasMaskedOffOperand"); bool HasVL = R->getValueAsBit("HasVL"); -Record *MaskedPolicyRecord = R->getValueAsDef("MaskedPolicy"); -PolicyScheme MaskedPolicy = -static_cast(MaskedPolicyRecord->getValueAsInt("Value")); -Record *UnMaskedPolicyRecord = R->getValueAsDef("UnMaskedPolicy"); -PolicyScheme UnMaskedPolicy = -static_cast(UnMaskedPolicyRecord->getValueAsInt("Value")); +Record *MPSRecord = R->getValueAsDef("MaskedPolicyScheme"); +auto MaskedPolicyScheme = +static_cast(MPSRecord->getValueAsInt("Value")); +Record *UMPSRecord = R->getValueAsDef("UnMaskedPolicyScheme"); +auto UnMaskedPolicyScheme = +static_cast(UMPSRecord->getValueAsInt("Value")); bool HasUnMaskedOverloaded = R->getValueAsBit("HasUnMaskedOverloaded"); std::vector Log2LMULList = R->getValueAsListOfInts("Log2LMUL"); bool HasBuiltinAlias = R->getValueAsBit("HasBuiltinAlias"); @@ -500,50 +500,19 @@ // Parse prototype and create a list of primitive type with transformers // (operand) in Prototype. Prototype[0] is output operand. -SmallVector Prototype = parsePrototypes(Prototypes); +SmallVector BasicPrototype = +parsePrototypes(Prototypes); SmallVector SuffixDesc = parsePrototypes(SuffixProto); SmallVector OverloadedSuffixDesc = parsePrototypes(OverloadedSuffixProto); // Compute Builtin types -SmallVector MaskedPrototype = Prototype; -if (HasMasked) { - // If HasMaskedOffOperand, insert result type as first input operand. - if (HasMaskedOffOperand) { -if (NF == 1) { - MaskedPrototype.insert(MaskedPrototype.begin() + 1, Prototype[0]); -} else { - // Convert - // (void, op0 address, op1 address, ...) - // to - // (void, op0 address, op1 address, ..., maskedoff0, maskedoff1, ...) - PrototypeDescriptor MaskoffType = Prototype[1]; - MaskoffType.TM &= ~static_cast(TypeModifier::Pointer); - for (unsigned I = 0; I < NF; ++I) -MaskedPrototype.insert(MaskedPrototype.begin() + NF + 1, - MaskoffType); -} - } - if (HasMaskedOffOperand && NF > 1) { -// Convert -// (void, op0 address, op1 address, ..., maskedoff0, maskedoff1, ...) -// to -// (void, op0 address, op1 address, ..., mask, maskedoff0, maskedoff1, -// ...) -MaskedPrototype.insert(MaskedPrototype.begin() + NF + 1, - PrototypeDescriptor::Mask); - } else { -// If HasMasked, insert PrototypeDescriptor:Mask as first input operand. -MaskedPrototype.insert(MaskedPrototype.begin() + 1, - PrototypeDescriptor::Mask); - } -} -// If HasVL, append PrototypeDescriptor:VL to last operand -if (HasVL) { - Prototype.push_back(PrototypeDescriptor::VL); - MaskedPrototype.push_back(PrototypeDescriptor::VL); -} +auto Prototype = RVVIntrinsic::computeBuiltinTypes( +BasicPrototype, /*IsMasked=*/false, /*HasMaskedOffOperand=*/false, +HasVL, NF); +auto MaskedPrototype = RVVIntrinsic::computeBuiltinTypes( +BasicPrototype, /*IsMasked=*/true, HasMaskedOffOperand, HasVL, NF); // Create Intrinsics for each type and LMUL. for (char I : TypeRange) { @@ -562,7 +531,7 @@ Out.push_back(std::make_unique( Name, SuffixStr, OverloadedName, OverloadedSuffixStr, IRName, /*IsMasked=*/false, /*HasMaskedOffOperand=*/false, HasVL, -UnMaskedPolicy, HasUnMaskedOverloaded, HasBuiltinAlias, +UnMaskedPolicyScheme, HasUnMaskedOverloaded, HasBuiltinAlias, ManualCodegen, *Types, IntrinsicTypes, RequiredFeatures, NF)); if (HasMasked) { // Create a masked intrinsic @@ -571,7 +540,7 @@ Out.push_back(std::make_unique( Name, SuffixStr, OverloadedName,
[PATCH] D126740: [RISCV][Clang] Refactor and rename rvv intrinsic related stuff. (NFC)
rogfer01 accepted this revision. rogfer01 added a comment. This revision is now accepted and ready to land. LGTM. Thanks @khchen ! (I was a bit confused by the refactoring of `computeBuiltinTypes` but it is definitely better this way) Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D126740/new/ https://reviews.llvm.org/D126740 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D126740: [RISCV][Clang] Refactor and rename rvv intrinsic related stuff. (NFC)
khchen created this revision. khchen added reviewers: craig.topper, rogfer01, kito-cheng, fakepaper56, eopXD. Herald added subscribers: sunshaoce, VincentWu, luke957, StephenFan, vkmr, frasercrmck, evandro, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, edward-jones, zzheng, jrtc27, shiva0217, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, arichardson. Herald added a project: All. khchen requested review of this revision. Herald added subscribers: cfe-commits, pcwang-thead, MaskRay. Herald added a project: clang. This changed is based on https://reviews.llvm.org/D111617 Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D126740 Files: clang/include/clang/Basic/riscv_vector.td clang/include/clang/Support/RISCVVIntrinsicUtils.h clang/lib/Support/RISCVVIntrinsicUtils.cpp clang/utils/TableGen/RISCVVEmitter.cpp Index: clang/utils/TableGen/RISCVVEmitter.cpp === --- clang/utils/TableGen/RISCVVEmitter.cpp +++ clang/utils/TableGen/RISCVVEmitter.cpp @@ -375,12 +375,12 @@ bool HasMasked = R->getValueAsBit("HasMasked"); bool HasMaskedOffOperand = R->getValueAsBit("HasMaskedOffOperand"); bool HasVL = R->getValueAsBit("HasVL"); -Record *MaskedPolicyRecord = R->getValueAsDef("MaskedPolicy"); -PolicyScheme MaskedPolicy = -static_cast(MaskedPolicyRecord->getValueAsInt("Value")); -Record *UnMaskedPolicyRecord = R->getValueAsDef("UnMaskedPolicy"); -PolicyScheme UnMaskedPolicy = -static_cast(UnMaskedPolicyRecord->getValueAsInt("Value")); +Record *MPSRecord = R->getValueAsDef("MaskedPolicyScheme"); +auto MaskedPolicyScheme = +static_cast(MPSRecord->getValueAsInt("Value")); +Record *UMPSRecord = R->getValueAsDef("UnMaskedPolicyScheme"); +auto UnMaskedPolicyScheme = +static_cast(UMPSRecord->getValueAsInt("Value")); bool HasUnMaskedOverloaded = R->getValueAsBit("HasUnMaskedOverloaded"); std::vector Log2LMULList = R->getValueAsListOfInts("Log2LMUL"); bool HasBuiltinAlias = R->getValueAsBit("HasBuiltinAlias"); @@ -396,50 +396,19 @@ // Parse prototype and create a list of primitive type with transformers // (operand) in Prototype. Prototype[0] is output operand. -SmallVector Prototype = parsePrototypes(Prototypes); +SmallVector BasicPrototype = +parsePrototypes(Prototypes); SmallVector SuffixDesc = parsePrototypes(SuffixProto); SmallVector OverloadedSuffixDesc = parsePrototypes(OverloadedSuffixProto); // Compute Builtin types -SmallVector MaskedPrototype = Prototype; -if (HasMasked) { - // If HasMaskedOffOperand, insert result type as first input operand. - if (HasMaskedOffOperand) { -if (NF == 1) { - MaskedPrototype.insert(MaskedPrototype.begin() + 1, Prototype[0]); -} else { - // Convert - // (void, op0 address, op1 address, ...) - // to - // (void, op0 address, op1 address, ..., maskedoff0, maskedoff1, ...) - PrototypeDescriptor MaskoffType = Prototype[1]; - MaskoffType.TM &= ~static_cast(TypeModifier::Pointer); - for (unsigned I = 0; I < NF; ++I) -MaskedPrototype.insert(MaskedPrototype.begin() + NF + 1, - MaskoffType); -} - } - if (HasMaskedOffOperand && NF > 1) { -// Convert -// (void, op0 address, op1 address, ..., maskedoff0, maskedoff1, ...) -// to -// (void, op0 address, op1 address, ..., mask, maskedoff0, maskedoff1, -// ...) -MaskedPrototype.insert(MaskedPrototype.begin() + NF + 1, - PrototypeDescriptor::Mask); - } else { -// If HasMasked, insert PrototypeDescriptor:Mask as first input operand. -MaskedPrototype.insert(MaskedPrototype.begin() + 1, - PrototypeDescriptor::Mask); - } -} -// If HasVL, append PrototypeDescriptor:VL to last operand -if (HasVL) { - Prototype.push_back(PrototypeDescriptor::VL); - MaskedPrototype.push_back(PrototypeDescriptor::VL); -} +auto Prototype = RVVIntrinsic::computeBuiltinTypes( +BasicPrototype, /*IsMasked=*/false, /*HasMaskedOffOperand=*/false, +HasVL, NF); +auto MaskedPrototype = RVVIntrinsic::computeBuiltinTypes( +BasicPrototype, /*IsMasked=*/true, HasMaskedOffOperand, HasVL, NF); // Create Intrinsics for each type and LMUL. for (char I : TypeRange) { @@ -458,7 +427,7 @@ Out.push_back(std::make_unique( Name, SuffixStr, OverloadedName, OverloadedSuffixStr, IRName, /*IsMasked=*/false, /*HasMaskedOffOperand=*/false, HasVL, -UnMaskedPolicy, HasUnMaskedOverloaded, HasBuiltinAlias, +UnMaskedPolicyScheme, HasUnMaskedOverloaded, HasBuiltinAlias,