From 8291af896321aed7e9691b00ad1deeb9ef0133eb Mon Sep 17 00:00:00 2001 From: Eric Schweitz Date: Thu, 21 Feb 2019 11:49:51 -0800 Subject: [PATCH] [flang] Address review comments on part 1 Original-commit: flang-compiler/f18@854e9836c37d0b2f0dd28749227a2b1e80ff893b Reviewed-on: https://github.com/flang-compiler/f18/pull/293 Tree-same-pre-rewrite: false --- flang/lib/IntermediateRepresentation/basicblock.h | 13 +++++++++---- flang/lib/IntermediateRepresentation/procedure.h | 11 ++++++----- flang/lib/IntermediateRepresentation/program.h | 5 +++-- flang/lib/IntermediateRepresentation/region.cc | 4 +++- flang/lib/IntermediateRepresentation/region.h | 9 +++++---- 5 files changed, 26 insertions(+), 16 deletions(-) diff --git a/flang/lib/IntermediateRepresentation/basicblock.h b/flang/lib/IntermediateRepresentation/basicblock.h index 22b948a3..37d8a05 100644 --- a/flang/lib/IntermediateRepresentation/basicblock.h +++ b/flang/lib/IntermediateRepresentation/basicblock.h @@ -21,11 +21,12 @@ namespace Fortran::IntermediateRepresentation { -struct Region; -struct Statement; +class Region; +class Statement; -struct BasicBlock final : public llvm::ilist_node, - public ChildMixin { +class BasicBlock final : public llvm::ilist_node, + public ChildMixin { +public: using StatementListType = llvm::iplist; using iterator = StatementListType::iterator; using const_iterator = StatementListType::const_iterator; @@ -35,8 +36,12 @@ struct BasicBlock final : public llvm::ilist_node, BasicBlock(const BasicBlock &) = delete; BasicBlock &operator=(const BasicBlock &) = delete; ~BasicBlock(); + + // callback to allow general access to contained sublist(s) StatementListType &getSublist(Statement *) { return Statements(); } + void insertBefore(Statement *stmt, Statement *before = nullptr); + static BasicBlock *Create( Region *parentRegion, BasicBlock *insertBefore = nullptr) { return new BasicBlock(parentRegion, insertBefore); diff --git a/flang/lib/IntermediateRepresentation/procedure.h b/flang/lib/IntermediateRepresentation/procedure.h index 44a8e06..c343565 100644 --- a/flang/lib/IntermediateRepresentation/procedure.h +++ b/flang/lib/IntermediateRepresentation/procedure.h @@ -23,12 +23,13 @@ namespace Fortran::IntermediateRepresentation { -struct Program; -struct Region; +class Program; +class Region; struct GraphWriter; -struct Procedure final : public llvm::ilist_node, - public ChildMixin { +class Procedure final : public llvm::ilist_node, + public ChildMixin { +public: friend GraphWriter; friend Program; friend Region; @@ -51,7 +52,7 @@ struct Procedure final : public llvm::ilist_node, iterator end() { return basicBlockList_.end(); } const_iterator end() const { return basicBlockList_.end(); } Region *getLastRegion() { return ®ionList_.back(); } - BasicBlock *StartBlock() { return &basicBlockList_.front(); } + BasicBlock *GetEntryBlock() { return &basicBlockList_.front(); } static Procedure *Create(Program *prog, FunctionType *ty, LinkageTypes linkage, unsigned addrSpace = 0u, const llvm::Twine &name = "", Procedure *before = nullptr) { diff --git a/flang/lib/IntermediateRepresentation/program.h b/flang/lib/IntermediateRepresentation/program.h index 9f543c8..d097596 100644 --- a/flang/lib/IntermediateRepresentation/program.h +++ b/flang/lib/IntermediateRepresentation/program.h @@ -25,10 +25,11 @@ namespace Fortran::IntermediateRepresentation { -struct Procedure; +class Procedure; struct GraphWriter; -struct Program final { +class Program final { +public: friend GraphWriter; using ProcedureListType = llvm::iplist; using ProcedureMapType = llvm::StringMap; diff --git a/flang/lib/IntermediateRepresentation/region.cc b/flang/lib/IntermediateRepresentation/region.cc index d93811e..eeb6a03 100644 --- a/flang/lib/IntermediateRepresentation/region.cc +++ b/flang/lib/IntermediateRepresentation/region.cc @@ -41,7 +41,9 @@ void Region::insertBefore(BasicBlock *block, BasicBlock *before) { std::vector Region::getBlocks() { std::vector result; for (auto &block : basicBlockList_) { - if (block.getParent() == this) result.push_back(&block); + if (block.getParent() == this) { + result.push_back(&block); + } } return result; } diff --git a/flang/lib/IntermediateRepresentation/region.h b/flang/lib/IntermediateRepresentation/region.h index bcf5a4a..1cd1562 100644 --- a/flang/lib/IntermediateRepresentation/region.h +++ b/flang/lib/IntermediateRepresentation/region.h @@ -21,11 +21,12 @@ namespace Fortran::IntermediateRepresentation { -struct Procedure; -struct BasicBlock; +class Procedure; +class BasicBlock; -struct Region final : public llvm::ilist_node, - public ChildMixin { +class Region final : public llvm::ilist_node, + public ChildMixin { +public: friend Procedure; friend BasicBlock; using BasicBlockListType = llvm::iplist; -- 2.7.4