Skip to content

Commit 903f6b7

Browse files
committed
[flang] Add missing CFI case for REAL and COMPLEX
ISO_Fortran_binding.h was updated with missing entries for CFI types for REAL and COMPLEX kinds 2,3,10,16. This patch updates TypeCode.h to use these new types. This patch is part of the upstreaming effort from fir-dev branch. Reviewed By: jeanPerier Differential Revision: https://reviews.llvm.org/D119283
1 parent 34840c1 commit 903f6b7

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

flang/include/flang/Optimizer/Support/TypeCode.h

+6-4
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,11 @@ inline int characterBitsToTypeCode(unsigned bitwidth) {
3737
inline int complexBitsToTypeCode(unsigned bitwidth) {
3838
// clang-format off
3939
switch (bitwidth) {
40+
case 16: return CFI_type_half_float_Complex; // CFI_type_bfloat_Complex ?
4041
case 32: return CFI_type_float_Complex;
4142
case 64: return CFI_type_double_Complex;
42-
case 80:
43-
case 128: return CFI_type_long_double_Complex;
43+
case 80: return CFI_type_extended_double_Complex;
44+
case 128: return CFI_type_float128_Complex;
4445
default: llvm_unreachable("unsupported complex size");
4546
}
4647
// clang-format on
@@ -74,10 +75,11 @@ inline int logicalBitsToTypeCode(unsigned bitwidth) {
7475
inline int realBitsToTypeCode(unsigned bitwidth) {
7576
// clang-format off
7677
switch (bitwidth) {
78+
case 16: return CFI_type_half_float; // CFI_type_bfloat ?
7779
case 32: return CFI_type_float;
7880
case 64: return CFI_type_double;
79-
case 80:
80-
case 128: return CFI_type_long_double;
81+
case 80: return CFI_type_extended_double;
82+
case 128: return CFI_type_float128;
8183
default: llvm_unreachable("unsupported real size");
8284
}
8385
// clang-format on

flang/test/Fir/convert-to-llvm.fir

+1-1
Original file line numberDiff line numberDiff line change
@@ -1583,7 +1583,7 @@ func @embox_typecode2(%arg0: !fir.ref<f128>) {
15831583
}
15841584

15851585
// CHECK-LABEL: llvm.func @embox_typecode2
1586-
// CHECK: %[[TYPE_CODE_F128:.*]] = llvm.mlir.constant(30 : i32) : i32
1586+
// CHECK: %[[TYPE_CODE_F128:.*]] = llvm.mlir.constant(31 : i32) : i32
15871587
// CHECK: %[[TYPE_CODE_F128_I8:.*]] = llvm.trunc %[[TYPE_CODE_F128]] : i32 to i8
15881588
// CHECK: %{{.*}} = llvm.insertvalue %[[TYPE_CODE_F128_I8]], %{{.*}}[4 : i32] : !llvm.struct<(ptr<f128>, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}})>
15891589

0 commit comments

Comments
 (0)