brintos

brintos / llvm-project-archived public Read only

0
0
Text · 7.2 KiB · 811af47 Raw
122 lines · cpp
1// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-cir %s -o %t.cir2// RUN: FileCheck --input-file=%t.cir %s -check-prefix=CIR3// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-llvm %s -o %t-cir.ll4// RUN: FileCheck --input-file=%t-cir.ll %s -check-prefix=LLVM5// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Wno-unused-value -emit-llvm %s -o %t.ll6// RUN: FileCheck --input-file=%t.ll %s -check-prefix=OGCG7 8void foo() {9 int _Complex a;10 int _Complex b;11 int _Complex r = __builtin_choose_expr(true, a, b);12}13 14// CIR: %[[COMPLEX_A:.*]] = cir.alloca !cir.complex<!s32i>, !cir.ptr<!cir.complex<!s32i>>, ["a"]15// CIR: %[[COMPLEX_R:.*]] = cir.alloca !cir.complex<!s32i>, !cir.ptr<!cir.complex<!s32i>>, ["r", init]16// CIR: %[[TMP_A:.*]] = cir.load{{.*}} %[[COMPLEX_A]] : !cir.ptr<!cir.complex<!s32i>>, !cir.complex<!s32i>17// CIR: cir.store{{.*}} %[[TMP_A]], %[[COMPLEX_R]] : !cir.complex<!s32i>, !cir.ptr<!cir.complex<!s32i>>18 19// LLVM: %[[COMPLEX_A:.*]] = alloca { i32, i32 }, i64 1, align 420// LLVM: %[[COMPLEX_B:.*]] = alloca { i32, i32 }, i64 1, align 421// LLVM: %[[COMPLEX_R:.*]] = alloca { i32, i32 }, i64 1, align 422// LLVM: %[[TMP_A:.*]] = load { i32, i32 }, ptr %[[COMPLEX_A]], align 423// LLVM: store { i32, i32 } %[[TMP_A]], ptr %[[COMPLEX_R]], align 424 25// OGCG: %[[COMPLEX_A:.*]] = alloca { i32, i32 }, align 426// OGCG: %[[COMPLEX_B:.*]] = alloca { i32, i32 }, align 427// OGCG: %[[COMPLEX_R:.*]] = alloca { i32, i32 }, align 428// OGCG: %[[A_REAL_PTR:.*]] = getelementptr inbounds nuw { i32, i32 }, ptr %[[COMPLEX_A]], i32 0, i32 029// OGCG: %[[A_REAL:.*]] = load i32, ptr %[[A_REAL_PTR]], align 430// OGCG: %[[A_IMAG_PTR:.*]] = getelementptr inbounds nuw { i32, i32 }, ptr %[[COMPLEX_A]], i32 0, i32 131// OGCG: %[[A_IMAG:.*]] = load i32, ptr %[[A_IMAG_PTR]], align 432// OGCG: %[[R_REAL_PTR:.*]] = getelementptr inbounds nuw { i32, i32 }, ptr %[[COMPLEX_R]], i32 0, i32 033// OGCG: %[[R_IMAG_PTR:.*]] = getelementptr inbounds nuw { i32, i32 }, ptr %[[COMPLEX_R]], i32 0, i32 134// OGCG: store i32 %[[A_REAL]], ptr %[[R_REAL_PTR]], align 435// OGCG: store i32 %[[A_IMAG]], ptr %[[R_IMAG_PTR]], align 436 37void foo2() {38  double _Complex a;39  double real = __builtin_creal(a);40}41 42// CIR: %[[COMPLEX:.*]] = cir.alloca !cir.complex<!cir.double>, !cir.ptr<!cir.complex<!cir.double>>, ["a"]43// CIR: %[[INIT:.*]] = cir.alloca !cir.double, !cir.ptr<!cir.double>, ["real", init]44// CIR: %[[TMP:.*]] = cir.load{{.*}} %[[COMPLEX]] : !cir.ptr<!cir.complex<!cir.double>>, !cir.complex<!cir.double>45// CIR: %[[REAL:.*]] = cir.complex.real %[[TMP]] : !cir.complex<!cir.double> -> !cir.double46// CIR: cir.store{{.*}} %[[REAL]], %[[INIT]] : !cir.double, !cir.ptr<!cir.double>47 48// LLVM: %[[COMPLEX:.*]] = alloca { double, double }, i64 1, align 849// LLVM: %[[INIT:.*]] = alloca double, i64 1, align 850// LLVM: %[[TMP:.*]] = load { double, double }, ptr %[[COMPLEX]], align 851// LLVM: %[[REAL:.*]] = extractvalue { double, double } %[[TMP]], 052// LLVM: store double %[[REAL]], ptr %[[INIT]], align 853 54// OGCG: %[[COMPLEX:.*]] = alloca { double, double }, align 855// OGCG: %[[INIT:.*]] = alloca double, align 856// OGCG: %[[A_REAL_PTR:.*]] = getelementptr inbounds nuw { double, double }, ptr %[[COMPLEX]], i32 0, i32 057// OGCG: %[[A_REAL:.*]] = load double, ptr %[[A_REAL_PTR]], align 858// OGCG: %[[A_IMAG_PTR:.*]] = getelementptr inbounds nuw { double, double }, ptr %[[COMPLEX]], i32 0, i32 159// OGCG: %[[A_IMAG:.*]] = load double, ptr %[[A_IMAG_PTR]], align 860// OGCG: store double %[[A_REAL]], ptr %[[INIT]], align 861 62void foo3() {63  double _Complex a;64  double imag = __builtin_cimag(a);65}66 67// CIR: %[[COMPLEX:.*]] = cir.alloca !cir.complex<!cir.double>, !cir.ptr<!cir.complex<!cir.double>>, ["a"]68// CIR: %[[INIT:.*]] = cir.alloca !cir.double, !cir.ptr<!cir.double>, ["imag", init]69// CIR: %[[TMP:.*]] = cir.load{{.*}} %[[COMPLEX]] : !cir.ptr<!cir.complex<!cir.double>>, !cir.complex<!cir.double>70// CIR: %[[IMAG:.*]] = cir.complex.imag %[[TMP]] : !cir.complex<!cir.double> -> !cir.double71// CIR: cir.store{{.*}} %[[IMAG]], %[[INIT]] : !cir.double, !cir.ptr<!cir.double>72 73// LLVM: %[[COMPLEX:.*]] = alloca { double, double }, i64 1, align 874// LLVM: %[[INIT:.*]] = alloca double, i64 1, align 875// LLVM: %[[TMP:.*]] = load { double, double }, ptr %[[COMPLEX]], align 876// LLVM: %[[IMAG:.*]] = extractvalue { double, double } %[[TMP]], 177// LLVM: store double %[[IMAG]], ptr %[[INIT]], align 878 79// OGCG: %[[COMPLEX:.*]] = alloca { double, double }, align 880// OGCG: %[[INIT:.*]] = alloca double, align 881// OGCG: %[[A_REAL_PTR:.*]] = getelementptr inbounds nuw { double, double }, ptr %[[COMPLEX]], i32 0, i32 082// OGCG: %[[A_REAL:.*]] = load double, ptr %[[A_REAL_PTR]], align 883// OGCG: %[[A_IMAG_PTR:.*]] = getelementptr inbounds nuw { double, double }, ptr %[[COMPLEX]], i32 0, i32 184// OGCG: %[[A_IMAG:.*]] = load double, ptr %[[A_IMAG_PTR]], align 885// OGCG: store double %[[A_IMAG]], ptr %[[INIT]], align 886 87void foo4() {88  float _Complex a;89  float _Complex b = __builtin_conjf(a);90}91 92// CIR: %[[COMPLEX:.*]] = cir.alloca !cir.complex<!cir.float>, !cir.ptr<!cir.complex<!cir.float>>, ["a"]93// CIR: %[[RESULT:.*]] = cir.alloca !cir.complex<!cir.float>, !cir.ptr<!cir.complex<!cir.float>>, ["b", init]94// CIR: %[[TMP:.*]] = cir.load{{.*}} %[[COMPLEX]] : !cir.ptr<!cir.complex<!cir.float>>, !cir.complex<!cir.float>95// CIR: %[[REAL:.*]] = cir.complex.real %[[TMP]] : !cir.complex<!cir.float> -> !cir.float96// CIR: %[[IMAG:.*]] = cir.complex.imag %[[TMP]] : !cir.complex<!cir.float> -> !cir.float97// CIR: %[[IMAG_MINUS:.*]] = cir.unary(minus, %[[IMAG]]) : !cir.float, !cir.float98// CIR: %[[RESULT_VAL:.*]] = cir.complex.create %[[REAL]], %[[IMAG_MINUS]] : !cir.float -> !cir.complex<!cir.float>99// CIR: cir.store{{.*}} %[[RESULT_VAL]], %[[RESULT]] : !cir.complex<!cir.float>, !cir.ptr<!cir.complex<!cir.float>>100 101// LLVM: %[[COMPLEX:.*]] = alloca { float, float }, i64 1, align 4102// LLVM: %[[RESULT:.*]] = alloca { float, float }, i64 1, align 4103// LLVM: %[[TMP:.*]] = load { float, float }, ptr %[[COMPLEX]], align 4104// LLVM: %[[REAL:.*]] = extractvalue { float, float } %[[TMP]], 0105// LLVM: %[[IMAG:.*]] = extractvalue { float, float } %[[TMP]], 1106// LLVM: %[[IMAG_MINUS:.*]] = fneg float %[[IMAG]]107// LLVM: %[[RESULT_TMP:.*]] = insertvalue { float, float } {{.*}}, float %[[REAL]], 0108// LLVM: %[[RESULT_VAL:.*]] = insertvalue { float, float } %[[RESULT_TMP]], float %[[IMAG_MINUS]], 1109// LLVM: store { float, float } %[[RESULT_VAL]], ptr %[[RESULT]], align 4110 111// OGCG: %[[COMPLEX:.*]] = alloca { float, float }, align 4112// OGCG: %[[RESULT:.*]] = alloca { float, float }, align 4113// OGCG: %[[A_REAL_PTR:.*]] = getelementptr inbounds nuw { float, float }, ptr %[[COMPLEX]], i32 0, i32 0114// OGCG: %[[A_REAL:.*]] = load float, ptr %[[A_REAL_PTR]], align 4115// OGCG: %[[A_IMAG_PTR:.*]] = getelementptr inbounds nuw { float, float }, ptr %[[COMPLEX]], i32 0, i32 1116// OGCG: %[[A_IMAG:.*]] = load float, ptr %[[A_IMAG_PTR]], align 4117// OGCG: %[[A_IMAG_MINUS:.*]] = fneg float  %[[A_IMAG]]118// OGCG: %[[RESULT_REAL_PTR:.*]] = getelementptr inbounds nuw { float, float }, ptr %[[RESULT]], i32 0, i32 0119// OGCG: %[[RESULT_IMAG_PTR:.*]] = getelementptr inbounds nuw { float, float }, ptr %[[RESULT]], i32 0, i32 1120// OGCG: store float %[[A_REAL]], ptr %[[RESULT_REAL_PTR]], align 4121// OGCG: store float %[[A_IMAG_MINUS]], ptr %[[RESULT_IMAG_PTR]], align 4122