[clang] 79e3d57 - [RISCV][NFC] Rename variables in rvv intrinsics related files.

Zakk Chen via cfe-commits cfe-commits at lists.llvm.org
Tue May 31 17:43:59 PDT 2022


Author: Zakk Chen
Date: 2022-05-31T17:43:01-07:00
New Revision: 79e3d57f52284c7d911724ef6298f765c747c20d

URL: https://github.com/llvm/llvm-project/commit/79e3d57f52284c7d911724ef6298f765c747c20d
DIFF: https://github.com/llvm/llvm-project/commit/79e3d57f52284c7d911724ef6298f765c747c20d.diff

LOG: [RISCV][NFC] Rename variables in rvv intrinsics related files.

This patch does the same thing as D125886 did.

- Use `Overloaded` rather than `Mangled`.
- Use `Prototype` or `Desc` rather than `Seq`, it's not just a string
sequence.

Reviewed By: fakepaper56

Differential Revision: https://reviews.llvm.org/D126634

Added: 
    

Modified: 
    clang/include/clang/Basic/riscv_vector.td
    clang/include/clang/Support/RISCVVIntrinsicUtils.h
    clang/lib/Support/RISCVVIntrinsicUtils.cpp
    clang/utils/TableGen/RISCVVEmitter.cpp

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Basic/riscv_vector.td b/clang/include/clang/Basic/riscv_vector.td
index 18304f55da0c..8a1e0eb74258 100644
--- a/clang/include/clang/Basic/riscv_vector.td
+++ b/clang/include/clang/Basic/riscv_vector.td
@@ -139,7 +139,7 @@ def HasPassthruOperand : Policy<1>;
 def HasPolicyOperand : Policy<2>;
 
 class RVVBuiltin<string suffix, string prototype, string type_range,
