forked from OSchip/llvm-project
[flang] code review comments
Original-commit: flang-compiler/f18@ef9bfa4bd7 Reviewed-on: https://github.com/flang-compiler/f18/pull/293
This commit is contained in:
parent
8291af8963
commit
f7f819c97b
|
@ -15,7 +15,7 @@
|
|||
#include "program.h"
|
||||
#include "stmt.h"
|
||||
|
||||
namespace Fortran::IntermediateRepresentation {
|
||||
namespace Fortran::FIR {
|
||||
|
||||
BasicBlock::BasicBlock(Region *parentRegion, BasicBlock *insertBefore)
|
||||
: ChildMixin{parentRegion} {
|
||||
|
@ -33,10 +33,10 @@ void BasicBlock::insertBefore(Statement *stmt, Statement *before) {
|
|||
}
|
||||
|
||||
void BasicBlock::addPred(BasicBlock *bb) {
|
||||
for (auto *p : predecessors_) {
|
||||
for (auto *p : preds_) {
|
||||
if (p == bb) return;
|
||||
}
|
||||
predecessors_.push_back(bb);
|
||||
preds_.push_back(bb);
|
||||
}
|
||||
|
||||
const Statement *BasicBlock::getTerminator() const {
|
|
@ -12,14 +12,14 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef FORTRAN_INTERMEDIATEREPRESENTATION_BASICBLOCK_H_
|
||||
#define FORTRAN_INTERMEDIATEREPRESENTATION_BASICBLOCK_H_
|
||||
#ifndef FORTRAN_FIR_BASICBLOCK_H_
|
||||
#define FORTRAN_FIR_BASICBLOCK_H_
|
||||
|
||||
#include "mixin.h"
|
||||
#include "region.h"
|
||||
#include <iostream>
|
||||
|
||||
namespace Fortran::IntermediateRepresentation {
|
||||
namespace Fortran::FIR {
|
||||
|
||||
class Region;
|
||||
class Statement;
|
||||
|
@ -54,19 +54,19 @@ public:
|
|||
void SetRegion(Region *region) { parent = region; }
|
||||
Region *GetRegion() const { return parent; }
|
||||
void addPred(BasicBlock *bb);
|
||||
std::vector<BasicBlock *> &Predecessors() { return predecessors_; }
|
||||
std::vector<BasicBlock *> &preds() { return preds_; }
|
||||
StatementListType &Statements() { return statementList_; }
|
||||
BasicBlock *SplitEdge(BasicBlock *toBlock) { return nullptr; }
|
||||
|
||||
private:
|
||||
StatementListType statementList_;
|
||||
std::vector<BasicBlock *> predecessors_;
|
||||
std::vector<BasicBlock *> preds_;
|
||||
explicit BasicBlock(Region *parentRegion, BasicBlock *insertBefore);
|
||||
};
|
||||
|
||||
inline std::list<BasicBlock *> pred_list(BasicBlock &block) {
|
||||
return std::list<BasicBlock *>{
|
||||
block.Predecessors().begin(), block.Predecessors().end()};
|
||||
block.preds().begin(), block.preds().end()};
|
||||
}
|
||||
|
||||
}
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
#include "procedure.h"
|
||||
|
||||
namespace Fortran::IntermediateRepresentation {
|
||||
namespace Fortran::FIR {
|
||||
|
||||
Procedure::Procedure(Program *program, FunctionType *ty, LinkageTypes lt,
|
||||
unsigned addrSpace, const llvm::Twine &n, Procedure *before)
|
||||
|
@ -63,16 +63,16 @@ void Procedure::FlattenRegions() {
|
|||
for (auto &block : GetBlocks()) {
|
||||
auto *region{block.GetRegion()};
|
||||
if (!region->IsOutermost()) {
|
||||
for (auto *successor : succ_list(block)) {
|
||||
auto *successorRegion{successor->GetRegion()};
|
||||
if (successorRegion != region &&
|
||||
DistinctScopes(successorRegion, region)) {
|
||||
if (IsAncestor(region, successorRegion)) {
|
||||
AddEnterScopes(RegionDepth(region, successorRegion),
|
||||
successor->SplitEdge(&block));
|
||||
} else if (IsAncestor(successorRegion, region)) {
|
||||
AddExitScopes(RegionDepth(successorRegion, region),
|
||||
block.SplitEdge(successor));
|
||||
for (auto *succ : succ_list(block)) {
|
||||
auto *succRegion{succ->GetRegion()};
|
||||
if (succRegion != region &&
|
||||
DistinctScopes(succRegion, region)) {
|
||||
if (IsAncestor(region, succRegion)) {
|
||||
AddEnterScopes(RegionDepth(region, succRegion),
|
||||
succ->SplitEdge(&block));
|
||||
} else if (IsAncestor(succRegion, region)) {
|
||||
AddExitScopes(RegionDepth(succRegion, region),
|
||||
block.SplitEdge(succ));
|
||||
} else {
|
||||
// TODO: edge to a cousin region
|
||||
CHECK(false);
|
|
@ -12,8 +12,8 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef FORTRAN_INTERMEDIATEREPRESENTATION_PROCEDURE_H_
|
||||
#define FORTRAN_INTERMEDIATEREPRESENTATION_PROCEDURE_H_
|
||||
#ifndef FORTRAN_FIR_PROCEDURE_H_
|
||||
#define FORTRAN_FIR_PROCEDURE_H_
|
||||
|
||||
#include "mixin.h"
|
||||
#include "program.h"
|
||||
|
@ -21,7 +21,7 @@
|
|||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/ADT/Twine.h"
|
||||
|
||||
namespace Fortran::IntermediateRepresentation {
|
||||
namespace Fortran::FIR {
|
||||
|
||||
class Program;
|
||||
class Region;
|
|
@ -14,10 +14,9 @@
|
|||
|
||||
#include "program.h"
|
||||
|
||||
namespace Fortran::IntermediateRepresentation {
|
||||
namespace Fortran::FIR {
|
||||
|
||||
Program::Program(llvm::StringRef id) : name_{id} {}
|
||||
Program::~Program() { procedureMap_.clear(); }
|
||||
|
||||
void Program::insertBefore(Procedure *subprog, Procedure *before) {
|
||||
if (before) {
|
|
@ -12,8 +12,8 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef FORTRAN_INTERMEDIATEREPRESENTATION_PROGRAM_H_
|
||||
#define FORTRAN_INTERMEDIATEREPRESENTATION_PROGRAM_H_
|
||||
#ifndef FORTRAN_FIR_PROGRAM_H_
|
||||
#define FORTRAN_FIR_PROGRAM_H_
|
||||
|
||||
#include "common.h"
|
||||
#include "procedure.h"
|
||||
|
@ -23,7 +23,7 @@
|
|||
#include "llvm/ADT/Twine.h"
|
||||
#include <string>
|
||||
|
||||
namespace Fortran::IntermediateRepresentation {
|
||||
namespace Fortran::FIR {
|
||||
|
||||
class Procedure;
|
||||
struct GraphWriter;
|
||||
|
@ -35,7 +35,6 @@ public:
|
|||
using ProcedureMapType = llvm::StringMap<Procedure *>;
|
||||
|
||||
explicit Program(llvm::StringRef id);
|
||||
~Program();
|
||||
void insertBefore(Procedure *subprog, Procedure *before = nullptr);
|
||||
ProcedureListType &getSublist(Procedure *) { return procedureList_; }
|
||||
bool containsProcedure(llvm::StringRef name) {
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
#include "program.h"
|
||||
|
||||
namespace Fortran::IntermediateRepresentation {
|
||||
namespace Fortran::FIR {
|
||||
|
||||
Region::Region(
|
||||
Procedure *procedure, Scope *scope, Region *inRegion, Region *insertBefore)
|
|
@ -12,14 +12,14 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef FORTRAN_INTERMEDIATEREPRESENTATION_REGION_H_
|
||||
#define FORTRAN_INTERMEDIATEREPRESENTATION_REGION_H_
|
||||
#ifndef FORTRAN_FIR_REGION_H_
|
||||
#define FORTRAN_FIR_REGION_H_
|
||||
|
||||
#include "procedure.h"
|
||||
#include "stmt.h"
|
||||
#include "../semantics/semantics.h"
|
||||
|
||||
namespace Fortran::IntermediateRepresentation {
|
||||
namespace Fortran::FIR {
|
||||
|
||||
class Procedure;
|
||||
class BasicBlock;
|
Loading…
Reference in New Issue