1 | //===-- lib/Common/Fortran-features.cpp -----------------------------------===// |
2 | // |
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 |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | #include "flang/Common/Fortran-features.h" |
10 | #include "flang/Common/Fortran.h" |
11 | #include "flang/Common/idioms.h" |
12 | |
13 | namespace Fortran::common { |
14 | |
15 | std::vector<const char *> LanguageFeatureControl::GetNames( |
16 | LogicalOperator opr) const { |
17 | std::vector<const char *> result; |
18 | result.push_back(AsFortran(opr)); |
19 | if (opr == LogicalOperator::Neqv && IsEnabled(LanguageFeature::XOROperator)) { |
20 | result.push_back(".xor." ); |
21 | } |
22 | if (IsEnabled(LanguageFeature::LogicalAbbreviations)) { |
23 | switch (opr) { |
24 | SWITCH_COVERS_ALL_CASES |
25 | case LogicalOperator::And: |
26 | result.push_back(".a." ); |
27 | break; |
28 | case LogicalOperator::Or: |
29 | result.push_back(".o." ); |
30 | break; |
31 | case LogicalOperator::Not: |
32 | result.push_back(".n." ); |
33 | break; |
34 | case LogicalOperator::Neqv: |
35 | if (IsEnabled(LanguageFeature::XOROperator)) { |
36 | result.push_back(".x." ); |
37 | } |
38 | break; |
39 | case LogicalOperator::Eqv: |
40 | break; |
41 | } |
42 | } |
43 | return result; |
44 | } |
45 | |
46 | std::vector<const char *> LanguageFeatureControl::GetNames( |
47 | RelationalOperator opr) const { |
48 | switch (opr) { |
49 | SWITCH_COVERS_ALL_CASES |
50 | case RelationalOperator::LT: |
51 | return {".lt." , "<" }; |
52 | case RelationalOperator::LE: |
53 | return {".le." , "<=" }; |
54 | case RelationalOperator::EQ: |
55 | return {".eq." , "==" }; |
56 | case RelationalOperator::GE: |
57 | return {".ge." , ">=" }; |
58 | case RelationalOperator::GT: |
59 | return {".gt." , ">" }; |
60 | case RelationalOperator::NE: |
61 | if (IsEnabled(LanguageFeature::AlternativeNE)) { |
62 | return {".ne." , "/=" , "<>" }; |
63 | } else { |
64 | return {".ne." , "/=" }; |
65 | } |
66 | } |
67 | } |
68 | |
69 | } // namespace Fortran::common |
70 | |