-                 string mangled_suffix = ""> {
+                 string overloaded_suffix = ""> {
   // Base name that will be prepended in __builtin_rvv_ and appended the
   // computed Suffix.
   string Name = NAME;
@@ -148,14 +148,14 @@ class RVVBuiltin<string suffix, string prototype, string type_range,
   // underscore (_). It is instantiated like Prototype.
   string Suffix = suffix;
 
-  // If empty, default MangledName is sub string of `Name` which end of first
-  // '_'. For example, the default mangled name  is `vadd` for Name `vadd_vv`.
+  // If empty, default OverloadedName is sub string of `Name` which end of first
+  // '_'. For example, the default overloaded name  is `vadd` for Name `vadd_vv`.
   // It's used for describe some special naming cases.
-  string MangledName = "";
+  string OverloadedName = "";
 
-  // If not empty, each MangledName will have this appended after an
+  // If not empty, each OverloadedName will have this appended after an
   // underscore (_). It is instantiated like Prototype.
-  string MangledSuffix = mangled_suffix;
+  string OverloadedSuffix = overloaded_suffix;
 
   // The 
diff erent variants of the builtin, parameterised with a type.
   string TypeRange = type_range;
@@ -378,7 +378,7 @@ class RVVIntExt<string intrinsic_name, string suffix, string prototype,
     : RVVBuiltin<suffix, prototype, type_range> {
   let IRName = intrinsic_name;
   let MaskedIRName = intrinsic_name # "_mask";
-  let MangledName = NAME;
+  let OverloadedName = NAME;
   let IntrinsicTypes = [-1, 0];
 }
 
@@ -462,29 +462,29 @@ class RVVFloatingUnaryBuiltin<string builtin_suffix, string ir_suffix,
 class RVVFloatingUnaryVVBuiltin : RVVFloatingUnaryBuiltin<"v", "v", "vv">;
 
 class RVVConvBuiltin<string suffix, string prototype, string type_range,
-                     string mangled_name>
+                     string overloaded_name>
     : RVVBuiltin<suffix, prototype, type_range> {
   let IntrinsicTypes = [-1, 0];
-  let MangledName = mangled_name;
+  let OverloadedName = overloaded_name;
 }
 
-class RVVConvToSignedBuiltin<string mangled_name>
-    : RVVConvBuiltin<"Iv", "Ivv", "xfd", mangled_name>;
+class RVVConvToSignedBuiltin<string overloaded_name>
+    : RVVConvBuiltin<"Iv", "Ivv", "xfd", overloaded_name>;
 
-class RVVConvToUnsignedBuiltin<string mangled_name>
-    : RVVConvBuiltin<"Uv", "Uvv", "xfd", mangled_name>;
+class RVVConvToUnsignedBuiltin<string overloaded_name>
+    : RVVConvBuiltin<"Uv", "Uvv", "xfd", overloaded_name>;
 
-class RVVConvToWidenSignedBuiltin<string mangled_name>
-    : RVVConvBuiltin<"Iw", "Iwv", "xf", mangled_name>;
+class RVVConvToWidenSignedBuiltin<string overloaded_name>
+    : RVVConvBuiltin<"Iw", "Iwv", "xf", overloaded_name>;
 
-class RVVConvToWidenUnsignedBuiltin<string mangled_name>
-    : RVVConvBuiltin<"Uw", "Uwv", "xf", mangled_name>;
+class RVVConvToWidenUnsignedBuiltin<string overloaded_name>
+    : RVVConvBuiltin<"Uw", "Uwv", "xf", overloaded_name>;
 
-class RVVConvToNarrowingSignedBuiltin<string mangled_name>
-    : RVVConvBuiltin<"Iv", "IvFw", "csi", mangled_name>;
+class RVVConvToNarrowingSignedBuiltin<string overloaded_name>
+    : RVVConvBuiltin<"Iv", "IvFw", "csi", overloaded_name>;
 
-class RVVConvToNarrowingUnsignedBuiltin<string mangled_name>
-    : RVVConvBuiltin<"Uv", "UvFw", "csi", mangled_name>;
+class RVVConvToNarrowingUnsignedBuiltin<string overloaded_name>
+    : RVVConvBuiltin<"Uv", "UvFw", "csi", overloaded_name>;
 
 let HasMaskedOffOperand = false in {
   multiclass RVVSignedReductionBuiltin {
@@ -516,7 +516,7 @@ multiclass RVVWidenBuiltinSet<string intrinsic_name, string type_range,
       IRName = intrinsic_name, MaskedIRName = intrinsic_name # "_mask" in {
     foreach s_p = suffixes_prototypes in {
       let Name = NAME # "_" # s_p[0],
-          MangledName = NAME # "_" # s_p[0] in {
+          OverloadedName = NAME # "_" # s_p[0] in {
         defvar suffix = s_p[1];
         defvar prototype = s_p[2];
         def : RVVOutOp0Op1Builtin<suffix, prototype, type_range>;
@@ -532,7 +532,7 @@ multiclass RVVWidenWOp0BuiltinSet<string intrinsic_name, string type_range,
       IRName = intrinsic_name, MaskedIRName = intrinsic_name # "_mask" in {
     foreach s_p = suffixes_prototypes in {
       let Name = NAME # "_" # s_p[0],
-          MangledName = NAME # "_" # s_p[0] in {
+          OverloadedName = NAME # "_" # s_p[0] in {
         defvar suffix = s_p[1];
         defvar prototype = s_p[2];
         def : RVVOutOp1Builtin<suffix, prototype, type_range>;
@@ -1424,7 +1424,7 @@ multiclass RVVPseudoVFUnaryBuiltin<string IR, string type_range> {
 multiclass RVVPseudoVWCVTBuiltin<string IR, string MName, string type_range,
                                  list<list<string>> suffixes_prototypes> {
   let Name = NAME,
-      MangledName = MName,
+      OverloadedName = MName,
       IRName = IR,
       MaskedIRName = IR # "_mask",
       ManualCodegen = [{
@@ -1462,7 +1462,7 @@ multiclass RVVPseudoVWCVTBuiltin<string IR, string MName, string type_range,
 multiclass RVVPseudoVNCVTBuiltin<string IR, string MName, string type_range,
                                  list<list<string>> suffixes_prototypes> {
   let Name = NAME,
-      MangledName = MName,
+      OverloadedName = MName,
       IRName = IR,
       MaskedIRName = IR # "_mask",
       ManualCodegen = [{
@@ -1792,7 +1792,7 @@ let HasMasked = false, MaskedPolicy = NonePolicy,
 
 // 12.16. Vector Integer Move Instructions
 let HasMasked = false, UnMaskedPolicy = HasPassthruOperand, MaskedPolicy = NonePolicy in {
-  let MangledName = "vmv_v" in {
+  let OverloadedName = "vmv_v" in {
     defm vmv_v : RVVOutBuiltinSet<"vmv_v_v", "csil",
                                    [["v", "Uv", "UvUv"]]>;
     defm vmv_v : RVVOutBuiltinSet<"vmv_v_v", "csilxfd",
@@ -2043,11 +2043,11 @@ let UnMaskedPolicy = HasPassthruOperand, HasUnMaskedOverloaded = false in {
 // 17. Vector Permutation Instructions
 // 17.1. Integer Scalar Move Instructions
 let HasMasked = false, MaskedPolicy = NonePolicy in {
-  let HasVL = false, MangledName = "vmv_x" in
+  let HasVL = false, OverloadedName = "vmv_x" in
     defm vmv_x : RVVOp0BuiltinSet<"vmv_x_s", "csil",
                                    [["s", "ve", "ev"],
                                     ["s", "UvUe", "UeUv"]]>;
-  let MangledName = "vmv_s" in
+  let OverloadedName = "vmv_s" in
     defm vmv_s : RVVOutBuiltinSet<"vmv_s_x", "csil",
                                    [["x", "v", "vve"],
                                     ["x", "Uv", "UvUvUe"]]>;
@@ -2055,10 +2055,10 @@ let HasMasked = false, MaskedPolicy = NonePolicy in {
 
 // 17.2. Floating-Point Scalar Move Instructions
 let HasMasked = false, MaskedPolicy = NonePolicy in {
-  let HasVL = false, MangledName = "vfmv_f" in
+  let HasVL = false, OverloadedName = "vfmv_f" in
     defm vfmv_f : RVVOp0BuiltinSet<"vfmv_f_s", "xfd",
                                      [["s", "ve", "ev"]]>;
-  let MangledName = "vfmv_s" in
+  let OverloadedName = "vfmv_s" in
     defm vfmv_s : RVVOutBuiltinSet<"vfmv_s_f", "xfd",
                                      [["f", "v", "vve"],
                                       ["x", "Uv", "UvUvUe"]]>;
@@ -2144,7 +2144,7 @@ let HasMasked = false, HasVL = false, IRName = "" in {
 
   // LMUL truncation
   // C/C++ Operand: VecTy, IR Operand: VecTy, Index
-  let Name = "vlmul_trunc_v", MangledName = "vlmul_trunc", MaskedPolicy = NonePolicy,
+  let Name = "vlmul_trunc_v", OverloadedName = "vlmul_trunc", MaskedPolicy = NonePolicy,
       ManualCodegen = [{ {
         ID = Intrinsic::experimental_vector_extract;
         IntrinsicTypes = {ResultType, Ops[0]->getType()};
@@ -2162,7 +2162,7 @@ let HasMasked = false, HasVL = false, IRName = "" in {
 
   // LMUL extension
   // C/C++ Operand: SubVecTy, IR Operand: VecTy, SubVecTy, Index
-  let Name = "vlmul_ext_v", MangledName = "vlmul_ext", MaskedPolicy = NonePolicy,
+  let Name = "vlmul_ext_v", OverloadedName = "vlmul_ext", MaskedPolicy = NonePolicy,
       ManualCodegen = [{
         ID = Intrinsic::experimental_vector_insert;
         IntrinsicTypes = {ResultType, Ops[0]->getType()};

diff  --git a/clang/include/clang/Support/RISCVVIntrinsicUtils.h b/clang/include/clang/Support/RISCVVIntrinsicUtils.h
index 0a7186d42c85..0e9fe97ab735 100644
--- a/clang/include/clang/Support/RISCVVIntrinsicUtils.h
+++ b/clang/include/clang/Support/RISCVVIntrinsicUtils.h
@@ -256,7 +256,7 @@ class RVVType {
   /// have illegal RVVType.
   static llvm::Optional<RVVTypes>
   computeTypes(BasicType BT, int Log2LMUL, unsigned NF,
-               llvm::ArrayRef<PrototypeDescriptor> PrototypeSeq);
+               llvm::ArrayRef<PrototypeDescriptor> Prototype);
   static llvm::Optional<RVVTypePtr> computeType(BasicType BT, int Log2LMUL,
                                                 PrototypeDescriptor Proto);
 };
@@ -287,7 +287,7 @@ class RVVIntrinsic {
 private:
   std::string BuiltinName; // Builtin name
   std::string Name;        // C intrinsic name.
-  std::string MangledName;
+  std::string OverloadedName;
   std::string IRName;
   bool IsMasked;
   bool HasVL;
@@ -304,20 +304,22 @@ class RVVIntrinsic {
   unsigned NF = 1;
 
 public:
-  RVVIntrinsic(llvm::StringRef Name, llvm::StringRef Suffix, llvm::StringRef MangledName,
-               llvm::StringRef MangledSuffix, llvm::StringRef IRName, bool IsMasked,
-               bool HasMaskedOffOperand, bool HasVL, PolicyScheme Scheme,
-               bool HasUnMaskedOverloaded, bool HasBuiltinAlias,
-               llvm::StringRef ManualCodegen, const RVVTypes &Types,
+  RVVIntrinsic(llvm::StringRef Name, llvm::StringRef Suffix,
+               llvm::StringRef OverloadedName, llvm::StringRef OverloadedSuffix,
+               llvm::StringRef IRName, bool IsMasked, bool HasMaskedOffOperand,
+               bool HasVL, PolicyScheme Scheme, bool HasUnMaskedOverloaded,
+               bool HasBuiltinAlias, llvm::StringRef ManualCodegen,
+               const RVVTypes &Types,
                const std::vector<int64_t> &IntrinsicTypes,
-               const std::vector<llvm::StringRef> &RequiredFeatures, unsigned NF);
+               const std::vector<llvm::StringRef> &RequiredFeatures,
+               unsigned NF);
   ~RVVIntrinsic() = default;
 
   RVVTypePtr getOutputType() const { return OutputType; }
   const RVVTypes &getInputTypes() const { return InputTypes; }
   llvm::StringRef getBuiltinName() const { return BuiltinName; }
   llvm::StringRef getName() const { return Name; }
-  llvm::StringRef getMangledName() const { return MangledName; }
+  llvm::StringRef getOverloadedName() const { return OverloadedName; }
   bool hasVL() const { return HasVL; }
   bool hasPolicy() const { return Scheme != SchemeNone; }
   bool hasPassthruOperand() const { return Scheme == HasPassthruOperand; }

diff  --git a/clang/lib/Support/RISCVVIntrinsicUtils.cpp b/clang/lib/Support/RISCVVIntrinsicUtils.cpp
index 92d29043f2cc..afcd03c41f97 100644
--- a/clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ b/clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -791,13 +791,13 @@ void RVVType::applyFixedLog2LMUL(int Log2LMUL, enum FixedLMULType Type) {
 
 Optional<RVVTypes>
 RVVType::computeTypes(BasicType BT, int Log2LMUL, unsigned NF,
-                      ArrayRef<PrototypeDescriptor> PrototypeSeq) {
+                      ArrayRef<PrototypeDescriptor> Prototype) {
   // LMUL x NF must be less than or equal to 8.
   if ((Log2LMUL >= 1) && (1 << Log2LMUL) * NF > 8)
     return llvm::None;
 
   RVVTypes Types;
-  for (const PrototypeDescriptor &Proto : PrototypeSeq) {
+  for (const PrototypeDescriptor &Proto : Prototype) {
     auto T = computeType(BT, Log2LMUL, Proto);
     if (!T.hasValue())
       return llvm::None;
@@ -847,8 +847,8 @@ Optional<RVVTypePtr> RVVType::computeType(BasicType BT, int Log2LMUL,
 // RVVIntrinsic implementation
 //===----------------------------------------------------------------------===//
 RVVIntrinsic::RVVIntrinsic(
-    StringRef NewName, StringRef Suffix, StringRef NewMangledName,
-    StringRef MangledSuffix, StringRef IRName, bool IsMasked,
+    StringRef NewName, StringRef Suffix, StringRef NewOverloadedName,
+    StringRef OverloadedSuffix, StringRef IRName, bool IsMasked,
     bool HasMaskedOffOperand, bool HasVL, PolicyScheme Scheme,
     bool HasUnMaskedOverloaded, bool HasBuiltinAlias, StringRef ManualCodegen,
     const RVVTypes &OutInTypes, const std::vector<int64_t> &NewIntrinsicTypes,
@@ -858,17 +858,17 @@ RVVIntrinsic::RVVIntrinsic(
       HasBuiltinAlias(HasBuiltinAlias), ManualCodegen(ManualCodegen.str()),
       NF(NF) {
 
-  // Init BuiltinName, Name and MangledName
+  // Init BuiltinName, Name and OverloadedName
   BuiltinName = NewName.str();
   Name = BuiltinName;
-  if (NewMangledName.empty())
-    MangledName = NewName.split("_").first.str();
+  if (NewOverloadedName.empty())
+    OverloadedName = NewName.split("_").first.str();
   else
-    MangledName = NewMangledName.str();
+    OverloadedName = NewOverloadedName.str();
   if (!Suffix.empty())
     Name += "_" + Suffix.str();
-  if (!MangledSuffix.empty())
-    MangledName += "_" + MangledSuffix.str();
+  if (!OverloadedSuffix.empty())
+    OverloadedName += "_" + OverloadedSuffix.str();
   if (IsMasked) {
     BuiltinName += "_m";
     Name += "_m";

diff  --git a/clang/utils/TableGen/RISCVVEmitter.cpp b/clang/utils/TableGen/RISCVVEmitter.cpp
index dc6cbcbbf4ed..8b008e0eec72 100644
--- a/clang/utils/TableGen/RISCVVEmitter.cpp
+++ b/clang/utils/TableGen/RISCVVEmitter.cpp
@@ -155,10 +155,10 @@ void emitIntrinsicFuncDef(const RVVIntrinsic &RVVI, raw_ostream &OS) {
   OS << ");\n";
 }
 
-void emitMangledFuncDef(const RVVIntrinsic &RVVI, raw_ostream &OS) {
+void emitOverloadedFuncDef(const RVVIntrinsic &RVVI, raw_ostream &OS) {
   OS << "__attribute__((__clang_builtin_alias__(";
   OS << "__builtin_rvv_" << RVVI.getBuiltinName() << ")))\n";
-  OS << RVVI.getOutputType()->getTypeStr() << " " << RVVI.getMangledName()
+  OS << RVVI.getOutputType()->getTypeStr() << " " << RVVI.getOverloadedName()
      << "(";
   // Emit function arguments
   const RVVTypes &InputTypes = RVVI.getInputTypes();
@@ -289,7 +289,7 @@ void RVVEmitter::createHeader(raw_ostream &OS) {
     if (!Inst.isMasked() && !Inst.hasUnMaskedOverloaded())
       return;
     OS << "__rvv_aio ";
-    emitMangledFuncDef(Inst, OS);
+    emitOverloadedFuncDef(Inst, OS);
   });
 
   OS << "#undef __rvv_aio\n";
@@ -387,8 +387,8 @@ void RVVEmitter::createRVVIntrinsics(
   for (auto *R : RV) {
     StringRef Name = R->getValueAsString("Name");
     StringRef SuffixProto = R->getValueAsString("Suffix");
-    StringRef OverloadedName = R->getValueAsString("MangledName");
-    StringRef OverloadedSuffixProto = R->getValueAsString("MangledSuffix");
+    StringRef OverloadedName = R->getValueAsString("OverloadedName");
+    StringRef OverloadedSuffixProto = R->getValueAsString("OverloadedSuffix");
     StringRef Prototypes = R->getValueAsString("Prototype");
     StringRef TypeRange = R->getValueAsString("TypeRange");
     bool HasMasked = R->getValueAsBit("HasMasked");


        


More information about the cfe-commits mailing list