[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:
parent
5a3b1413f3
commit
f9d6c0a338
|
@ -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
|
||||
)
|
||||
|
||||
|
|
|
@ -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__
|
|
@ -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_
|
|
@ -20,7 +20,6 @@
|
|||
#include "../common/enum-set.h"
|
||||
#include "../common/fortran.h"
|
||||
#include "../common/idioms.h"
|
||||
#include "../semantics/default-kinds.h"
|
||||
#include <algorithm>
|
||||
#include <map>
|
||||
#include <ostream>
|
||||
|
@ -206,7 +205,7 @@ struct IntrinsicInterface {
|
|||
TypePattern result;
|
||||
Rank rank{Rank::elemental};
|
||||
std::optional<SpecificCall> 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<SpecificCall> 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<SpecificCall> 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<SpecificCall> Probe(const CallCharacteristics &,
|
||||
ActualArguments &, parser::ContextualMessages *) const;
|
||||
|
||||
semantics::IntrinsicTypeDefaultKinds defaults;
|
||||
common::IntrinsicTypeDefaultKinds defaults;
|
||||
std::multimap<std::string, const IntrinsicInterface *> genericFuncs;
|
||||
std::multimap<std::string, const SpecificIntrinsicInterface *> 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;
|
||||
|
|
|
@ -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 <optional>
|
||||
#include <ostream>
|
||||
|
||||
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 <set>
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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 <ostream>
|
||||
|
||||
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{
|
||||
|
|
|
@ -23,6 +23,10 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
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<std::string> &searchDirectories() const {
|
||||
|
@ -76,7 +78,7 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
const IntrinsicTypeDefaultKinds &defaultKinds_;
|
||||
const common::IntrinsicTypeDefaultKinds &defaultKinds_;
|
||||
std::vector<std::string> searchDirectories_;
|
||||
std::string moduleDirectory_{"."s};
|
||||
bool warningsAreErrors_{false};
|
||||
|
|
|
@ -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)};
|
||||
|
|
|
@ -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<std::string> fortranSources, otherSources, relocatables;
|
||||
bool anyFiles{false};
|
||||
|
|
Loading…
Reference in New Issue