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
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054 #if defined(BUILD_OS_DARWIN)
00055 #include <limits.h>
00056 #else
00057 #include <values.h>
00058 #endif
00059 #include "defs.h"
00060 #include "errors.h"
00061 #include "gnu_config.h"
00062 #ifdef KEY
00063
00064 #include "gnu/hwint.h"
00065 #endif
00066 #include "gnu/flags.h"
00067 extern "C" {
00068 #include "gnu/system.h"
00069 #include "gnu/tree.h"
00070 #include "gnu/toplev.h"
00071 }
00072 #if defined(TARG_IA32) || defined(TARG_X8664)
00073
00074
00075 #undef TARGET_PENTIUM
00076 #endif
00077
00078 #ifdef KEY
00079 #ifdef TARG_MIPS
00080
00081
00082 #undef ABI_N32
00083 #endif
00084 #endif
00085
00086 #include "symtab.h"
00087 #include "strtab.h"
00088 #include "tree_symtab.h"
00089 #include "wn.h"
00090 #include "wfe_expr.h"
00091 #include "wfe_misc.h"
00092 #include "wfe_dst.h"
00093 #include "ir_reader.h"
00094 #include <cmplrs/rcodes.h>
00095 #ifdef KEY
00096 #include "erfe.h"
00097 #endif
00098 #include "config_asm.h"
00099
00100 extern FILE *tree_dump_file;
00101
00102 extern INT pstatic_as_global;
00103
00104 static char*
00105 Get_Name (tree node)
00106 {
00107 static UINT anon_num = 0;
00108 static char buf[256];
00109
00110 if (node != NULL) {
00111 if (TREE_CODE (node) == IDENTIFIER_NODE)
00112 return IDENTIFIER_POINTER (node);
00113 else if (TREE_CODE (node) == TYPE_DECL)
00114
00115 return IDENTIFIER_POINTER (DECL_NAME (node));
00116 else if (DECL_NAME (node)) {
00117
00118 return IDENTIFIER_POINTER (DECL_NAME (node));
00119 }
00120 }
00121
00122
00123 ++anon_num;
00124 sprintf(buf, "%sanonymous%s%d", Label_Name_Separator, Label_Name_Separator, anon_num);
00125 return buf;
00126 }
00127
00128 #ifdef TARG_SL
00129
00130
00131 TYPE_ID
00132 Get_Mtype_For_Integer_Type(tree type_tree, INT64 tsize)
00133 {
00134 TYPE_ID mtype;
00135 switch(tsize) {
00136 case 1:
00137 mtype = MTYPE_I1;
00138 break;
00139 case 2:
00140 mtype = MTYPE_I2;
00141 break;
00142 case 4:
00143 mtype = MTYPE_I4;
00144 break;
00145 case 8:
00146 DevWarn("8 byte types being used");
00147 mtype = MTYPE_I8;
00148 break;
00149 }
00150 return mtype;
00151 }
00152 #endif
00153
00154
00155 #ifdef KEY
00156 extern void WFE_add_pragma_to_enclosing_regions (WN_PRAGMA_ID, ST *);
00157
00158
00159
00160 BOOL
00161 Is_shared_mp_var (tree decl_node)
00162 {
00163 ST * st = DECL_ST (decl_node);
00164
00165 if (st && ST_sclass (st) == SCLASS_AUTO)
00166 return TRUE;
00167
00168 return FALSE;
00169 }
00170 #endif // KEY
00171
00172
00173 extern TY_IDX
00174 Create_TY_For_Tree (tree type_tree, TY_IDX idx)
00175 {
00176 if (TREE_CODE(type_tree) == ERROR_MARK)
00177 exit (RC_USER_ERROR);
00178
00179 TY_IDX orig_idx = idx;
00180 if(TREE_CODE_CLASS(TREE_CODE(type_tree)) != 't') {
00181 DevWarn("Bad tree class passed to Create_TY_For_Tree %c",
00182 TREE_CODE_CLASS(TREE_CODE(type_tree)));
00183 return idx;
00184 }
00185 #ifdef KEY
00186 UINT align = TYPE_ALIGN(type_tree) / BITSPERBYTE;
00187 #endif
00188
00189 if (TYPE_NAME(type_tree) &&
00190 idx == 0 &&
00191 (TREE_CODE(type_tree) == RECORD_TYPE ||
00192 TREE_CODE(type_tree) == UNION_TYPE) &&
00193 TREE_CODE(TYPE_NAME(type_tree)) == TYPE_DECL &&
00194 TYPE_MAIN_VARIANT(type_tree) != type_tree) {
00195 idx = Get_TY (TYPE_MAIN_VARIANT(type_tree));
00196 #ifdef TARG_NVISA
00197 if (TREE_CODE(type_tree) == RECORD_TYPE) {
00198 char *name = Get_Name(TYPE_NAME(type_tree));
00199 if (strcmp(name, "char1") == 0)
00200 Set_TY_can_be_vector(idx);
00201 else if (strcmp(name, "uchar1") == 0)
00202 Set_TY_can_be_vector(idx);
00203 else if (strcmp(name, "char2") == 0)
00204 Set_TY_can_be_vector(idx);
00205 else if (strcmp(name, "uchar2") == 0)
00206 Set_TY_can_be_vector(idx);
00207 else if (strcmp(name, "char3") == 0)
00208 Set_TY_can_be_vector(idx);
00209 else if (strcmp(name, "uchar3") == 0)
00210 Set_TY_can_be_vector(idx);
00211 else if (strcmp(name, "char4") == 0)
00212 Set_TY_can_be_vector(idx);
00213 else if (strcmp(name, "uchar4") == 0)
00214 Set_TY_can_be_vector(idx);
00215 else if (strcmp(name, "short1") == 0)
00216 Set_TY_can_be_vector(idx);
00217 else if (strcmp(name, "ushort1") == 0)
00218 Set_TY_can_be_vector(idx);
00219 else if (strcmp(name, "short2") == 0)
00220 Set_TY_can_be_vector(idx);
00221 else if (strcmp(name, "ushort2") == 0)
00222 Set_TY_can_be_vector(idx);
00223 else if (strcmp(name, "short3") == 0)
00224 Set_TY_can_be_vector(idx);
00225 else if (strcmp(name, "ushort3") == 0)
00226 Set_TY_can_be_vector(idx);
00227 else if (strcmp(name, "short4") == 0)
00228 Set_TY_can_be_vector(idx);
00229 else if (strcmp(name, "ushort4") == 0)
00230 Set_TY_can_be_vector(idx);
00231 else if (strcmp(name, "int1") == 0)
00232 Set_TY_can_be_vector(idx);
00233 else if (strcmp(name, "uint1") == 0)
00234 Set_TY_can_be_vector(idx);
00235 else if (strcmp(name, "int2") == 0)
00236 Set_TY_can_be_vector(idx);
00237 else if (strcmp(name, "uint2") == 0)
00238 Set_TY_can_be_vector(idx);
00239 else if (strcmp(name, "int3") == 0)
00240 Set_TY_can_be_vector(idx);
00241 else if (strcmp(name, "uint3") == 0)
00242 Set_TY_can_be_vector(idx);
00243 else if (strcmp(name, "int4") == 0)
00244 Set_TY_can_be_vector(idx);
00245 else if (strcmp(name, "uint4") == 0)
00246 Set_TY_can_be_vector(idx);
00247 else if (strcmp(name, "long1") == 0)
00248 Set_TY_can_be_vector(idx);
00249 else if (strcmp(name, "ulong1") == 0)
00250 Set_TY_can_be_vector(idx);
00251 else if (strcmp(name, "long2") == 0)
00252 Set_TY_can_be_vector(idx);
00253 else if (strcmp(name, "ulong2") == 0)
00254 Set_TY_can_be_vector(idx);
00255 else if (strcmp(name, "long3") == 0)
00256 Set_TY_can_be_vector(idx);
00257 else if (strcmp(name, "ulong3") == 0)
00258 Set_TY_can_be_vector(idx);
00259 else if (strcmp(name, "long4") == 0)
00260 Set_TY_can_be_vector(idx);
00261 else if (strcmp(name, "ulong4") == 0)
00262 Set_TY_can_be_vector(idx);
00263 else if (strcmp(name, "float1") == 0)
00264 Set_TY_can_be_vector(idx);
00265 else if (strcmp(name, "float2") == 0)
00266 Set_TY_can_be_vector(idx);
00267 else if (strcmp(name, "float3") == 0)
00268 Set_TY_can_be_vector(idx);
00269 else if (strcmp(name, "float4") == 0)
00270 Set_TY_can_be_vector(idx);
00271 }
00272 #endif
00273 if (TYPE_READONLY(type_tree))
00274 Set_TY_is_const (idx);
00275 if (TYPE_VOLATILE(type_tree))
00276 Set_TY_is_volatile (idx);
00277 #ifdef KEY
00278 if (TYPE_RESTRICT(type_tree))
00279 Set_TY_is_restrict (idx);
00280 Set_TY_align (idx, align);
00281 #endif
00282 TYPE_TY_IDX(type_tree) = idx;
00283 if(Debug_Level >= 2) {
00284 struct mongoose_gcc_DST_IDX dst =
00285 Create_DST_type_For_Tree(type_tree,idx,orig_idx);
00286 TYPE_DST_IDX(type_tree) = dst;
00287 }
00288 return idx;
00289 }
00290
00291 TYPE_ID mtype;
00292 INT64 tsize;
00293 BOOL variable_size = FALSE;
00294 tree type_size = TYPE_SIZE(type_tree);
00295
00296 #ifndef KEY
00297 UINT align = TYPE_ALIGN(type_tree) / BITSPERBYTE;
00298 #endif
00299 if (TREE_CODE(type_tree) == VOID_TYPE)
00300 tsize = 0;
00301 else
00302 if (type_size == NULL) {
00303 #ifndef KEY
00304
00305 FmtAssert(TREE_CODE(type_tree) == ARRAY_TYPE
00306 || TREE_CODE(type_tree) == UNION_TYPE
00307 || TREE_CODE(type_tree) == RECORD_TYPE,
00308 ("Create_TY_For_Tree: type_size NULL for non ARRAY/RECORD"));
00309 #endif
00310 tsize = 0;
00311 }
00312 else {
00313 if (TREE_CODE(type_size) != INTEGER_CST) {
00314 if (TREE_CODE(type_tree) == ARRAY_TYPE)
00315 DevWarn ("Encountered VLA at line %d", lineno);
00316 else
00317 #ifndef KEY
00318 Fail_FmtAssertion ("VLA at line %d not currently implemented", lineno);
00319 #else
00320
00321 {
00322 #ifdef PSC_TO_OPEN64
00323 printf("opencc: variable-length structure not yet implemented\n");
00324 #endif
00325 exit(2);
00326 }
00327 #endif
00328 variable_size = TRUE;
00329 tsize = 0;
00330 }
00331 else
00332 #ifdef KEY // bug 3045
00333 tsize = (Get_Integer_Value(type_size) + BITSPERBYTE - 1)
00334 / BITSPERBYTE;
00335 #else
00336 tsize = Get_Integer_Value(type_size) / BITSPERBYTE;
00337 #endif
00338 }
00339 switch (TREE_CODE(type_tree)) {
00340 case VOID_TYPE:
00341 idx = MTYPE_To_TY (MTYPE_V);
00342 break;
00343 case BOOLEAN_TYPE:
00344 case INTEGER_TYPE:
00345 switch (tsize) {
00346 case 1:
00347 #ifdef TARG_SL
00348 mtype = Get_Mtype_For_Integer_Type(type_tree, tsize);
00349 #else
00350 mtype = MTYPE_I1;
00351 #endif
00352 break;
00353 case 2:
00354 #ifdef TARG_SL
00355 mtype = Get_Mtype_For_Integer_Type(type_tree, tsize);
00356 #else
00357 mtype = MTYPE_I2;
00358 #endif
00359 break;
00360
00361 case 4:
00362 #ifdef TARG_SL
00363 mtype = Get_Mtype_For_Integer_Type(type_tree, tsize);
00364 #else
00365 mtype = MTYPE_I4;
00366 #endif
00367 break;
00368
00369 case 8:
00370 #ifdef TARG_SL
00371 mtype = Get_Mtype_For_Integer_Type(type_tree, tsize);
00372 #else
00373 mtype = MTYPE_I8;
00374 #endif
00375 break;
00376
00377 #if !defined(TARG_X8664) && !defined(TARG_IA64) && !defined(TARG_MIPS)
00378 #ifdef _LP64
00379 case 16: mtype = MTYPE_I8; break;
00380 #endif
00381 #else
00382
00383
00384
00385
00386 case 16: mtype = MTYPE_I8; break;
00387 #endif
00388 default: FmtAssert(FALSE, ("Get_TY unexpected size"));
00389 }
00390 if (TREE_UNSIGNED(type_tree)) {
00391 mtype = MTYPE_complement(mtype);
00392 }
00393 #ifdef KEY
00394 if (lookup_attribute ("may_alias", TYPE_ATTRIBUTES (type_tree)))
00395 {
00396
00397
00398 TY &ty = New_TY (idx);
00399 TY_Init (ty, tsize, KIND_SCALAR, mtype,
00400 Save_Str(Get_Name(TYPE_NAME(type_tree))) );
00401 Set_TY_no_ansi_alias (ty);
00402 } else
00403 #endif
00404 #ifdef TARG_NVISA
00405
00406
00407
00408
00409
00410
00411
00412 if (tsize == 1 && type_tree == char_type_node) {
00413
00414 TY &ty = New_TY (idx);
00415 TY_Init (ty, tsize, KIND_SCALAR, mtype,
00416 Save_Str(Get_Name(TYPE_NAME(type_tree))) );
00417 Set_TY_is_character(ty);
00418 } else
00419 #endif
00420 idx = MTYPE_To_TY (mtype);
00421
00422 #ifdef TARG_X8664
00423
00424
00425
00426 if( TARGET_64BIT )
00427 #endif // TARG_X8664
00428 Set_TY_align (idx, align);
00429
00430 break;
00431 case CHAR_TYPE:
00432 mtype = (TREE_UNSIGNED(type_tree) ? MTYPE_U1 : MTYPE_I1);
00433 idx = MTYPE_To_TY (mtype);
00434 break;
00435 case ENUMERAL_TYPE:
00436 mtype = (TREE_UNSIGNED(type_tree) ? MTYPE_U4 : MTYPE_I4);
00437 #ifdef KEY
00438
00439 if( tsize == 8 ){
00440 mtype = (TREE_UNSIGNED(type_tree) ? MTYPE_U8 : MTYPE_I8);
00441 }
00442 #endif
00443 idx = MTYPE_To_TY (mtype);
00444 break;
00445 case REAL_TYPE:
00446 switch (tsize) {
00447 case 4: mtype = MTYPE_F4; break;
00448 case 8: mtype = MTYPE_F8; break;
00449 #if defined(TARG_IA64)
00450 case 12:
00451 case 16: mtype = MTYPE_F10; break;
00452 #elif defined(TARG_MIPS) || defined(TARG_IA32) || defined(TARG_X8664) || defined(TARG_NVISA)
00453 case 12:
00454 case 16: mtype = MTYPE_FQ; break;
00455 #else
00456 case 16: mtype = MTYPE_F16; break;
00457 #endif
00458 default: FmtAssert(FALSE, ("Get_TY unexpected REAL_TYPE size %d", tsize));
00459 }
00460 idx = MTYPE_To_TY (mtype);
00461 break;
00462 case COMPLEX_TYPE:
00463 switch (tsize) {
00464 #ifdef KEY
00465 case 2:
00466 case 4: ErrMsg (EC_Unsupported_Type, "Complex integer");
00467 #endif
00468 case 8: mtype = MTYPE_C4; break;
00469 case 16: mtype = MTYPE_C8; break;
00470 #if defined(TARG_MIPS) || defined(TARG_IA32) || defined(TARG_X8664)
00471 case 32: mtype = MTYPE_CQ; break;
00472 #endif
00473 #ifdef TARG_IA64
00474 #ifdef PATHSCALE_MERGE
00475 case 32: mtype = MTYPE_C10; break;
00476 #endif
00477 case 24: mtype = MTYPE_C10; break;
00478 #endif
00479 #if defined(TARG_IA32) || defined(TARG_X8664)
00480 case 24: mtype = MTYPE_CQ; break;
00481 #endif
00482 default: FmtAssert(FALSE, ("Get_TY unexpected size"));
00483 }
00484 idx = MTYPE_To_TY (mtype);
00485 break;
00486 case REFERENCE_TYPE:
00487 case POINTER_TYPE:
00488 idx = Make_Pointer_Type (Get_TY (TREE_TYPE(type_tree)));
00489 Set_TY_align (idx, align);
00490 break;
00491 case ARRAY_TYPE:
00492 {
00493 TY &ty = New_TY (idx);
00494 TY_Init (ty, tsize, KIND_ARRAY, MTYPE_M,
00495 Save_Str(Get_Name(TYPE_NAME(type_tree))) );
00496 Set_TY_etype (ty, Get_TY (TREE_TYPE(type_tree)));
00497 Set_TY_align (idx, TY_align(TY_etype(ty)));
00498 if (TYPE_NAME(type_tree) == NULL)
00499 Set_TY_anonymous(ty);
00500
00501
00502 ARB_HANDLE arb = New_ARB ();
00503 ARB_Init (arb, 0, 0, 0);
00504 Set_TY_arb (ty, arb);
00505 Set_ARB_first_dimen (arb);
00506 Set_ARB_last_dimen (arb);
00507 Set_ARB_dimension (arb, 1);
00508 #ifdef KEY
00509
00510
00511
00512
00513
00514 if (!TYPE_SIZE(TREE_TYPE(type_tree)))
00515 break;
00516 #endif
00517 if (TREE_CODE(TYPE_SIZE(TREE_TYPE(type_tree))) == INTEGER_CST) {
00518 Set_ARB_const_stride (arb);
00519 Set_ARB_stride_val (arb,
00520 Get_Integer_Value (TYPE_SIZE(TREE_TYPE(type_tree)))
00521 / BITSPERBYTE);
00522 }
00523 else {
00524 WN *swn;
00525 swn = WFE_Expand_Expr (TYPE_SIZE(TREE_TYPE(type_tree)));
00526 if (WN_opcode (swn) == OPC_U4I4CVT ||
00527 WN_opcode (swn) == OPC_U8I8CVT) {
00528 swn = WN_kid0 (swn);
00529 }
00530 #ifdef KEY
00531
00532
00533
00534
00535 if (WN_operator (swn) != OPR_LDID) {
00536 TY_IDX ty_idx =
00537 Get_TY (TREE_TYPE (type_size));
00538 TYPE_ID mtype = TY_mtype (ty_idx);
00539 ST *st;
00540 st = Gen_Temp_Symbol (ty_idx, "__save_expr");
00541 #ifdef KEY
00542 WFE_add_pragma_to_enclosing_regions (WN_PRAGMA_LOCAL,
00543 st);
00544 #endif
00545 WFE_Set_ST_Addr_Saved (swn);
00546 swn = WN_Stid (mtype, 0, st, ty_idx, swn);
00547 WFE_Stmt_Append (swn, Get_Srcpos());
00548 swn = WN_Ldid (mtype, 0, st, ty_idx);
00549 }
00550 #endif
00551 FmtAssert (WN_operator (swn) == OPR_LDID,
00552 ("stride operator for VLA not LDID"));
00553 ST *st = WN_st (swn);
00554 TY_IDX ty_idx = ST_type (st);
00555 WN *wn = WN_CreateXpragma (WN_PRAGMA_COPYIN_BOUND,
00556 (ST_IDX) NULL, 1);
00557 WN_kid0 (wn) = WN_Ldid (TY_mtype (ty_idx), 0, st, ty_idx);
00558 WFE_Stmt_Append (wn, Get_Srcpos());
00559 Clear_ARB_const_stride (arb);
00560 Set_ARB_stride_var (arb, (ST_IDX) ST_st_idx (st));
00561 }
00562 Set_ARB_const_lbnd (arb);
00563 Set_ARB_lbnd_val (arb, 0);
00564 if (type_size) {
00565 #ifdef KEY
00566
00567 if (!TYPE_MAX_VALUE (TYPE_DOMAIN (type_tree))) {
00568 Set_ARB_const_ubnd (arb);
00569 Set_ARB_ubnd_val (arb, 0xffffffff);
00570 } else
00571 #endif
00572 if (TREE_CODE(TYPE_MAX_VALUE (TYPE_DOMAIN (type_tree))) ==
00573 INTEGER_CST) {
00574 Set_ARB_const_ubnd (arb);
00575 Set_ARB_ubnd_val (arb, Get_Integer_Value (
00576 TYPE_MAX_VALUE (TYPE_DOMAIN (type_tree)) ));
00577 }
00578 #ifdef KEY
00579
00580
00581 else if (!TYPE_DEFER_EXPANSION (type_tree))
00582 #else
00583 else
00584 #endif
00585 {
00586 WN *uwn = WFE_Expand_Expr (TYPE_MAX_VALUE (TYPE_DOMAIN (type_tree)) );
00587 if (WN_opcode (uwn) == OPC_U4I4CVT ||
00588 WN_opcode (uwn) == OPC_U8I8CVT) {
00589 uwn = WN_kid0 (uwn);
00590 }
00591 #ifdef KEY
00592
00593
00594
00595
00596 if (WN_operator (uwn) != OPR_LDID) {
00597 TY_IDX ty_idx =
00598 Get_TY (TREE_TYPE (type_size));
00599 TYPE_ID mtype = TY_mtype (ty_idx);
00600 ST *st;
00601 st = Gen_Temp_Symbol (ty_idx, "__save_expr");
00602 #ifdef KEY
00603 WFE_add_pragma_to_enclosing_regions (WN_PRAGMA_LOCAL,
00604 st);
00605 #endif
00606 WFE_Set_ST_Addr_Saved (uwn);
00607 uwn = WN_Stid (mtype, 0, st, ty_idx, uwn);
00608 WFE_Stmt_Append (uwn, Get_Srcpos());
00609 uwn = WN_Ldid (mtype, 0, st, ty_idx);
00610 }
00611 #endif
00612 FmtAssert (WN_operator (uwn) == OPR_LDID,
00613 ("bounds operator for VLA not LDID"));
00614 ST *st = WN_st (uwn);
00615 TY_IDX ty_idx = ST_type (st);
00616 WN *wn = WN_CreateXpragma (WN_PRAGMA_COPYIN_BOUND,
00617 (ST_IDX) NULL, 1);
00618 WN_kid0 (wn) = WN_Ldid (TY_mtype (ty_idx), 0, st, ty_idx);
00619 WFE_Stmt_Append (wn, Get_Srcpos());
00620 Clear_ARB_const_ubnd (arb);
00621 Set_ARB_ubnd_var (arb, ST_st_idx (st));
00622 }
00623 #ifdef KEY
00624 else
00625 {
00626 Clear_ARB_const_ubnd (arb);
00627 Set_ARB_ubnd_val (arb, 0);
00628 }
00629 #endif
00630 }
00631 else {
00632 Clear_ARB_const_ubnd (arb);
00633 Set_ARB_ubnd_val (arb, 0);
00634 }
00635 if (variable_size
00636 #ifdef KEY
00637
00638 && !TYPE_DEFER_EXPANSION (type_tree)
00639 #endif
00640 ) {
00641 WN *swn, *wn;
00642 swn = WFE_Expand_Expr (type_size);
00643 if (TY_size(TY_etype(ty))) {
00644 if (WN_opcode (swn) == OPC_U4I4CVT ||
00645 WN_opcode (swn) == OPC_U8I8CVT) {
00646 swn = WN_kid0 (swn);
00647 }
00648 #ifdef KEY
00649
00650
00651
00652
00653 if (WN_operator (swn) != OPR_LDID) {
00654 TY_IDX ty_idx =
00655 Get_TY (TREE_TYPE (type_size));
00656 TYPE_ID mtype = TY_mtype (ty_idx);
00657 ST *st;
00658 st = Gen_Temp_Symbol (ty_idx, "__save_expr");
00659 #ifdef KEY
00660 WFE_add_pragma_to_enclosing_regions
00661 (WN_PRAGMA_LOCAL, st);
00662 #endif
00663 WFE_Set_ST_Addr_Saved (swn);
00664 swn = WN_Stid (mtype, 0, st, ty_idx, swn);
00665 WFE_Stmt_Append (swn, Get_Srcpos());
00666 swn = WN_Ldid (mtype, 0, st, ty_idx);
00667 }
00668 #endif
00669 FmtAssert (WN_operator (swn) == OPR_LDID,
00670 ("size operator for VLA not LDID"));
00671 ST *st = WN_st (swn);
00672 TY_IDX ty_idx = ST_type (st);
00673 TYPE_ID mtype = TY_mtype (ty_idx);
00674 swn = WN_Div (mtype, swn, WN_Intconst (mtype, BITSPERBYTE));
00675 wn = WN_Stid (mtype, 0, st, ty_idx, swn);
00676 WFE_Stmt_Append (wn, Get_Srcpos());
00677 }
00678 }
00679 }
00680 break;
00681 case RECORD_TYPE:
00682 case UNION_TYPE:
00683 {
00684 TY &ty = (idx == TY_IDX_ZERO) ? New_TY(idx) : Ty_Table[idx];
00685
00686
00687
00688
00689
00690 if (TYPE_MAIN_VARIANT(type_tree) != type_tree)
00691 TY_Init(ty, tsize, KIND_STRUCT, MTYPE_M,
00692 Save_Str(Get_Name(TYPE_NAME(TYPE_MAIN_VARIANT(type_tree)))));
00693 else
00694 TY_Init (ty, tsize, KIND_STRUCT, MTYPE_M,
00695 Save_Str(Get_Name(TYPE_NAME(type_tree))) );
00696 if (TYPE_NAME(type_tree) == NULL)
00697 Set_TY_anonymous(ty);
00698 if (TREE_CODE(type_tree) == UNION_TYPE) {
00699 Set_TY_is_union(idx);
00700 }
00701 if (align == 0) align = 1;
00702 Set_TY_align (idx, align);
00703
00704 TYPE_TY_IDX(type_tree) = idx;
00705
00706
00707
00708
00709
00710
00711
00712 Set_TY_fld (ty, FLD_HANDLE());
00713 FLD_IDX first_field_idx = Fld_Table.Size ();
00714 tree field;
00715 FLD_HANDLE fld;
00716 for (field = TREE_PURPOSE(type_tree);
00717 field;
00718 field = TREE_CHAIN(field) )
00719 {
00720 if (TREE_CODE(field) == TYPE_DECL) {
00721 DevWarn ("got TYPE_DECL in field list");
00722 continue;
00723 }
00724 if (TREE_CODE(field) == CONST_DECL) {
00725 DevWarn ("got CONST_DECL in field list");
00726 continue;
00727 }
00728 fld = New_FLD ();
00729 FLD_Init (fld, Save_Str(Get_Name(DECL_NAME(field))),
00730 0,
00731 Get_Integer_Value(DECL_FIELD_OFFSET(field)) +
00732 Get_Integer_Value(DECL_FIELD_BIT_OFFSET(field))
00733 / BITSPERBYTE );
00734 if (DECL_NAME(field) == NULL)
00735 Set_FLD_is_anonymous(fld);
00736 #ifdef OLDCODE
00737 if ( ! DECL_BIT_FIELD(field)
00738 && Get_Integer_Value(DECL_SIZE(field)) > 0
00739 && Get_Integer_Value(DECL_SIZE(field))
00740 != (TY_size(Get_TY(TREE_TYPE(field)))
00741 * BITSPERBYTE) )
00742 {
00743
00744
00745
00746
00747
00748 DevWarn("field size %d doesn't match type size %d",
00749 Get_Integer_Value(DECL_SIZE(field)),
00750 TY_size(Get_TY(TREE_TYPE(field)))
00751 * BITSPERBYTE );
00752 DECL_BIT_FIELD(field) = 1;
00753 }
00754 if (DECL_BIT_FIELD(field)) {
00755 Set_FLD_is_bit_field (fld);
00756
00757 Set_FLD_bofst (fld,
00758
00759 Get_Integer_Value(
00760 DECL_FIELD_BIT_OFFSET(field))
00761 % BITSPERBYTE );
00762 Set_FLD_bsize (fld, Get_Integer_Value(DECL_SIZE(field)));
00763 }
00764 #endif
00765 }
00766 FLD_IDX last_field_idx = Fld_Table.Size () - 1;
00767 if (last_field_idx >= first_field_idx) {
00768 Set_TY_fld (ty, FLD_HANDLE (first_field_idx));
00769 Set_FLD_last_field (FLD_HANDLE (last_field_idx));
00770 }
00771
00772 fld = TY_fld(ty);
00773 for (field = TREE_PURPOSE(type_tree);
00774 field;
00775 field = TREE_CHAIN(field))
00776 {
00777 #ifdef KEY
00778 const int FLD_BIT_FIELD_SIZE = 64;
00779 #endif
00780 if (TREE_CODE(field) == TYPE_DECL)
00781 continue;
00782 if (TREE_CODE(field) == CONST_DECL)
00783 continue;
00784 if ( ! DECL_BIT_FIELD(field)
00785 #ifdef KEY
00786 && DECL_SIZE(field)
00787
00788
00789 && Get_Integer_Value(DECL_SIZE(field)) <=
00790 FLD_BIT_FIELD_SIZE
00791 #endif
00792 && Get_Integer_Value(DECL_SIZE(field)) > 0
00793 && Get_Integer_Value(DECL_SIZE(field))
00794 != (TY_size(Get_TY(TREE_TYPE(field)))
00795 * BITSPERBYTE) )
00796 {
00797
00798
00799
00800
00801
00802 DevWarn("field size %lld doesn't match type size %lld",
00803 Get_Integer_Value(DECL_SIZE(field)),
00804 TY_size(Get_TY(TREE_TYPE(field)))
00805 * BITSPERBYTE );
00806 DECL_BIT_FIELD(field) = 1;
00807 }
00808 if (DECL_BIT_FIELD(field)) {
00809 Set_FLD_is_bit_field (fld);
00810
00811 Set_FLD_bofst (fld,
00812
00813 Get_Integer_Value(
00814 DECL_FIELD_BIT_OFFSET(field))
00815 % BITSPERBYTE );
00816 Set_FLD_bsize (fld, Get_Integer_Value(DECL_SIZE(field)));
00817 }
00818 TY_IDX fty_idx = Get_TY(TREE_TYPE(field));
00819 if ((TY_align (fty_idx) > align) || (TY_is_packed (fty_idx)))
00820 Set_TY_is_packed (ty);
00821 Set_FLD_type(fld, fty_idx);
00822 fld = FLD_next(fld);
00823 }
00824 }
00825 break;
00826 case METHOD_TYPE:
00827 DevWarn ("Encountered METHOD_TYPE at line %d", lineno);
00828 case FUNCTION_TYPE:
00829 {
00830 tree arg;
00831 INT32 num_args;
00832 TY &ty = New_TY (idx);
00833 TY_Init (ty, 0, KIND_FUNCTION, MTYPE_UNKNOWN, 0);
00834 Set_TY_align (idx, 1);
00835 TY_IDX ret_ty_idx;
00836 TY_IDX arg_ty_idx;
00837 TYLIST tylist_idx;
00838
00839
00840
00841
00842
00843 ret_ty_idx = Get_TY(TREE_TYPE(type_tree));
00844 for (arg = TYPE_ARG_TYPES(type_tree);
00845 arg;
00846 arg = TREE_CHAIN(arg))
00847 arg_ty_idx = Get_TY(TREE_VALUE(arg));
00848
00849
00850
00851 if (!WFE_Keep_Zero_Length_Structs &&
00852 TY_mtype (ret_ty_idx) == MTYPE_M &&
00853 TY_size (ret_ty_idx) == 0) {
00854
00855 DevWarn ("function returning zero length struct at line %d", lineno);
00856 ret_ty_idx = Be_Type_Tbl (MTYPE_V);
00857 }
00858
00859 Set_TYLIST_type (New_TYLIST (tylist_idx), ret_ty_idx);
00860 Set_TY_tylist (ty, tylist_idx);
00861 for (num_args = 0, arg = TYPE_ARG_TYPES(type_tree);
00862 arg;
00863 num_args++, arg = TREE_CHAIN(arg))
00864 {
00865 arg_ty_idx = Get_TY(TREE_VALUE(arg));
00866 if (!WFE_Keep_Zero_Length_Structs &&
00867 TY_mtype (arg_ty_idx) == MTYPE_M &&
00868 TY_size (arg_ty_idx) == 0) {
00869
00870 DevWarn ("zero length struct encountered in function prototype at line %d", lineno);
00871 }
00872 else
00873 Set_TYLIST_type (New_TYLIST (tylist_idx), arg_ty_idx);
00874 }
00875 if (num_args)
00876 {
00877 Set_TY_has_prototype(idx);
00878 if (arg_ty_idx != Be_Type_Tbl(MTYPE_V))
00879 {
00880 Set_TYLIST_type (New_TYLIST (tylist_idx), 0);
00881 Set_TY_is_varargs(idx);
00882 }
00883 else
00884 Set_TYLIST_type (Tylist_Table [tylist_idx], 0);
00885 }
00886 else
00887 Set_TYLIST_type (New_TYLIST (tylist_idx), 0);
00888 }
00889 break;
00890 #ifdef TARG_X8664
00891
00892 case VECTOR_TYPE:
00893 {
00894 switch (GET_MODE_SIZE (TYPE_MODE (type_tree)))
00895 {
00896 case 8:
00897 switch (GET_MODE_UNIT_SIZE (TYPE_MODE (type_tree)))
00898 {
00899 case 1:
00900 idx = MTYPE_To_TY (MTYPE_M8I1);
00901 break;
00902 case 2:
00903 idx = MTYPE_To_TY (MTYPE_M8I2);
00904 break;
00905 case 4:
00906 if (TREE_CODE (TREE_TYPE (type_tree)) == INTEGER_TYPE)
00907 idx = MTYPE_To_TY (MTYPE_M8I4);
00908 else
00909 idx = MTYPE_To_TY (MTYPE_M8F4);
00910 break;
00911 default: Fail_FmtAssertion ("Get_TY: NYI");
00912 }
00913 break;
00914 case 16:
00915 switch (GET_MODE_UNIT_SIZE (TYPE_MODE (type_tree)))
00916 {
00917 case 1:
00918 idx = MTYPE_To_TY (MTYPE_V16I1);
00919 break;
00920 case 2:
00921 idx = MTYPE_To_TY (MTYPE_V16I2);
00922 break;
00923 case 4:
00924 if (TREE_CODE (TREE_TYPE (type_tree)) == INTEGER_TYPE)
00925 idx = MTYPE_To_TY (MTYPE_V16I4);
00926 else
00927 idx = MTYPE_To_TY (MTYPE_V16F4);
00928 break;
00929 case 8:
00930 if (TREE_CODE (TREE_TYPE (type_tree)) == INTEGER_TYPE)
00931 idx = MTYPE_To_TY (MTYPE_V16I8);
00932 else
00933 idx = MTYPE_To_TY (MTYPE_V16F8);
00934 break;
00935 default: Fail_FmtAssertion ("Get_TY: NYI");
00936 }
00937 break;
00938 default:
00939 Fail_FmtAssertion ("Get_TY: Unexpected vector type");
00940 }
00941 }
00942 break;
00943 #endif // TARG_X8664
00944 default:
00945 FmtAssert(FALSE, ("Get_TY unexpected tree_type"));
00946 }
00947 if (TYPE_READONLY(type_tree))
00948 Set_TY_is_const (idx);
00949 if (TYPE_VOLATILE(type_tree))
00950 Set_TY_is_volatile (idx);
00951 #ifdef KEY
00952 if (TYPE_RESTRICT(type_tree))
00953 Set_TY_is_restrict (idx);
00954 #endif
00955 TYPE_TY_IDX(type_tree) = idx;
00956 if(Debug_Level >= 2) {
00957 struct mongoose_gcc_DST_IDX dst =
00958 Create_DST_type_For_Tree(type_tree,idx,orig_idx);
00959 TYPE_DST_IDX(type_tree) = dst;
00960 }
00961 return idx;
00962 }
00963
00964 #ifdef KEY
00965 void
00966 Create_DST_For_Tree (tree decl_node, ST* st)
00967 {
00968 struct mongoose_gcc_DST_IDX dst =
00969 Create_DST_decl_For_Tree(decl_node,st);
00970 DECL_DST_IDX(decl_node) = dst;
00971 return;
00972 }
00973 #endif
00974
00975 ST*
00976 Create_ST_For_Tree (tree decl_node)
00977 {
00978 TY_IDX ty_idx;
00979 ST* st;
00980 char *name;
00981 ST_SCLASS sclass;
00982 ST_EXPORT eclass;
00983 SYMTAB_IDX level;
00984
00985 if (TREE_CODE(decl_node) == ERROR_MARK)
00986 exit (RC_USER_ERROR);
00987
00988 #ifdef PATHSCALE_MERGE
00989
00990 if (TREE_CODE (decl_node) == VAR_DECL &&
00991 (TREE_STATIC(decl_node) || DECL_EXTERNAL(decl_node) || TREE_PUBLIC(decl_node) ) &&
00992 DECL_ASSEMBLER_NAME(decl_node) ) {
00993 name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME(decl_node));
00994 if (*name == '*' ) name++;
00995 }
00996 else if (DECL_NAME (decl_node)) {
00997 #ifdef TARG_NVISA
00998 if (TREE_CODE(decl_node) == PARM_DECL) {
00999 static char buf[256];
01000
01001
01002 sprintf(buf, "__cudaparm_%s_%s",
01003 ST_name(Get_Current_PU_ST()),
01004 IDENTIFIER_POINTER (DECL_NAME (decl_node)));
01005 name = buf;
01006 }
01007 else
01008 #endif
01009 name = IDENTIFIER_POINTER (DECL_NAME (decl_node));
01010 }
01011
01012 #endif
01013 else {
01014 DevWarn ("no name for DECL_NODE");
01015 name = "__unknown__";
01016 }
01017
01018 switch (TREE_CODE(decl_node)) {
01019
01020 case FUNCTION_DECL:
01021 {
01022 TY_IDX func_ty_idx = Get_TY(TREE_TYPE(decl_node));
01023
01024 if (DECL_WIDEN_RETVAL (decl_node)) {
01025
01026
01027
01028
01029 tree type_tree = TREE_TYPE(decl_node);
01030 tree ret_type_tree = TREE_TYPE (type_tree);
01031 TY_IDX ret_ty_idx = Get_TY(ret_type_tree);
01032 if (MTYPE_signed (TY_mtype (ret_ty_idx)))
01033 TREE_TYPE (type_tree) = long_long_integer_type_node;
01034 else
01035 TREE_TYPE (type_tree) = long_long_unsigned_type_node;
01036 TY_IDX old_func_ty_idx = func_ty_idx;
01037 func_ty_idx = Create_TY_For_Tree (type_tree, TY_IDX_ZERO);
01038 TREE_TYPE (type_tree) = ret_type_tree;
01039 TYPE_TY_IDX(type_tree) = old_func_ty_idx;
01040 }
01041
01042 sclass = SCLASS_EXTERN;
01043 eclass = TREE_PUBLIC(decl_node) ? EXPORT_PREEMPTIBLE : EXPORT_LOCAL;
01044 level = GLOBAL_SYMTAB+1;
01045
01046 PU_IDX pu_idx;
01047 PU& pu = New_PU (pu_idx);
01048
01049 PU_Init (pu, func_ty_idx, level);
01050
01051 st = New_ST (GLOBAL_SYMTAB);
01052
01053 if (DECL_CDECL(decl_node))
01054 Set_PU_is_cdecl(pu_idx);
01055
01056 #ifdef KEY // Fix bug # 34
01057
01058 char * check_for_star = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (
01059 decl_node));
01060 if (*check_for_star == '*')
01061 check_for_star++;
01062 ST_Init (st, Save_Str (check_for_star),
01063 CLASS_FUNC, sclass, eclass, TY_IDX (pu_idx));
01064 #else
01065 ST_Init (st,
01066 Save_Str ( IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl_node))),
01067 CLASS_FUNC, sclass, eclass, TY_IDX (pu_idx));
01068 #endif // KEY
01069
01070
01071
01072
01073 }
01074 break;
01075
01076 case PARM_DECL:
01077 case VAR_DECL:
01078 {
01079 if (TREE_CODE(decl_node) == PARM_DECL) {
01080 sclass = SCLASS_FORMAL;
01081 eclass = EXPORT_LOCAL;
01082 level = CURRENT_SYMTAB;
01083 }
01084 else {
01085 if (DECL_CONTEXT (decl_node) == 0) {
01086 if (TREE_PUBLIC (decl_node)) {
01087 if (DECL_INITIAL(decl_node))
01088 sclass = SCLASS_DGLOBAL;
01089 else if (TREE_STATIC(decl_node)) {
01090 if (flag_no_common || DECL_SECTION_NAME(decl_node) ||
01091 DECL_THREAD_LOCAL(decl_node) )
01092 sclass = SCLASS_UGLOBAL;
01093 else
01094 sclass = SCLASS_COMMON;
01095 }
01096 else
01097 sclass = SCLASS_EXTERN;
01098 #ifdef TARG_IA64
01099
01100 extern BOOL Use_Call_Shared_Link,Gp_Rel_Aggresive_Opt;
01101 if (!flag_pic) {
01102 if (Use_Call_Shared_Link && Gp_Rel_Aggresive_Opt &&
01103 sclass != SCLASS_EXTERN && sclass != SCLASS_COMMON)
01104 eclass = EXPORT_PROTECTED;
01105 else
01106 eclass = EXPORT_PREEMPTIBLE;
01107 }
01108 else
01109 eclass = EXPORT_PREEMPTIBLE;
01110 }
01111 #else
01112 eclass = EXPORT_PREEMPTIBLE;
01113 }
01114 #endif
01115 else {
01116 sclass = SCLASS_FSTATIC;
01117 eclass = EXPORT_LOCAL;
01118 #ifdef TARG_NVISA
01119 if (TREE_CODE(TREE_TYPE(decl_node)) == ARRAY_TYPE
01120 && TYPE_SIZE(TREE_TYPE(decl_node)) == NULL)
01121 {
01122
01123
01124
01125
01126
01127
01128
01129 DevWarn("static array of unknown size, change to common");
01130 sclass = SCLASS_COMMON;
01131 eclass = EXPORT_PREEMPTIBLE;
01132 }
01133 #endif
01134 }
01135 level = GLOBAL_SYMTAB;
01136 }
01137 else {
01138 if (DECL_EXTERNAL(decl_node)) {
01139 sclass = SCLASS_EXTERN;
01140 level = GLOBAL_SYMTAB;
01141 eclass = EXPORT_PREEMPTIBLE;
01142 }
01143 else {
01144 if (TREE_STATIC (decl_node)) {
01145 sclass = SCLASS_PSTATIC;
01146 if (pstatic_as_global
01147 #ifdef KEY
01148
01149
01150
01151 || DECL_PROMOTE_STATIC (decl_node)
01152 #endif
01153 )
01154 level = GLOBAL_SYMTAB;
01155 else
01156 level = CURRENT_SYMTAB;
01157 }
01158 else {
01159 sclass = SCLASS_AUTO;
01160 level = decl_node->decl.symtab_idx ?
01161 decl_node->decl.symtab_idx : CURRENT_SYMTAB;
01162 }
01163 eclass = EXPORT_LOCAL;
01164 }
01165 }
01166 }
01167 st = New_ST (level);
01168 ty_idx = Get_TY (TREE_TYPE(decl_node));
01169 if (TY_kind (ty_idx) == KIND_ARRAY &&
01170 TREE_STATIC (decl_node) &&
01171 DECL_INITIAL (decl_node) == FALSE &&
01172 TY_size (ty_idx) == 0) {
01173 Set_TY_size (ty_idx, TY_size (Get_TY (TREE_TYPE (TREE_TYPE (decl_node)))));
01174 }
01175 #ifndef KEY
01176
01177
01178 if (TY_mtype (ty_idx) == MTYPE_M &&
01179 Aggregate_Alignment > 0 &&
01180 Aggregate_Alignment > TY_align (ty_idx))
01181 Set_TY_align (ty_idx, Aggregate_Alignment);
01182 #endif // !KEY
01183
01184 if (TREE_READONLY(decl_node))
01185 Set_TY_is_const (ty_idx);
01186 if (TREE_THIS_VOLATILE(decl_node))
01187 Set_TY_is_volatile (ty_idx);
01188
01189 #ifdef KEY
01190
01191 if (DECL_USER_ALIGN (decl_node))
01192 Set_TY_align (ty_idx, DECL_ALIGN_UNIT (decl_node));
01193
01194
01195
01196
01197
01198 #endif // KEY
01199 ST_Init (st, Save_Str(name), CLASS_VAR, sclass, eclass, ty_idx);
01200 if (TREE_CODE(decl_node) == PARM_DECL) {
01201 Set_ST_is_value_parm(st);
01202 }
01203 if (TREE_CODE(decl_node) == VAR_DECL && TREE_READONLY(decl_node)
01204
01205
01206
01207 && ST_sclass(st) != SCLASS_AUTO)
01208 {
01209 Set_ST_is_const_var(st);
01210 }
01211 if (TREE_CODE(decl_node) == VAR_DECL && DECL_THREAD_LOCAL(decl_node)) {
01212 Set_ST_is_thread_local (st);
01213 }
01214 }
01215 break;
01216
01217 default:
01218 {
01219 Fail_FmtAssertion ("Create_ST_For_Tree: unexpected tree type");
01220 }
01221 break;
01222 }
01223
01224 DECL_ST(decl_node) = st;
01225
01226 if ((DECL_WEAK (decl_node)) && (TREE_CODE (decl_node) != PARM_DECL)) {
01227 Set_ST_is_weak_symbol (st);
01228
01229
01230
01231
01232 }
01233
01234 #ifdef TARG_NVISA
01235 if (DECL_GLOBAL(decl_node)) {
01236 Set_ST_in_global_mem (st);
01237 }
01238 if (DECL_LOCAL(decl_node)) {
01239 Set_ST_in_local_mem (st);
01240 }
01241 if (DECL_SHARED(decl_node)) {
01242 Set_ST_in_shared_mem (st);
01243 if (ST_sclass(st) == SCLASS_FORMAL)
01244 Set_ST_is_const_var(st);
01245 }
01246 if (DECL_CONSTANT(decl_node)) {
01247 Set_ST_in_constant_mem (st);
01248 Set_ST_is_const_var(st);
01249 }
01250 if (DECL_TEXTURE(decl_node)) {
01251 Set_ST_in_texture_mem (st);
01252 }
01253 if (DECL_THREAD_LIMIT (decl_node) != 0 &&
01254 DECL_BLOCK_LIMIT (decl_node) != 0 ) {
01255 Set_PU_thread_limit (Pu_Table [ST_pu(st)], DECL_THREAD_LIMIT (decl_node));
01256 Set_PU_block_limit (Pu_Table [ST_pu(st)], DECL_BLOCK_LIMIT (decl_node));
01257 }
01258 #endif
01259
01260 if (DECL_SECTION_NAME (decl_node)) {
01261 if (TREE_CODE (decl_node) == FUNCTION_DECL)
01262 level = GLOBAL_SYMTAB;
01263 ST_ATTR_IDX st_attr_idx;
01264 ST_ATTR& st_attr = New_ST_ATTR (level, st_attr_idx);
01265 ST_ATTR_Init (st_attr, ST_st_idx (st), ST_ATTR_SECTION_NAME,
01266 Save_Str (TREE_STRING_POINTER (DECL_SECTION_NAME (decl_node))));
01267 Set_ST_has_named_section (st);
01268 }
01269
01270 if (DECL_SYSCALL_LINKAGE (decl_node)) {
01271 Set_PU_has_syscall_linkage (Pu_Table [ST_pu(st)]);
01272 }
01273
01274 #if defined(TARG_SL)
01275 if(DECL_SL_MODEL_NAME(decl_node)) {
01276 if(TREE_CODE(decl_node) == VAR_DECL &&
01277 TREE_CODE(DECL_SL_MODEL_NAME(decl_node)) == STRING_CST)
01278 {
01279 if(!strcmp(TREE_STRING_POINTER(DECL_SL_MODEL_NAME(decl_node)), "small"))
01280 Set_ST_gprel(st);
01281 else if(!strcmp(TREE_STRING_POINTER(DECL_SL_MODEL_NAME(decl_node)), "large"))
01282 Set_ST_not_gprel(st);
01283 else
01284 Fail_FmtAssertion("incorrect model type for sl data model");
01285 }
01286 }
01287 #endif
01288
01289 if(Debug_Level >= 2) {
01290 #ifdef KEY
01291
01292 if (ST_sclass(st) != SCLASS_EXTERN) {
01293 DST_INFO_IDX dst_idx ;
01294 struct mongoose_gcc_DST_IDX tdst
01295 = DECL_DST_IDX(decl_node);
01296 cp_to_dst_from_tree(&dst_idx,&tdst);
01297
01298
01299
01300
01301
01302
01303
01304
01305 if(ST_class(st) == CLASS_VAR && !DST_IS_NULL(dst_idx)) {
01306 DST_INFO *info_ptr = DST_INFO_IDX_TO_PTR(dst_idx);
01307 DST_ATTR_IDX attr_idx = DST_INFO_attributes(info_ptr);
01308 DST_VARIABLE *attr = DST_ATTR_IDX_TO_PTR(attr_idx, DST_VARIABLE);
01309 DST_ASSOC_INFO_st_idx(DST_VARIABLE_def_st(attr)) = ST_st_idx(st);
01310 } else {
01311 struct mongoose_gcc_DST_IDX dst =
01312 Create_DST_decl_For_Tree(decl_node,st);
01313 DECL_DST_IDX(decl_node) = dst;
01314 }
01315 }
01316 #else
01317 struct mongoose_gcc_DST_IDX dst =
01318 Create_DST_decl_For_Tree(decl_node,st);
01319 DECL_DST_IDX(decl_node) = dst;
01320 #endif
01321 }
01322
01323
01324
01325
01326
01327
01328
01329
01330
01331
01332
01333
01334 #ifdef TARG_SL
01335 const char* section_name;
01336 int has_assigned_section = 0;
01337 if(DECL_VBUF(decl_node))
01338 {
01339 if(DECL_V1BUF(decl_node) && TREE_CODE(decl_node) != FUNCTION_DECL
01340 && !POINTER_TYPE_P(TREE_TYPE(decl_node)))
01341 {
01342 Set_ST_in_v1buf(st);
01343 Set_ST_gprel(st);
01344 }
01345 else if(DECL_V2BUF(decl_node) && TREE_CODE(decl_node) != FUNCTION_DECL
01346 && !POINTER_TYPE_P(TREE_TYPE(decl_node)))
01347 {
01348 Set_ST_in_v2buf(st);
01349 Set_ST_gprel(st);
01350
01351 TY_IDX st_ty_idx=ST_type(st);
01352 Set_TY_size (st_ty_idx, TY_size(st_ty_idx)*2);
01353
01354 }
01355 else if(DECL_V4BUF(decl_node) && TREE_CODE(decl_node) != FUNCTION_DECL
01356 && !POINTER_TYPE_P(TREE_TYPE(decl_node)))
01357 {
01358 Set_ST_in_v4buf(st);
01359 Set_ST_gprel(st);
01360
01361 TY_IDX st_ty_idx=ST_type(st);
01362 Set_TY_size (st_ty_idx, TY_size(st_ty_idx)*4);
01363
01364 }
01365 }
01366 else if(DECL_SBUF(decl_node) && TREE_CODE(decl_node) != FUNCTION_DECL
01367 && !POINTER_TYPE_P(TREE_TYPE(decl_node))) {
01368 if(TREE_CODE(TREE_TYPE(decl_node)) == ARRAY_TYPE)
01369 {
01370 tree element_type = TREE_TYPE(decl_node);
01371 while(TREE_CODE(element_type) == ARRAY_TYPE)
01372 element_type = TREE_TYPE(element_type);
01373
01374 if(!POINTER_TYPE_P(element_type))
01375 {
01376 Set_ST_in_sbuf(st);
01377 Set_ST_gprel(st);
01378 }
01379 }
01380 else
01381 {
01382 Set_ST_in_sbuf(st);
01383 Set_ST_gprel(st);
01384 }
01385 }
01386 else if(DECL_SDRAM(decl_node) && TREE_CODE(decl_node) != FUNCTION_DECL
01387 && !POINTER_TYPE_P(TREE_TYPE(decl_node))) {
01388 Set_ST_in_sdram(st);
01389 }
01390 #endif // TARG_SL
01391
01392 return st;
01393 }