[PATCH] D110233: [fir] inline is_box_type and isa_aggregate

Valentin Clement via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 22 05:25:15 PDT 2021


clementval created this revision.
Herald added a subscriber: mehdi_amini.
clementval requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D110233

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


Index: flang/lib/Optimizer/Dialect/FIRType.cpp
===================================================================
--- flang/lib/Optimizer/Dialect/FIRType.cpp
+++ flang/lib/Optimizer/Dialect/FIRType.cpp
@@ -203,20 +203,11 @@
   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>(
Index: flang/include/flang/Optimizer/Dialect/FIRType.h
===================================================================
--- flang/include/flang/Optimizer/Dialect/FIRType.h
+++ flang/include/flang/Optimizer/Dialect/FIRType.h
@@ -65,7 +65,9 @@
 bool isa_passbyref_type(mlir::Type t);
 
 /// Is `t` a boxed type?
-bool isa_box_type(mlir::Type t);
+inline bool isa_box_type(mlir::Type t) {
+  return t.isa<BoxType>() || t.isa<BoxCharType>() || t.isa<BoxProcType>();
+}
 
 /// 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 +76,14 @@
   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 +117,14 @@
   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);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D110233.374189.patch
Type: text/x-patch
Size: 2675 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210922/5ad723c6/attachment.bin>


More information about the llvm-commits mailing list