2020-02-25 23:11:52 +08:00
|
|
|
//===-- lib/Common/Fortran.cpp --------------------------------------------===//
|
2019-11-03 00:56:46 +08:00
|
|
|
//
|
2019-12-21 04:52:07 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2019-11-03 00:56:46 +08:00
|
|
|
//
|
2020-01-11 04:12:03 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
2019-11-03 00:56:46 +08:00
|
|
|
|
2020-02-25 23:11:52 +08:00
|
|
|
#include "flang/Common/Fortran.h"
|
2019-11-03 00:56:46 +08:00
|
|
|
|
|
|
|
namespace Fortran::common {
|
|
|
|
|
|
|
|
const char *AsFortran(NumericOperator opr) {
|
|
|
|
switch (opr) {
|
|
|
|
SWITCH_COVERS_ALL_CASES
|
2020-03-29 12:00:16 +08:00
|
|
|
case NumericOperator::Power:
|
|
|
|
return "**";
|
|
|
|
case NumericOperator::Multiply:
|
|
|
|
return "*";
|
|
|
|
case NumericOperator::Divide:
|
|
|
|
return "/";
|
|
|
|
case NumericOperator::Add:
|
|
|
|
return "+";
|
|
|
|
case NumericOperator::Subtract:
|
|
|
|
return "-";
|
2019-11-03 00:56:46 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *AsFortran(LogicalOperator opr) {
|
|
|
|
switch (opr) {
|
|
|
|
SWITCH_COVERS_ALL_CASES
|
2020-03-29 12:00:16 +08:00
|
|
|
case LogicalOperator::And:
|
|
|
|
return ".and.";
|
|
|
|
case LogicalOperator::Or:
|
|
|
|
return ".or.";
|
|
|
|
case LogicalOperator::Eqv:
|
|
|
|
return ".eqv.";
|
|
|
|
case LogicalOperator::Neqv:
|
|
|
|
return ".neqv.";
|
|
|
|
case LogicalOperator::Not:
|
|
|
|
return ".not.";
|
2019-11-03 00:56:46 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *AsFortran(RelationalOperator opr) {
|
|
|
|
switch (opr) {
|
|
|
|
SWITCH_COVERS_ALL_CASES
|
2020-03-29 12:00:16 +08:00
|
|
|
case RelationalOperator::LT:
|
|
|
|
return "<";
|
|
|
|
case RelationalOperator::LE:
|
|
|
|
return "<=";
|
|
|
|
case RelationalOperator::EQ:
|
|
|
|
return "==";
|
|
|
|
case RelationalOperator::NE:
|
|
|
|
return "/=";
|
|
|
|
case RelationalOperator::GE:
|
|
|
|
return ">=";
|
|
|
|
case RelationalOperator::GT:
|
|
|
|
return ">";
|
2019-11-03 00:56:46 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-29 12:00:16 +08:00
|
|
|
} // namespace Fortran::common
|