|
| 1 | +// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir -mmlir --mlir-print-ir-before=cir-lowering-prepare %s -o %t.cir 2> %t-before.cir |
| 2 | +// RUN: FileCheck --input-file=%t-before.cir %s --check-prefix=CIR-BEFORE-LPP |
| 3 | +// RUN: FileCheck --input-file=%t.cir %s --check-prefix=CIR |
| 4 | +// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o %t-cir.ll |
| 5 | +// RUN: FileCheck --input-file=%t-cir.ll %s --check-prefix=LLVM |
| 6 | +// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-linux-gnu -emit-llvm %s -o %t.ll |
| 7 | +// RUN: FileCheck --input-file=%t.ll %s --check-prefix=OGCG |
| 8 | + |
| 9 | +float num; |
| 10 | +float _Complex a = {num, num}; |
| 11 | + |
| 12 | +// CIR-BEFORE-LPP: cir.global external @num = #cir.fp<0.000000e+00> : !cir.float |
| 13 | +// CIR-BEFORE-LPP: cir.global external @a = ctor : !cir.complex<!cir.float> { |
| 14 | +// CIR-BEFORE-LPP: %[[THIS:.*]] = cir.get_global @a : !cir.ptr<!cir.complex<!cir.float>> |
| 15 | +// CIR-BEFORE-LPP: %[[NUM:.*]] = cir.get_global @num : !cir.ptr<!cir.float> |
| 16 | +// CIR-BEFORE-LPP: %[[REAL:.*]] = cir.load{{.*}} %[[NUM]] : !cir.ptr<!cir.float>, !cir.float |
| 17 | +// CIR-BEFORE-LPP: %[[NUM:.*]] = cir.get_global @num : !cir.ptr<!cir.float> |
| 18 | +// CIR-BEFORE-LPP: %[[IMAG:.*]] = cir.load{{.*}} %[[NUM]] : !cir.ptr<!cir.float>, !cir.float |
| 19 | +// CIR-BEFORE-LPP: %[[COMPLEX_VAL:.*]] = cir.complex.create %[[REAL]], %[[IMAG]] : !cir.float -> !cir.complex<!cir.float> |
| 20 | +// CIR-BEFORE-LPP: cir.store{{.*}} %[[COMPLEX_VAL:.*]], %[[THIS]] : !cir.complex<!cir.float>, !cir.ptr<!cir.complex<!cir.float>> |
| 21 | +// CIR-BEFORE-LPP: } |
| 22 | + |
| 23 | +// CIR: cir.global external @num = #cir.fp<0.000000e+00> : !cir.float |
| 24 | +// CIR: cir.global external @a = #cir.zero : !cir.complex<!cir.float> |
| 25 | +// CIR: cir.func internal private @__cxx_global_var_init() |
| 26 | +// CIR: %[[A_ADDR:.*]] = cir.get_global @a : !cir.ptr<!cir.complex<!cir.float>> |
| 27 | +// CIR: %[[NUM:.*]] = cir.get_global @num : !cir.ptr<!cir.float> |
| 28 | +// CIR: %[[REAL:.*]] = cir.load{{.*}} %[[NUM]] : !cir.ptr<!cir.float>, !cir.float |
| 29 | +// CIR: %[[NUM:.*]] = cir.get_global @num : !cir.ptr<!cir.float> |
| 30 | +// CIR: %[[IMAG:.*]] = cir.load{{.*}} %[[NUM]] : !cir.ptr<!cir.float>, !cir.float |
| 31 | +// CIR: %[[COMPLEX_VAL:.*]] = cir.complex.create %[[REAL]], %[[IMAG]] : !cir.float -> !cir.complex<!cir.float> |
| 32 | +// CIR: cir.store{{.*}} %[[COMPLEX_VAL]], %[[A_ADDR]] : !cir.complex<!cir.float>, !cir.ptr<!cir.complex<!cir.float>> |
| 33 | + |
| 34 | +// LLVM: define internal void @__cxx_global_var_init() |
| 35 | +// LLVM: %[[REAL:.*]] = load float, ptr @num, align 4 |
| 36 | +// LLVM: %[[IMAG:.*]] = load float, ptr @num, align 4 |
| 37 | +// LLVM: %[[TMP_COMPLEX_VAL:.*]] = insertvalue { float, float } {{.*}}, float %[[REAL]], 0 |
| 38 | +// LLVM: %[[COMPLEX_VAL:.*]] = insertvalue { float, float } %[[TMP_COMPLEX_VAL]], float %[[IMAG]], 1 |
| 39 | +// LLVM: store { float, float } %[[COMPLEX_VAL]], ptr @a, align 4 |
| 40 | + |
| 41 | +// OGCG: define internal void @__cxx_global_var_init() {{.*}} section ".text.startup" |
| 42 | +// OGCG: %[[REAL:.*]] = load float, ptr @num, align 4 |
| 43 | +// OGCG: %[[IMAG:.*]] = load float, ptr @num, align 4 |
| 44 | +// OGCG: store float %[[REAL]], ptr @a, align 4 |
| 45 | +// OGCG: store float %[[IMAG]], ptr getelementptr inbounds nuw ({ float, float }, ptr @a, i32 0, i32 1), align 4 |
0 commit comments