00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #ifndef dra_internal_INCLUDED
00037 #define dra_internal_INCLUDED
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179 #ifndef defs_INCLUDED
00180 #include "defs.h"
00181 #endif
00182
00183 #ifndef pragmas_INCLUDED
00184 #include "wn_pragmas.h"
00185 #endif
00186
00187 #ifndef CXX_MEMORY_INCLUDED
00188 #include "cxx_memory.h"
00189 #endif
00190
00191 #ifndef cxx_hash_INCLUDED
00192 #include "cxx_hash.h"
00193 #endif
00194
00195
00196 #ifndef cxx_base_INCLUDED
00197 #include "cxx_base.h"
00198 #endif
00199
00200 #ifndef mtypes_INCLUDED
00201 #include "mtypes.h"
00202 #endif
00203
00204 #include "symtab.h"
00205
00206
00207 typedef struct {
00208 DISTRIBUTE_TYPE _distr_type;
00209
00210
00211
00212
00213
00214 INT64 _chunksize;
00215
00216 } RESHAPED_DIM;
00217
00218
00219
00220 class DRA_INFO {
00221
00222 private:
00223
00224 INT16 _ndims;
00225
00226 INT64 _esize;
00227
00228 struct mem_pool *_pool;
00229
00230 RESHAPED_DIM *_dims;
00231
00232 public:
00233
00234 DRA_INFO (INT16 ndims, INT64 esize, struct mem_pool *pool) {
00235 _ndims = ndims;
00236 _esize = esize;
00237 _pool = pool;
00238 _dims = CXX_NEW_ARRAY(RESHAPED_DIM, ndims, pool);
00239 for (INT16 i = 0; i < ndims; i++) {
00240 _dims[i]._chunksize = 0;
00241 }
00242 }
00243
00244 INT16 Num_Dims() const { return _ndims; }
00245
00246 DISTRIBUTE_TYPE Distr_Type (INT16 dim) const {
00247 return _dims[dim]._distr_type;
00248 }
00249
00250 INT64 Chunk_Const_Val (INT16 dim) const {
00251 return _dims[dim]._chunksize;
00252 }
00253
00254 void Init (INT16 dim, DISTRIBUTE_TYPE dt) {
00255 Is_True ((dt == DISTRIBUTE_BLOCK) ||
00256 (dt == DISTRIBUTE_STAR) ||
00257 (dt == DISTRIBUTE_CYCLIC_EXPR),
00258 ("Distribute type must be BLOCK, STAR, or CYCLIC_EXPR"));
00259 _dims[dim]._distr_type = dt;
00260 }
00261
00262 void Init (INT16 dim, DISTRIBUTE_TYPE dt, INT64 chunksize) {
00263 Is_True (dt == DISTRIBUTE_CYCLIC_CONST,
00264 ("Distribute type must be CYCLIC_CONST"));
00265 _dims[dim]._distr_type = dt;
00266 _dims[dim]._chunksize = chunksize;
00267 }
00268
00269 INT64 Element_Size () const { return _esize; }
00270
00271 void Print (FILE* fp) const {
00272 fprintf (fp, "Distribution: \n");
00273 for (INT16 i = 0; i < _ndims; i++) {
00274 DISTRIBUTE_TYPE dt = _dims[i]._distr_type;
00275 fprintf (fp, "%s",
00276 (dt == DISTRIBUTE_STAR) ? "STAR" :
00277 (dt == DISTRIBUTE_BLOCK) ? "BLOCK" :
00278 (dt == DISTRIBUTE_CYCLIC_EXPR) ? "CYCLIC_EXPR" :
00279 (dt == DISTRIBUTE_CYCLIC_CONST) ? "CYCLIC_CONST" :
00280 "unknown");
00281 if (dt == DISTRIBUTE_CYCLIC_CONST) {
00282 fprintf (fp, " (%lld)", _dims[i]._chunksize);
00283 }
00284 }
00285 fprintf (fp, "\n");
00286 }
00287
00288 };
00289
00290
00291
00292 class STRING_NODE : public SLIST_NODE {
00293 DECLARE_SLIST_NODE_CLASS(STRING_NODE);
00294
00295 private:
00296 STR_IDX _string;
00297
00298 public:
00299 STRING_NODE(STR_IDX string) { Set_Next(NULL); _string = string; }
00300 STR_IDX String() { return _string; }
00301 };
00302
00303
00304 class STRING_LIST : public SLIST {
00305 DECLARE_SLIST_CLASS(STRING_LIST, STRING_NODE);
00306 };
00307
00308
00309 class STRING_ITER : public SLIST_ITER {
00310 DECLARE_SLIST_ITER_CLASS(STRING_ITER, STRING_NODE, STRING_LIST);
00311 };
00312
00313
00314
00315
00316 typedef HASH_TABLE<ST*, DRA_INFO*> DRA_HASH_TABLE;
00317
00318
00319
00320
00321 typedef HASH_TABLE<STR_IDX, STRING_LIST*> STRING_LIST_TABLE;
00322
00323
00324 typedef struct {
00325 ST *st;
00326 BOOL is_clone;
00327 BOOL is_called;
00328 } MANGLED_FUNC;
00329
00330
00331
00332 typedef HASH_TABLE<STR_IDX, MANGLED_FUNC*> NAME_ST_TABLE;
00333
00334 typedef HASH_TABLE_ITER <STR_IDX, MANGLED_FUNC*> NAME_ST_TABLE_ITER;
00335
00336
00337 class DRA_GLOBAL_INFO {
00338 TY_IDX _orig_ty;
00339 DRA_GLOBAL_INFO (void);
00340 DRA_GLOBAL_INFO (const DRA_GLOBAL_INFO&);
00341 DRA_GLOBAL_INFO* operator= (const DRA_GLOBAL_INFO&);
00342 public:
00343 DRA_GLOBAL_INFO(TY_IDX ty) { _orig_ty = ty; }
00344 TY_IDX Get_TY () { return _orig_ty; }
00345 };
00346
00347 typedef HASH_TABLE<ST*, DRA_GLOBAL_INFO*> DRA_GLOBAL_HASH_TABLE;
00348 extern DRA_GLOBAL_HASH_TABLE* dra_global;
00349
00350 typedef HASH_TABLE<ST_IDX, BOOL> DRA_COMMON_HASH_TABLE;
00351
00352
00353
00354
00355 extern NAME_ST_TABLE *DRA_func_table;
00356
00357
00358
00359
00360 extern DRA_HASH_TABLE *DRA_array_table;
00361
00362
00363
00364
00365 extern struct mem_pool DRA_name_pool, *DRA_name_pool_ptr;
00366
00367
00368
00369
00370 extern INT DRA_file_desc;
00371
00372 extern char *DRA_file_mmap;
00373
00374 extern char DRA_file_name[];
00375
00376 class WN;
00377
00378
00379
00380 extern void DRA_Read_Pragmas (WN *func_nd,
00381 DRA_HASH_TABLE *dra_table);
00382
00383 extern void DRA_Mangle_All (WN *func_wn,
00384 DRA_HASH_TABLE *dra_table,
00385 struct pu_info *pu_info);
00386
00387 extern void DRA_EC_Declare_Types ();
00388
00389 extern void DRA_EC_Array_Portion_Parms (WN *func_nd,
00390 WN *entry_nd);
00391
00392 extern WN *Get_Preamble_End (WN *pu_wn);
00393
00394 extern ST *Find_Return_Registers (TYPE_ID type,
00395 PREG_NUM *rreg1,
00396 PREG_NUM *rreg2);
00397
00398
00399
00400
00401 extern void DRA_Open_And_Map_File();
00402
00403 extern void DRA_Set_Write_Location();
00404
00405 extern void DRA_Mem_Unmap_File();
00406
00407 extern void DRA_Close_File();
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417 static const char* DRA_MANGLE_SIG = "__nn__";
00418 static const INT DRA_MANGLE_SIG_LEN = strlen(DRA_MANGLE_SIG);
00419
00420 static const char DRA_STAR_CODE = 'S';
00421 static const char DRA_BLOCK_CODE = 'B';
00422 static const char DRA_CYCLIC_CODE = 'C';
00423 static const char DRA_NDIMS_END = 'D';
00424 static const char DRA_ESIZE_END = 'E';
00425 static const char DRA_ARG_SEPARATOR = '_';
00426
00427
00428
00429
00430 static const char* DRA_FILE_SEPARATOR = "----\n";
00431
00432
00433
00434 extern TY_IDX Get_Array_Type (ST* st);
00435
00436
00437
00438 extern TY_IDX Get_Original_Type (ST* st);
00439
00440 #endif