-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[flang] Move DumpEvaluateExpr from Lower to Semantics #128723
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
36aad22
[flang] Move DumpEvaluateExpr from Lower to Semantics
kparzysz 613af06
Remove unused header
kparzysz 6c0d52e
format
kparzysz 8402e55
Use brace initialization
kparzysz 2529d9a
Put definitions in namespace to avoid extra qualifications
kparzysz 7913072
Fix file name in comment
kparzysz fe0ebf9
Fix name of include guard
kparzysz f118265
Merge branch 'main' into users/kparzysz/dump-ev-expr
kparzysz 23aad32
Change function/member naming
kparzysz 4c6c395
Add braces around if/for bodies
kparzysz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,19 @@ | ||
| //===-- Lower/DumpEvaluateExpr.h --------------------------------*- C++ -*-===// | ||
| //===-- Semantics/DumpEvaluateExpr.h ----------------------------*- C++ -*-===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #ifndef FORTRAN_LOWER_DUMPEVALUATEEXPR_H | ||
| #define FORTRAN_LOWER_DUMPEVALUATEEXPR_H | ||
| #ifndef FORTRAN_SEMANTICS_DUMPEVALUATEEXPR_H | ||
| #define FORTRAN_SEMANTICS_DUMPEVALUATEEXPR_H | ||
|
|
||
| #include "flang/Evaluate/tools.h" | ||
| #include "flang/Lower/Support/Utils.h" | ||
| #include "llvm/ADT/StringRef.h" | ||
| #include "llvm/ADT/Twine.h" | ||
|
|
||
| namespace Fortran::lower { | ||
| namespace Fortran::semantics { | ||
|
|
||
| /// Class to dump Fortran::evaluate::Expr trees out in a user readable way. | ||
| /// | ||
|
|
@@ -24,8 +23,7 @@ class DumpEvaluateExpr { | |
| DumpEvaluateExpr() : outs(llvm::errs()) {} | ||
| DumpEvaluateExpr(llvm::raw_ostream &str) : outs(str) {} | ||
|
|
||
| template <typename A> | ||
| static void dump(const A &x) { | ||
| template <typename A> static void dump(const A &x) { | ||
| DumpEvaluateExpr{}.show(x); | ||
| } | ||
| template <typename A> | ||
|
|
@@ -38,49 +36,41 @@ class DumpEvaluateExpr { | |
| void show(const Fortran::common::Indirection<A, C> &x) { | ||
| show(x.value()); | ||
| } | ||
| template <typename A> | ||
| void show(const Fortran::semantics::SymbolRef x) { | ||
| template <typename A> void show(const Fortran::semantics::SymbolRef x) { | ||
| show(*x); | ||
| } | ||
| template <typename A> | ||
| void show(const std::unique_ptr<A> &x) { | ||
| template <typename A> void show(const std::unique_ptr<A> &x) { | ||
| show(x.get()); | ||
| } | ||
| template <typename A> | ||
| void show(const std::shared_ptr<A> &x) { | ||
| template <typename A> void show(const std::shared_ptr<A> &x) { | ||
| show(x.get()); | ||
| } | ||
| template <typename A> | ||
| void show(const A *x) { | ||
| template <typename A> void show(const A *x) { | ||
| if (x) { | ||
| show(*x); | ||
| return; | ||
| } | ||
| print("nullptr"); | ||
| } | ||
| template <typename A> | ||
| void show(const std::optional<A> &x) { | ||
| template <typename A> void show(const std::optional<A> &x) { | ||
| if (x) { | ||
| show(*x); | ||
| return; | ||
| } | ||
| print("None"); | ||
| } | ||
| template <typename... A> | ||
| void show(const std::variant<A...> &u) { | ||
| template <typename... A> void show(const std::variant<A...> &u) { | ||
| Fortran::common::visit([&](const auto &v) { show(v); }, u); | ||
| } | ||
| template <typename A> | ||
| void show(const std::vector<A> &x) { | ||
| template <typename A> void show(const std::vector<A> &x) { | ||
| indent("vector"); | ||
| for (const auto &v : x) | ||
| show(v); | ||
| outdent(); | ||
| } | ||
| void show(const Fortran::evaluate::BOZLiteralConstant &); | ||
| void show(const Fortran::evaluate::NullPointer &); | ||
| template <typename T> | ||
| void show(const Fortran::evaluate::Constant<T> &x) { | ||
| template <typename T> void show(const Fortran::evaluate::Constant<T> &x) { | ||
| if constexpr (T::category == Fortran::common::TypeCategory::Derived) { | ||
| indent("derived constant"); | ||
| for (const auto &map : x.values()) | ||
|
||
|
|
@@ -105,14 +95,12 @@ class DumpEvaluateExpr { | |
| void show(const Fortran::evaluate::DataRef &x); | ||
| void show(const Fortran::evaluate::Substring &x); | ||
| void show(const Fortran::evaluate::ComplexPart &x); | ||
| template <typename T> | ||
| void show(const Fortran::evaluate::Designator<T> &x) { | ||
| template <typename T> void show(const Fortran::evaluate::Designator<T> &x) { | ||
| indent("designator"); | ||
| show(x.u); | ||
| outdent(); | ||
| } | ||
| template <typename T> | ||
| void show(const Fortran::evaluate::Variable<T> &x) { | ||
| template <typename T> void show(const Fortran::evaluate::Variable<T> &x) { | ||
| indent("variable"); | ||
| show(x.u); | ||
| outdent(); | ||
|
|
@@ -127,8 +115,7 @@ class DumpEvaluateExpr { | |
| show(x.arguments()); | ||
| outdent(); | ||
| } | ||
| template <typename T> | ||
| void show(const Fortran::evaluate::FunctionRef<T> &x) { | ||
| template <typename T> void show(const Fortran::evaluate::FunctionRef<T> &x) { | ||
| indent("function ref"); | ||
| show(x.proc()); | ||
| show(x.arguments()); | ||
|
|
@@ -145,8 +132,7 @@ class DumpEvaluateExpr { | |
| show(v); | ||
| outdent(); | ||
| } | ||
| template <typename T> | ||
| void show(const Fortran::evaluate::ImpliedDo<T> &x) { | ||
| template <typename T> void show(const Fortran::evaluate::ImpliedDo<T> &x) { | ||
| indent("implied do"); | ||
| show(x.lower()); | ||
| show(x.upper()); | ||
|
|
@@ -155,9 +141,9 @@ class DumpEvaluateExpr { | |
| outdent(); | ||
| } | ||
| void show(const Fortran::semantics::ParamValue &x); | ||
| void | ||
| show(const Fortran::semantics::DerivedTypeSpec::ParameterMapType::value_type | ||
| &x); | ||
| void show( | ||
| const Fortran::semantics::DerivedTypeSpec::ParameterMapType::value_type | ||
| &x); | ||
| void show(const Fortran::semantics::DerivedTypeSpec &x); | ||
| void show(const Fortran::evaluate::StructureConstructorValues::value_type &x); | ||
| void show(const Fortran::evaluate::StructureConstructor &x); | ||
|
|
@@ -174,10 +160,9 @@ class DumpEvaluateExpr { | |
| show(op.right()); | ||
| outdent(); | ||
| } | ||
| void | ||
| show(const Fortran::evaluate::Relational<Fortran::evaluate::SomeType> &x); | ||
| template <typename T> | ||
| void show(const Fortran::evaluate::Expr<T> &x) { | ||
| void show( | ||
| const Fortran::evaluate::Relational<Fortran::evaluate::SomeType> &x); | ||
| template <typename T> void show(const Fortran::evaluate::Expr<T> &x) { | ||
| indent("expr T"); | ||
| show(x.u); | ||
| outdent(); | ||
|
|
@@ -192,21 +177,18 @@ class DumpEvaluateExpr { | |
| unsigned level = 0; | ||
| }; | ||
|
|
||
| LLVM_DUMP_METHOD void | ||
| dumpEvExpr(const Fortran::evaluate::Expr<Fortran::evaluate::SomeType> &x); | ||
| LLVM_DUMP_METHOD void dumpEvExpr( | ||
| const Fortran::evaluate::Expr< | ||
| Fortran::evaluate::Type<Fortran::common::TypeCategory::Integer, 4>> &x); | ||
| LLVM_DUMP_METHOD void dumpEvExpr( | ||
| const Fortran::evaluate::Expr< | ||
| Fortran::evaluate::Type<Fortran::common::TypeCategory::Integer, 8>> &x); | ||
| const Fortran::evaluate::Expr<Fortran::evaluate::SomeType> &x); | ||
| LLVM_DUMP_METHOD void dumpEvExpr(const Fortran::evaluate::Expr< | ||
| Fortran::evaluate::Type<Fortran::common::TypeCategory::Integer, 4>> &x); | ||
| LLVM_DUMP_METHOD void dumpEvExpr(const Fortran::evaluate::Expr< | ||
| Fortran::evaluate::Type<Fortran::common::TypeCategory::Integer, 8>> &x); | ||
| LLVM_DUMP_METHOD void dumpEvExpr(const Fortran::evaluate::ArrayRef &x); | ||
| LLVM_DUMP_METHOD void dumpEvExpr(const Fortran::evaluate::DataRef &x); | ||
| LLVM_DUMP_METHOD void dumpEvExpr(const Fortran::evaluate::Substring &x); | ||
| LLVM_DUMP_METHOD void dumpEvExpr( | ||
| const Fortran::evaluate::Designator< | ||
| Fortran::evaluate::Type<Fortran::common::TypeCategory::Integer, 4>> &x); | ||
| LLVM_DUMP_METHOD void dumpEvExpr(const Fortran::evaluate::Designator< | ||
| Fortran::evaluate::Type<Fortran::common::TypeCategory::Integer, 4>> &x); | ||
|
|
||
| } // namespace Fortran::lower | ||
| } // namespace Fortran::semantics | ||
|
|
||
| #endif // FORTRAN_LOWER_DUMPEVALUATEEXPR_H | ||
| #endif // FORTRAN_SEMANTICS_DUMPEVALUATEEXPR_H | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
braces please