Skip to content

Commit 66dc2cf

Browse files
committed
[TableGen] Add an option to SubtargetFeature to disable setting the field to the maximum value
1 parent 62af9e3 commit 66dc2cf

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

llvm/docs/WritingAnLLVMBackend.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1772,7 +1772,8 @@ is assumed to be a bool and only one SubtargetFeature should refer to it.
17721772
Otherwise, it is assumed to be an integer. The integer value may be the name
17731773
of an enum constant. If multiple features use the same integer field, the
17741774
field will be set to the maximum value of all enabled features that share
1775-
the field.
1775+
the field if `SetMaxValue` are set to true (by default), or we will set the
1776+
field to the last specified value.
17761777

17771778
.. code-block:: text
17781779
@@ -1783,6 +1784,7 @@ the field.
17831784
string Value = v;
17841785
string Desc = d;
17851786
list<SubtargetFeature> Implies = i;
1787+
bit SetMaxValue = true;
17861788
}
17871789
17881790
In the ``Sparc.td`` file, the ``SubtargetFeature`` is used to define the

llvm/include/llvm/Target/Target.td

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -494,12 +494,17 @@ class SubtargetFeature<string n, string f, string v, string d,
494494
//
495495
// A value of "true" or "false" implies the field is a bool. Otherwise,
496496
// it is assumed to be an integer. the integer value may be the name of an
497-
// enum constant. If multiple features use the same integer field, the
498-
// field will be set to the maximum value of all enabled features that
499-
// share the field.
500-
//
497+
// enum constant.
501498
string Value = v;
502499

500+
// SetMaxValue - Should we set the maximum value to the integer field.
501+
//
502+
// If multiple features use the same integer field, the field will be set to
503+
// the maximum value of all enabled features that share the field if `SetMaxValue`
504+
// are set to true (by default), or we will set the field to the last specified
505+
// value.
506+
bit SetMaxValue = true;
507+
503508
// Desc - Feature description. Used by command line (-mattr=) to display help
504509
// information.
505510
//

llvm/utils/TableGen/SubtargetEmitter.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1902,13 +1902,14 @@ void SubtargetEmitter::parseFeaturesFunction(raw_ostream &OS) {
19021902
StringRef Instance = R->getName();
19031903
StringRef Value = R->getValueAsString("Value");
19041904
StringRef FieldName = R->getValueAsString("FieldName");
1905+
bool SetMaxValue = R->getValueAsBit("SetMaxValue");
19051906

1906-
if (Value == "true" || Value == "false")
1907+
if (Value == "true" || Value == "false" || !SetMaxValue)
19071908
OS << " if (Bits[" << Target << "::" << Instance << "]) " << FieldName
19081909
<< " = " << Value << ";\n";
19091910
else
19101911
OS << " if (Bits[" << Target << "::" << Instance << "] && " << FieldName
1911-
<< " < " << Value << ") " << FieldName << " = " << Value << ";\n";
1912+
<< " != " << Value << ") " << FieldName << " = " << Value << ";\n";
19121913
}
19131914

19141915
OS << "}\n";

0 commit comments

Comments
 (0)