diff options
author | Christopher Tetreault <ctetreau@quicinc.com> | 2020-04-10 13:49:05 -0700 |
---|---|---|
committer | Christopher Tetreault <ctetreau@quicinc.com> | 2020-04-10 13:58:11 -0700 |
commit | 2a922da3a95f77a0eec96eab9ebc8c1ff090fb8c (patch) | |
tree | fcd4c06ef763d4f1e5a522d18c7900157bd81a23 /llvm/lib/AsmParser/LLParser.cpp | |
parent | c162bc2aedbe7412a56063cd2284d1c7b1858f05 (diff) | |
download | llvm-2a922da3a95f77a0eec96eab9ebc8c1ff090fb8c.zip llvm-2a922da3a95f77a0eec96eab9ebc8c1ff090fb8c.tar.gz llvm-2a922da3a95f77a0eec96eab9ebc8c1ff090fb8c.tar.bz2 |
Clean up usages of asserting vector getters in Type
Summary:
Remove usages of asserting vector getters in Type in preparation for the
VectorType refactor. The existence of these functions complicates the
refactor while adding little value.
Reviewers: dexonsmith, sdesmalen, efriedma
Reviewed By: sdesmalen
Subscribers: hiraditya, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D77274
Diffstat (limited to 'llvm/lib/AsmParser/LLParser.cpp')
-rw-r--r-- | llvm/lib/AsmParser/LLParser.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp index ebb1720..2e446ab 100644 --- a/llvm/lib/AsmParser/LLParser.cpp +++ b/llvm/lib/AsmParser/LLParser.cpp @@ -3588,16 +3588,17 @@ bool LLParser::ParseValID(ValID &ID, PerFunctionState *PFS) { ExplicitTypeLoc, "explicit pointee type doesn't match operand's pointee type"); - unsigned GEPWidth = - BaseType->isVectorTy() ? BaseType->getVectorNumElements() : 0; + unsigned GEPWidth = BaseType->isVectorTy() + ? cast<VectorType>(BaseType)->getNumElements() + : 0; ArrayRef<Constant *> Indices(Elts.begin() + 1, Elts.end()); for (Constant *Val : Indices) { Type *ValTy = Val->getType(); if (!ValTy->isIntOrIntVectorTy()) return Error(ID.Loc, "getelementptr index must be an integer"); - if (ValTy->isVectorTy()) { - unsigned ValNumEl = ValTy->getVectorNumElements(); + if (auto *ValVTy = dyn_cast<VectorType>(ValTy)) { + unsigned ValNumEl = ValVTy->getNumElements(); if (GEPWidth && (ValNumEl != GEPWidth)) return Error( ID.Loc, @@ -7233,8 +7234,9 @@ int LLParser::ParseGetElementPtr(Instruction *&Inst, PerFunctionState &PFS) { bool AteExtraComma = false; // GEP returns a vector of pointers if at least one of parameters is a vector. // All vector parameters should have the same vector width. - ElementCount GEPWidth = BaseType->isVectorTy() ? - BaseType->getVectorElementCount() : ElementCount(0, false); + ElementCount GEPWidth = BaseType->isVectorTy() + ? cast<VectorType>(BaseType)->getElementCount() + : ElementCount(0, false); while (EatIfPresent(lltok::comma)) { if (Lex.getKind() == lltok::MetadataVar) { @@ -7245,8 +7247,8 @@ int LLParser::ParseGetElementPtr(Instruction *&Inst, PerFunctionState &PFS) { if (!Val->getType()->isIntOrIntVectorTy()) return Error(EltLoc, "getelementptr index must be an integer"); - if (Val->getType()->isVectorTy()) { - ElementCount ValNumEl = Val->getType()->getVectorElementCount(); + if (auto *ValVTy = dyn_cast<VectorType>(Val->getType())) { + ElementCount ValNumEl = ValVTy->getElementCount(); if (GEPWidth != ElementCount(0, false) && GEPWidth != ValNumEl) return Error(EltLoc, "getelementptr vector index has a wrong number of elements"); |