1f4a2713aSLionel Sambuc // RUN: %clang_cc1 -triple s390x-linux-gnu -O2 -emit-llvm -o - %s | FileCheck %s
2f4a2713aSLionel Sambuc
3f4a2713aSLionel Sambuc unsigned int gi;
4f4a2713aSLionel Sambuc unsigned long gl;
5f4a2713aSLionel Sambuc
test_store_m(unsigned int i)6f4a2713aSLionel Sambuc void test_store_m(unsigned int i) {
7f4a2713aSLionel Sambuc asm("st %1, %0" : "=m" (gi) : "r" (i));
8f4a2713aSLionel Sambuc // CHECK-LABEL: define void @test_store_m(i32 zeroext %i)
9f4a2713aSLionel Sambuc // CHECK: call void asm "st $1, $0", "=*m,r"(i32* @gi, i32 %i)
10f4a2713aSLionel Sambuc }
11f4a2713aSLionel Sambuc
test_store_Q(unsigned int i)12f4a2713aSLionel Sambuc void test_store_Q(unsigned int i) {
13f4a2713aSLionel Sambuc asm("st %1, %0" : "=Q" (gi) : "r" (i));
14f4a2713aSLionel Sambuc // CHECK-LABEL: define void @test_store_Q(i32 zeroext %i)
15f4a2713aSLionel Sambuc // CHECK: call void asm "st $1, $0", "=*Q,r"(i32* @gi, i32 %i)
16f4a2713aSLionel Sambuc }
17f4a2713aSLionel Sambuc
test_store_R(unsigned int i)18f4a2713aSLionel Sambuc void test_store_R(unsigned int i) {
19f4a2713aSLionel Sambuc asm("st %1, %0" : "=R" (gi) : "r" (i));
20f4a2713aSLionel Sambuc // CHECK-LABEL: define void @test_store_R(i32 zeroext %i)
21f4a2713aSLionel Sambuc // CHECK: call void asm "st $1, $0", "=*R,r"(i32* @gi, i32 %i)
22f4a2713aSLionel Sambuc }
23f4a2713aSLionel Sambuc
test_store_S(unsigned int i)24f4a2713aSLionel Sambuc void test_store_S(unsigned int i) {
25f4a2713aSLionel Sambuc asm("st %1, %0" : "=S" (gi) : "r" (i));
26f4a2713aSLionel Sambuc // CHECK-LABEL: define void @test_store_S(i32 zeroext %i)
27f4a2713aSLionel Sambuc // CHECK: call void asm "st $1, $0", "=*S,r"(i32* @gi, i32 %i)
28f4a2713aSLionel Sambuc }
29f4a2713aSLionel Sambuc
test_store_T(unsigned int i)30f4a2713aSLionel Sambuc void test_store_T(unsigned int i) {
31f4a2713aSLionel Sambuc asm("st %1, %0" : "=T" (gi) : "r" (i));
32f4a2713aSLionel Sambuc // CHECK-LABEL: define void @test_store_T(i32 zeroext %i)
33f4a2713aSLionel Sambuc // CHECK: call void asm "st $1, $0", "=*T,r"(i32* @gi, i32 %i)
34f4a2713aSLionel Sambuc }
35f4a2713aSLionel Sambuc
test_load_m()36f4a2713aSLionel Sambuc int test_load_m() {
37f4a2713aSLionel Sambuc unsigned int i;
38f4a2713aSLionel Sambuc asm("l %0, %1" : "=r" (i) : "m" (gi));
39f4a2713aSLionel Sambuc return i;
40f4a2713aSLionel Sambuc // CHECK-LABEL: define signext i32 @test_load_m()
41f4a2713aSLionel Sambuc // CHECK: call i32 asm "l $0, $1", "=r,*m"(i32* @gi)
42f4a2713aSLionel Sambuc }
43f4a2713aSLionel Sambuc
test_load_Q()44f4a2713aSLionel Sambuc int test_load_Q() {
45f4a2713aSLionel Sambuc unsigned int i;
46f4a2713aSLionel Sambuc asm("l %0, %1" : "=r" (i) : "Q" (gi));
47f4a2713aSLionel Sambuc return i;
48f4a2713aSLionel Sambuc // CHECK-LABEL: define signext i32 @test_load_Q()
49f4a2713aSLionel Sambuc // CHECK: call i32 asm "l $0, $1", "=r,*Q"(i32* @gi)
50f4a2713aSLionel Sambuc }
51f4a2713aSLionel Sambuc
test_load_R()52f4a2713aSLionel Sambuc int test_load_R() {
53f4a2713aSLionel Sambuc unsigned int i;
54f4a2713aSLionel Sambuc asm("l %0, %1" : "=r" (i) : "R" (gi));
55f4a2713aSLionel Sambuc return i;
56f4a2713aSLionel Sambuc // CHECK-LABEL: define signext i32 @test_load_R()
57f4a2713aSLionel Sambuc // CHECK: call i32 asm "l $0, $1", "=r,*R"(i32* @gi)
58f4a2713aSLionel Sambuc }
59f4a2713aSLionel Sambuc
test_load_S()60f4a2713aSLionel Sambuc int test_load_S() {
61f4a2713aSLionel Sambuc unsigned int i;
62f4a2713aSLionel Sambuc asm("l %0, %1" : "=r" (i) : "S" (gi));
63f4a2713aSLionel Sambuc return i;
64f4a2713aSLionel Sambuc // CHECK-LABEL: define signext i32 @test_load_S()
65f4a2713aSLionel Sambuc // CHECK: call i32 asm "l $0, $1", "=r,*S"(i32* @gi)
66f4a2713aSLionel Sambuc }
67f4a2713aSLionel Sambuc
test_load_T()68f4a2713aSLionel Sambuc int test_load_T() {
69f4a2713aSLionel Sambuc unsigned int i;
70f4a2713aSLionel Sambuc asm("l %0, %1" : "=r" (i) : "T" (gi));
71f4a2713aSLionel Sambuc return i;
72f4a2713aSLionel Sambuc // CHECK-LABEL: define signext i32 @test_load_T()
73f4a2713aSLionel Sambuc // CHECK: call i32 asm "l $0, $1", "=r,*T"(i32* @gi)
74f4a2713aSLionel Sambuc }
75f4a2713aSLionel Sambuc
test_mI(unsigned char * c)76f4a2713aSLionel Sambuc void test_mI(unsigned char *c) {
77f4a2713aSLionel Sambuc asm volatile("cli %0, %1" :: "Q" (*c), "I" (100));
78f4a2713aSLionel Sambuc // CHECK-LABEL: define void @test_mI(i8* %c)
79f4a2713aSLionel Sambuc // CHECK: call void asm sideeffect "cli $0, $1", "*Q,I"(i8* %c, i32 100)
80f4a2713aSLionel Sambuc }
81f4a2713aSLionel Sambuc
test_dJa(unsigned int i,unsigned int j)82f4a2713aSLionel Sambuc unsigned int test_dJa(unsigned int i, unsigned int j) {
83f4a2713aSLionel Sambuc asm("sll %0, %2(%3)" : "=d" (i) : "0" (i), "J" (1000), "a" (j));
84f4a2713aSLionel Sambuc return i;
85f4a2713aSLionel Sambuc // CHECK-LABEL: define zeroext i32 @test_dJa(i32 zeroext %i, i32 zeroext %j)
86f4a2713aSLionel Sambuc // CHECK: call i32 asm "sll $0, $2($3)", "=d,0,J,a"(i32 %i, i32 1000, i32 %j)
87f4a2713aSLionel Sambuc }
88f4a2713aSLionel Sambuc
test_rK(unsigned long i)89f4a2713aSLionel Sambuc unsigned long test_rK(unsigned long i) {
90f4a2713aSLionel Sambuc asm("aghi %0, %2" : "=r" (i) : "0" (i), "K" (-30000));
91f4a2713aSLionel Sambuc return i;
92f4a2713aSLionel Sambuc // CHECK-LABEL: define i64 @test_rK(i64 %i)
93f4a2713aSLionel Sambuc // CHECK: call i64 asm "aghi $0, $2", "=r,0,K"(i64 %i, i32 -30000)
94f4a2713aSLionel Sambuc }
95f4a2713aSLionel Sambuc
test_rL(unsigned long i)96f4a2713aSLionel Sambuc unsigned long test_rL(unsigned long i) {
97f4a2713aSLionel Sambuc asm("sllg %0, %1, %2" : "=r" (i) : "r" (i), "L" (500000));
98f4a2713aSLionel Sambuc return i;
99f4a2713aSLionel Sambuc // CHECK-LABEL: define i64 @test_rL(i64 %i)
100f4a2713aSLionel Sambuc // CHECK: call i64 asm "sllg $0, $1, $2", "=r,r,L"(i64 %i, i32 500000)
101f4a2713aSLionel Sambuc }
102f4a2713aSLionel Sambuc
test_M()103f4a2713aSLionel Sambuc void test_M() {
104f4a2713aSLionel Sambuc asm volatile("#FOO %0" :: "M"(0x7fffffff));
105f4a2713aSLionel Sambuc // CHECK-LABEL: define void @test_M()
106f4a2713aSLionel Sambuc // CHECK: call void asm sideeffect "#FOO $0", "M"(i32 2147483647)
107f4a2713aSLionel Sambuc }
108f4a2713aSLionel Sambuc
test_f32(float f,float g)109f4a2713aSLionel Sambuc float test_f32(float f, float g) {
110f4a2713aSLionel Sambuc asm("aebr %0, %2" : "=f" (f) : "0" (f), "f" (g));
111f4a2713aSLionel Sambuc return f;
112f4a2713aSLionel Sambuc // CHECK-LABEL: define float @test_f32(float %f, float %g)
113f4a2713aSLionel Sambuc // CHECK: call float asm "aebr $0, $2", "=f,0,f"(float %f, float %g)
114f4a2713aSLionel Sambuc }
115f4a2713aSLionel Sambuc
test_f64(double f,double g)116f4a2713aSLionel Sambuc double test_f64(double f, double g) {
117f4a2713aSLionel Sambuc asm("adbr %0, %2" : "=f" (f) : "0" (f), "f" (g));
118f4a2713aSLionel Sambuc return f;
119f4a2713aSLionel Sambuc // CHECK-LABEL: define double @test_f64(double %f, double %g)
120f4a2713aSLionel Sambuc // CHECK: call double asm "adbr $0, $2", "=f,0,f"(double %f, double %g)
121f4a2713aSLionel Sambuc }
122f4a2713aSLionel Sambuc
test_f128(long double f,long double g)123f4a2713aSLionel Sambuc long double test_f128(long double f, long double g) {
124f4a2713aSLionel Sambuc asm("axbr %0, %2" : "=f" (f) : "0" (f), "f" (g));
125f4a2713aSLionel Sambuc return f;
126*0a6a1f1dSLionel Sambuc // CHECK: define void @test_f128(fp128* noalias nocapture sret [[DEST:%.*]], fp128* nocapture readonly, fp128* nocapture readonly)
127f4a2713aSLionel Sambuc // CHECK: %f = load fp128* %0
128f4a2713aSLionel Sambuc // CHECK: %g = load fp128* %1
129f4a2713aSLionel Sambuc // CHECK: [[RESULT:%.*]] = tail call fp128 asm "axbr $0, $2", "=f,0,f"(fp128 %f, fp128 %g)
130f4a2713aSLionel Sambuc // CHECK: store fp128 [[RESULT]], fp128* [[DEST]]
131f4a2713aSLionel Sambuc }
132