Index: llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp =================================================================== --- llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp +++ llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp @@ -1306,7 +1306,7 @@ if (Token.range().front() == 's' || Token.range().front() == 'p') { StringRef SizeStr = Token.range().drop_front(); if (SizeStr.size() == 0 || !llvm::all_of(SizeStr, isdigit)) - return error("Expected integers after 's'/'p' type character"); + return error("expected integers after 's'/'p' type character"); } if (Token.range().front() == 's') { @@ -1324,32 +1324,39 @@ // Now we're looking for a vector. if (Token.isNot(MIToken::less)) return error(Loc, - "expected unsized, pN, sN or for GlobalISel type"); - + "expected sN, pA, , or for GlobalISel type"); lex(); if (Token.isNot(MIToken::IntegerLiteral)) - return error(Loc, "expected for vctor type"); + return error(Loc, "expected or for vector type"); uint64_t NumElements = Token.integerValue().getZExtValue(); lex(); if (Token.isNot(MIToken::Identifier) || Token.stringValue() != "x") - return error(Loc, "expected '' for vector type"); + return error(Loc, "expected or for vector type"); lex(); - if (Token.range().front() != 's') - return error(Loc, "expected '' for vector type"); + if (Token.range().front() != 's' && Token.range().front() != 'p') + return error(Loc, "expected or for vector type"); StringRef SizeStr = Token.range().drop_front(); if (SizeStr.size() == 0 || !llvm::all_of(SizeStr, isdigit)) - return error("Expected integers after 's' type character"); - uint64_t ScalarSize = APSInt(Token.range().drop_front()).getZExtValue(); + return error("expected integers after 's'/'p' type character"); + + if (Token.range().front() == 's') + Ty = LLT::scalar(APSInt(Token.range().drop_front()).getZExtValue()); + else if (Token.range().front() == 'p') { + const DataLayout &DL = MF.getDataLayout(); + unsigned AS = APSInt(Token.range().drop_front()).getZExtValue(); + Ty = LLT::pointer(AS, DL.getPointerSizeInBits(AS)); + } else + return error(Loc, "expected or for vector type"); lex(); if (Token.isNot(MIToken::greater)) - return error(Loc, "expected '' for vector type"); + return error(Loc, "expected or for vector type"); lex(); - Ty = LLT::vector(NumElements, ScalarSize); + Ty = LLT::vector(NumElements, Ty); return false; } @@ -1359,10 +1366,10 @@ if (TypeStr.front() != 'i' && TypeStr.front() != 's' && TypeStr.front() != 'p') return error( - "A typed immediate operand should start with one of 'i', 's', or 'p'"); + "a typed immediate operand should start with one of 'i', 's', or 'p'"); StringRef SizeStr = Token.range().drop_front(); if (SizeStr.size() == 0 || !llvm::all_of(SizeStr, isdigit)) - return error("Expected integers after 'i'/'s'/'p' type character"); + return error("expected integers after 'i'/'s'/'p' type character"); auto Loc = Token.location(); lex(); Index: llvm/trunk/test/CodeGen/MIR/AArch64/parse-low-level-type-invalid0.mir =================================================================== --- llvm/trunk/test/CodeGen/MIR/AArch64/parse-low-level-type-invalid0.mir +++ llvm/trunk/test/CodeGen/MIR/AArch64/parse-low-level-type-invalid0.mir @@ -0,0 +1,10 @@ +# RUN: not llc -mtriple=aarch64-- -run-pass none -o /dev/null %s 2>&1 | FileCheck %s +# When a low-level type is only a single 's'/'p' character +--- +name: test_low_level_type_is_single_s_p +body: | + bb.0: + liveins: $x0 + ; CHECK: [[@LINE+1]]:10: expected integers after 's'/'p' type character + %0:_(s) = COPY $x0 +... Index: llvm/trunk/test/CodeGen/MIR/AArch64/parse-low-level-type-invalid1.mir =================================================================== --- llvm/trunk/test/CodeGen/MIR/AArch64/parse-low-level-type-invalid1.mir +++ llvm/trunk/test/CodeGen/MIR/AArch64/parse-low-level-type-invalid1.mir @@ -0,0 +1,10 @@ +# RUN: not llc -mtriple=aarch64-- -run-pass none -o /dev/null %s 2>&1 | FileCheck %s +# When a low-level type does not start with 's', 'p', or '<' +--- +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 + %0:_(i64) = COPY $x0 +... Index: llvm/trunk/test/CodeGen/MIR/AArch64/parse-low-level-type-invalid2.mir =================================================================== --- llvm/trunk/test/CodeGen/MIR/AArch64/parse-low-level-type-invalid2.mir +++ llvm/trunk/test/CodeGen/MIR/AArch64/parse-low-level-type-invalid2.mir @@ -0,0 +1,10 @@ +# RUN: not llc -mtriple=aarch64-- -run-pass none -o /dev/null %s 2>&1 | FileCheck %s +# When a low-level type is a vector with only a single 's'/'p' character for element type +--- +name: test_low_level_type_is_single_s_p +body: | + bb.0: + liveins: $q0 + ; CHECK: [[@LINE+1]]:15: expected integers after 's'/'p' type character + %0:_(<2 x p>) = COPY $q0 +... Index: llvm/trunk/test/CodeGen/MIR/AArch64/parse-low-level-type-invalid3.mir =================================================================== --- llvm/trunk/test/CodeGen/MIR/AArch64/parse-low-level-type-invalid3.mir +++ llvm/trunk/test/CodeGen/MIR/AArch64/parse-low-level-type-invalid3.mir @@ -0,0 +1,10 @@ +# RUN: not llc -mtriple=aarch64-- -run-pass none -o /dev/null %s 2>&1 | FileCheck %s +# When a low-level type is a vector which element type does not start with 's' or 'p' +--- +name: test_low_level_type_does_not_start_with_s_p +body: | + bb.0: + liveins: $q0 + ; CHECK: [[@LINE+1]]:10: expected or for vector type + %0:_(<2 x i64>) = COPY $q0 +... Index: llvm/trunk/test/CodeGen/MIR/AArch64/print-parse-vector-of-pointers-llt.mir =================================================================== --- llvm/trunk/test/CodeGen/MIR/AArch64/print-parse-vector-of-pointers-llt.mir +++ llvm/trunk/test/CodeGen/MIR/AArch64/print-parse-vector-of-pointers-llt.mir @@ -0,0 +1,11 @@ +# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py +# RUN: llc -mtriple=aarch64-- -run-pass none -o - %s 2>&1 | FileCheck %s +--- +name: test_vector_of_pointers_llt +body: | + bb.0: + liveins: $q0 + ; CHECK-LABEL: name: test_vector_of_pointers_llt + ; CHECK: [[COPY:%[0-9]+]]:_(<2 x p0>) = COPY $q0 + %0:_(<2 x p0>) = COPY $q0 +... Index: llvm/trunk/test/CodeGen/MIR/WebAssembly/typed-immediate-operand-invalid0.mir =================================================================== --- llvm/trunk/test/CodeGen/MIR/WebAssembly/typed-immediate-operand-invalid0.mir +++ llvm/trunk/test/CodeGen/MIR/WebAssembly/typed-immediate-operand-invalid0.mir @@ -7,7 +7,7 @@ body: | bb.0: liveins: $arguments - ; CHECK: [[@LINE+1]]:24: Expected integers after 'i'/'s'/'p' type character + ; CHECK: [[@LINE+1]]:24: expected integers after 'i'/'s'/'p' type character %0:i32 = CONST_I32 i 0, implicit-def dead $arguments RETURN_VOID implicit-def dead $arguments ... Index: llvm/trunk/test/CodeGen/MIR/WebAssembly/typed-immediate-operand-invalid1.mir =================================================================== --- llvm/trunk/test/CodeGen/MIR/WebAssembly/typed-immediate-operand-invalid1.mir +++ llvm/trunk/test/CodeGen/MIR/WebAssembly/typed-immediate-operand-invalid1.mir @@ -7,7 +7,7 @@ body: | bb.0: liveins: $arguments - ; CHECK: [[@LINE+1]]:24: A typed immediate operand should start with one of 'i', 's', or 'p' + ; CHECK: [[@LINE+1]]:24: a typed immediate operand should start with one of 'i', 's', or 'p' %0:i32 = CONST_I32 abc 0, implicit-def dead $arguments RETURN_VOID implicit-def dead $arguments ...