• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===-- Lower/IO.h -- lower I/O statements ----------------------*- C++ -*-===//
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 #ifndef FORTRAN_LOWER_IO_H
10 #define FORTRAN_LOWER_IO_H
11 
12 #include "flang/Common/reference.h"
13 #include "flang/Semantics/symbol.h"
14 #include "llvm/ADT/DenseMap.h"
15 #include "llvm/ADT/SmallSet.h"
16 
17 namespace mlir {
18 class Value;
19 } // namespace mlir
20 
21 namespace Fortran {
22 namespace parser {
23 using Label = std::uint64_t;
24 struct BackspaceStmt;
25 struct CloseStmt;
26 struct EndfileStmt;
27 struct FlushStmt;
28 struct InquireStmt;
29 struct OpenStmt;
30 struct PrintStmt;
31 struct ReadStmt;
32 struct RewindStmt;
33 struct WaitStmt;
34 struct WriteStmt;
35 } // namespace parser
36 
37 namespace lower {
38 
39 class AbstractConverter;
40 class BridgeImpl;
41 
42 namespace pft {
43 struct Evaluation;
44 using LabelEvalMap = llvm::DenseMap<Fortran::parser::Label, Evaluation *>;
45 using SymbolRef = Fortran::common::Reference<const Fortran::semantics::Symbol>;
46 using LabelSet = llvm::SmallSet<Fortran::parser::Label, 5>;
47 using SymbolLabelMap = llvm::DenseMap<SymbolRef, LabelSet>;
48 } // namespace pft
49 
50 /// Generate IO call(s) for BACKSPACE; return the IOSTAT code
51 mlir::Value genBackspaceStatement(AbstractConverter &,
52                                   const parser::BackspaceStmt &);
53 
54 /// Generate IO call(s) for CLOSE; return the IOSTAT code
55 mlir::Value genCloseStatement(AbstractConverter &, const parser::CloseStmt &);
56 
57 /// Generate IO call(s) for ENDFILE; return the IOSTAT code
58 mlir::Value genEndfileStatement(AbstractConverter &,
59                                 const parser::EndfileStmt &);
60 
61 /// Generate IO call(s) for FLUSH; return the IOSTAT code
62 mlir::Value genFlushStatement(AbstractConverter &, const parser::FlushStmt &);
63 
64 /// Generate IO call(s) for INQUIRE; return the IOSTAT code
65 mlir::Value genInquireStatement(AbstractConverter &,
66                                 const parser::InquireStmt &);
67 
68 /// Generate IO call(s) for OPEN; return the IOSTAT code
69 mlir::Value genOpenStatement(AbstractConverter &, const parser::OpenStmt &);
70 
71 /// Generate IO call(s) for PRINT
72 void genPrintStatement(AbstractConverter &converter,
73                        const parser::PrintStmt &stmt,
74                        pft::LabelEvalMap &labelMap,
75                        pft::SymbolLabelMap &assignMap);
76 
77 /// Generate IO call(s) for READ; return the IOSTAT code
78 mlir::Value genReadStatement(AbstractConverter &converter,
79                              const parser::ReadStmt &stmt,
80                              pft::LabelEvalMap &labelMap,
81                              pft::SymbolLabelMap &assignMap);
82 
83 /// Generate IO call(s) for REWIND; return the IOSTAT code
84 mlir::Value genRewindStatement(AbstractConverter &, const parser::RewindStmt &);
85 
86 /// Generate IO call(s) for WAIT; return the IOSTAT code
87 mlir::Value genWaitStatement(AbstractConverter &, const parser::WaitStmt &);
88 
89 /// Generate IO call(s) for WRITE; return the IOSTAT code
90 mlir::Value genWriteStatement(AbstractConverter &converter,
91                               const parser::WriteStmt &stmt,
92                               pft::LabelEvalMap &labelMap,
93                               pft::SymbolLabelMap &assignMap);
94 
95 } // namespace lower
96 } // namespace Fortran
97 
98 #endif // FORTRAN_LOWER_IO_H
99