diff options
author | Bob Wilson <bob.wilson@apple.com> | 2009-07-29 16:35:59 +0000 |
---|---|---|
committer | Bob Wilson <bob.wilson@apple.com> | 2009-07-29 16:35:59 +0000 |
commit | 09b1366f3f310b5648aa8cd72ed16b9f19b4c68d (patch) | |
tree | c388f73f5da14ab27fb395151a39b5c304537a09 /utils/TableGen | |
parent | dc297c1f66499de864135bdd4d79d653f3d280dc (diff) | |
download | external_llvm-09b1366f3f310b5648aa8cd72ed16b9f19b4c68d.zip external_llvm-09b1366f3f310b5648aa8cd72ed16b9f19b4c68d.tar.gz external_llvm-09b1366f3f310b5648aa8cd72ed16b9f19b4c68d.tar.bz2 |
Fix the verifier to handle intrinsics with LLVMMatchType parameters, where
the return type of the intrinsic is not overloaded, i.e., where the type
being matched is some other parameter. The argument to LLVMMatchType is
an index into the list of overloaded types (ignoring the fixed types),
but VerifyIntrinsicPrototype is expecting its arguments for LLVMMatchType
parameters to be indices into the combined list of _all_ return values and
parameters, not just the overloaded ones.
This patch changes TableGen to keep track for each overloaded type of the
corresponding index into the list of return values and parameters. It
then generates the values expected by VerifyIntrinsicPrototype.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77467 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/TableGen')
-rw-r--r-- | utils/TableGen/IntrinsicEmitter.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/utils/TableGen/IntrinsicEmitter.cpp b/utils/TableGen/IntrinsicEmitter.cpp index f4157bb..d1e9b03 100644 --- a/utils/TableGen/IntrinsicEmitter.cpp +++ b/utils/TableGen/IntrinsicEmitter.cpp @@ -304,6 +304,7 @@ void IntrinsicEmitter::EmitVerifier(const std::vector<CodeGenIntrinsic> &Ints, const RecPair &ArgTypes = I->first; const std::vector<Record*> &RetTys = ArgTypes.first; const std::vector<Record*> &ParamTys = ArgTypes.second; + std::vector<unsigned> OverloadedTypeIndices; OS << " VerifyIntrinsicPrototype(ID, IF, " << RetTys.size() << ", " << ParamTys.size(); @@ -315,6 +316,9 @@ void IntrinsicEmitter::EmitVerifier(const std::vector<CodeGenIntrinsic> &Ints, if (ArgType->isSubClassOf("LLVMMatchType")) { unsigned Number = ArgType->getValueAsInt("Number"); + assert(Number < OverloadedTypeIndices.size() && + "Invalid matching number!"); + Number = OverloadedTypeIndices[Number]; if (ArgType->isSubClassOf("LLVMExtendedElementVectorType")) OS << "~(ExtendedElementVectorType | " << Number << ")"; else if (ArgType->isSubClassOf("LLVMTruncatedElementVectorType")) @@ -325,6 +329,9 @@ void IntrinsicEmitter::EmitVerifier(const std::vector<CodeGenIntrinsic> &Ints, MVT::SimpleValueType VT = getValueType(ArgType->getValueAsDef("VT")); OS << getEnumName(VT); + if (VT == MVT::iAny || VT == MVT::fAny || VT == MVT::iPTRAny) + OverloadedTypeIndices.push_back(j); + if (VT == MVT::isVoid && j != 0 && j != je - 1) throw "Var arg type not last argument"; } @@ -337,6 +344,9 @@ void IntrinsicEmitter::EmitVerifier(const std::vector<CodeGenIntrinsic> &Ints, if (ArgType->isSubClassOf("LLVMMatchType")) { unsigned Number = ArgType->getValueAsInt("Number"); + assert(Number < OverloadedTypeIndices.size() && + "Invalid matching number!"); + Number = OverloadedTypeIndices[Number]; if (ArgType->isSubClassOf("LLVMExtendedElementVectorType")) OS << "~(ExtendedElementVectorType | " << Number << ")"; else if (ArgType->isSubClassOf("LLVMTruncatedElementVectorType")) @@ -347,6 +357,9 @@ void IntrinsicEmitter::EmitVerifier(const std::vector<CodeGenIntrinsic> &Ints, MVT::SimpleValueType VT = getValueType(ArgType->getValueAsDef("VT")); OS << getEnumName(VT); + if (VT == MVT::iAny || VT == MVT::fAny || VT == MVT::iPTRAny) + OverloadedTypeIndices.push_back(j + RetTys.size()); + if (VT == MVT::isVoid && j != 0 && j != je - 1) throw "Var arg type not last argument"; } |