aboutsummaryrefslogtreecommitdiff
path: root/backend/utils/TableGen/Common
diff options
context:
space:
mode:
Diffstat (limited to 'backend/utils/TableGen/Common')
-rw-r--r--backend/utils/TableGen/Common/CodeGenSelection.cpp14
-rw-r--r--backend/utils/TableGen/Common/CodeGenTarget.h6
2 files changed, 20 insertions, 0 deletions
diff --git a/backend/utils/TableGen/Common/CodeGenSelection.cpp b/backend/utils/TableGen/Common/CodeGenSelection.cpp
index defe98b..0d59d6b 100644
--- a/backend/utils/TableGen/Common/CodeGenSelection.cpp
+++ b/backend/utils/TableGen/Common/CodeGenSelection.cpp
@@ -297,6 +297,20 @@ bool CodeGenTarget::normalizeSelectionRules(NormalizedTargetModel &Result) {
++Normalized.Specificity;
}
+ if (Rule.MemoryPredicate) {
+ if (Rule.MemoryPredicate->Bytes == 0 ||
+ (MatchInstruction != nullptr && !MatchInstruction->RequiresMemoryOperands)) {
+ fail(Rule.MemoryPredicate->Range,
+ "selection memory predicate requires a nonzero size and a memory opcode");
+ return false;
+ }
+ Normalized.MemoryPredicate = {
+ .MemoryOperandIndex = Rule.MemoryPredicate->MemoryOperandIndex,
+ .Bytes = Rule.MemoryPredicate->Bytes,
+ };
+ ++Normalized.Specificity;
+ }
+
std::unordered_set<std::string> TargetPredicateSymbols;
for (const SourceSelectionTargetPredicate &Predicate : Rule.TargetPredicates) {
if (!isIdentifier(Predicate.Symbol) ||
diff --git a/backend/utils/TableGen/Common/CodeGenTarget.h b/backend/utils/TableGen/Common/CodeGenTarget.h
index 020bb88..3a7d299 100644
--- a/backend/utils/TableGen/Common/CodeGenTarget.h
+++ b/backend/utils/TableGen/Common/CodeGenTarget.h
@@ -200,6 +200,11 @@ struct NormalizedSelectionFloatingPredicate final {
std::uint32_t Predicate = 0;
};
+struct NormalizedSelectionMemoryPredicate final {
+ std::uint32_t MemoryOperandIndex = 0;
+ std::uint32_t Bytes = 0;
+};
+
struct NormalizedSelectionConstantRange final {
std::int64_t Minimum = 0;
std::int64_t Maximum = 0;
@@ -272,6 +277,7 @@ struct NormalizedSelectionRule final {
std::optional<NormalizedSelectionTypePredicate> ResultType;
std::optional<NormalizedSelectionIntegerPredicate> IntegerPredicate;
std::optional<NormalizedSelectionFloatingPredicate> FloatingPredicate;
+ std::optional<NormalizedSelectionMemoryPredicate> MemoryPredicate;
std::vector<std::string> TargetPredicates;
std::vector<NormalizedSelectionOperandTypePredicate> OperandTypes;
std::vector<NormalizedSelectionOperandBankPredicate> OperandBanks;