1 /* 2 * Copyright (c) 1993-2018, NVIDIA CORPORATION. All rights reserved. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 * 16 */ 17 18 #ifndef DIRECT_H_ 19 #define DIRECT_H_ 20 21 /** 22 \file 23 \brief directive/pragma data structures. 24 */ 25 26 #include "gbldefs.h" 27 #include "error.h" 28 #include "global.h" 29 #include "symtab.h" 30 #include <stdio.h> 31 32 #ifdef FE90 33 /* INDEPENDENT information */ 34 typedef struct _newvar_ { 35 int var; 36 struct _newvar_ *next; 37 } NEWVAR; 38 39 typedef struct _reducvar_ { 40 int var; /* REDUCTION variable */ 41 int newvar; /* INDEP loop's copy of REDUCTION variable */ 42 struct _reducvar_ *next; 43 } REDUCVAR; 44 45 typedef struct _reduc_ja_spec {/* HPF/JA REDUCTION clause item */ 46 int var; /* reduction variable */ 47 int newvar; /* INDEP loop's copy of reduction variable */ 48 int nlocvars; /* number of location variables */ 49 REDUCVAR *locvar_list; /* [ / location variable list / ] */ 50 struct _reduc_ja_spec *next; 51 } REDUC_JA_SPEC; 52 53 typedef struct _reduc_ja { /* HPF/JA REDUCTION clause (with reduc-op) */ 54 int opr; /* if != 0, OP_xxx value */ 55 int intrin; /* if != 0, sptr to intrinsic */ 56 REDUC_JA_SPEC *speclist; /* list of reduction variables */ 57 struct _reduc_ja *next; 58 } REDUC_JA; 59 60 typedef struct { 61 NEWVAR *new_list; 62 int onhome; 63 REDUCVAR *reduction_list; 64 REDUC_JA *reduction_ja_list; 65 NEWVAR *index_list; 66 } INDEP_INFO; 67 68 typedef struct _hpf2_on_info_ { 69 NEWVAR *new_list; 70 int onhome; 71 int block; /* if == 0, simple on dir */ 72 struct _hpf2_on_info_ *next; 73 } HPF2_ON_INFO; 74 75 typedef struct _index_reuse_ {/* contents of one INDEX_REUSE directive */ 76 int condvar; /* if != 0, sptr to scalar logical temporary 77 storing the 'index reuse condition' */ 78 NEWVAR *reuse_list; /* list of array variables in INDEX_REUSE */ 79 struct _index_reuse_ *next; 80 } INDEX_REUSE; 81 82 #endif // FE90 83 84 typedef struct { 85 /* NOTES: 86 * 1. all members must be int 87 * 2. any additions/modifications imply load_dirset() and store_dirset() 88 * in direct.c, and set_flg() in pragma.c, must be modified. 89 * 3. set_flg() cares about the order in which the members occur. 90 * 4. the member x must be the last member in this structure. 91 * DIRSET_XFLAG is x's offset (in units of ints) from the beginning 92 * of the structure. 93 */ 94 int opt; 95 int vect; 96 int depchk; 97 int fcon; /* C-only, but always declared */ 98 int single; /* C-only, but always declared */ 99 int tpvalue[TPNVERSION]; /* target processor(s), for unified binary */ 100 int x[sizeof(flg.x) / sizeof(int)]; /* same as flg.x[...] */ 101 } DIRSET; 102 103 #define DIRSET_XFLAG 15 104 105 typedef struct lpprg_ {/* pragma information for loops */ 106 int beg_line; /* beginning line # of loop */ 107 int end_line; /* ending line # of loop */ 108 DIRSET dirset; /* dirset for the loop */ 109 #ifdef FE90 110 INDEP_INFO *indep; /* locates a loop's INDEP_INFO */ 111 INDEX_REUSE *index_reuse_list; /* locates a loop's INDEX_REUSE */ 112 #endif 113 } LPPRG; 114 115 typedef struct {/* loop pragma stack */ 116 int dirx; /* index into lpg of the loop's dirset */ 117 } LPG_STK; 118 119 /** \brief Directive structure 120 */ 121 typedef struct { 122 DIRSET gbl; /**< Holding area for global-scoped pragmas */ 123 DIRSET rou; /**< Holding area for routine-scoped pragmas */ 124 DIRSET loop; /**< Holding area for loop-scoped pragmas */ 125 DIRSET rou_begin; /**< Pragmas which apply to the beginning of a routine. 126 * For C, this structure must be saved away for each 127 * function appearing in the source file. 128 */ 129 bool loop_flag; /**< Seen pragma with loop scope */ 130 bool in_loop; /**< Currently in loop with pragmas */ 131 bool carry_fwd; /**< If global/routine pragma seen, must be carried 132 * forward to all outer loops which follow in the 133 * routine. 134 */ 135 /** 136 * for C, need to allocate a DIRSET for each function -- is located 137 * by the function's ENTRY aux structure and is assigned by dir_rou_end(). 138 * 139 * for C & Fortran, need to allocate a DIRSET for a loop which has 140 * pragmas associated with it. 141 */ 142 DIRSET *stgb; 143 int size; 144 int avail; 145 /** 146 * for C & Fortran, each function is associated with a set of 147 * loop pragma information. The set is organized as a table 148 * and will be ordered according to occurrence of loops (with 149 * associated pragmas) in the function. 150 */ 151 struct { 152 LPPRG *stgb; 153 int size; 154 int avail; 155 } lpg; 156 struct { 157 LPG_STK *stgb; 158 int size; 159 int top; 160 } lpg_stk; 161 #ifdef FE90 162 struct { 163 LPPRG *stgb; 164 int size; 165 int avail; 166 } dynlpg; 167 INDEP_INFO *indep; /**< Locates where to record an INDEPENDENT's INDEP_INFO 168 * while processing the INDEPENDENT statement; 169 * locates a loop's INDEP_INFO structure after 170 * a call to open_pragma() 171 */ 172 INDEX_REUSE *index_reuse_list; /**< Likewise for an INDEX_REUSE structure */ 173 #endif 174 } DIRECT; 175 176 extern DIRECT direct; 177 178 #ifdef FE90 179 void open_dynpragma(int, int); /* ilidir.h */ 180 void save_dynpragma(int); 181 void direct_loop_save(void); 182 #endif 183 184 void direct_export(FILE *ff); 185 186 /** 187 \brief ... 188 */ 189 int direct_import(FILE *ff); 190 191 /** 192 \brief ... 193 */ 194 void direct_fini(void); 195 196 /** 197 \brief ... 198 */ 199 void direct_init(void); 200 201 /** 202 \brief ... 203 */ 204 void direct_loop_end(int beg_line, int end_line); 205 206 /** 207 \brief ... 208 */ 209 void direct_loop_enter(void); 210 211 /** 212 \brief ... 213 */ 214 void direct_rou_end(void); 215 216 /** 217 \brief ... 218 */ 219 void direct_rou_load(int func); 220 221 /** 222 \brief ... 223 */ 224 void direct_rou_setopt(int func, int opt); 225 226 /** 227 \brief ... 228 */ 229 void direct_xf(char *fn, int x, int v); 230 231 /** 232 \brief ... 233 */ 234 void direct_yf(char *fn, int x, int v); 235 236 /** 237 \brief ... 238 */ 239 void dirset_options(bool restore); 240 241 /** 242 \brief ... 243 */ 244 void load_dirset(DIRSET *currdir); 245 246 /** 247 \brief ... 248 */ 249 void store_dirset(DIRSET *currdir); 250 251 #endif // DIRECT_H_ 252