diff options
author | Bob Wilson <bob.wilson@apple.com> | 2009-04-16 21:51:05 +0000 |
---|---|---|
committer | Bob Wilson <bob.wilson@apple.com> | 2009-04-16 21:51:05 +0000 |
commit | d305e707a65fa18cbe828cae2338499661c9229e (patch) | |
tree | ad523234ffd50dc1c163bfb0b977546a647690d3 /utils/TableGen/CodeGenTarget.cpp | |
parent | 3f91bb3ce4c8f6e31c4051cc10799e54c3a26a3a (diff) |
Fix PR3994: LLVMMatchType arguments do not refer to absolute return value
and argument positions but only to the overloaded intrinsic parameters.
Keep a separate list of these overloaded parameters in CodeGenTarget.cpp
so they can be resolved easily. Remove assertions from IntrinsicEmitter.cpp:
they were harmless but confusing, and the assertions elsewhere in TableGen
will catch any incorrect values.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69316 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/TableGen/CodeGenTarget.cpp')
-rw-r--r-- | utils/TableGen/CodeGenTarget.cpp | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/utils/TableGen/CodeGenTarget.cpp b/utils/TableGen/CodeGenTarget.cpp index 0c9da806cc..aad1be9416 100644 --- a/utils/TableGen/CodeGenTarget.cpp +++ b/utils/TableGen/CodeGenTarget.cpp @@ -490,22 +490,30 @@ CodeGenIntrinsic::CodeGenIntrinsic(Record *R) { } // Parse the list of return types. + std::vector<MVT::SimpleValueType> OverloadedVTs; ListInit *TypeList = R->getValueAsListInit("RetTypes"); for (unsigned i = 0, e = TypeList->getSize(); i != e; ++i) { Record *TyEl = TypeList->getElementAsRecord(i); assert(TyEl->isSubClassOf("LLVMType") && "Expected a type!"); MVT::SimpleValueType VT; if (TyEl->isSubClassOf("LLVMMatchType")) { - VT = IS.RetVTs[TyEl->getValueAsInt("Number")]; + unsigned MatchTy = TyEl->getValueAsInt("Number"); + assert(MatchTy < OverloadedVTs.size() && + "Invalid matching number!"); + VT = OverloadedVTs[MatchTy]; // It only makes sense to use the extended and truncated vector element // variants with iAny types; otherwise, if the intrinsic is not // overloaded, all the types can be specified directly. assert(((!TyEl->isSubClassOf("LLVMExtendedElementVectorType") && !TyEl->isSubClassOf("LLVMTruncatedElementVectorType")) || VT == MVT::iAny) && "Expected iAny type"); - } else + } else { VT = getValueType(TyEl->getValueAsDef("VT")); - isOverloaded |= VT == MVT::iAny || VT == MVT::fAny || VT == MVT::iPTRAny; + } + if (VT == MVT::iAny || VT == MVT::fAny || VT == MVT::iPTRAny) { + OverloadedVTs.push_back(VT); + isOverloaded |= true; + } IS.RetVTs.push_back(VT); IS.RetTypeDefs.push_back(TyEl); } @@ -521,10 +529,9 @@ CodeGenIntrinsic::CodeGenIntrinsic(Record *R) { MVT::SimpleValueType VT; if (TyEl->isSubClassOf("LLVMMatchType")) { unsigned MatchTy = TyEl->getValueAsInt("Number"); - if (MatchTy < IS.RetVTs.size()) - VT = IS.RetVTs[MatchTy]; - else - VT = IS.ParamVTs[MatchTy - IS.RetVTs.size()]; + assert(MatchTy < OverloadedVTs.size() && + "Invalid matching number!"); + VT = OverloadedVTs[MatchTy]; // It only makes sense to use the extended and truncated vector element // variants with iAny types; otherwise, if the intrinsic is not // overloaded, all the types can be specified directly. @@ -533,7 +540,10 @@ CodeGenIntrinsic::CodeGenIntrinsic(Record *R) { VT == MVT::iAny) && "Expected iAny type"); } else VT = getValueType(TyEl->getValueAsDef("VT")); - isOverloaded |= VT == MVT::iAny || VT == MVT::fAny || VT == MVT::iPTRAny; + if (VT == MVT::iAny || VT == MVT::fAny || VT == MVT::iPTRAny) { + OverloadedVTs.push_back(VT); + isOverloaded |= true; + } IS.ParamVTs.push_back(VT); IS.ParamTypeDefs.push_back(TyEl); } |