Revert "[llvm] Improve llvm.objectsize computation by computing GEP, alloca and mallo...
[llvm-project.git] / clang / test / CodeGen / LoongArch / inline-asm-constraints.c
blobb19494284bd994f386fbc379f54348d719478a5b
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
4 /// Test LoongArch specific inline assembly constraints.
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));
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)));
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));
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)));
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));
46 void test_J(void) {
47 // CHECK-LABEL: define{{.*}} void @test_J()
48 // CHECK: call void asm sideeffect "", "J"(i32 0)
49 asm volatile ("" :: "J"(0));
52 void test_K(void) {
53 // CHECK-LABEL: define{{.*}} void @test_K()
54 // CHECK: call void asm sideeffect "", "K"(i32 4095)
55 asm volatile ("" :: "K"(4095));
56 // CHECK: call void asm sideeffect "", "K"(i32 0)
57 asm volatile ("" :: "K"(0));
60 void test_ZB(int *p) {
61 // CHECK-LABEL: define{{.*}} void @test_ZB(ptr noundef %p)
62 // CHECK: call void asm sideeffect "", "*^ZB"(ptr elementtype(i32) %p)
63 asm volatile ("" :: "ZB"(*p));
66 void test_ZC(int *p) {
67 // CHECK-LABEL: define{{.*}} void @test_ZC(ptr noundef %p)
68 // CHECK: call void asm sideeffect "", "*^ZC"(ptr elementtype(i32) %p)
69 asm volatile ("" :: "ZC"(*p));