diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2007-05-22 19:30:31 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2007-05-22 19:30:31 +0000 |
commit | 84c614d1ac671b1a5524169f20028f51c30be728 (patch) | |
tree | 403c9fb91adee430fa6b28594dd2f0728a7c71a8 /utils | |
parent | 4ad513ca153430c3a7f36be1ef43af04534e1f5d (diff) | |
download | external_llvm-84c614d1ac671b1a5524169f20028f51c30be728.zip external_llvm-84c614d1ac671b1a5524169f20028f51c30be728.tar.gz external_llvm-84c614d1ac671b1a5524169f20028f51c30be728.tar.bz2 |
The Intrinsic::getDeclaration function's Tys parameter only contains the
types of the iAny types involved in the overloaded intrinsic. Thus, we
can't use the argument number as the index but have to count them separately
in order to index Tys correctly. This patch rectifies this situation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37296 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils')
-rw-r--r-- | utils/TableGen/IntrinsicEmitter.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/utils/TableGen/IntrinsicEmitter.cpp b/utils/TableGen/IntrinsicEmitter.cpp index 834e142..a362553 100644 --- a/utils/TableGen/IntrinsicEmitter.cpp +++ b/utils/TableGen/IntrinsicEmitter.cpp @@ -134,11 +134,18 @@ static bool EmitTypeVerify(std::ostream &OS, Record *ArgType) { return false; } -static void EmitTypeGenerate(std::ostream &OS, Record *ArgType, unsigned ArgNo){ +static void EmitTypeGenerate(std::ostream &OS, Record *ArgType, + unsigned &ArgNo) { if (ArgType->isSubClassOf("LLVMIntegerType")) { unsigned BitWidth = ArgType->getValueAsInt("Width"); + // NOTE: The ArgNo variable here is not the absolute argument number, it is + // the index of the "arbitrary" type in the Tys array passed to the + // Intrinsic::getDeclaration function. Consequently, we only want to + // increment it when we actually hit an arbitray integer type which is + // identified by BitWidth == 0. Getting this wrong leads to very subtle + // bugs! if (BitWidth == 0) - OS << "Tys[" << ArgNo << "]"; + OS << "Tys[" << ArgNo++ << "]"; else OS << "IntegerType::get(" << BitWidth << ")"; } else if (ArgType->isSubClassOf("LLVMVectorType")) { @@ -253,16 +260,16 @@ void IntrinsicEmitter::EmitGenerator(const std::vector<CodeGenIntrinsic> &Ints, --N; } + unsigned ArgNo = 0; OS << " ResultTy = "; - EmitTypeGenerate(OS, ArgTypes[0], 0); + EmitTypeGenerate(OS, ArgTypes[0], ArgNo); OS << ";\n"; for (unsigned j = 1; j != N; ++j) { OS << " ArgTys.push_back("; - EmitTypeGenerate(OS, ArgTypes[j], j); + EmitTypeGenerate(OS, ArgTypes[j], ArgNo); OS << ");\n"; } - OS << " break;\n"; } OS << " }\n"; |