[flang-commits] [flang] 903f6b7 - [flang] Add missing CFI case for REAL and COMPLEX

Valentin Clement via flang-commits flang-commits at lists.llvm.org
Wed Feb 9 01:07:44 PST 2022


Author: Valentin Clement
Date: 2022-02-09T10:07:40+01:00
New Revision: 903f6b71704f92d9f55ffee60b6c6a9968feba83

URL: https://github.com/llvm/llvm-project/commit/903f6b71704f92d9f55ffee60b6c6a9968feba83
DIFF: https://github.com/llvm/llvm-project/commit/903f6b71704f92d9f55ffee60b6c6a9968feba83.diff

LOG: [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

Added: 
    

Modified: 
    flang/include/flang/Optimizer/Support/TypeCode.h
    flang/test/Fir/convert-to-llvm.fir

Removed: 
    


################################################################################
diff  --git a/flang/include/flang/Optimizer/Support/TypeCode.h b/flang/include/flang/Optimizer/Support/TypeCode.h
index ae9e96b8fc41e..fef937b518aa8 100644
--- a/flang/include/flang/Optimizer/Support/TypeCode.h
+++ b/flang/include/flang/Optimizer/Support/TypeCode.h
@@ -37,10 +37,11 @@ inline int characterBitsToTypeCode(unsigned bitwidth) {
 inline int complexBitsToTypeCode(unsigned bitwidth) {
   // clang-format off
   switch (bitwidth) {
+  case 16:  return CFI_type_half_float_Complex; // CFI_type_bfloat_Complex ?
   case 32:  return CFI_type_float_Complex;
   case 64:  return CFI_type_double_Complex;
-  case 80:
-  case 128: return CFI_type_long_double_Complex;
+  case 80:  return CFI_type_extended_double_Complex;
+  case 128: return CFI_type_float128_Complex;
   default:  llvm_unreachable("unsupported complex size");
   }
   // clang-format on
@@ -74,10 +75,11 @@ inline int logicalBitsToTypeCode(unsigned bitwidth) {
 inline int realBitsToTypeCode(unsigned bitwidth) {
   // clang-format off
   switch (bitwidth) {
+  case 16:  return CFI_type_half_float; // CFI_type_bfloat ?
   case 32:  return CFI_type_float;
   case 64:  return CFI_type_double;
-  case 80:
-  case 128: return CFI_type_long_double;
+  case 80:  return CFI_type_extended_double;
+  case 128: return CFI_type_float128;
   default:  llvm_unreachable("unsupported real size");
   }
   // clang-format on

diff  --git a/flang/test/Fir/convert-to-llvm.fir b/flang/test/Fir/convert-to-llvm.fir
index fc384879b7fec..ef079b63007ad 100644
--- a/flang/test/Fir/convert-to-llvm.fir
+++ b/flang/test/Fir/convert-to-llvm.fir
@@ -1583,7 +1583,7 @@ func @embox_typecode2(%arg0: !fir.ref<f128>) {
 }
 
 // CHECK-LABEL: llvm.func @embox_typecode2
-// CHECK: %[[TYPE_CODE_F128:.*]] = llvm.mlir.constant(30 : i32) : i32
+// CHECK: %[[TYPE_CODE_F128:.*]] = llvm.mlir.constant(31 : i32) : i32
 // CHECK: %[[TYPE_CODE_F128_I8:.*]] = llvm.trunc %[[TYPE_CODE_F128]] : i32 to i8
 // CHECK: %{{.*}} = llvm.insertvalue %[[TYPE_CODE_F128_I8]], %{{.*}}[4 : i32] : !llvm.struct<(ptr<f128>, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}})>
 


        


More information about the flang-commits mailing list