[flang-commits] [flang] ce59ccd - [fir][NFC] inline trival isa_<type> functions

Valentin Clement via flang-commits flang-commits at lists.llvm.org
Thu Sep 23 02:09:18 PDT 2021


Author: Valentin Clement
Date: 2021-09-23T11:09:13+02:00
New Revision: ce59ccd04023cab3a837da14079ca2dcbfebb70c

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

LOG: [fir][NFC] inline trival isa_<type> functions

This patch is part of the upstreaming effort from fir-dev branch and sync changes. Inline trival `isa_<type>` functions.

Co-authored-by: schweitzpgi

Reviewed By: kiranchandramohan

Differential Revision: https://reviews.llvm.org/D110233

Added: 
    

Modified: 
    flang/include/flang/Optimizer/Dialect/FIRType.h
    flang/lib/Optimizer/Dialect/FIRType.cpp

Removed: 
    


################################################################################
diff  --git a/flang/include/flang/Optimizer/Dialect/FIRType.h b/flang/include/flang/Optimizer/Dialect/FIRType.h
index ca0dddd2a2c71..21e592167f847 100644
--- a/flang/include/flang/Optimizer/Dialect/FIRType.h
+++ b/flang/include/flang/Optimizer/Dialect/FIRType.h
@@ -57,15 +57,22 @@ bool isa_std_type(mlir::Type t);
 bool isa_fir_or_std_type(mlir::Type t);
 
 /// Is `t` a FIR dialect type that implies a memory (de)reference?
-bool isa_ref_type(mlir::Type t);
+inline bool isa_ref_type(mlir::Type t) {
+  return t.isa<ReferenceType>() || t.isa<PointerType>() || t.isa<HeapType>();
+}
+
+/// Is `t` a boxed type?
+inline bool isa_box_type(mlir::Type t) {
+  return t.isa<BoxType>() || t.isa<BoxCharType>() || t.isa<BoxProcType>();
+}
 
 /// Is `t` a type that is always trivially pass-by-reference? Specifically, this
 /// is testing if `t` is a ReferenceType or any box type. Compare this to
 /// conformsWithPassByRef(), which includes pointers and allocatables.
-bool isa_passbyref_type(mlir::Type t);
-
-/// Is `t` a boxed type?
-bool isa_box_type(mlir::Type t);
+inline bool isa_passbyref_type(mlir::Type t) {
+  return t.isa<ReferenceType>() || isa_box_type(t) ||
+         t.isa<mlir::FunctionType>();
+}
 
 /// Is `t` a type that can conform to be pass-by-reference? Depending on the
 /// context, these types may simply demote to pass-by-reference or a reference
@@ -74,8 +81,14 @@ inline bool conformsWithPassByRef(mlir::Type t) {
   return isa_ref_type(t) || isa_box_type(t);
 }
 
+/// Is `t` a derived (record) type?
+inline bool isa_derived(mlir::Type t) { return t.isa<fir::RecordType>(); }
+
 /// Is `t` a FIR dialect aggregate type?
-bool isa_aggregate(mlir::Type t);
+inline bool isa_aggregate(mlir::Type t) {
+  return t.isa<SequenceType>() || fir::isa_derived(t) ||
+         t.isa<mlir::TupleType>();
+}
 
 /// Extract the `Type` pointed to from a FIR memory reference type. If `t` is
 /// not a memory reference type, then returns a null `Type`.
@@ -109,13 +122,14 @@ inline bool isa_complex(mlir::Type t) {
   return t.isa<fir::ComplexType>() || t.isa<mlir::ComplexType>();
 }
 
+/// Is `t` a CHARACTER type with a LEN other than 1?
 inline bool isa_char_string(mlir::Type t) {
   if (auto ct = t.dyn_cast_or_null<fir::CharacterType>())
     return ct.getLen() != fir::CharacterType::singleton();
   return false;
 }
 
-/// Is `t` a box type for which it is not possible to deduce the box size.
+/// Is `t` a box type for which it is not possible to deduce the box size?
 /// It is not possible to deduce the size of a box that describes an entity
 /// of unknown rank or type.
 bool isa_unknown_size_box(mlir::Type t);

diff  --git a/flang/lib/Optimizer/Dialect/FIRType.cpp b/flang/lib/Optimizer/Dialect/FIRType.cpp
index 39ef3ba8fac9f..57d202014e4eb 100644
--- a/flang/lib/Optimizer/Dialect/FIRType.cpp
+++ b/flang/lib/Optimizer/Dialect/FIRType.cpp
@@ -199,24 +199,6 @@ bool isa_fir_or_std_type(mlir::Type t) {
   return isa_fir_type(t) || isa_std_type(t);
 }
 
-bool isa_ref_type(mlir::Type t) {
-  return t.isa<ReferenceType>() || t.isa<PointerType>() || t.isa<HeapType>();
-}
-
-bool isa_box_type(mlir::Type t) {
-  return t.isa<BoxType>() || t.isa<BoxCharType>() || t.isa<BoxProcType>();
-}
-
-bool isa_passbyref_type(mlir::Type t) {
-  return t.isa<ReferenceType>() || isa_box_type(t) ||
-         t.isa<mlir::FunctionType>();
-}
-
-bool isa_aggregate(mlir::Type t) {
-  return t.isa<SequenceType>() || t.isa<RecordType>() ||
-         t.isa<mlir::TupleType>();
-}
-
 mlir::Type dyn_cast_ptrEleTy(mlir::Type t) {
   return llvm::TypeSwitch<mlir::Type, mlir::Type>(t)
       .Case<fir::ReferenceType, fir::PointerType, fir::HeapType>(


        


More information about the flang-commits mailing list