[flang] Move default intrinsic type kinds from lib/semantics to lib/common

Original-commit: flang-compiler/f18@887e72dd61
Reviewed-on: https://github.com/flang-compiler/f18/pull/265
Tree-same-pre-rewrite: false
This commit is contained in:
peter klausler 2019-01-18 12:40:47 -08:00
parent 5a3b1413f3
commit f9d6c0a338
12 changed files with 35 additions and 37 deletions

View File

@ -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"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
@ -13,6 +13,7 @@
# limitations under the License. # limitations under the License.
add_library(FortranCommon add_library(FortranCommon
default-kinds.cc
idioms.cc idioms.cc
) )

View File

@ -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"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
@ -13,9 +13,9 @@
// limitations under the License. // limitations under the License.
#include "default-kinds.h" #include "default-kinds.h"
#include "../common/idioms.h" #include "idioms.h"
namespace Fortran::semantics { namespace Fortran::common {
IntrinsicTypeDefaultKinds::IntrinsicTypeDefaultKinds() { IntrinsicTypeDefaultKinds::IntrinsicTypeDefaultKinds() {
#if __x86_64__ #if __x86_64__

View File

@ -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"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with 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 // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#ifndef FORTRAN_DEFAULT_KINDS_H_ #ifndef FORTRAN_COMMON_DEFAULT_KINDS_H_
#define FORTRAN_DEFAULT_KINDS_H_ #define FORTRAN_COMMON_DEFAULT_KINDS_H_
#include "../common/fortran.h" #include "../common/fortran.h"
// Represent the default values of the kind parameters of the // Represent the default values of the kind parameters of the
// various intrinsic types. These can be configured by means of // various intrinsic types. These can be configured by means of
// the compiler command line. // the compiler command line.
namespace Fortran::semantics { namespace Fortran::common {
using Fortran::common::TypeCategory;
class IntrinsicTypeDefaultKinds { class IntrinsicTypeDefaultKinds {
public: public:
@ -56,4 +54,4 @@ private:
int defaultLogicalKind_{defaultIntegerKind_}; int defaultLogicalKind_{defaultIntegerKind_};
}; };
} }
#endif // FORTRAN_DEFAULT_KINDS_H_ #endif // FORTRAN_COMMON_DEFAULT_KINDS_H_

View File

@ -20,7 +20,6 @@
#include "../common/enum-set.h" #include "../common/enum-set.h"
#include "../common/fortran.h" #include "../common/fortran.h"
#include "../common/idioms.h" #include "../common/idioms.h"
#include "../semantics/default-kinds.h"
#include <algorithm> #include <algorithm>
#include <map> #include <map>
#include <ostream> #include <ostream>
@ -206,7 +205,7 @@ struct IntrinsicInterface {
TypePattern result; TypePattern result;
Rank rank{Rank::elemental}; Rank rank{Rank::elemental};
std::optional<SpecificCall> Match(const CallCharacteristics &, std::optional<SpecificCall> Match(const CallCharacteristics &,
const semantics::IntrinsicTypeDefaultKinds &, ActualArguments &, const common::IntrinsicTypeDefaultKinds &, ActualArguments &,
parser::ContextualMessages &messages) const; parser::ContextualMessages &messages) const;
std::ostream &Dump(std::ostream &) const; std::ostream &Dump(std::ostream &) const;
}; };
@ -757,7 +756,7 @@ static const SpecificIntrinsicInterface specificIntrinsicFunction[]{
// procedure reference. // procedure reference.
std::optional<SpecificCall> IntrinsicInterface::Match( std::optional<SpecificCall> IntrinsicInterface::Match(
const CallCharacteristics &call, const CallCharacteristics &call,
const semantics::IntrinsicTypeDefaultKinds &defaults, const common::IntrinsicTypeDefaultKinds &defaults,
ActualArguments &arguments, parser::ContextualMessages &messages) const { ActualArguments &arguments, parser::ContextualMessages &messages) const {
// Attempt to construct a 1-1 correspondence between the dummy arguments in // Attempt to construct a 1-1 correspondence between the dummy arguments in
// a particular intrinsic procedure's generic interface and the actual // a particular intrinsic procedure's generic interface and the actual
@ -1158,7 +1157,7 @@ std::optional<SpecificCall> IntrinsicInterface::Match(
} }
struct IntrinsicProcTable::Implementation { struct IntrinsicProcTable::Implementation {
explicit Implementation(const semantics::IntrinsicTypeDefaultKinds &dfts) explicit Implementation(const common::IntrinsicTypeDefaultKinds &dfts)
: defaults{dfts} { : defaults{dfts} {
for (const IntrinsicInterface &f : genericIntrinsicFunction) { for (const IntrinsicInterface &f : genericIntrinsicFunction) {
genericFuncs.insert(std::make_pair(std::string{f.name}, &f)); genericFuncs.insert(std::make_pair(std::string{f.name}, &f));
@ -1171,7 +1170,7 @@ struct IntrinsicProcTable::Implementation {
std::optional<SpecificCall> Probe(const CallCharacteristics &, std::optional<SpecificCall> Probe(const CallCharacteristics &,
ActualArguments &, parser::ContextualMessages *) const; ActualArguments &, parser::ContextualMessages *) const;
semantics::IntrinsicTypeDefaultKinds defaults; common::IntrinsicTypeDefaultKinds defaults;
std::multimap<std::string, const IntrinsicInterface *> genericFuncs; std::multimap<std::string, const IntrinsicInterface *> genericFuncs;
std::multimap<std::string, const SpecificIntrinsicInterface *> specificFuncs; std::multimap<std::string, const SpecificIntrinsicInterface *> specificFuncs;
std::ostream &Dump(std::ostream &) const; std::ostream &Dump(std::ostream &) const;
@ -1253,7 +1252,7 @@ IntrinsicProcTable::~IntrinsicProcTable() {
} }
IntrinsicProcTable IntrinsicProcTable::Configure( IntrinsicProcTable IntrinsicProcTable::Configure(
const semantics::IntrinsicTypeDefaultKinds &defaults) { const common::IntrinsicTypeDefaultKinds &defaults) {
IntrinsicProcTable result; IntrinsicProcTable result;
result.impl_ = new IntrinsicProcTable::Implementation(defaults); result.impl_ = new IntrinsicProcTable::Implementation(defaults);
return result; return result;

View File

@ -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"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
@ -16,9 +16,9 @@
#define FORTRAN_EVALUATE_INTRINSICS_H_ #define FORTRAN_EVALUATE_INTRINSICS_H_
#include "call.h" #include "call.h"
#include "../common/default-kinds.h"
#include "../parser/char-block.h" #include "../parser/char-block.h"
#include "../parser/message.h" #include "../parser/message.h"
#include "../semantics/default-kinds.h"
#include <optional> #include <optional>
#include <ostream> #include <ostream>
@ -43,7 +43,7 @@ private:
public: public:
~IntrinsicProcTable(); ~IntrinsicProcTable();
static IntrinsicProcTable Configure( static IntrinsicProcTable Configure(
const semantics::IntrinsicTypeDefaultKinds &); const common::IntrinsicTypeDefaultKinds &);
// Probe the intrinsics for a match against a specific call. // Probe the intrinsics for a match against a specific call.
// On success, the actual arguments are transferred to the result // On success, the actual arguments are transferred to the result

View File

@ -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"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
@ -18,7 +18,6 @@ add_library(FortranSemantics
attr.cc attr.cc
canonicalize-do.cc canonicalize-do.cc
check-do-concurrent.cc check-do-concurrent.cc
default-kinds.cc
expression.cc expression.cc
mod-file.cc mod-file.cc
resolve-labels.cc resolve-labels.cc

View File

@ -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"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
@ -16,7 +16,6 @@
#define FORTRAN_SEMANTICS_MOD_FILE_H_ #define FORTRAN_SEMANTICS_MOD_FILE_H_
#include "attr.h" #include "attr.h"
#include "default-kinds.h"
#include "resolve-names.h" #include "resolve-names.h"
#include "../parser/message.h" #include "../parser/message.h"
#include <set> #include <set>

View File

@ -14,7 +14,6 @@
#include "resolve-names.h" #include "resolve-names.h"
#include "attr.h" #include "attr.h"
#include "default-kinds.h"
#include "expression.h" #include "expression.h"
#include "mod-file.h" #include "mod-file.h"
#include "rewrite-parse-tree.h" #include "rewrite-parse-tree.h"
@ -22,6 +21,7 @@
#include "semantics.h" #include "semantics.h"
#include "symbol.h" #include "symbol.h"
#include "type.h" #include "type.h"
#include "../common/default-kinds.h"
#include "../common/fortran.h" #include "../common/fortran.h"
#include "../common/indirection.h" #include "../common/indirection.h"
#include "../evaluate/common.h" #include "../evaluate/common.h"

View File

@ -16,7 +16,6 @@
#include "assignment.h" #include "assignment.h"
#include "canonicalize-do.h" #include "canonicalize-do.h"
#include "check-do-concurrent.h" #include "check-do-concurrent.h"
#include "default-kinds.h"
#include "expression.h" #include "expression.h"
#include "mod-file.h" #include "mod-file.h"
#include "resolve-labels.h" #include "resolve-labels.h"
@ -24,6 +23,7 @@
#include "rewrite-parse-tree.h" #include "rewrite-parse-tree.h"
#include "scope.h" #include "scope.h"
#include "symbol.h" #include "symbol.h"
#include "../common/default-kinds.h"
#include <ostream> #include <ostream>
namespace Fortran::semantics { namespace Fortran::semantics {
@ -32,7 +32,7 @@ static void DoDumpSymbols(std::ostream &, const Scope &, int indent = 0);
static void PutIndent(std::ostream &, int indent); static void PutIndent(std::ostream &, int indent);
SemanticsContext::SemanticsContext( SemanticsContext::SemanticsContext(
const IntrinsicTypeDefaultKinds &defaultKinds) const common::IntrinsicTypeDefaultKinds &defaultKinds)
: defaultKinds_{defaultKinds}, : defaultKinds_{defaultKinds},
intrinsics_{evaluate::IntrinsicProcTable::Configure(defaultKinds)}, intrinsics_{evaluate::IntrinsicProcTable::Configure(defaultKinds)},
foldingContext_{evaluate::FoldingContext{ foldingContext_{evaluate::FoldingContext{

View File

@ -23,6 +23,10 @@
#include <string> #include <string>
#include <vector> #include <vector>
namespace Fortran::common {
class IntrinsicTypeDefaultKinds;
}
namespace Fortran::parser { namespace Fortran::parser {
struct Program; struct Program;
class CookedSource; class CookedSource;
@ -30,13 +34,11 @@ class CookedSource;
namespace Fortran::semantics { namespace Fortran::semantics {
class IntrinsicTypeDefaultKinds;
class SemanticsContext { class SemanticsContext {
public: public:
SemanticsContext(const IntrinsicTypeDefaultKinds &); SemanticsContext(const common::IntrinsicTypeDefaultKinds &);
const IntrinsicTypeDefaultKinds &defaultKinds() const { const common::IntrinsicTypeDefaultKinds &defaultKinds() const {
return defaultKinds_; return defaultKinds_;
} }
const std::vector<std::string> &searchDirectories() const { const std::vector<std::string> &searchDirectories() const {
@ -76,7 +78,7 @@ public:
} }
private: private:
const IntrinsicTypeDefaultKinds &defaultKinds_; const common::IntrinsicTypeDefaultKinds &defaultKinds_;
std::vector<std::string> searchDirectories_; std::vector<std::string> searchDirectories_;
std::string moduleDirectory_{"."s}; std::string moduleDirectory_{"."s};
bool warningsAreErrors_{false}; bool warningsAreErrors_{false};

View File

@ -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"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
@ -135,7 +135,7 @@ struct TestCall {
}; };
void TestIntrinsics() { void TestIntrinsics() {
semantics::IntrinsicTypeDefaultKinds defaults; common::IntrinsicTypeDefaultKinds defaults;
MATCH(4, defaults.GetDefaultKind(TypeCategory::Integer)); MATCH(4, defaults.GetDefaultKind(TypeCategory::Integer));
MATCH(4, defaults.GetDefaultKind(TypeCategory::Real)); MATCH(4, defaults.GetDefaultKind(TypeCategory::Real));
IntrinsicProcTable table{IntrinsicProcTable::Configure(defaults)}; IntrinsicProcTable table{IntrinsicProcTable::Configure(defaults)};

View File

@ -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"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with 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. // Temporary Fortran front end driver main program for development scaffolding.
#include "../../lib/common/default-kinds.h"
#include "../../lib/parser/characters.h" #include "../../lib/parser/characters.h"
#include "../../lib/parser/features.h" #include "../../lib/parser/features.h"
#include "../../lib/parser/message.h" #include "../../lib/parser/message.h"
@ -22,7 +23,6 @@
#include "../../lib/parser/parsing.h" #include "../../lib/parser/parsing.h"
#include "../../lib/parser/provenance.h" #include "../../lib/parser/provenance.h"
#include "../../lib/parser/unparse.h" #include "../../lib/parser/unparse.h"
#include "../../lib/semantics/default-kinds.h"
#include "../../lib/semantics/dump-parse-tree.h" #include "../../lib/semantics/dump-parse-tree.h"
#include "../../lib/semantics/expression.h" #include "../../lib/semantics/expression.h"
#include "../../lib/semantics/semantics.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_MINOR__", "1");
options.predefinitions.emplace_back("__F18_PATCHLEVEL__", "1"); options.predefinitions.emplace_back("__F18_PATCHLEVEL__", "1");
Fortran::semantics::IntrinsicTypeDefaultKinds defaultKinds; Fortran::common::IntrinsicTypeDefaultKinds defaultKinds;
std::vector<std::string> fortranSources, otherSources, relocatables; std::vector<std::string> fortranSources, otherSources, relocatables;
bool anyFiles{false}; bool anyFiles{false};