1 // RUN: %clang_cc1 -triple loongarch32 -O2 -emit-llvm %s -o - | FileCheck %s 2 // RUN: %clang_cc1 -triple loongarch64 -O2 -emit-llvm %s -o - | FileCheck %s 3 4 /// Test LoongArch specific inline assembly constraints. 5 6 float f; 7 double d; 8 void test_f(void) { 9 // CHECK-LABEL: define{{.*}} void @test_f() 10 // CHECK: [[FLT_ARG:%[a-zA-Z_0-9]+]] = load float, ptr @f 11 // CHECK: call void asm sideeffect "", "f"(float [[FLT_ARG]]) 12 asm volatile ("" :: "f"(f)); 13 // CHECK: [[FLT_ARG:%[a-zA-Z_0-9]+]] = load double, ptr @d 14 // CHECK: call void asm sideeffect "", "f"(double [[FLT_ARG]]) 15 asm volatile ("" :: "f"(d)); 16 } 17 18 void test_k(int *p, int idx) { 19 // CHECK-LABEL: define{{.*}} void @test_k(ptr noundef %p, i32 noundef{{.*}} %idx) 20 // CHECK: call void asm sideeffect "", "*k"(ptr elementtype(i32) %{{.*}}) 21 asm volatile("" :: "k"(*(p+idx))); 22 } 23 24 void test_l(void) { 25 // CHECK-LABEL: define{{.*}} void @test_l() 26 // CHECK: call void asm sideeffect "", "l"(i32 32767) 27 asm volatile ("" :: "l"(32767)); 28 // CHECK: call void asm sideeffect "", "l"(i32 -32768) 29 asm volatile ("" :: "l"(-32768)); 30 } 31 32 void test_m(int *p) { 33 // CHECK-LABEL: define{{.*}} void @test_m(ptr noundef %p) 34 // CHECK: call void asm sideeffect "", "*m"(ptr nonnull elementtype(i32) %{{.*}}) 35 asm volatile("" :: "m"(*(p+4))); 36 } 37 38 void test_I(void) { 39 // CHECK-LABEL: define{{.*}} void @test_I() 40 // CHECK: call void asm sideeffect "", "I"(i32 2047) 41 asm volatile ("" :: "I"(2047)); 42 // CHECK: call void asm sideeffect "", "I"(i32 -2048) 43 asm volatile ("" :: "I"(-2048)); 44 } 45 46 void test_K(void) { 47 // CHECK-LABEL: define{{.*}} void @test_K() 48 // CHECK: call void asm sideeffect "", "K"(i32 4095) 49 asm volatile ("" :: "K"(4095)); 50 // CHECK: call void asm sideeffect "", "K"(i32 0) 51 asm volatile ("" :: "K"(0)); 52 } 53 54 void test_ZB(int *p) { 55 // CHECK-LABEL: define{{.*}} void @test_ZB(ptr noundef %p) 56 // CHECK: call void asm sideeffect "", "*^ZB"(ptr elementtype(i32) %p) 57 asm volatile ("" :: "ZB"(*p)); 58 } 59 60 void test_ZC(int *p) { 61 // CHECK-LABEL: define{{.*}} void @test_ZC(ptr noundef %p) 62 // CHECK: call void asm sideeffect "", "*^ZC"(ptr elementtype(i32) %p) 63 asm volatile ("" :: "ZC"(*p)); 64 } 65