summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2007-05-22 19:30:31 +0000
committerReid Spencer <rspencer@reidspencer.com>2007-05-22 19:30:31 +0000
commitc23c9fce3498ea94ee85bf74991c705dda2590ab (patch)
tree5b2c067e7d1d5546c1c6a8d4ad2592bbb7c64746
parentbdf03b41748dc782116c1a19c1f606a3aa8e0d2f (diff)
downloadbcm5719-llvm-c23c9fce3498ea94ee85bf74991c705dda2590ab.tar.gz
bcm5719-llvm-c23c9fce3498ea94ee85bf74991c705dda2590ab.zip
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. llvm-svn: 37296
-rw-r--r--llvm/utils/TableGen/IntrinsicEmitter.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/llvm/utils/TableGen/IntrinsicEmitter.cpp b/llvm/utils/TableGen/IntrinsicEmitter.cpp
index 834e1429ba4..a362553d2ae 100644
--- a/llvm/utils/TableGen/IntrinsicEmitter.cpp
+++ b/llvm/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";
OpenPOWER on IntegriCloud