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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
| ; Test 64-bit GPR accesses to a PC-relative location.
;
; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
@gsrc16 = global i16 1
@gsrc32 = global i32 1
@gsrc64 = global i64 1
@gdst16 = global i16 2
@gdst32 = global i32 2
@gdst64 = global i64 2
@gsrc16u = global i16 1, align 1, section "foo"
@gsrc32u = global i32 1, align 2, section "foo"
@gsrc64u = global i64 1, align 4, section "foo"
@gdst16u = global i16 2, align 1, section "foo"
@gdst32u = global i32 2, align 2, section "foo"
@gdst64u = global i64 2, align 4, section "foo"
; Check sign-extending loads from i16.
define i64 @f1() {
; CHECK-LABEL: f1:
; CHECK: lghrl %r2, gsrc16
; CHECK: br %r14
%val = load i16, i16 *@gsrc16
%ext = sext i16 %val to i64
ret i64 %ext
}
; Check zero-extending loads from i16.
define i64 @f2() {
; CHECK-LABEL: f2:
; CHECK: llghrl %r2, gsrc16
; CHECK: br %r14
%val = load i16, i16 *@gsrc16
%ext = zext i16 %val to i64
ret i64 %ext
}
; Check sign-extending loads from i32.
define i64 @f3() {
; CHECK-LABEL: f3:
; CHECK: lgfrl %r2, gsrc32
; CHECK: br %r14
%val = load i32, i32 *@gsrc32
%ext = sext i32 %val to i64
ret i64 %ext
}
; Check zero-extending loads from i32.
define i64 @f4() {
; CHECK-LABEL: f4:
; CHECK: llgfrl %r2, gsrc32
; CHECK: br %r14
%val = load i32, i32 *@gsrc32
%ext = zext i32 %val to i64
ret i64 %ext
}
; Check truncating 16-bit stores.
define void @f5(i64 %val) {
; CHECK-LABEL: f5:
; CHECK: sthrl %r2, gdst16
; CHECK: br %r14
%half = trunc i64 %val to i16
store i16 %half, i16 *@gdst16
ret void
}
; Check truncating 32-bit stores.
define void @f6(i64 %val) {
; CHECK-LABEL: f6:
; CHECK: strl %r2, gdst32
; CHECK: br %r14
%word = trunc i64 %val to i32
store i32 %word, i32 *@gdst32
ret void
}
; Check plain loads and stores.
define void @f7() {
; CHECK-LABEL: f7:
; CHECK: lgrl %r0, gsrc64
; CHECK: stgrl %r0, gdst64
; CHECK: br %r14
%val = load i64, i64 *@gsrc64
store i64 %val, i64 *@gdst64
ret void
}
; Repeat f1 with an unaligned variable.
define i64 @f8() {
; CHECK-LABEL: f8:
; CHECK: lgrl [[REG:%r[0-5]]], gsrc16u@GOT
; CHECK: lgh %r2, 0([[REG]])
; CHECK: br %r14
%val = load i16, i16 *@gsrc16u, align 1
%ext = sext i16 %val to i64
ret i64 %ext
}
; Repeat f2 with an unaligned variable.
define i64 @f9() {
; CHECK-LABEL: f9:
; CHECK: lgrl [[REG:%r[0-5]]], gsrc16u@GOT
; CHECK: llgh %r2, 0([[REG]])
; CHECK: br %r14
%val = load i16, i16 *@gsrc16u, align 1
%ext = zext i16 %val to i64
ret i64 %ext
}
; Repeat f3 with an unaligned variable.
define i64 @f10() {
; CHECK-LABEL: f10:
; CHECK: larl [[REG:%r[0-5]]], gsrc32u
; CHECK: lgf %r2, 0([[REG]])
; CHECK: br %r14
%val = load i32, i32 *@gsrc32u, align 2
%ext = sext i32 %val to i64
ret i64 %ext
}
; Repeat f4 with an unaligned variable.
define i64 @f11() {
; CHECK-LABEL: f11:
; CHECK: larl [[REG:%r[0-5]]], gsrc32u
; CHECK: llgf %r2, 0([[REG]])
; CHECK: br %r14
%val = load i32, i32 *@gsrc32u, align 2
%ext = zext i32 %val to i64
ret i64 %ext
}
; Repeat f5 with an unaligned variable.
define void @f12(i64 %val) {
; CHECK-LABEL: f12:
; CHECK: lgrl [[REG:%r[0-5]]], gdst16u@GOT
; CHECK: sth %r2, 0([[REG]])
; CHECK: br %r14
%half = trunc i64 %val to i16
store i16 %half, i16 *@gdst16u, align 1
ret void
}
; Repeat f6 with an unaligned variable.
define void @f13(i64 %val) {
; CHECK-LABEL: f13:
; CHECK: larl [[REG:%r[0-5]]], gdst32u
; CHECK: st %r2, 0([[REG]])
; CHECK: br %r14
%word = trunc i64 %val to i32
store i32 %word, i32 *@gdst32u, align 2
ret void
}
; Repeat f7 with unaligned variables.
define void @f14() {
; CHECK-LABEL: f14:
; CHECK: larl [[REG:%r[0-5]]], gsrc64u
; CHECK: lg [[VAL:%r[0-5]]], 0([[REG]])
; CHECK: larl [[REG:%r[0-5]]], gdst64u
; CHECK: stg [[VAL]], 0([[REG]])
; CHECK: br %r14
%val = load i64, i64 *@gsrc64u, align 4
store i64 %val, i64 *@gdst64u, align 4
ret void
}
|