1//===- FrontendOptions.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// Coding style: https://mlir.llvm.org/getting_started/DeveloperGuide/
10//
11//===----------------------------------------------------------------------===//
12
13#include "flang/Frontend/FrontendOptions.h"
14
15using namespace Fortran::frontend;
16
17bool Fortran::frontend::isFixedFormSuffix(llvm::StringRef suffix) {
18 // Note: Keep this list in-sync with flang/test/lit.cfg.py
19 return suffix == "f77" || suffix == "f" || suffix == "F" || suffix == "ff" ||
20 suffix == "for" || suffix == "FOR" || suffix == "fpp" ||
21 suffix == "FPP";
22}
23
24bool Fortran::frontend::isFreeFormSuffix(llvm::StringRef suffix) {
25 // Note: Keep this list in-sync with flang/test/lit.cfg.py
26 return suffix == "f90" || suffix == "F90" || suffix == "ff90" ||
27 suffix == "f95" || suffix == "F95" || suffix == "ff95" ||
28 suffix == "f03" || suffix == "F03" || suffix == "f08" ||
29 suffix == "F08" || suffix == "f18" || suffix == "F18" ||
30 suffix == "cuf" || suffix == "CUF";
31}
32
33bool Fortran::frontend::isToBePreprocessed(llvm::StringRef suffix) {
34 return suffix == "F" || suffix == "FOR" || suffix == "fpp" ||
35 suffix == "FPP" || suffix == "F90" || suffix == "F95" ||
36 suffix == "F03" || suffix == "F08" || suffix == "F18" ||
37 suffix == "CUF";
38}
39
40bool Fortran::frontend::isCUDAFortranSuffix(llvm::StringRef suffix) {
41 return suffix == "cuf" || suffix == "CUF";
42}
43
44InputKind FrontendOptions::getInputKindForExtension(llvm::StringRef extension) {
45 if (isFixedFormSuffix(extension) || isFreeFormSuffix(extension)) {
46 return Language::Fortran;
47 }
48
49 if (extension == "bc" || extension == "ll")
50 return Language::LLVM_IR;
51 if (extension == "fir" || extension == "mlir")
52 return Language::MLIR;
53
54 return Language::Unknown;
55}
56

source code of flang/lib/Frontend/FrontendOptions.cpp