1 /* file "mark_io.cc" of the fixfortran program for SUIF */
3 /* Copyright (c) 1994 Stanford University
7 This software is provided under the terms described in
8 the "suif_copyright.h" include file. */
10 #include <suif_copyright.h>
13 * This file contains code to mark call instructions that do Fortran
14 * I/O as either input or output.
17 #define RCS_BASE_FILE mark_io_cc
19 #include "fixfortran.h"
23 "$Id: mark_io.cc,v 1.1.1.1 1998/06/16 15:17:25 brm Exp $")
25 /*----------------------------------------------------------------------*
26 Begin Type Declarations
27 *----------------------------------------------------------------------*/
29 /*----------------------------------------------------------------------*
31 *----------------------------------------------------------------------*/
32 /*----------------------------------------------------------------------*
33 Begin Private Function Declarations
34 *----------------------------------------------------------------------*/
36 /*----------------------------------------------------------------------*
37 End Private Function Declarations
38 *----------------------------------------------------------------------*/
39 /*----------------------------------------------------------------------*
40 Begin Public Function Implementations
41 *----------------------------------------------------------------------*/
43 extern void mark_io_on_list(tree_node_list
*node_list
)
45 static boolean is_read
= FALSE
;
46 static boolean is_write
= FALSE
;
48 tree_node_list_iter
node_iter(node_list
);
49 while (!node_iter
.is_empty())
51 tree_node
*this_node
= node_iter
.step();
52 switch (this_node
->kind())
56 tree_instr
*the_tree_instr
= (tree_instr
*)this_node
;
57 instruction
*the_instr
= the_tree_instr
->instr();
58 if (the_instr
->opcode() != io_cal
)
60 in_cal
*the_call
= (in_cal
*)the_instr
;
61 proc_sym
*the_proc
= proc_for_call(the_call
);
64 const char *pname
= the_proc
->name();
65 if ((strcmp(pname
, "do_fio") == 0) ||
66 (strcmp(pname
, "do_lio") == 0) ||
67 (strcmp(pname
, "do_uio") == 0))
69 assert(is_read
|| is_write
);
71 the_call
->append_annote(k_io_read
);
73 the_call
->append_annote(k_io_write
);
75 else if ((strlen(pname
) == 6) && (pname
[1] == '_'))
79 boolean closed
= FALSE
;
80 if (strcmp(&(pname
[3]), "sne") == 0)
88 the_call
->append_annote(k_io_read
);
90 else if (pname
[2] == 'w')
96 the_call
->append_annote(k_io_write
);
99 else if (pname
[0] == 'e')
104 the_call
->append_annote(k_io_read
);
107 else if (pname
[2] == 'w')
110 the_call
->append_annote(k_io_write
);
119 tree_loop
*the_loop
= (tree_loop
*)this_node
;
120 mark_io_on_list(the_loop
->body());
121 mark_io_on_list(the_loop
->test());
126 tree_for
*the_for
= (tree_for
*)this_node
;
127 mark_io_on_list(the_for
->body());
128 mark_io_on_list(the_for
->landing_pad());
133 tree_if
*the_if
= (tree_if
*)this_node
;
134 mark_io_on_list(the_if
->header());
135 mark_io_on_list(the_if
->then_part());
136 mark_io_on_list(the_if
->else_part());
141 tree_block
*the_block
= (tree_block
*)this_node
;
142 mark_io_on_list(the_block
->body());
151 /*----------------------------------------------------------------------*
152 End Public Function Implementations
153 *----------------------------------------------------------------------*/
154 /*----------------------------------------------------------------------*
155 Begin Private Function Implementations
156 *----------------------------------------------------------------------*/
158 /*----------------------------------------------------------------------*
159 End Private Function Implementations
160 *----------------------------------------------------------------------*/