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