1 //===-- lib/Common/Fortran.cpp --------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "flang/Common/Fortran.h"
11 namespace Fortran::common
{
13 const char *AsFortran(NumericOperator opr
) {
15 SWITCH_COVERS_ALL_CASES
16 case NumericOperator::Power
:
18 case NumericOperator::Multiply
:
20 case NumericOperator::Divide
:
22 case NumericOperator::Add
:
24 case NumericOperator::Subtract
:
29 const char *AsFortran(LogicalOperator opr
) {
31 SWITCH_COVERS_ALL_CASES
32 case LogicalOperator::And
:
34 case LogicalOperator::Or
:
36 case LogicalOperator::Eqv
:
38 case LogicalOperator::Neqv
:
40 case LogicalOperator::Not
:
45 const char *AsFortran(RelationalOperator opr
) {
47 SWITCH_COVERS_ALL_CASES
48 case RelationalOperator::LT
:
50 case RelationalOperator::LE
:
52 case RelationalOperator::EQ
:
54 case RelationalOperator::NE
:
56 case RelationalOperator::GE
:
58 case RelationalOperator::GT
:
63 const char *AsFortran(DefinedIo x
) {
65 SWITCH_COVERS_ALL_CASES
66 case DefinedIo::ReadFormatted
:
67 return "read(formatted)";
68 case DefinedIo::ReadUnformatted
:
69 return "read(unformatted)";
70 case DefinedIo::WriteFormatted
:
71 return "write(formatted)";
72 case DefinedIo::WriteUnformatted
:
73 return "write(unformatted)";
77 std::string
AsFortran(IgnoreTKRSet tkr
) {
79 if (tkr
.test(IgnoreTKR::Type
)) {
82 if (tkr
.test(IgnoreTKR::Kind
)) {
85 if (tkr
.test(IgnoreTKR::Rank
)) {
88 if (tkr
.test(IgnoreTKR::Device
)) {
91 if (tkr
.test(IgnoreTKR::Managed
)) {
94 if (tkr
.test(IgnoreTKR::Contiguous
)) {
100 bool AreCompatibleCUDADataAttrs(std::optional
<CUDADataAttr
> x
,
101 std::optional
<CUDADataAttr
> y
, IgnoreTKRSet ignoreTKR
) {
104 } else if (x
&& y
&& *x
== *y
) {
106 } else if (ignoreTKR
.test(IgnoreTKR::Device
) &&
107 x
.value_or(CUDADataAttr::Device
) == CUDADataAttr::Device
&&
108 y
.value_or(CUDADataAttr::Device
) == CUDADataAttr::Device
) {
110 } else if (ignoreTKR
.test(IgnoreTKR::Managed
) &&
111 x
.value_or(CUDADataAttr::Managed
) == CUDADataAttr::Managed
&&
112 y
.value_or(CUDADataAttr::Managed
) == CUDADataAttr::Managed
) {
119 } // namespace Fortran::common