From: Eric Schweitz Date: Fri, 22 Feb 2019 23:51:44 +0000 (-0800) Subject: [flang] changes per review comments X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bd22bbb5677c8c4dfa17599d8651f1f40451d02b;p=platform%2Fupstream%2Fllvm.git [flang] changes per review comments Original-commit: flang-compiler/f18@3868f0c934d8ca8c19d567e011bdcc7c652a7ad9 Reviewed-on: https://github.com/flang-compiler/f18/pull/297 --- diff --git a/flang/lib/IntermediateRepresentation/afforestation.cc b/flang/lib/FIR/afforestation.cc similarity index 98% rename from flang/lib/IntermediateRepresentation/afforestation.cc rename to flang/lib/FIR/afforestation.cc index 3d1b283..a47dedd 100644 --- a/flang/lib/IntermediateRepresentation/afforestation.cc +++ b/flang/lib/FIR/afforestation.cc @@ -22,7 +22,7 @@ #include "llvm/Support/FileSystem.h" #include "llvm/Support/raw_ostream.h" -namespace Fortran::IntermediateRepresentation { +namespace Fortran::FIR { static llvm::raw_ostream *debugChannel; static llvm::raw_ostream &DebugChannel() { @@ -1108,22 +1108,22 @@ static Expression *BuildLoopLatchExpression( return AlwaysTrueExpression(); } -static void CreateSwitchHelper(IntermediateRepresentationBuilder *builder, +static void CreateSwitchHelper(FIRBuilder *builder, const Evaluation &condition, BasicBlock *defaultCase, const SwitchStmt::ValueSuccPairListType &rest) { builder->CreateSwitch(condition, defaultCase, rest); } -static void CreateSwitchCaseHelper(IntermediateRepresentationBuilder *builder, +static void CreateSwitchCaseHelper(FIRBuilder *builder, const Evaluation &condition, BasicBlock *defaultCase, const SwitchCaseStmt::ValueSuccPairListType &rest) { builder->CreateSwitchCase(condition, defaultCase, rest); } -static void CreateSwitchRankHelper(IntermediateRepresentationBuilder *builder, +static void CreateSwitchRankHelper(FIRBuilder *builder, const Evaluation &condition, BasicBlock *defaultCase, const SwitchRankStmt::ValueSuccPairListType &rest) { builder->CreateSwitchRank(condition, defaultCase, rest); } -static void CreateSwitchTypeHelper(IntermediateRepresentationBuilder *builder, +static void CreateSwitchTypeHelper(FIRBuilder *builder, const Evaluation &condition, BasicBlock *defaultCase, const SwitchTypeStmt::ValueSuccPairListType &rest) { builder->CreateSwitchType(condition, defaultCase, rest); @@ -1135,7 +1135,7 @@ struct FortranIRLowering { FortranIRLowering(semantics::SemanticsContext &sc, bool debugLinearIR) : fir_{new Program("program_name")}, semanticsContext_{sc}, - debugLinearIntermediateRepresentation_{debugLinearIR} {} + debugLinearFIR_{debugLinearIR} {} ~FortranIRLowering() { CHECK(!builder_); } template constexpr bool Pre(const A &) { return true; } @@ -1169,15 +1169,15 @@ struct FortranIRLowering { void ProcessRoutine(const T &here, const std::string &name) { CHECK(!fir_->containsProcedure(name)); auto *subp{fir_->getOrInsertProcedure(name, nullptr, {})}; - builder_ = new IntermediateRepresentationBuilder( + builder_ = new FIRBuilder( *CreateBlock(subp->getLastRegion())); AnalysisData ad; ControlFlowAnalyzer linearize{linearOperations_, ad}; Walk(here, linearize); - if (debugLinearIntermediateRepresentation_) { + if (debugLinearFIR_) { dumpLinearRepresentation(); } - ConstructIntermediateRepresentation(ad); + ConstructFIR(ad); DrawRemainingArcs(); Cleanup(); } @@ -1539,7 +1539,7 @@ struct FortranIRLowering { builder_->CreateExpr(forallConstructStmt); } - void ConstructIntermediateRepresentation(AnalysisData &ad) { + void ConstructFIR(AnalysisData &ad) { for (auto iter{linearOperations_.begin()}, iend{linearOperations_.end()}; iter != iend; ++iter) { const auto &op{*iter}; @@ -1818,7 +1818,7 @@ struct FortranIRLowering { } else { using namespace std::placeholders; controlFlowEdgesToAdd_.emplace_back(std::bind( - [](IntermediateRepresentationBuilder *builder, BasicBlock *block, + [](FIRBuilder *builder, BasicBlock *block, LinearLabelRef dest, const LabelMapType &map) { builder->SetInsertionPoint(block); CHECK(map.find(dest) != map.end()); @@ -1837,7 +1837,7 @@ struct FortranIRLowering { } else { using namespace std::placeholders; controlFlowEdgesToAdd_.emplace_back(std::bind( - [](IntermediateRepresentationBuilder *builder, BasicBlock *block, + [](FIRBuilder *builder, BasicBlock *block, Expression *expr, LinearLabelRef trueDest, LinearLabelRef falseDest, const LabelMapType &map) { builder->SetInsertionPoint(block); @@ -1876,7 +1876,7 @@ struct FortranIRLowering { if (defer) { using namespace std::placeholders; controlFlowEdgesToAdd_.emplace_back(std::bind( - [](IntermediateRepresentationBuilder *builder, BasicBlock *block, + [](FIRBuilder *builder, BasicBlock *block, const Evaluation &expr, LinearLabelRef defaultDest, const std::vector &values, const std::vector &labels, F function, @@ -1916,7 +1916,7 @@ struct FortranIRLowering { if (defer) { using namespace std::placeholders; controlFlowEdgesToAdd_.emplace_back(std::bind( - [](IntermediateRepresentationBuilder *builder, BasicBlock *block, + [](FIRBuilder *builder, BasicBlock *block, Variable *variable, const std::vector &fixme, const LabelMapType &map) { builder->SetInsertionPoint(block); @@ -1945,13 +1945,13 @@ struct FortranIRLowering { blockMap_.clear(); } - IntermediateRepresentationBuilder *builder_{nullptr}; + FIRBuilder *builder_{nullptr}; Program *fir_; std::list linearOperations_; std::list controlFlowEdgesToAdd_; LabelMapType blockMap_; semantics::SemanticsContext &semanticsContext_; - bool debugLinearIntermediateRepresentation_; + bool debugLinearFIR_; }; Program *CreateFortranIR(const parser::Program &program, diff --git a/flang/lib/IntermediateRepresentation/afforestation.h b/flang/lib/FIR/afforestation.h similarity index 85% rename from flang/lib/IntermediateRepresentation/afforestation.h rename to flang/lib/FIR/afforestation.h index cd639b5..3906665 100644 --- a/flang/lib/IntermediateRepresentation/afforestation.h +++ b/flang/lib/FIR/afforestation.h @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef FORTRAN_INTERMEDIATEREPRESENTATION_AFFORESTATION_H_ -#define FORTRAN_INTERMEDIATEREPRESENTATION_AFFORESTATION_H_ +#ifndef FORTRAN_FIR_AFFORESTATION_H_ +#define FORTRAN_FIR_AFFORESTATION_H_ #include @@ -25,7 +25,7 @@ namespace Fortran::semantics { class SemanticsContext; } -namespace Fortran::IntermediateRepresentation { +namespace Fortran::FIR { class Program; void SetDebugChannel(const std::string &filename);