xref: /llvm-project/llvm/test/Assembler/symbolic-addrspace.ll (revision f850035493e6f055182b443083a04a1d80bfd5c8)
1;; Check that we can parse symbolic addres space constants "A", "G", "P".
2;; NB: These do not round-trip via llvm-as, they are purely for initial parsing
3;; and will be converted to a numerical constant that does not depend on the
4;; datalayout by the .ll parser.
5; RUN: split-file %s %t --leading-lines
6; RUN: llvm-as < %t/valid.ll | llvm-dis | FileCheck %s
7; RUN: llvm-as < %t/alloca-in-other-as.ll | llvm-dis | FileCheck %s --check-prefix ALLOCA-IN-GLOBALS
8; RUN: not llvm-as < %t/bad-not-string.ll 2>&1 | FileCheck %s --check-prefix=ERR-NOT-STR
9; RUN: not llvm-as < %t/bad-unknown-char.ll 2>&1 | FileCheck %s --check-prefix=ERR-BAD-CHAR
10; RUN: not llvm-as < %t/bad-multiple-valid-chars.ll 2>&1 | FileCheck %s --check-prefix=ERR-MULTIPLE-CHARS
11; RUN: not llvm-as < %t/bad-using-at-symbol.ll 2>&1 | FileCheck %s --check-prefix=ERR-AT-SYMBOL
12; RUN: not llvm-as < %t/bad-number-in-quotes.ll 2>&1 | FileCheck %s --check-prefix=ERR-NUMBER-IN-QUOTES
13
14;--- valid.ll
15target datalayout = "A1-G2-P3"
16; CHECK: target datalayout = "A1-G2-P3"
17
18; CHECK: @str = private addrspace(2) constant [4 x i8] c"str\00"
19@str = private addrspace("G") constant [4 x i8] c"str\00"
20
21define void @foo() {
22  ; CHECK: %alloca = alloca i32, align 4, addrspace(1)
23  %alloca = alloca i32, addrspace("A")
24  ret void
25}
26
27; CHECK: define void @bar() addrspace(3) {
28define void @bar() addrspace("P") {
29  ; CHECK: call addrspace(3) void @foo()
30  call addrspace("P") void @foo()
31  ret void
32}
33
34;--- alloca-in-other-as.ll
35target datalayout = "A1-G2-P3"
36; ALLOCA-IN-GLOBALS: target datalayout = "A1-G2-P3"
37
38define void @foo() {
39  ; ALLOCA-IN-GLOBALS: %alloca = alloca i32, align 4, addrspace(2){{$}}
40  ; ALLOCA-IN-GLOBALS: %alloca2 = alloca i32, align 4, addrspace(1){{$}}
41  ; ALLOCA-IN-GLOBALS: %alloca3 = alloca i32, align 4{{$}}
42  ; ALLOCA-IN-GLOBALS: %alloca4 = alloca i32, align 4, addrspace(3){{$}}
43  %alloca = alloca i32, addrspace("G")
44  %alloca2 = alloca i32, addrspace("A")
45  %alloca3 = alloca i32
46  %alloca4 = alloca i32, addrspace("P")
47  ret void
48}
49
50;--- bad-not-string.ll
51target datalayout = "G2"
52@str = private addrspace(D) constant [4 x i8] c"str\00"
53; ERR-NOT-STR: [[#@LINE-1]]:26: error: expected integer or string constant
54
55;--- bad-unknown-char.ll
56target datalayout = "G2"
57@str = private addrspace("D") constant [4 x i8] c"str\00"
58; ERR-BAD-CHAR: [[#@LINE-1]]:26: error: invalid symbolic addrspace 'D'
59
60;--- bad-multiple-valid-chars.ll
61target datalayout = "A1-G2"
62@str = private addrspace("AG") constant [4 x i8] c"str\00"
63; ERR-MULTIPLE-CHARS: [[#@LINE-1]]:26: error: invalid symbolic addrspace 'AG'
64
65;--- bad-using-at-symbol.ll
66target datalayout = "A1-G2"
67@str = private addrspace(@A) constant [4 x i8] c"str\00"
68; ERR-AT-SYMBOL: [[#@LINE-1]]:26: error: expected integer or string constant
69
70;--- bad-number-in-quotes.ll
71target datalayout = "A1-G2"
72@str = private addrspace("10") constant [4 x i8] c"str\00"
73; ERR-NUMBER-IN-QUOTES: [[#@LINE-1]]:26: error: invalid symbolic addrspace '10'
74