diff --git a/flang/lib/common/CMakeLists.txt b/flang/lib/common/CMakeLists.txt index da12c5b36628..aeecaf10f589 100644 --- a/flang/lib/common/CMakeLists.txt +++ b/flang/lib/common/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. +# Copyright (c) 2018-2019, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,6 +13,7 @@ # limitations under the License. add_library(FortranCommon + default-kinds.cc idioms.cc ) diff --git a/flang/lib/semantics/default-kinds.cc b/flang/lib/common/default-kinds.cc similarity index 94% rename from flang/lib/semantics/default-kinds.cc rename to flang/lib/common/default-kinds.cc index f9dfe3e96499..18bdcb824686 100644 --- a/flang/lib/semantics/default-kinds.cc +++ b/flang/lib/common/default-kinds.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. +// Copyright (c) 2018-2019, NVIDIA CORPORATION. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -13,9 +13,9 @@ // limitations under the License. #include "default-kinds.h" -#include "../common/idioms.h" +#include "idioms.h" -namespace Fortran::semantics { +namespace Fortran::common { IntrinsicTypeDefaultKinds::IntrinsicTypeDefaultKinds() { #if __x86_64__ diff --git a/flang/lib/semantics/default-kinds.h b/flang/lib/common/default-kinds.h similarity index 90% rename from flang/lib/semantics/default-kinds.h rename to flang/lib/common/default-kinds.h index d1f633966069..96aa7bd82916 100644 --- a/flang/lib/semantics/default-kinds.h +++ b/flang/lib/common/default-kinds.h @@ -1,4 +1,4 @@ -// Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. +// Copyright (c) 2018-2019, NVIDIA CORPORATION. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,17 +12,15 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef FORTRAN_DEFAULT_KINDS_H_ -#define FORTRAN_DEFAULT_KINDS_H_ +#ifndef FORTRAN_COMMON_DEFAULT_KINDS_H_ +#define FORTRAN_COMMON_DEFAULT_KINDS_H_ #include "../common/fortran.h" // Represent the default values of the kind parameters of the // various intrinsic types. These can be configured by means of // the compiler command line. -namespace Fortran::semantics { - -using Fortran::common::TypeCategory; +namespace Fortran::common { class IntrinsicTypeDefaultKinds { public: @@ -56,4 +54,4 @@ private: int defaultLogicalKind_{defaultIntegerKind_}; }; } -#endif // FORTRAN_DEFAULT_KINDS_H_ +#endif // FORTRAN_COMMON_DEFAULT_KINDS_H_ diff --git a/flang/lib/evaluate/intrinsics.cc b/flang/lib/evaluate/intrinsics.cc index 6757da844595..d0ed806b3e34 100644 --- a/flang/lib/evaluate/intrinsics.cc +++ b/flang/lib/evaluate/intrinsics.cc @@ -20,7 +20,6 @@ #include "../common/enum-set.h" #include "../common/fortran.h" #include "../common/idioms.h" -#include "../semantics/default-kinds.h" #include #include #include @@ -206,7 +205,7 @@ struct IntrinsicInterface { TypePattern result; Rank rank{Rank::elemental}; std::optional Match(const CallCharacteristics &, - const semantics::IntrinsicTypeDefaultKinds &, ActualArguments &, + const common::IntrinsicTypeDefaultKinds &, ActualArguments &, parser::ContextualMessages &messages) const; std::ostream &Dump(std::ostream &) const; }; @@ -757,7 +756,7 @@ static const SpecificIntrinsicInterface specificIntrinsicFunction[]{ // procedure reference. std::optional IntrinsicInterface::Match( const CallCharacteristics &call, - const semantics::IntrinsicTypeDefaultKinds &defaults, + const common::IntrinsicTypeDefaultKinds &defaults, ActualArguments &arguments, parser::ContextualMessages &messages) const { // Attempt to construct a 1-1 correspondence between the dummy arguments in // a particular intrinsic procedure's generic interface and the actual @@ -1158,7 +1157,7 @@ std::optional IntrinsicInterface::Match( } struct IntrinsicProcTable::Implementation { - explicit Implementation(const semantics::IntrinsicTypeDefaultKinds &dfts) + explicit Implementation(const common::IntrinsicTypeDefaultKinds &dfts) : defaults{dfts} { for (const IntrinsicInterface &f : genericIntrinsicFunction) { genericFuncs.insert(std::make_pair(std::string{f.name}, &f)); @@ -1171,7 +1170,7 @@ struct IntrinsicProcTable::Implementation { std::optional Probe(const CallCharacteristics &, ActualArguments &, parser::ContextualMessages *) const; - semantics::IntrinsicTypeDefaultKinds defaults; + common::IntrinsicTypeDefaultKinds defaults; std::multimap genericFuncs; std::multimap specificFuncs; std::ostream &Dump(std::ostream &) const; @@ -1253,7 +1252,7 @@ IntrinsicProcTable::~IntrinsicProcTable() { } IntrinsicProcTable IntrinsicProcTable::Configure( - const semantics::IntrinsicTypeDefaultKinds &defaults) { + const common::IntrinsicTypeDefaultKinds &defaults) { IntrinsicProcTable result; result.impl_ = new IntrinsicProcTable::Implementation(defaults); return result; diff --git a/flang/lib/evaluate/intrinsics.h b/flang/lib/evaluate/intrinsics.h index cc9d501885df..65d2dbf60753 100644 --- a/flang/lib/evaluate/intrinsics.h +++ b/flang/lib/evaluate/intrinsics.h @@ -1,4 +1,4 @@ -// Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. +// Copyright (c) 2018-2019, NVIDIA CORPORATION. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -16,9 +16,9 @@ #define FORTRAN_EVALUATE_INTRINSICS_H_ #include "call.h" +#include "../common/default-kinds.h" #include "../parser/char-block.h" #include "../parser/message.h" -#include "../semantics/default-kinds.h" #include #include @@ -43,7 +43,7 @@ private: public: ~IntrinsicProcTable(); static IntrinsicProcTable Configure( - const semantics::IntrinsicTypeDefaultKinds &); + const common::IntrinsicTypeDefaultKinds &); // Probe the intrinsics for a match against a specific call. // On success, the actual arguments are transferred to the result diff --git a/flang/lib/semantics/CMakeLists.txt b/flang/lib/semantics/CMakeLists.txt index e7953aa2dbf9..d3642e96028c 100644 --- a/flang/lib/semantics/CMakeLists.txt +++ b/flang/lib/semantics/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. +# Copyright (c) 2018-2019, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -18,7 +18,6 @@ add_library(FortranSemantics attr.cc canonicalize-do.cc check-do-concurrent.cc - default-kinds.cc expression.cc mod-file.cc resolve-labels.cc diff --git a/flang/lib/semantics/mod-file.h b/flang/lib/semantics/mod-file.h index 47a5bf41ad35..6b08c79c4037 100644 --- a/flang/lib/semantics/mod-file.h +++ b/flang/lib/semantics/mod-file.h @@ -1,4 +1,4 @@ -// Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. +// Copyright (c) 2018-2019, NVIDIA CORPORATION. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -16,7 +16,6 @@ #define FORTRAN_SEMANTICS_MOD_FILE_H_ #include "attr.h" -#include "default-kinds.h" #include "resolve-names.h" #include "../parser/message.h" #include diff --git a/flang/lib/semantics/resolve-names.cc b/flang/lib/semantics/resolve-names.cc index 052ec1f2c762..db91b48f9c3a 100644 --- a/flang/lib/semantics/resolve-names.cc +++ b/flang/lib/semantics/resolve-names.cc @@ -14,7 +14,6 @@ #include "resolve-names.h" #include "attr.h" -#include "default-kinds.h" #include "expression.h" #include "mod-file.h" #include "rewrite-parse-tree.h" @@ -22,6 +21,7 @@ #include "semantics.h" #include "symbol.h" #include "type.h" +#include "../common/default-kinds.h" #include "../common/fortran.h" #include "../common/indirection.h" #include "../evaluate/common.h" diff --git a/flang/lib/semantics/semantics.cc b/flang/lib/semantics/semantics.cc index cfd7b38f11a2..7f72ad677608 100644 --- a/flang/lib/semantics/semantics.cc +++ b/flang/lib/semantics/semantics.cc @@ -16,7 +16,6 @@ #include "assignment.h" #include "canonicalize-do.h" #include "check-do-concurrent.h" -#include "default-kinds.h" #include "expression.h" #include "mod-file.h" #include "resolve-labels.h" @@ -24,6 +23,7 @@ #include "rewrite-parse-tree.h" #include "scope.h" #include "symbol.h" +#include "../common/default-kinds.h" #include namespace Fortran::semantics { @@ -32,7 +32,7 @@ static void DoDumpSymbols(std::ostream &, const Scope &, int indent = 0); static void PutIndent(std::ostream &, int indent); SemanticsContext::SemanticsContext( - const IntrinsicTypeDefaultKinds &defaultKinds) + const common::IntrinsicTypeDefaultKinds &defaultKinds) : defaultKinds_{defaultKinds}, intrinsics_{evaluate::IntrinsicProcTable::Configure(defaultKinds)}, foldingContext_{evaluate::FoldingContext{ diff --git a/flang/lib/semantics/semantics.h b/flang/lib/semantics/semantics.h index a7bfecd1e797..de974b5dfce2 100644 --- a/flang/lib/semantics/semantics.h +++ b/flang/lib/semantics/semantics.h @@ -23,6 +23,10 @@ #include #include +namespace Fortran::common { +class IntrinsicTypeDefaultKinds; +} + namespace Fortran::parser { struct Program; class CookedSource; @@ -30,13 +34,11 @@ class CookedSource; namespace Fortran::semantics { -class IntrinsicTypeDefaultKinds; - class SemanticsContext { public: - SemanticsContext(const IntrinsicTypeDefaultKinds &); + SemanticsContext(const common::IntrinsicTypeDefaultKinds &); - const IntrinsicTypeDefaultKinds &defaultKinds() const { + const common::IntrinsicTypeDefaultKinds &defaultKinds() const { return defaultKinds_; } const std::vector &searchDirectories() const { @@ -76,7 +78,7 @@ public: } private: - const IntrinsicTypeDefaultKinds &defaultKinds_; + const common::IntrinsicTypeDefaultKinds &defaultKinds_; std::vector searchDirectories_; std::string moduleDirectory_{"."s}; bool warningsAreErrors_{false}; diff --git a/flang/test/evaluate/intrinsics.cc b/flang/test/evaluate/intrinsics.cc index 933e261aa5ab..e9a6a36551e0 100644 --- a/flang/test/evaluate/intrinsics.cc +++ b/flang/test/evaluate/intrinsics.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. +// Copyright (c) 2018-2019, NVIDIA CORPORATION. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -135,7 +135,7 @@ struct TestCall { }; void TestIntrinsics() { - semantics::IntrinsicTypeDefaultKinds defaults; + common::IntrinsicTypeDefaultKinds defaults; MATCH(4, defaults.GetDefaultKind(TypeCategory::Integer)); MATCH(4, defaults.GetDefaultKind(TypeCategory::Real)); IntrinsicProcTable table{IntrinsicProcTable::Configure(defaults)}; diff --git a/flang/tools/f18/f18.cc b/flang/tools/f18/f18.cc index 60f5fa0ae277..b0959897a8fa 100644 --- a/flang/tools/f18/f18.cc +++ b/flang/tools/f18/f18.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. +// Copyright (c) 2018-2019, NVIDIA CORPORATION. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // Temporary Fortran front end driver main program for development scaffolding. +#include "../../lib/common/default-kinds.h" #include "../../lib/parser/characters.h" #include "../../lib/parser/features.h" #include "../../lib/parser/message.h" @@ -22,7 +23,6 @@ #include "../../lib/parser/parsing.h" #include "../../lib/parser/provenance.h" #include "../../lib/parser/unparse.h" -#include "../../lib/semantics/default-kinds.h" #include "../../lib/semantics/dump-parse-tree.h" #include "../../lib/semantics/expression.h" #include "../../lib/semantics/semantics.h" @@ -319,7 +319,7 @@ int main(int argc, char *const argv[]) { options.predefinitions.emplace_back("__F18_MINOR__", "1"); options.predefinitions.emplace_back("__F18_PATCHLEVEL__", "1"); - Fortran::semantics::IntrinsicTypeDefaultKinds defaultKinds; + Fortran::common::IntrinsicTypeDefaultKinds defaultKinds; std::vector fortranSources, otherSources, relocatables; bool anyFiles{false};