a few more warnings
[suif.git] / src / basesuif / fixfortran / mark_io.cc
blob192a6570947b5284cacb9882e762c8775d109eb5
1 /* file "mark_io.cc" of the fixfortran program for SUIF */
3 /* Copyright (c) 1994 Stanford University
5 All rights reserved.
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"
20 #include <string.h>
22 RCS_BASE(
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 /*----------------------------------------------------------------------*
30 End Type Declarations
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())
54 case TREE_INSTR:
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)
59 break;
60 in_cal *the_call = (in_cal *)the_instr;
61 proc_sym *the_proc = proc_for_call(the_call);
62 if (the_proc == NULL)
63 break;
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);
70 if (is_read)
71 the_call->append_annote(k_io_read);
72 else
73 the_call->append_annote(k_io_write);
75 else if ((strlen(pname) == 6) && (pname[1] == '_'))
77 if (pname[0] == 's')
79 boolean closed = FALSE;
80 if (strcmp(&(pname[3]), "sne") == 0)
81 closed = TRUE;
82 if (pname[2] == 'r')
84 assert(!is_read);
85 assert(!is_write);
86 if (!closed)
87 is_read = TRUE;
88 the_call->append_annote(k_io_read);
90 else if (pname[2] == 'w')
92 assert(!is_read);
93 assert(!is_write);
94 if (!closed)
95 is_write = TRUE;
96 the_call->append_annote(k_io_write);
99 else if (pname[0] == 'e')
101 if (pname[2] == 'r')
103 assert(is_read);
104 the_call->append_annote(k_io_read);
105 is_read = FALSE;
107 else if (pname[2] == 'w')
109 assert(is_write);
110 the_call->append_annote(k_io_write);
111 is_write = FALSE;
115 break;
117 case TREE_LOOP:
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());
122 break;
124 case TREE_FOR:
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());
129 break;
131 case TREE_IF:
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());
137 break;
139 case TREE_BLOCK:
141 tree_block *the_block = (tree_block *)this_node;
142 mark_io_on_list(the_block->body());
143 break;
145 default:
146 assert(FALSE);
151 /*----------------------------------------------------------------------*
152 End Public Function Implementations
153 *----------------------------------------------------------------------*/
154 /*----------------------------------------------------------------------*
155 Begin Private Function Implementations
156 *----------------------------------------------------------------------*/
158 /*----------------------------------------------------------------------*
159 End Private Function Implementations
160 *----------------------------------------------------------------------*/