diff --git a/llvm/lib/CodeGen/MIRParser/MIParser.cpp b/llvm/lib/CodeGen/MIRParser/MIParser.cpp index c01b34d6f490b..f5d80b2ae27c2 100644 --- a/llvm/lib/CodeGen/MIRParser/MIParser.cpp +++ b/llvm/lib/CodeGen/MIRParser/MIParser.cpp @@ -1946,12 +1946,28 @@ bool MIParser::parseLowLevelType(StringRef::iterator Loc, LLT &Ty) { // Now we're looking for a vector. if (Token.isNot(MIToken::less)) - return error(Loc, - "expected sN, pA, , or for GlobalISel type"); + return error(Loc, "expected sN, pA, , , , " + "or for GlobalISel type"); lex(); - if (Token.isNot(MIToken::IntegerLiteral)) + bool HasVScale = + Token.is(MIToken::Identifier) && Token.stringValue() == "vscale"; + if (HasVScale) { + lex(); + if (Token.isNot(MIToken::Identifier) || Token.stringValue() != "x") + return error("expected or "); + lex(); + } + + auto GetError = [this, &HasVScale, Loc]() { + if (HasVScale) + return error( + Loc, "expected or for vector type"); return error(Loc, "expected or for vector type"); + }; + + if (Token.isNot(MIToken::IntegerLiteral)) + return GetError(); uint64_t NumElements = Token.integerValue().getZExtValue(); if (!verifyVectorElementCount(NumElements)) return error("invalid number of vector elements"); @@ -1959,11 +1975,12 @@ bool MIParser::parseLowLevelType(StringRef::iterator Loc, LLT &Ty) { lex(); if (Token.isNot(MIToken::Identifier) || Token.stringValue() != "x") - return error(Loc, "expected or for vector type"); + return GetError(); lex(); if (Token.range().front() != 's' && Token.range().front() != 'p') - return error(Loc, "expected or for vector type"); + return GetError(); + StringRef SizeStr = Token.range().drop_front(); if (SizeStr.size() == 0 || !llvm::all_of(SizeStr, isdigit)) return error("expected integers after 's'/'p' type character"); @@ -1981,14 +1998,15 @@ bool MIParser::parseLowLevelType(StringRef::iterator Loc, LLT &Ty) { Ty = LLT::pointer(AS, DL.getPointerSizeInBits(AS)); } else - return error(Loc, "expected or for vector type"); + return GetError(); lex(); if (Token.isNot(MIToken::greater)) - return error(Loc, "expected or for vector type"); + return GetError(); + lex(); - Ty = LLT::fixed_vector(NumElements, Ty); + Ty = LLT::vector(ElementCount::get(NumElements, HasVScale), Ty); return false; } diff --git a/llvm/test/CodeGen/MIR/AArch64/parse-low-level-type-invalid1.mir b/llvm/test/CodeGen/MIR/AArch64/parse-low-level-type-invalid1.mir index 3545640271d10..4a7b68dab623a 100644 --- a/llvm/test/CodeGen/MIR/AArch64/parse-low-level-type-invalid1.mir +++ b/llvm/test/CodeGen/MIR/AArch64/parse-low-level-type-invalid1.mir @@ -5,6 +5,6 @@ name: test_low_level_type_does_not_start_with_s_p_lt body: | bb.0: liveins: $x0 - ; CHECK: [[@LINE+1]]:10: expected sN, pA, , or for GlobalISel type + ; CHECK: [[@LINE+1]]:10: expected sN, pA, , , , or for GlobalISel type %0:_(i64) = COPY $x0 ... diff --git a/llvm/test/CodeGen/MIR/Generic/scalable-vector-type-err0.mir b/llvm/test/CodeGen/MIR/Generic/scalable-vector-type-err0.mir new file mode 100644 index 0000000000000..5553d97acd003 --- /dev/null +++ b/llvm/test/CodeGen/MIR/Generic/scalable-vector-type-err0.mir @@ -0,0 +1,10 @@ +# RUN: not llc -run-pass none -o - %s 2>&1 | FileCheck %s +--- +name: err_after_vscale0 +body: | + bb.0: + %0:_( or + diff --git a/llvm/test/CodeGen/MIR/Generic/scalable-vector-type-err1.mir b/llvm/test/CodeGen/MIR/Generic/scalable-vector-type-err1.mir new file mode 100644 index 0000000000000..12bfb82ebcd12 --- /dev/null +++ b/llvm/test/CodeGen/MIR/Generic/scalable-vector-type-err1.mir @@ -0,0 +1,9 @@ +# RUN: not llc -run-pass none -o - %s 2>&1 | FileCheck %s +--- +name: err_after_vscale1 +body: | + bb.0: + %0:_( or diff --git a/llvm/test/CodeGen/MIR/Generic/scalable-vector-type-err10.mir b/llvm/test/CodeGen/MIR/Generic/scalable-vector-type-err10.mir new file mode 100644 index 0000000000000..7d7d7e49f23fe --- /dev/null +++ b/llvm/test/CodeGen/MIR/Generic/scalable-vector-type-err10.mir @@ -0,0 +1,10 @@ +# RUN: not llc -run-pass none -o - %s 2>&1 | FileCheck %s + +--- +name: err_after_vscalexMxp +body: | + bb.0: + %0:_(&1 | FileCheck %s + +--- +name: err_after_vscalexMxs32 +body: | + bb.0: + %0:_( or for vector type diff --git a/llvm/test/CodeGen/MIR/Generic/scalable-vector-type-err12.mir b/llvm/test/CodeGen/MIR/Generic/scalable-vector-type-err12.mir new file mode 100644 index 0000000000000..5ced1aea30c08 --- /dev/null +++ b/llvm/test/CodeGen/MIR/Generic/scalable-vector-type-err12.mir @@ -0,0 +1,10 @@ +# RUN: not llc -run-pass none -o - %s 2>&1 | FileCheck %s + +--- +name: err_after_vscalexMxp0 +body: | + bb.0: + %0:_( or for vector type diff --git a/llvm/test/CodeGen/MIR/Generic/scalable-vector-type-err13.mir b/llvm/test/CodeGen/MIR/Generic/scalable-vector-type-err13.mir new file mode 100644 index 0000000000000..94b8230233fa6 --- /dev/null +++ b/llvm/test/CodeGen/MIR/Generic/scalable-vector-type-err13.mir @@ -0,0 +1,10 @@ +# RUN: not llc -run-pass none -o - %s 2>&1 | FileCheck %s + +--- +name: err_after_vscalexMxs32X +body: | + bb.0: + %0:_( or for vector type diff --git a/llvm/test/CodeGen/MIR/Generic/scalable-vector-type-err14.mir b/llvm/test/CodeGen/MIR/Generic/scalable-vector-type-err14.mir new file mode 100644 index 0000000000000..323e2d975692f --- /dev/null +++ b/llvm/test/CodeGen/MIR/Generic/scalable-vector-type-err14.mir @@ -0,0 +1,10 @@ +# RUN: not llc -run-pass none -o - %s 2>&1 | FileCheck %s + +--- +name: err_after_vscalexMxp0 +body: | + bb.0: + %0:_( or for vector type diff --git a/llvm/test/CodeGen/MIR/Generic/scalable-vector-type-err15.mir b/llvm/test/CodeGen/MIR/Generic/scalable-vector-type-err15.mir new file mode 100644 index 0000000000000..d1613869bf671 --- /dev/null +++ b/llvm/test/CodeGen/MIR/Generic/scalable-vector-type-err15.mir @@ -0,0 +1,10 @@ +# RUN: not llc -run-pass none -o - %s 2>&1 | FileCheck %s + +--- +name: err_after_vscale0 +body: | + bb.0: + %0:_(notatype) = IMPLICIT_DEF +... + +# CHECK: expected sN, pA, , , , or for GlobalISel type diff --git a/llvm/test/CodeGen/MIR/Generic/scalable-vector-type-err2.mir b/llvm/test/CodeGen/MIR/Generic/scalable-vector-type-err2.mir new file mode 100644 index 0000000000000..c504a7d6be249 --- /dev/null +++ b/llvm/test/CodeGen/MIR/Generic/scalable-vector-type-err2.mir @@ -0,0 +1,9 @@ +# RUN: not llc -run-pass none -o - %s 2>&1 | FileCheck %s +--- +name: err_after_vscalex0 +body: | + bb.0: + %0:_( or for vector type diff --git a/llvm/test/CodeGen/MIR/Generic/scalable-vector-type-err3.mir b/llvm/test/CodeGen/MIR/Generic/scalable-vector-type-err3.mir new file mode 100644 index 0000000000000..c504a7d6be249 --- /dev/null +++ b/llvm/test/CodeGen/MIR/Generic/scalable-vector-type-err3.mir @@ -0,0 +1,9 @@ +# RUN: not llc -run-pass none -o - %s 2>&1 | FileCheck %s +--- +name: err_after_vscalex0 +body: | + bb.0: + %0:_( or for vector type diff --git a/llvm/test/CodeGen/MIR/Generic/scalable-vector-type-err4.mir b/llvm/test/CodeGen/MIR/Generic/scalable-vector-type-err4.mir new file mode 100644 index 0000000000000..654f534f4d301 --- /dev/null +++ b/llvm/test/CodeGen/MIR/Generic/scalable-vector-type-err4.mir @@ -0,0 +1,10 @@ +# RUN: not llc -run-pass none -o - %s 2>&1 | FileCheck %s +--- +name: err_after_vscalex1 +body: | + bb.0: + %0:_( or for vector type + diff --git a/llvm/test/CodeGen/MIR/Generic/scalable-vector-type-err5.mir b/llvm/test/CodeGen/MIR/Generic/scalable-vector-type-err5.mir new file mode 100644 index 0000000000000..26be2868c522e --- /dev/null +++ b/llvm/test/CodeGen/MIR/Generic/scalable-vector-type-err5.mir @@ -0,0 +1,9 @@ +# RUN: not llc -run-pass none -o - %s 2>&1 | FileCheck %s +--- +name: err_after_vscalexM +body: | + bb.0: + %0:_( or for vector type diff --git a/llvm/test/CodeGen/MIR/Generic/scalable-vector-type-err6.mir b/llvm/test/CodeGen/MIR/Generic/scalable-vector-type-err6.mir new file mode 100644 index 0000000000000..07a30f57139dc --- /dev/null +++ b/llvm/test/CodeGen/MIR/Generic/scalable-vector-type-err6.mir @@ -0,0 +1,11 @@ +# RUN: not llc -run-pass none -o - %s 2>&1 | FileCheck %s + +--- +name: err_after_vscalexMx0 +body: | + bb.0: + %0:_( or for vector type + diff --git a/llvm/test/CodeGen/MIR/Generic/scalable-vector-type-err7.mir b/llvm/test/CodeGen/MIR/Generic/scalable-vector-type-err7.mir new file mode 100644 index 0000000000000..dba902efe6331 --- /dev/null +++ b/llvm/test/CodeGen/MIR/Generic/scalable-vector-type-err7.mir @@ -0,0 +1,9 @@ +# RUN: not llc -run-pass none -o - %s 2>&1 | FileCheck %s +--- +name: err_after_vscalexMx1 +body: | + bb.0: + %0:_( or for vector type diff --git a/llvm/test/CodeGen/MIR/Generic/scalable-vector-type-err8.mir b/llvm/test/CodeGen/MIR/Generic/scalable-vector-type-err8.mir new file mode 100644 index 0000000000000..8bedeabaa7906 --- /dev/null +++ b/llvm/test/CodeGen/MIR/Generic/scalable-vector-type-err8.mir @@ -0,0 +1,10 @@ +# RUN: not llc -run-pass none -o - %s 2>&1 | FileCheck %s + +--- +name: err_after_vscalexMxs +body: | + bb.0: + %0:_(&1 | FileCheck %s +--- +name: err_after_vscalexMxpX +body: | + bb.0: + %0:_() = IMPLICIT_DEF + ; CHECK-NEXT: [[COPY:%[0-9]+]]:_() = COPY [[DEF]]() + %0:_() = IMPLICIT_DEF + %1:_() = COPY %0 +... + +--- +name: test_nxv1s16 +body: | + bb.0: + ; CHECK-LABEL: name: test_nxv1s16 + ; CHECK: [[DEF:%[0-9]+]]:_() = IMPLICIT_DEF + ; CHECK-NEXT: [[COPY:%[0-9]+]]:_() = COPY [[DEF]]() + %0:_() = IMPLICIT_DEF + %1:_() = COPY %0 +... + +--- +name: test_nxv1s32 +body: | + bb.0: + ; CHECK-LABEL: name: test_nxv1s32 + ; CHECK: [[DEF:%[0-9]+]]:_() = IMPLICIT_DEF + ; CHECK-NEXT: [[COPY:%[0-9]+]]:_() = COPY [[DEF]]() + %0:_() = IMPLICIT_DEF + %1:_() = COPY %0 +... + +--- +name: test_nxv1s64 +body: | + bb.0: + ; CHECK-LABEL: name: test_nxv1s64 + ; CHECK: [[DEF:%[0-9]+]]:_() = IMPLICIT_DEF + ; CHECK-NEXT: [[COPY:%[0-9]+]]:_() = COPY [[DEF]]() + %0:_() = IMPLICIT_DEF + %1:_() = COPY %0 +... + +--- +name: test_nxv4s8 +body: | + bb.0: + ; CHECK-LABEL: name: test_nxv4s8 + ; CHECK: [[DEF:%[0-9]+]]:_() = IMPLICIT_DEF + ; CHECK-NEXT: [[COPY:%[0-9]+]]:_() = COPY [[DEF]]() + %0:_() = IMPLICIT_DEF + %1:_() = COPY %0 +... + +--- +name: test_nxv4s16 +body: | + bb.0: + ; CHECK-LABEL: name: test_nxv4s16 + ; CHECK: [[DEF:%[0-9]+]]:_() = IMPLICIT_DEF + ; CHECK-NEXT: [[COPY:%[0-9]+]]:_() = COPY [[DEF]]() + %0:_() = IMPLICIT_DEF + %1:_() = COPY %0 +... + +--- +name: test_nxv4s32 +body: | + bb.0: + ; CHECK-LABEL: name: test_nxv4s32 + ; CHECK: [[DEF:%[0-9]+]]:_() = IMPLICIT_DEF + ; CHECK-NEXT: [[COPY:%[0-9]+]]:_() = COPY [[DEF]]() + %0:_() = IMPLICIT_DEF + %1:_() = COPY %0 +... + +--- +name: test_nxv4s64 +body: | + bb.0: + ; CHECK-LABEL: name: test_nxv4s64 + ; CHECK: [[DEF:%[0-9]+]]:_() = IMPLICIT_DEF + ; CHECK-NEXT: [[COPY:%[0-9]+]]:_() = COPY [[DEF]]() + %0:_() = IMPLICIT_DEF + %1:_() = COPY %0 +... + +--- +name: test_nxv1p0 +body: | + bb.0: + ; CHECK-LABEL: name: test_nxv1p0 + ; CHECK: [[DEF:%[0-9]+]]:_() = IMPLICIT_DEF + ; CHECK-NEXT: [[COPY:%[0-9]+]]:_() = COPY [[DEF]]() + %0:_() = IMPLICIT_DEF + %1:_() = COPY %0 +... + +--- +name: test_nxv1sp1 +body: | + bb.0: + ; CHECK-LABEL: name: test_nxv1sp1 + ; CHECK: [[DEF:%[0-9]+]]:_() = IMPLICIT_DEF + ; CHECK-NEXT: [[COPY:%[0-9]+]]:_() = COPY [[DEF]]() + %0:_() = IMPLICIT_DEF + %1:_() = COPY %0 +... + +--- +name: test_nxv4p0 +body: | + bb.0: + ; CHECK-LABEL: name: test_nxv4p0 + ; CHECK: [[DEF:%[0-9]+]]:_() = IMPLICIT_DEF + ; CHECK-NEXT: [[COPY:%[0-9]+]]:_() = COPY [[DEF]]() + %0:_() = IMPLICIT_DEF + %1:_() = COPY %0 +... + +--- +name: test_nxv4p1 +body: | + bb.0: + ; CHECK-LABEL: name: test_nxv4p1 + ; CHECK: [[DEF:%[0-9]+]]:_() = IMPLICIT_DEF + ; CHECK-NEXT: [[COPY:%[0-9]+]]:_() = COPY [[DEF]]() + %0:_() = IMPLICIT_DEF + %1:_() = COPY %0 +...