summaryrefslogtreecommitdiffstats
path: root/llvm/utils
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2012-01-03 23:04:28 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2012-01-03 23:04:28 +0000
commitbd75a417f91444fe10b8aca088967701c960ece0 (patch)
tree2e9247ded7cf19dcf1f68dd8db895eaf8c6738ad /llvm/utils
parent7249e36704756c215a3391a9e7b544602bda4780 (diff)
downloadbcm5719-llvm-bd75a417f91444fe10b8aca088967701c960ece0.tar.gz
bcm5719-llvm-bd75a417f91444fe10b8aca088967701c960ece0.zip
Don't use enums larger than 1 << 31 for target features.
Patch by Andy Zhang! llvm-svn: 147491
Diffstat (limited to 'llvm/utils')
-rw-r--r--llvm/utils/TableGen/SubtargetEmitter.cpp45
1 files changed, 29 insertions, 16 deletions
diff --git a/llvm/utils/TableGen/SubtargetEmitter.cpp b/llvm/utils/TableGen/SubtargetEmitter.cpp
index 34cd9a9e906..986c50f8786 100644
--- a/llvm/utils/TableGen/SubtargetEmitter.cpp
+++ b/llvm/utils/TableGen/SubtargetEmitter.cpp
@@ -39,28 +39,41 @@ void SubtargetEmitter::Enumeration(raw_ostream &OS,
OS << "namespace " << Target << " {\n";
- // Open enumeration
- OS << "enum {\n";
+ // For bit flag enumerations with more than 32 items, emit constants.
+ // Emit an enum for everything else.
+ if (isBits && N > 32) {
+ // For each record
+ for (unsigned i = 0; i < N; i++) {
+ // Next record
+ Record *Def = DefList[i];
+
+ // Get and emit name and expression (1 << i)
+ OS << " const uint64_t " << Def->getName() << " = 1ULL << " << i << ";\n";
+ }
+ } else {
+ // Open enumeration
+ OS << "enum {\n";
- // For each record
- for (unsigned i = 0; i < N;) {
- // Next record
- Record *Def = DefList[i];
+ // For each record
+ for (unsigned i = 0; i < N;) {
+ // Next record
+ Record *Def = DefList[i];
- // Get and emit name
- OS << " " << Def->getName();
+ // Get and emit name
+ OS << " " << Def->getName();
- // If bit flags then emit expression (1 << i)
- if (isBits) OS << " = " << " 1ULL << " << i;
+ // If bit flags then emit expression (1 << i)
+ if (isBits) OS << " = " << " 1ULL << " << i;
- // Depending on 'if more in the list' emit comma
- if (++i < N) OS << ",";
+ // Depending on 'if more in the list' emit comma
+ if (++i < N) OS << ",";
- OS << "\n";
- }
+ OS << "\n";
+ }
- // Close enumeration
- OS << "};\n";
+ // Close enumeration
+ OS << "};\n";
+ }
OS << "}\n";
}
OpenPOWER on IntegriCloud