-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathifrchk.h
More file actions
151 lines (128 loc) · 5.77 KB
/
ifrchk.h
File metadata and controls
151 lines (128 loc) · 5.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/* ifrchk.h: procedures for detecting variable interference
*
* COPYRIGHT 2010. California Institute of Technology
*
* This file is part of chpsim.
*
* Chpsim is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version, and under the terms of the
* following disclaimer of liability:
*
* The California Institute of Technology shall allow RECIPIENT to use and
* distribute this software subject to the terms of the included license
* agreement with the understanding that:
*
* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE CALIFORNIA
* INSTITUTE OF TECHNOLOGY (CALTECH). THE SOFTWARE IS PROVIDED "AS-IS" TO THE
* RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY WARRANTIES OF
* PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE OR PURPOSE
* (AS SET FORTH IN UNITED STATES UCC Sect. 2312-2313) OR FOR ANY PURPOSE
* WHATSOEVER, FOR THE SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
*
* IN NO EVENT SHALL CALTECH BE LIABLE FOR ANY DAMAGES AND/OR COSTS,
* INCLUDING, BUT NOT LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY
* KIND, INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
* REGARDLESS OF WHETHER CALTECH BE ADVISED, HAVE REASON TO KNOW, OR, IN FACT,
* SHALL KNOW OF THE POSSIBILITY.
*
* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF THE
* SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY CALTECH FOR
* ALL THIRD-PARTY CLAIMS RESULTING FROM THE ACTIONS OF RECIPIENT IN THE
* USE OF THE SOFTWARE.
*
* In addition, RECIPIENT also agrees that Caltech is under no obligation to
* provide technical support for the Software.
*
* Finally, Caltech places no restrictions on RECIPIENT's use, preparation of
* Derivative Works, public display or redistribution of the Software other
* than those specified in the GNU General Public License and the requirement
* that all copies of the Software released be marked with the language
* provided in this notice.
*
* You should have received a copy of the GNU General Public License
* along with chpsim. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Chris Moore
*/
#ifndef IFRCHK_H
#define IFRCHK_H
#include <standard.h>
#include <llist.h>
#include <hash.h>
#include <var_string.h>
#include "parse_obj.h"
#include "print.h"
#include "interact.h"
#include "exec.h"
FLAGS(ifrchk_var_flags)
{ FIRST_FLAG(IFRVAR_read), /* set if var is read in current thread */
NEXT_FLAG(IFRVAR_write), /* set if var is written in current thread */
NEXT_FLAG(IFRVAR_pread), /* set if var was read in previous thread */
NEXT_FLAG(IFRVAR_pwrite), /* set if var was written in previous thread */
NEXT_FLAG(IFRVAR_rw), /* set if var needs read-write checking */
NEXT_FLAG(IFRVAR_ww) /* set if var needs write-write checking */
};
typedef struct ifrchk_var
{ ifrchk_var_flags flags;
int write_idx;
} ifrchk_var;
FLAGS(ifrchk_flags)
{ FIRST_FLAG(IFRCHK_set), /* indicates a second pass to set EXPR_ifrchk */
NEXT_FLAG(IFRCHK_assign), /* set if current expr is being written to */
NEXT_FLAG(IFRCHK_haschk), /* set if current chp body needs checking */
NEXT_FLAG(IFRCHK_volstmt) /* set if current stmt needs volatile checking */
};
typedef struct ifrchk_info
{ ifrchk_flags flags;
int nr_var, thread_idx;
ifrchk_var *var;
} ifrchk_info;
extern void ifrchk_setup(user_info *f);
/* Compile time check to see which statements need
* runtime interference checks
*/
extern int app_ifrchk;
#define set_ifrchk(C) set_app(CLASS_ ## C, app_ifrchk, (obj_func*)ifrchk_ ## C)
/* To set ifrchk_abc as ifrchk function for class abc */
#define set_ifrchk_cp(C,D) \
set_app(CLASS_ ## C, app_ifrchk, (obj_func*)ifrchk_ ## D)
/* Used if C is a copy of D, and uses the same ifrchk function */
/********** strict checks ***************************************************/
#define IS_PARALLEL_STMT(S) \
(((S)->class == CLASS_parallel_stmt \
|| ((S)->class == CLASS_rep_stmt && ((rep_stmt*)(S))->rep_sym == ',')) \
&& IS_SET((S)->flags, EXPR_ifrchk))
/* The above should match exactly the set of statements which call
* strict_check_frame_end/update as part of their pop method.
*/
extern void strict_check_init(process_state *ps, exec_info *f);
extern void strict_check_term(process_state *ps, exec_info *f);
extern void strict_check_read(value_tp *v, exec_info *f);
extern void strict_check_read_elem(value_tp *v, exec_info *f);
/* To be called when one or more elements of v will be read */
extern void strict_check_read_bits(value_tp *v, int l, int h, exec_info *f);
/* To be called when reading bits l through h of integer v */
extern void strict_check_write(value_tp *v, exec_info *f);
extern void strict_check_write_elem(value_tp *v, exec_info *f);
/* To be called when one or more elements of v will be written */
extern void strict_check_write_bits(value_tp *v, int l, int h, exec_info *f);
/* To be called when writing bits l through h of integer v */
extern void strict_check_delete(value_tp *v, exec_info *f);
/* Upon ending a function/routine call, use this to remove
* all f->prev->var[i] for all i
* OBSOLETE because stric checking is no longer performed inside of
* function/routine calls.
*/
extern void strict_check_frame_end(exec_info *f);
/* Pre: f->prev has ended sequential operations and popped the
* parallel statement f->curr
*/
extern void strict_check_update(ctrl_state *cs, exec_info *f);
/* This should be called after cs has completed a parallel statement
* (i.e. all children of cs have terminated)
*/
extern void init_ifrchk(int app1);
/* call at startup; pass unused object app indices */
#endif /* IFRCHK_H */