Go to the documentation of this file.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 #ifndef defs_INCLUDED
00179 #include "defs.h"
00180 #endif
00181
00182 #ifndef pragmas_INCLUDED
00183 #include "wn_pragmas.h"
00184 #endif
00185
00186 #ifndef CXX_MEMORY_INCLUDED
00187 #include "cxx_memory.h"
00188 #endif
00189
00190 #ifndef cxx_hash_INCLUDED
00191 #include "cxx_hash.h"
00192 #endif
00193
00194
00195 #ifndef cxx_base_INCLUDED
00196 #include "cxx_base.h"
00197 #endif
00198
00199 #ifndef mtypes_INCLUDED
00200 #include "mtypes.h"
00201 #endif
00202
00203 #include "symtab.h"
00204
00205
00206 typedef struct {
00207 DISTRIBUTE_TYPE _distr_type;
00208
00209
00210
00211
00212
00213 INT64 _chunksize;
00214
00215 } RESHAPED_DIM;
00216
00217
00218
00219 class DRA_INFO {
00220
00221 private:
00222
00223 INT16 _ndims;
00224
00225 INT64 _esize;
00226
00227 struct mem_pool *_pool;
00228
00229 RESHAPED_DIM *_dims;
00230
00231 public:
00232
00233 DRA_INFO (INT16 ndims, INT64 esize, struct mem_pool *pool) {
00234 _ndims = ndims;
00235 _esize = esize;
00236 _pool = pool;
00237 _dims = CXX_NEW_ARRAY(RESHAPED_DIM, ndims, pool);
00238 for (INT16 i = 0; i < ndims; i++) {
00239 _dims[i]._chunksize = 0;
00240 }
00241 }
00242
00243 INT16 Num_Dims() const { return _ndims; }
00244
00245 DISTRIBUTE_TYPE Distr_Type (INT16 dim) const {
00246 return _dims[dim]._distr_type;
00247 }
00248
00249 INT64 Chunk_Const_Val (INT16 dim) const {
00250 return _dims[dim]._chunksize;
00251 }
00252
00253 void Init (INT16 dim, DISTRIBUTE_TYPE dt) {
00254 Is_True ((dt == DISTRIBUTE_BLOCK) ||
00255 (dt == DISTRIBUTE_STAR) ||
00256 (dt == DISTRIBUTE_CYCLIC_EXPR),
00257 ("Distribute type must be BLOCK, STAR, or CYCLIC_EXPR"));
00258 _dims[dim]._distr_type = dt;
00259 }
00260
00261 void Init (INT16 dim, DISTRIBUTE_TYPE dt, INT64 chunksize) {
00262 Is_True (dt == DISTRIBUTE_CYCLIC_CONST,
00263 ("Distribute type must be CYCLIC_CONST"));
00264 _dims[dim]._distr_type = dt;
00265 _dims[dim]._chunksize = chunksize;
00266 }
00267
00268 INT64 Element_Size () const { return _esize; }
00269
00270 void Print (FILE* fp) const {
00271 fprintf (fp, "Distribution: \n");
00272 for (INT16 i = 0; i < _ndims; i++) {
00273 DISTRIBUTE_TYPE dt = _dims[i]._distr_type;
00274 fprintf (fp, "%s",
00275 (dt == DISTRIBUTE_STAR) ? "STAR" :
00276 (dt == DISTRIBUTE_BLOCK) ? "BLOCK" :
00277 (dt == DISTRIBUTE_CYCLIC_EXPR) ? "CYCLIC_EXPR" :
00278 (dt == DISTRIBUTE_CYCLIC_CONST) ? "CYCLIC_CONST" :
00279 "unknown");
00280 if (dt == DISTRIBUTE_CYCLIC_CONST) {
00281 fprintf (fp, " (%lld)", _dims[i]._chunksize);
00282 }
00283 }
00284 fprintf (fp, "\n");
00285 }
00286
00287 };
00288
00289
00290
00291 class STRING_NODE : public SLIST_NODE {
00292 DECLARE_SLIST_NODE_CLASS(STRING_NODE);
00293
00294 private:
00295 STR_IDX _string;
00296
00297 public:
00298 STRING_NODE(STR_IDX string) { Set_Next(NULL); _string = string; }
00299 STR_IDX String() { return _string; }
00300 };
00301
00302
00303 class STRING_LIST : public SLIST {
00304 DECLARE_SLIST_CLASS(STRING_LIST, STRING_NODE);
00305 };
00306
00307
00308 class STRING_ITER : public SLIST_ITER {
00309 DECLARE_SLIST_ITER_CLASS(STRING_ITER, STRING_NODE, STRING_LIST);
00310 };
00311
00312
00313
00314
00315 typedef HASH_TABLE<ST*, DRA_INFO*> DRA_HASH_TABLE;
00316
00317
00318
00319
00320 typedef HASH_TABLE<STR_IDX, STRING_LIST*> STRING_LIST_TABLE;
00321
00322
00323 typedef struct {
00324 ST *st;
00325 BOOL is_clone;
00326 BOOL is_called;
00327 } MANGLED_FUNC;
00328
00329
00330
00331 typedef HASH_TABLE<STR_IDX, MANGLED_FUNC*> NAME_ST_TABLE;
00332
00333 typedef HASH_TABLE_ITER <STR_IDX, MANGLED_FUNC*> NAME_ST_TABLE_ITER;
00334
00335
00336 class DRA_GLOBAL_INFO {
00337 TY_IDX _orig_ty;
00338 DRA_GLOBAL_INFO (void);
00339 DRA_GLOBAL_INFO (const DRA_GLOBAL_INFO&);
00340 DRA_GLOBAL_INFO* operator= (const DRA_GLOBAL_INFO&);
00341 public:
00342 DRA_GLOBAL_INFO(TY_IDX ty) { _orig_ty = ty; }
00343 TY_IDX Get_TY () { return _orig_ty; }
00344 };
00345
00346 typedef HASH_TABLE<ST*, DRA_GLOBAL_INFO*> DRA_GLOBAL_HASH_TABLE;
00347 extern DRA_GLOBAL_HASH_TABLE* dra_global;
00348
00349 typedef HASH_TABLE<ST_IDX, BOOL> DRA_COMMON_HASH_TABLE;
00350
00351
00352
00353
00354 extern NAME_ST_TABLE *DRA_func_table;
00355
00356
00357
00358
00359 extern DRA_HASH_TABLE *DRA_array_table;
00360
00361
00362
00363
00364 extern struct mem_pool DRA_name_pool, *DRA_name_pool_ptr;
00365
00366
00367
00368
00369 extern INT DRA_file_desc;
00370
00371 extern char *DRA_file_mmap;
00372
00373 extern char DRA_file_name[];
00374
00375 class WN;
00376
00377
00378
00379 extern void DRA_Read_Pragmas (WN *func_nd,
00380 DRA_HASH_TABLE *dra_table);
00381
00382 extern void DRA_Mangle_All (WN *func_wn,
00383 DRA_HASH_TABLE *dra_table,
00384 struct pu_info *pu_info);
00385
00386 extern void DRA_EC_Declare_Types ();
00387
00388 extern void DRA_EC_Array_Portion_Parms (WN *func_nd,
00389 WN *entry_nd);
00390
00391 extern WN *Get_Preamble_End (WN *pu_wn);
00392
00393 extern ST *Find_Return_Registers (TYPE_ID type,
00394 PREG_NUM *rreg1,
00395 PREG_NUM *rreg2);
00396
00397
00398
00399
00400 extern void DRA_Open_And_Map_File();
00401
00402 extern void DRA_Set_Write_Location();
00403
00404 extern void DRA_Mem_Unmap_File();
00405
00406 extern void DRA_Close_File();
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416 static const char* DRA_MANGLE_SIG = "__nn__";
00417 static const INT DRA_MANGLE_SIG_LEN = strlen(DRA_MANGLE_SIG);
00418
00419 static const char DRA_STAR_CODE = 'S';
00420 static const char DRA_BLOCK_CODE = 'B';
00421 static const char DRA_CYCLIC_CODE = 'C';
00422 static const char DRA_NDIMS_END = 'D';
00423 static const char DRA_ESIZE_END = 'E';
00424 static const char DRA_ARG_SEPARATOR = '_';
00425
00426
00427
00428
00429 static const char* DRA_FILE_SEPARATOR = "----\n";
00430
00431
00432
00433 extern TY_IDX Get_Array_Type (ST* st);
00434
00435
00436
00437 extern TY_IDX Get_Original_Type (ST* st);
00438
00439 #endif