1 //===- SubtargetFeatureInfo.h - Helpers for subtarget features ------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_UTIL_TABLEGEN_SUBTARGETFEATUREINFO_H
11 #define LLVM_UTIL_TABLEGEN_SUBTARGETFEATUREINFO_H
13 #include "llvm/TableGen/Error.h"
14 #include "llvm/TableGen/Record.h"
24 /// Helper class for storing information on a subtarget feature which
25 /// participates in instruction matching.
26 struct SubtargetFeatureInfo {
27 /// \brief The predicate record for this feature.
30 /// \brief An unique index assigned to represent this feature.
33 SubtargetFeatureInfo(Record *D, uint64_t Idx) : TheDef(D), Index(Idx) {}
35 /// \brief The name of the enumerated constant identifying this feature.
36 std::string getEnumName() const {
37 return "Feature_" + TheDef->getName().str();
41 static std::vector<std::pair<Record *, SubtargetFeatureInfo>>
42 getAll(const RecordKeeper &Records);
44 /// Emit the subtarget feature flag definitions.
45 static void emitSubtargetFeatureFlagEnumeration(
46 std::map<Record *, SubtargetFeatureInfo, LessRecordByID>
50 static void emitNameTable(std::map<Record *, SubtargetFeatureInfo,
51 LessRecordByID> &SubtargetFeatures,
54 /// Emit the function to compute the list of available features given a
57 /// \param TargetName The name of the target as used in class prefixes (e.g.
58 /// <TargetName>Subtarget)
59 /// \param ClassName The name of the class (without the <Target> prefix)
60 /// that will contain the generated functions.
61 /// \param FuncName The name of the function to emit.
62 /// \param SubtargetFeatures A map of TableGen records to the
63 /// SubtargetFeatureInfo equivalent.
64 static void emitComputeAvailableFeatures(
65 StringRef TargetName, StringRef ClassName, StringRef FuncName,
66 std::map<Record *, SubtargetFeatureInfo, LessRecordByID>
70 } // end namespace llvm
72 #endif // LLVM_UTIL_TABLEGEN_SUBTARGETFEATUREINFO_H