summaryrefslogtreecommitdiffstats
path: root/llvm/utils/TableGen/SubtargetFeatureInfo.h
diff options
context:
space:
mode:
authorDaniel Sanders <daniel_l_sanders@apple.com>2016-11-15 09:51:02 +0000
committerDaniel Sanders <daniel_l_sanders@apple.com>2016-11-15 09:51:02 +0000
commitea6ef3d3faaecf6937d39919629eca88c637f627 (patch)
tree28db4b5209bd89fda3410d848e20d9622e4c42f7 /llvm/utils/TableGen/SubtargetFeatureInfo.h
parent473a3e7fed16ec27db398047d29082ce6cf9d318 (diff)
downloadbcm5719-llvm-ea6ef3d3faaecf6937d39919629eca88c637f627.tar.gz
bcm5719-llvm-ea6ef3d3faaecf6937d39919629eca88c637f627.zip
[tablegen] Extract portions of AsmMatcherEmitter for re-use by another generator. NFC.
Summary: This change is preparation for a change that will allow targets to verify that the instructions they emit meet the predicates they specify. This is useful to ensure that C++ legalization/lowering/instruction-selection doesn't incorrectly select code for a different subtarget than intended. Such cases are not caught by the integrated assembler when emitting instructions directly to an object file. Reviewers: qcolombet Subscribers: qcolombet, beanz, mgorny, llvm-commits, modocache Differential Revision: https://reviews.llvm.org/D25614 llvm-svn: 286945
Diffstat (limited to 'llvm/utils/TableGen/SubtargetFeatureInfo.h')
-rw-r--r--llvm/utils/TableGen/SubtargetFeatureInfo.h57
1 files changed, 57 insertions, 0 deletions
diff --git a/llvm/utils/TableGen/SubtargetFeatureInfo.h b/llvm/utils/TableGen/SubtargetFeatureInfo.h
new file mode 100644
index 00000000000..ddd04d5bb45
--- /dev/null
+++ b/llvm/utils/TableGen/SubtargetFeatureInfo.h
@@ -0,0 +1,57 @@
+//===- SubtargetFeatureInfo.h - Helpers for subtarget features ------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_UTIL_TABLEGEN_SUBTARGETFEATUREINFO_H
+#define LLVM_UTIL_TABLEGEN_SUBTARGETFEATUREINFO_H
+
+#include "llvm/TableGen/Error.h"
+#include "llvm/TableGen/Record.h"
+
+#include <map>
+
+namespace llvm {
+class Record;
+class RecordKeeper;
+
+/// Helper class for storing information on a subtarget feature which
+/// participates in instruction matching.
+struct SubtargetFeatureInfo {
+ /// \brief The predicate record for this feature.
+ Record *TheDef;
+
+ /// \brief An unique index assigned to represent this feature.
+ uint64_t Index;
+
+ SubtargetFeatureInfo(Record *D, uint64_t Idx) : TheDef(D), Index(Idx) {}
+
+ /// \brief The name of the enumerated constant identifying this feature.
+ std::string getEnumName() const { return "Feature_" + TheDef->getName(); }
+
+ void dump() const;
+ static std::vector<std::pair<Record *, SubtargetFeatureInfo>>
+ getAll(const RecordKeeper &Records);
+
+ /// Emit the function to compute the list of available features given a
+ /// subtarget.
+ ///
+ /// \param TargetName The name of the target as used in class prefixes (e.g.
+ /// <TargetName>Subtarget)
+ /// \param ClassName The name of the class (without the <Target> prefix)
+ /// that will contain the generated functions.
+ /// \param SubtargetFeatures A map of TableGen records to the
+ /// SubtargetFeatureInfo equivalent.
+ static void emitComputeAvailableFeatures(
+ StringRef TargetName, StringRef ClassName,
+ std::map<Record *, SubtargetFeatureInfo, LessRecordByID>
+ &SubtargetFeatures,
+ raw_ostream &OS);
+};
+} // end namespace llvm
+
+#endif // LLVM_UTIL_TABLEGEN_SUBTARGETFEATUREINFO_H
OpenPOWER on IntegriCloud