diff options
author | Jim Laskey <jlaskey@mac.com> | 2007-02-06 18:30:58 +0000 |
---|---|---|
committer | Jim Laskey <jlaskey@mac.com> | 2007-02-06 18:30:58 +0000 |
commit | 95d97b90e8427255c8298f5d3a1ab605af62aab4 (patch) | |
tree | 88b37ef034eed96d39c368a8ce07a329de590a0a | |
parent | 01ba6adc8fb8e3fa80cd5506cf8c0cf4ee5efdb5 (diff) | |
download | external_llvm-95d97b90e8427255c8298f5d3a1ab605af62aab4.zip external_llvm-95d97b90e8427255c8298f5d3a1ab605af62aab4.tar.gz external_llvm-95d97b90e8427255c8298f5d3a1ab605af62aab4.tar.bz2 |
Error check and eliminate unnecessary value.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33966 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | utils/TableGen/IntrinsicEmitter.cpp | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/utils/TableGen/IntrinsicEmitter.cpp b/utils/TableGen/IntrinsicEmitter.cpp index 9a1132a..ab52752 100644 --- a/utils/TableGen/IntrinsicEmitter.cpp +++ b/utils/TableGen/IntrinsicEmitter.cpp @@ -108,11 +108,8 @@ EmitIntrinsicToNameTable(const std::vector<CodeGenIntrinsic> &Ints, OS << "#endif\n\n"; } -static void EmitTypeVerify(std::ostream &OS, Record *ArgType) { - if (ArgType->getValueAsString("TypeVal") == "...") { - OS << "-2, "; - return; - } +static bool EmitTypeVerify(std::ostream &OS, Record *ArgType) { + if (ArgType->getValueAsString("TypeVal") == "...") return true; OS << "(int)" << ArgType->getValueAsString("TypeVal") << ", "; // If this is an integer type, check the width is correct. @@ -124,6 +121,8 @@ static void EmitTypeVerify(std::ostream &OS, Record *ArgType) { EmitTypeVerify(OS, ArgType->getValueAsDef("ElTy")); OS << ArgType->getValueAsInt("NumElts") << ", "; } + + return false; } /// RecordListComparator - Provide a determinstic comparator for lists of @@ -172,9 +171,17 @@ void IntrinsicEmitter::EmitVerifier(const std::vector<CodeGenIntrinsic> &Ints, const std::vector<Record*> &ArgTypes = I->first; OS << " VerifyIntrinsicPrototype(IF, "; - for (unsigned j = 0; j != ArgTypes.size(); ++j) - EmitTypeVerify(OS, ArgTypes[j]); - OS << "-1);\n"; + bool VarArg = false; + for (unsigned j = 0; j != ArgTypes.size(); ++j) { + VarArg = EmitTypeVerify(OS, ArgTypes[j]); + if (VarArg) { + if ((j+1) != ArgTypes.size()) + throw "Var arg type not last argument"; + break; + } + } + + OS << (VarArg ? "-2);\n" : "-1);\n"); OS << " break;\n"; } OS << " }\n"; |