File: symbolic-addrspace.ll

package info (click to toggle)
llvm-toolchain-17 1%3A17.0.6-22
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,799,624 kB
  • sloc: cpp: 6,428,607; ansic: 1,383,196; asm: 793,408; python: 223,504; objc: 75,364; f90: 60,502; lisp: 33,869; pascal: 15,282; sh: 9,684; perl: 7,453; ml: 4,937; awk: 3,523; makefile: 2,889; javascript: 2,149; xml: 888; fortran: 619; cs: 573
file content (73 lines) | stat: -rw-r--r-- 2,967 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
;; Check that we can parse symbolic addres space constants "A", "G", "P".
;; NB: These do not round-trip via llvm-as, they are purely for initial parsing
;; and will be converted to a numerical constant that does not depend on the
;; datalayout by the .ll parser.
; RUN: split-file %s %t --leading-lines
; RUN: llvm-as < %t/valid.ll | llvm-dis | FileCheck %s
; RUN: llvm-as < %t/alloca-in-other-as.ll | llvm-dis | FileCheck %s --check-prefix ALLOCA-IN-GLOBALS
; RUN: not llvm-as < %t/bad-not-string.ll 2>&1 | FileCheck %s --check-prefix=ERR-NOT-STR
; RUN: not llvm-as < %t/bad-unknown-char.ll 2>&1 | FileCheck %s --check-prefix=ERR-BAD-CHAR
; RUN: not llvm-as < %t/bad-multiple-valid-chars.ll 2>&1 | FileCheck %s --check-prefix=ERR-MULTIPLE-CHARS
; RUN: not llvm-as < %t/bad-using-at-symbol.ll 2>&1 | FileCheck %s --check-prefix=ERR-AT-SYMBOL
; RUN: not llvm-as < %t/bad-number-in-quotes.ll 2>&1 | FileCheck %s --check-prefix=ERR-NUMBER-IN-QUOTES

;--- valid.ll
target datalayout = "A1-G2-P3"
; CHECK: target datalayout = "A1-G2-P3"

; CHECK: @str = private addrspace(2) constant [4 x i8] c"str\00"
@str = private addrspace("G") constant [4 x i8] c"str\00"

define void @foo() {
  ; CHECK: %alloca = alloca i32, align 4, addrspace(1)
  %alloca = alloca i32, addrspace("A")
  ret void
}

; CHECK: define void @bar() addrspace(3) {
define void @bar() addrspace("P") {
  ; CHECK: call addrspace(3) void @foo()
  call addrspace("P") void @foo()
  ret void
}

;--- alloca-in-other-as.ll
target datalayout = "A1-G2-P3"
; ALLOCA-IN-GLOBALS: target datalayout = "A1-G2-P3"

define void @foo() {
  ; ALLOCA-IN-GLOBALS: %alloca = alloca i32, align 4, addrspace(2){{$}}
  ; ALLOCA-IN-GLOBALS: %alloca2 = alloca i32, align 4, addrspace(1){{$}}
  ; ALLOCA-IN-GLOBALS: %alloca3 = alloca i32, align 4{{$}}
  ; ALLOCA-IN-GLOBALS: %alloca4 = alloca i32, align 4, addrspace(3){{$}}
  %alloca = alloca i32, addrspace("G")
  %alloca2 = alloca i32, addrspace("A")
  %alloca3 = alloca i32
  %alloca4 = alloca i32, addrspace("P")
  ret void
}

;--- bad-not-string.ll
target datalayout = "G2"
@str = private addrspace(D) constant [4 x i8] c"str\00"
; ERR-NOT-STR: [[#@LINE-1]]:26: error: expected integer or string constant

;--- bad-unknown-char.ll
target datalayout = "G2"
@str = private addrspace("D") constant [4 x i8] c"str\00"
; ERR-BAD-CHAR: [[#@LINE-1]]:26: error: invalid symbolic addrspace 'D'

;--- bad-multiple-valid-chars.ll
target datalayout = "A1-G2"
@str = private addrspace("AG") constant [4 x i8] c"str\00"
; ERR-MULTIPLE-CHARS: [[#@LINE-1]]:26: error: invalid symbolic addrspace 'AG'

;--- bad-using-at-symbol.ll
target datalayout = "A1-G2"
@str = private addrspace(@A) constant [4 x i8] c"str\00"
; ERR-AT-SYMBOL: [[#@LINE-1]]:26: error: expected integer or string constant

;--- bad-number-in-quotes.ll
target datalayout = "A1-G2"
@str = private addrspace("10") constant [4 x i8] c"str\00"
; ERR-NUMBER-IN-QUOTES: [[#@LINE-1]]:26: error: invalid symbolic addrspace '10'