[llvm] d846ce7 - [TableGen][Target] Rename Attribute field in SubtargetFeature class to FieldName.

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 21 18:02:27 PDT 2023


Author: Craig Topper
Date: 2023-06-21T17:53:50-07:00
New Revision: d846ce7bc4f52ef45f773e3ed8dc41c0d5ef5b2c

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

LOG: [TableGen][Target] Rename Attribute field in SubtargetFeature class to FieldName.

The word "attribute" has a specific meaning in LLVM. Avoid using it
here to mean something different.

This addresses feedback from D153180.

Reviewed By: arsenm

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

Added: 
    

Modified: 
    llvm/docs/WritingAnLLVMBackend.rst
    llvm/include/llvm/Target/Target.td
    llvm/utils/TableGen/SubtargetEmitter.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/docs/WritingAnLLVMBackend.rst b/llvm/docs/WritingAnLLVMBackend.rst
index 12da372520af8..31ebc6204c98f 100644
--- a/llvm/docs/WritingAnLLVMBackend.rst
+++ b/llvm/docs/WritingAnLLVMBackend.rst
@@ -1760,24 +1760,24 @@ command-line options ``-mcpu=`` and ``-mattr=``.
 TableGen uses definitions in the ``Target.td`` and ``Sparc.td`` files to
 generate code in ``SparcGenSubtarget.inc``.  In ``Target.td``, shown below, the
 ``SubtargetFeature`` interface is defined.  The first 4 string parameters of
-the ``SubtargetFeature`` interface are a feature name, an attribute set by the
-feature, the value of the attribute, and a description of the feature.  (The
-fifth parameter is a list of features whose presence is implied, and its
-default value is an empty array.)
+the ``SubtargetFeature`` interface are a feature name, a XXXSubtarget field set
+by the feature, the value of the XXXSubtarget field, and a description of the
+feature.  (The fifth parameter is a list of features whose presence is implied,
+and its default value is an empty array.)
 
-If the value for the attribute is the string "true" or "false", the attribute
+If the value for the field is the string "true" or "false", the field
 is assumed to be a bool and only one SubtargetFeature should refer to it.
 Otherwise, it is assumed to be an integer. The integer value may be the name
-of an enum constant. If multiple features use the same integer attribute, the
-attribute will be set to the maximum value of all enabled features that share
-the attribute.
+of an enum constant. If multiple features use the same integer field, the
+field will be set to the maximum value of all enabled features that share
+the field.
 
 .. code-block:: text
 
-  class SubtargetFeature<string n, string a, string v, string d,
+  class SubtargetFeature<string n, string f, string v, string d,
                          list<SubtargetFeature> i = []> {
     string Name = n;
-    string Attribute = a;
+    string FieldName = f;
     string Value = v;
     string Desc = d;
     list<SubtargetFeature> Implies = i;

diff  --git a/llvm/include/llvm/Target/Target.td b/llvm/include/llvm/Target/Target.td
index 5db0ec675051a..06521fa584cb0 100644
--- a/llvm/include/llvm/Target/Target.td
+++ b/llvm/include/llvm/Target/Target.td
@@ -1657,24 +1657,24 @@ class Target {
 //===----------------------------------------------------------------------===//
 // SubtargetFeature - A characteristic of the chip set.
 //
-class SubtargetFeature<string n, string a,  string v, string d,
+class SubtargetFeature<string n, string f, string v, string d,
                        list<SubtargetFeature> i = []> {
   // Name - Feature name.  Used by command line (-mattr=) to determine the
   // appropriate target chip.
   //
   string Name = n;
 
-  // Attribute - Attribute to be set by feature.
+  // FieldName - Field in XXXSubtarget to be set by feature.
   //
-  string Attribute = a;
+  string FieldName = f;
 
-  // Value - Value the attribute to be set to by feature.
+  // Value - Value the XXXSubtarget field to be set to by feature.
   //
-  // A value of "true" or "false" implies the attribute is a bool. Otherwise,
+  // A value of "true" or "false" implies the field is a bool. Otherwise,
   // it is assumed to be an integer. the integer value may be the name of an
-  // enum constant. If multiple features use the same integer attribute, the
-  // attribute will be set to the maximum value of all enabled features that
-  // share the attribute.
+  // enum constant. If multiple features use the same integer field, the
+  // field will be set to the maximum value of all enabled features that
+  // share the field.
   //
   string Value = v;
 

diff  --git a/llvm/utils/TableGen/SubtargetEmitter.cpp b/llvm/utils/TableGen/SubtargetEmitter.cpp
index bd96ea74829d9..b13a3725834f2 100644
--- a/llvm/utils/TableGen/SubtargetEmitter.cpp
+++ b/llvm/utils/TableGen/SubtargetEmitter.cpp
@@ -205,12 +205,12 @@ void SubtargetEmitter::EmitSubtargetInfoMacroCalls(raw_ostream &OS) {
   llvm::sort(FeatureList, LessRecordFieldName());
 
   for (const Record *Feature : FeatureList) {
-    const StringRef Attribute = Feature->getValueAsString("Attribute");
+    const StringRef FieldName = Feature->getValueAsString("FieldName");
     const StringRef Value = Feature->getValueAsString("Value");
 
     // Only handle boolean features for now, excluding BitVectors and enums.
     const bool IsBool = (Value == "false" || Value == "true") &&
-                        !StringRef(Attribute).contains('[');
+                        !StringRef(FieldName).contains('[');
     if (!IsBool)
       continue;
 
@@ -219,9 +219,9 @@ void SubtargetEmitter::EmitSubtargetInfoMacroCalls(raw_ostream &OS) {
 
     // Define the getter with lowercased first char: xxxYyy() { return XxxYyy; }
     const std::string Getter =
-        Attribute.substr(0, 1).lower() + Attribute.substr(1).str();
+        FieldName.substr(0, 1).lower() + FieldName.substr(1).str();
 
-    OS << "GET_SUBTARGETINFO_MACRO(" << Attribute << ", " << Default << ", "
+    OS << "GET_SUBTARGETINFO_MACRO(" << FieldName << ", " << Default << ", "
        << Getter << ")\n";
   }
   OS << "#undef GET_SUBTARGETINFO_MACRO\n";
@@ -1804,17 +1804,17 @@ void SubtargetEmitter::ParseFeaturesFunction(raw_ostream &OS) {
     // Next record
     StringRef Instance = R->getName();
     StringRef Value = R->getValueAsString("Value");
-    StringRef Attribute = R->getValueAsString("Attribute");
+    StringRef FieldName = R->getValueAsString("FieldName");
 
     if (Value=="true" || Value=="false")
       OS << "  if (Bits[" << Target << "::"
          << Instance << "]) "
-         << Attribute << " = " << Value << ";\n";
+         << FieldName << " = " << Value << ";\n";
     else
       OS << "  if (Bits[" << Target << "::"
          << Instance << "] && "
-         << Attribute << " < " << Value << ") "
-         << Attribute << " = " << Value << ";\n";
+         << FieldName << " < " << Value << ") "
+         << FieldName << " = " << Value << ";\n";
   }
 
   OS << "}\n";


        


More information about the llvm-commits mailing list