]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/utils/TableGen/SubtargetFeatureInfo.h
MFV 316891
[FreeBSD/FreeBSD.git] / contrib / llvm / utils / TableGen / SubtargetFeatureInfo.h
1 //===- SubtargetFeatureInfo.h - Helpers for subtarget features ------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef LLVM_UTIL_TABLEGEN_SUBTARGETFEATUREINFO_H
11 #define LLVM_UTIL_TABLEGEN_SUBTARGETFEATUREINFO_H
12
13 #include "llvm/TableGen/Error.h"
14 #include "llvm/TableGen/Record.h"
15
16 #include <map>
17 #include <string>
18 #include <vector>
19
20 namespace llvm {
21 class Record;
22 class RecordKeeper;
23
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.
28   Record *TheDef;
29
30   /// \brief An unique index assigned to represent this feature.
31   uint64_t Index;
32
33   SubtargetFeatureInfo(Record *D, uint64_t Idx) : TheDef(D), Index(Idx) {}
34
35   /// \brief The name of the enumerated constant identifying this feature.
36   std::string getEnumName() const {
37     return "Feature_" + TheDef->getName().str();
38   }
39
40   void dump() const;
41   static std::vector<std::pair<Record *, SubtargetFeatureInfo>>
42   getAll(const RecordKeeper &Records);
43
44   /// Emit the subtarget feature flag definitions.
45   static void emitSubtargetFeatureFlagEnumeration(
46       std::map<Record *, SubtargetFeatureInfo, LessRecordByID>
47           &SubtargetFeatures,
48       raw_ostream &OS);
49
50   static void emitNameTable(std::map<Record *, SubtargetFeatureInfo,
51                                      LessRecordByID> &SubtargetFeatures,
52                             raw_ostream &OS);
53
54   /// Emit the function to compute the list of available features given a
55   /// subtarget.
56   ///
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>
67           &SubtargetFeatures,
68       raw_ostream &OS);
69 };
70 } // end namespace llvm
71
72 #endif // LLVM_UTIL_TABLEGEN_SUBTARGETFEATUREINFO_H