|
| 1 | +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir |
| 2 | +// RUN: FileCheck --input-file=%t.cir %s |
| 3 | +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm -fno-clangir-call-conv-lowering %s -o %t.ll |
| 4 | +// RUN: FileCheck --input-file=%t.ll --check-prefix=LLVM %s |
| 5 | + |
| 6 | +// TODO: remove the -fno-clangir-call-conv-lowering flag when ABI lowering for |
| 7 | +// int128 is supported. |
| 8 | + |
| 9 | +// CHECK-LABEL: @_Z5test1n |
| 10 | +// LLVM-LABEL: @_Z5test1n |
| 11 | +__int128 test1(__int128 x) { |
| 12 | + return x; |
| 13 | + // CHECK: cir.return %{{.+}} : !s128i |
| 14 | + // LLVM: ret i128 %{{.+}} |
| 15 | +} |
| 16 | + |
| 17 | +// CHECK-LABEL: @_Z5test2o |
| 18 | +// LLVM-LABEL: @_Z5test2o |
| 19 | +unsigned __int128 test2(unsigned __int128 x) { |
| 20 | + return x; |
| 21 | + // CHECK: cir.return %{{.+}} : !u128i |
| 22 | + // LLVM: ret i128 %{{.+}} |
| 23 | +} |
| 24 | + |
| 25 | +// CHECK-LABEL: @_Z11unary_arithn |
| 26 | +// LLVM-LABEL: @_Z11unary_arithn |
| 27 | +__int128 unary_arith(__int128 x) { |
| 28 | + return ++x; |
| 29 | + // CHECK: %{{.+}} = cir.unary(inc, %{{.+}}) : !s128i, !s128i |
| 30 | + // LLVM: %{{.+}} = add i128 %{{.+}}, 1 |
| 31 | +} |
| 32 | + |
| 33 | +// CHECK-LABEL: @_Z12binary_arithnn |
| 34 | +// LLVM-LABEL: @_Z12binary_arithnn |
| 35 | +__int128 binary_arith(__int128 x, __int128 y) { |
| 36 | + return x + y; |
| 37 | + // CHECK: %{{.+}} = cir.binop(add, %{{.+}}, %{{.+}}) nsw : !s128i |
| 38 | + // LLVM: %{{.+}} = add nsw i128 %{{.+}}, %{{.+}} |
| 39 | +} |
| 40 | + |
| 41 | +volatile int int_var; |
| 42 | +volatile double double_var; |
| 43 | + |
| 44 | +// CHECK-LABEL: @_Z19integral_conversionn |
| 45 | +// LLVM-LABEL: @_Z19integral_conversionn |
| 46 | +__int128 integral_conversion(__int128 x) { |
| 47 | + int_var = x; |
| 48 | + // CHECK: %[[#VAL:]] = cir.cast(integral, %{{.+}} : !s128i), !s32i |
| 49 | + // LLVM: %{{.+}} = trunc i128 %{{.+}} to i32 |
| 50 | + |
| 51 | + return int_var; |
| 52 | + // CHECK: %{{.+}} = cir.cast(integral, %{{.+}} : !s32i), !s128i |
| 53 | + // LLVM: %{{.+}} = sext i32 %{{.+}} to i128 |
| 54 | +} |
| 55 | + |
| 56 | +// CHECK-LABEL: @_Z16float_conversionn |
| 57 | +// LLVM-LABEL: @_Z16float_conversionn |
| 58 | +__int128 float_conversion(__int128 x) { |
| 59 | + double_var = x; |
| 60 | + // CHECK: %[[#VAL:]] = cir.cast(int_to_float, %{{.+}} : !s128i), !cir.double |
| 61 | + // LLVM: %{{.+}} = sitofp i128 %{{.+}} to double |
| 62 | + |
| 63 | + return double_var; |
| 64 | + // CHECK: %{{.+}} = cir.cast(float_to_int, %{{.+}} : !cir.double), !s128i |
| 65 | + // LLVM: %{{.+}} = fptosi double %{{.+}} to i128 |
| 66 | +} |
| 67 | + |
| 68 | +// CHECK-LABEL: @_Z18boolean_conversionn |
| 69 | +// LLVM-LABEL: @_Z18boolean_conversionn |
| 70 | +bool boolean_conversion(__int128 x) { |
| 71 | + return x; |
| 72 | + // CHECK: %{{.+}} = cir.cast(int_to_bool, %{{.+}} : !s128i), !cir.bool |
| 73 | + // LLVM: %{{.+}} = icmp ne i128 %{{.+}}, 0 |
| 74 | +} |
0 commit comments