diff options
author | Aaron Ballman <aaron@aaronballman.com> | 2013-07-15 16:53:32 +0000 |
---|---|---|
committer | Aaron Ballman <aaron@aaronballman.com> | 2013-07-15 16:53:32 +0000 |
commit | e59e358823fa31ebb9da5066d49112fc867e092a (patch) | |
tree | d45f5c3fc249ef9d83e0dbac3a9c7d008e9e992b /llvm/utils/TableGen/FixedLenDecoderEmitter.cpp | |
parent | a75eba9c05d100395ba46c91959cd241c137965e (diff) | |
download | bcm5719-llvm-e59e358823fa31ebb9da5066d49112fc867e092a.tar.gz bcm5719-llvm-e59e358823fa31ebb9da5066d49112fc867e092a.zip |
Teaching llvm-tblgen to not emit a switch statement when there are no case statements.
llvm-svn: 186330
Diffstat (limited to 'llvm/utils/TableGen/FixedLenDecoderEmitter.cpp')
-rw-r--r-- | llvm/utils/TableGen/FixedLenDecoderEmitter.cpp | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/llvm/utils/TableGen/FixedLenDecoderEmitter.cpp b/llvm/utils/TableGen/FixedLenDecoderEmitter.cpp index 0c3017f3892..6e452409ab7 100644 --- a/llvm/utils/TableGen/FixedLenDecoderEmitter.cpp +++ b/llvm/utils/TableGen/FixedLenDecoderEmitter.cpp @@ -879,15 +879,20 @@ emitPredicateFunction(formatted_raw_ostream &OS, PredicateSet &Predicates, OS.indent(Indentation) << "static bool checkDecoderPredicate(unsigned Idx, " << "uint64_t Bits) {\n"; Indentation += 2; - OS.indent(Indentation) << "switch (Idx) {\n"; - OS.indent(Indentation) << "default: llvm_unreachable(\"Invalid index!\");\n"; - unsigned Index = 0; - for (PredicateSet::const_iterator I = Predicates.begin(), E = Predicates.end(); - I != E; ++I, ++Index) { - OS.indent(Indentation) << "case " << Index << ":\n"; - OS.indent(Indentation+2) << "return (" << *I << ");\n"; + if (!Predicates.empty()) { + OS.indent(Indentation) << "switch (Idx) {\n"; + OS.indent(Indentation) << "default: llvm_unreachable(\"Invalid index!\");\n"; + unsigned Index = 0; + for (PredicateSet::const_iterator I = Predicates.begin(), E = Predicates.end(); + I != E; ++I, ++Index) { + OS.indent(Indentation) << "case " << Index << ":\n"; + OS.indent(Indentation+2) << "return (" << *I << ");\n"; + } + OS.indent(Indentation) << "}\n"; + } else { + // No case statement to emit + OS.indent(Indentation) << "llvm_unreachable(\"Invalid index!\");\n"; } - OS.indent(Indentation) << "}\n"; Indentation -= 2; OS.indent(Indentation) << "}\n\n"; } |