summaryrefslogtreecommitdiff
path: root/flang
diff options
context:
space:
mode:
authorpeter klausler <pklausler@nvidia.com>2018-10-05 09:57:53 -0700
committerpeter klausler <pklausler@nvidia.com>2018-10-12 16:02:31 -0700
commit75a32097fd6eddb0eb7e701ba38e36cc406812d4 (patch)
treedb8b57b2f465dd4c0417d3217c037c4661850e8b /flang
parenta70f596719ef0ad97a73c265e2c1a1c2db67b99e (diff)
downloadllvm-75a32097fd6eddb0eb7e701ba38e36cc406812d4.tar.gz
[flang] checkpoint
Original-commit: flang-compiler/f18@e103152671f6f1a03417a265bbf581ec50b42d81 Reviewed-on: https://github.com/flang-compiler/f18/pull/212 Tree-same-pre-rewrite: false
Diffstat (limited to 'flang')
-rw-r--r--flang/lib/evaluate/intrinsics.cc31
-rw-r--r--flang/lib/evaluate/intrinsics.h5
2 files changed, 30 insertions, 6 deletions
diff --git a/flang/lib/evaluate/intrinsics.cc b/flang/lib/evaluate/intrinsics.cc
index d36868a8f54b..1efadd86a2d7 100644
--- a/flang/lib/evaluate/intrinsics.cc
+++ b/flang/lib/evaluate/intrinsics.cc
@@ -807,11 +807,36 @@ struct IntrinsicTable::Implementation {
}
}
+ std::optional<SpecificIntrinsic> Probe(const CallCharacteristics &) const;
+
semantics::IntrinsicTypeDefaultKinds defaults;
std::multimap<std::string, const IntrinsicInterface *> genericFuncs;
std::multimap<std::string, const SpecificIntrinsicInterface *> specificFuncs;
};
+std::optional<SpecificIntrinsic> IntrinsicTable::Implementation::Probe(
+ const CallCharacteristics &call) const {
+ if (call.isSubroutineCall) {
+ return std::nullopt; // TODO
+ }
+ // Probe the specific intrinsic functions first.
+ std::string name{call.name.ToString()};
+ auto specificRange{specificFuncs.equal_range(name)};
+ for (auto iter{specificRange.first}; iter != specificRange.second; ++iter) {
+ if (auto specific{iter->second->Match(call, defaults)}) {
+ specific->name = iter->second->generic;
+ return specific;
+ }
+ }
+ auto genericRange{specificFuncs.equal_range(name)};
+ for (auto iter{genericRange.first}; iter != genericRange.second; ++iter) {
+ if (auto specific{iter->second->Match(call, defaults)}) {
+ return specific;
+ }
+ }
+ return std::nullopt;
+}
+
IntrinsicTable::~IntrinsicTable() {
delete impl_;
impl_ = nullptr;
@@ -825,10 +850,8 @@ IntrinsicTable IntrinsicTable::Configure(
}
std::optional<SpecificIntrinsic> IntrinsicTable::Probe(
- const CallCharacteristics &call) {
+ const CallCharacteristics &call) const {
CHECK(impl_ != nullptr || !"IntrinsicTable: not configured");
- if (call.isSubroutineCall) {
- return std::nullopt; // TODO
- }
+ return impl_->Probe(call);
}
} // namespace Fortran::evaluate
diff --git a/flang/lib/evaluate/intrinsics.h b/flang/lib/evaluate/intrinsics.h
index 97bc3ed7b828..f019f774fc27 100644
--- a/flang/lib/evaluate/intrinsics.h
+++ b/flang/lib/evaluate/intrinsics.h
@@ -49,6 +49,7 @@ struct CallCharacteristics {
};
struct SpecificIntrinsic {
+ // SpecificIntrinsic(SpecificIntrinsic &&) = default;
explicit SpecificIntrinsic(const char *n) : name{n} {}
SpecificIntrinsic(const char *n, bool isElem, DynamicType dt, int r)
: name{n}, isElemental{isElem}, type{dt}, rank{r} {}
@@ -65,10 +66,10 @@ private:
public:
~IntrinsicTable();
static IntrinsicTable Configure(const semantics::IntrinsicTypeDefaultKinds &);
- std::optional<SpecificIntrinsic> Probe(const CallCharacteristics &);
+ std::optional<SpecificIntrinsic> Probe(const CallCharacteristics &) const;
private:
- Implementation *impl_{nullptr};
+ Implementation *impl_{nullptr}; // owning pointer
};
} // namespace Fortran::evaluate
#endif // FORTRAN_EVALUATE_INTRINSICS_H_