77 lines · c
1// RUN: %clang_cc1 -triple loongarch32 -O2 -emit-llvm %s -o - | FileCheck %s2// RUN: %clang_cc1 -triple loongarch64 -O2 -emit-llvm %s -o - | FileCheck %s3 4/// Test LoongArch specific inline assembly constraints.5 6float f;7double d;8void test_f(void) {9// CHECK-LABEL: define{{.*}} void @test_f()10// CHECK: [[FLT_ARG:%[a-zA-Z_0-9]+]] = load float, ptr @f11// 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 @d14// CHECK: call void asm sideeffect "", "f"(double [[FLT_ARG]])15 asm volatile ("" :: "f"(d));16}17 18void 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 24void 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 32void 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 38void test_q(void) {39// CHECK-LABEL: define{{.*}} void @test_q()40// CHECK: call void asm sideeffect "", "q"(i32 0)41 asm volatile ("" :: "q"(0));42}43 44void test_I(void) {45// CHECK-LABEL: define{{.*}} void @test_I()46// CHECK: call void asm sideeffect "", "I"(i32 2047)47 asm volatile ("" :: "I"(2047));48// CHECK: call void asm sideeffect "", "I"(i32 -2048)49 asm volatile ("" :: "I"(-2048));50}51 52void test_J(void) {53// CHECK-LABEL: define{{.*}} void @test_J()54// CHECK: call void asm sideeffect "", "J"(i32 0)55 asm volatile ("" :: "J"(0));56}57 58void test_K(void) {59// CHECK-LABEL: define{{.*}} void @test_K()60// CHECK: call void asm sideeffect "", "K"(i32 4095)61 asm volatile ("" :: "K"(4095));62// CHECK: call void asm sideeffect "", "K"(i32 0)63 asm volatile ("" :: "K"(0));64}65 66void test_ZB(int *p) {67// CHECK-LABEL: define{{.*}} void @test_ZB(ptr noundef %p)68// CHECK: call void asm sideeffect "", "*^ZB"(ptr elementtype(i32) %p)69 asm volatile ("" :: "ZB"(*p));70}71 72void test_ZC(int *p) {73// CHECK-LABEL: define{{.*}} void @test_ZC(ptr noundef %p)74// CHECK: call void asm sideeffect "", "*^ZC"(ptr elementtype(i32) %p)75 asm volatile ("" :: "ZC"(*p));76}77