diff options
8 files changed, 73 insertions, 15 deletions
diff --git a/llvm/lib/CodeGen/MIRParser/MIParser.cpp b/llvm/lib/CodeGen/MIRParser/MIParser.cpp index acb4ab6ad1b..c1c93575e35 100644 --- a/llvm/lib/CodeGen/MIRParser/MIParser.cpp +++ b/llvm/lib/CodeGen/MIRParser/MIParser.cpp @@ -1306,7 +1306,7 @@ bool MIParser::parseLowLevelType(StringRef::iterator Loc, LLT &Ty) {    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 @@ bool MIParser::parseLowLevelType(StringRef::iterator Loc, LLT &Ty) {    // Now we're looking for a vector.    if (Token.isNot(MIToken::less))      return error(Loc, -                 "expected unsized, pN, sN or <N x sM> for GlobalISel type"); - +                 "expected sN, pA, <M x sN>, or <M x pA> for GlobalISel type");    lex();    if (Token.isNot(MIToken::IntegerLiteral)) -    return error(Loc, "expected <N x sM> for vctor type"); +    return error(Loc, "expected <M x sN> or <M x pA> for vector type");    uint64_t NumElements = Token.integerValue().getZExtValue();    lex();    if (Token.isNot(MIToken::Identifier) || Token.stringValue() != "x") -    return error(Loc, "expected '<N x sM>' for vector type"); +    return error(Loc, "expected <M x sN> or <M x pA> for vector type");    lex(); -  if (Token.range().front() != 's') -    return error(Loc, "expected '<N x sM>' for vector type"); +  if (Token.range().front() != 's' && Token.range().front() != 'p') +    return error(Loc, "expected <M x sN> or <M x pA> 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 <M x sN> or <M x pA> for vector type");    lex();    if (Token.isNot(MIToken::greater)) -    return error(Loc, "expected '<N x sM>' for vector type"); +    return error(Loc, "expected <M x sN> or <M x pA> for vector type");    lex(); -  Ty = LLT::vector(NumElements, ScalarSize); +  Ty = LLT::vector(NumElements, Ty);    return false;  } @@ -1359,10 +1366,10 @@ bool MIParser::parseTypedImmediateOperand(MachineOperand &Dest) {    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(); diff --git a/llvm/test/CodeGen/MIR/AArch64/parse-low-level-type-invalid0.mir b/llvm/test/CodeGen/MIR/AArch64/parse-low-level-type-invalid0.mir new file mode 100644 index 00000000000..cece3601dc1 --- /dev/null +++ b/llvm/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 +... 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 new file mode 100644 index 00000000000..3545640271d --- /dev/null +++ b/llvm/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, <M x sN>, or <M x pA> for GlobalISel type +    %0:_(i64) = COPY $x0 +... diff --git a/llvm/test/CodeGen/MIR/AArch64/parse-low-level-type-invalid2.mir b/llvm/test/CodeGen/MIR/AArch64/parse-low-level-type-invalid2.mir new file mode 100644 index 00000000000..1bff7a5ec9c --- /dev/null +++ b/llvm/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 +... diff --git a/llvm/test/CodeGen/MIR/AArch64/parse-low-level-type-invalid3.mir b/llvm/test/CodeGen/MIR/AArch64/parse-low-level-type-invalid3.mir new file mode 100644 index 00000000000..ebb3d37f9df --- /dev/null +++ b/llvm/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 <M x sN> or <M x pA> for vector type +    %0:_(<2 x i64>) = COPY $q0 +... diff --git a/llvm/test/CodeGen/MIR/AArch64/print-parse-vector-of-pointers-llt.mir b/llvm/test/CodeGen/MIR/AArch64/print-parse-vector-of-pointers-llt.mir new file mode 100644 index 00000000000..a91b974b02e --- /dev/null +++ b/llvm/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 +... diff --git a/llvm/test/CodeGen/MIR/WebAssembly/typed-immediate-operand-invalid0.mir b/llvm/test/CodeGen/MIR/WebAssembly/typed-immediate-operand-invalid0.mir index dcb940cc6ac..b9f138c14b0 100644 --- a/llvm/test/CodeGen/MIR/WebAssembly/typed-immediate-operand-invalid0.mir +++ b/llvm/test/CodeGen/MIR/WebAssembly/typed-immediate-operand-invalid0.mir @@ -7,7 +7,7 @@ liveins:  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  ... diff --git a/llvm/test/CodeGen/MIR/WebAssembly/typed-immediate-operand-invalid1.mir b/llvm/test/CodeGen/MIR/WebAssembly/typed-immediate-operand-invalid1.mir index 032bdf3d8fa..03e722f6c3c 100644 --- a/llvm/test/CodeGen/MIR/WebAssembly/typed-immediate-operand-invalid1.mir +++ b/llvm/test/CodeGen/MIR/WebAssembly/typed-immediate-operand-invalid1.mir @@ -7,7 +7,7 @@ liveins:  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  ...  | 

