we don't want people to override printBasicBlockLabel.
[llvm/avr.git] / include / llvm / Target / SubtargetFeature.h
blob58333e2b424f627403a2d69a5fdb05240d865963
1 //===-- llvm/Target/SubtargetFeature.h - CPU characteristics ----*- C++ -*-===//
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 // This file defines and manages user or tool specified CPU characteristics.
11 // The intent is to be able to package specific features that should or should
12 // not be used on a specific target processor. A tool, such as llc, could, as
13 // as example, gather chip info from the command line, a long with features
14 // that should be used on that chip.
16 //===----------------------------------------------------------------------===//
18 #ifndef LLVM_TARGET_SUBTARGETFEATURE_H
19 #define LLVM_TARGET_SUBTARGETFEATURE_H
21 #include <string>
22 #include <vector>
23 #include <cstring>
24 #include "llvm/Support/DataTypes.h"
26 namespace llvm {
27 class raw_ostream;
29 //===----------------------------------------------------------------------===//
30 ///
31 /// SubtargetFeatureKV - Used to provide key value pairs for feature and
32 /// CPU bit flags.
34 struct SubtargetFeatureKV {
35 const char *Key; // K-V key string
36 const char *Desc; // Help descriptor
37 uint32_t Value; // K-V integer value
38 uint32_t Implies; // K-V bit mask
40 // Compare routine for std binary search
41 bool operator<(const SubtargetFeatureKV &S) const {
42 return strcmp(Key, S.Key) < 0;
46 //===----------------------------------------------------------------------===//
47 ///
48 /// SubtargetInfoKV - Used to provide key value pairs for CPU and arbitrary
49 /// pointers.
51 struct SubtargetInfoKV {
52 const char *Key; // K-V key string
53 void *Value; // K-V pointer value
55 // Compare routine for std binary search
56 bool operator<(const SubtargetInfoKV &S) const {
57 return strcmp(Key, S.Key) < 0;
61 //===----------------------------------------------------------------------===//
62 ///
63 /// SubtargetFeatures - Manages the enabling and disabling of subtarget
64 /// specific features. Features are encoded as a string of the form
65 /// "cpu,+attr1,+attr2,-attr3,...,+attrN"
66 /// A comma separates each feature from the next (all lowercase.)
67 /// The first feature is always the CPU subtype (eg. pentiumm). If the CPU
68 /// value is "generic" then the CPU subtype should be generic for the target.
69 /// Each of the remaining features is prefixed with + or - indicating whether
70 /// that feature should be enabled or disabled contrary to the cpu
71 /// specification.
72 ///
74 class SubtargetFeatures {
75 std::vector<std::string> Features; // Subtarget features as a vector
76 public:
77 explicit SubtargetFeatures(const std::string &Initial = std::string());
79 /// Features string accessors.
80 std::string getString() const;
81 void setString(const std::string &Initial);
83 /// Set the CPU string. Replaces previous setting. Setting to "" clears CPU.
84 void setCPU(const std::string &String);
86 /// Setting CPU string only if no string is set.
87 void setCPUIfNone(const std::string &String);
89 /// Returns current CPU string.
90 const std::string & getCPU() const;
92 /// Adding Features.
93 void AddFeature(const std::string &String, bool IsEnabled = true);
95 /// Get feature bits.
96 uint32_t getBits(const SubtargetFeatureKV *CPUTable,
97 size_t CPUTableSize,
98 const SubtargetFeatureKV *FeatureTable,
99 size_t FeatureTableSize);
101 /// Get info pointer
102 void *getInfo(const SubtargetInfoKV *Table, size_t TableSize);
104 /// Print feature string.
105 void print(raw_ostream &OS) const;
107 // Dump feature info.
108 void dump() const;
111 } // End namespace llvm
113 #endif