xref: /llvm-project/llvm/test/Assembler/constant-splat-diagnostics.ll (revision 9c6693f9012dbf59cf9ebabc9097ce3f25f05cb6)
1; RUN: rm -rf %t && split-file %s %t
2
3; RUN: not llvm-as < %t/not_a_constant.ll -o /dev/null 2>&1 | FileCheck -check-prefix=NOT_A_CONSTANT %s
4; RUN: not llvm-as < %t/not_a_sclar.ll -o /dev/null 2>&1 | FileCheck -check-prefix=NOT_A_SCALAR %s
5; RUN: not llvm-as < %t/not_a_vector.ll -o /dev/null 2>&1 | FileCheck -check-prefix=NOT_A_VECTOR %s
6; RUN: not llvm-as < %t/wrong_explicit_type.ll -o /dev/null 2>&1 | FileCheck -check-prefix=WRONG_EXPLICIT_TYPE %s
7; RUN: not llvm-as < %t/wrong_implicit_type.ll -o /dev/null 2>&1 | FileCheck -check-prefix=WRONG_IMPLICIT_TYPE %s
8
9;--- not_a_constant.ll
10; NOT_A_CONSTANT: error: expected instruction opcode
11define <4 x i32> @not_a_constant(i32 %a) {
12  %splat = splat (i32 %a)
13  ret <vscale x 4 x i32> %splat
14}
15
16;--- not_a_sclar.ll
17; NOT_A_SCALAR: error: constant expression type mismatch: got type '<1 x i32>' but expected 'i32'
18define <4 x i32> @not_a_scalar() {
19  ret <4 x i32> splat (<1 x i32> <i32 7>)
20}
21
22;--- not_a_vector.ll
23; NOT_A_VECTOR: error: vector constant must have vector type
24define <4 x i32> @not_a_vector() {
25  ret i32 splat (i32 7)
26}
27
28;--- wrong_explicit_type.ll
29; WRONG_EXPLICIT_TYPE: error: constant expression type mismatch: got type 'i8' but expected 'i32'
30define <4 x i32> @wrong_explicit_type() {
31  ret <4 x i32> splat (i8 7)
32}
33
34;--- wrong_implicit_type.ll
35; WRONG_IMPLICIT_TYPE: error: constant expression type mismatch: got type 'i8' but expected 'i32'
36define void @wrong_implicit_type(<4 x i32> %a) {
37  %add = add <4 x i32> %a, splat (i8 7)
38  ret void
39}
40
41