Subversion Repositories Open64

[/] [trunk/] [osprey/] [wgen/] [wgen_spin_symbol.cxx] - Diff between revs 2360 and 2694

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 2360 Rev 2694
Line 84... Line 84...
#include "erfe.h"
#include "erfe.h"
#ifdef TARG_X8664
#ifdef TARG_X8664
#include <ctype.h>
#include <ctype.h>
#endif
#endif
//#include "tree_cmp.h"
//#include "tree_cmp.h"
 
#include <erglob.h>
#include <ext/hash_set>
#include <ext/hash_set>
using __gnu_cxx::hash_set;
using __gnu_cxx::hash_set;
typedef struct {
typedef struct {
    size_t operator()(void* p) const { return reinterpret_cast<size_t>(p); }
    size_t operator()(void* p) const { return reinterpret_cast<size_t>(p); }
} void_ptr_hash;
} void_ptr_hash;
Line 97... Line 97...
extern BOOL flag_no_common;
extern BOOL flag_no_common;
extern gs_t decl_arguments;
extern gs_t decl_arguments;
 
 
extern void Push_Deferred_Function(gs_t);
extern void Push_Deferred_Function(gs_t);
extern char *WGEN_Tree_Node_Name(gs_t op);
extern char *WGEN_Tree_Node_Name(gs_t op);
 
#if defined(TARG_SL)
 
extern char *Orig_Src_File_Name, *Src_File_Name;
 
#endif
#ifdef KEY
#ifdef KEY
// =====================================================================
// =====================================================================
// bug 8346: A function's VLA argument types should only be expanded
// bug 8346: A function's VLA argument types should only be expanded
// when necessary, to prevent size-expression-whirl from landing in an
// when necessary, to prevent size-expression-whirl from landing in an
// unintended location. If we attempt to expand such a type while
// unintended location. If we attempt to expand such a type while
Line 424... Line 426...
      else
      else
#ifndef KEY
#ifndef KEY
        Fail_FmtAssertion ("VLA at line %d not currently implemented", lineno);
        Fail_FmtAssertion ("VLA at line %d not currently implemented", lineno);
#else
#else
      // bugs 943, 11277, 10506
      // bugs 943, 11277, 10506
      {
#if defined(TARG_SL)
        // Should use ErrMsg (or something similar) instead.
        ErrMsg(EC_Unimplemented_Feature, "variable-length structure",
        printf(OPEN64_NAME_PREFIX "cc: variable-length structure not yet implemented\n");
          Orig_Src_File_Name?Orig_Src_File_Name:Src_File_Name, lineno);
        exit(2);
#else
      }
        ErrMsg(EC_Unimplemented_Feature, "variable-length structure");
 
#endif
#endif
#endif
      variable_size = TRUE;
      variable_size = TRUE;
      tsize = 0;
      tsize = 0;
    }
    }
    else
    else
Line 480... Line 483...
      // a new type to which we can attach the flag.
      // a new type to which we can attach the flag.
      TY &ty = New_TY (idx);
      TY &ty = New_TY (idx);
      TY_Init (ty, tsize, KIND_SCALAR, mtype,
      TY_Init (ty, tsize, KIND_SCALAR, mtype,
               Save_Str(Get_Name(gs_type_name(type_tree))) );
               Save_Str(Get_Name(gs_type_name(type_tree))) );
      Set_TY_no_ansi_alias (ty);
      Set_TY_no_ansi_alias (ty);
 
#if defined(TARG_SL)
 
      // for -m32, it is not the predefined type, alignment shoule be set.
 
      // Corresponding to following code about bug#2932.
 
      if (!TARGET_64BIT)
 
        Set_TY_align (idx, align);
 
#endif
    } else
    } else
#endif
#endif
    idx = MTYPE_To_TY (mtype);  // use predefined type
    idx = MTYPE_To_TY (mtype);  // use predefined type
#ifdef TARG_X8664
#if defined(TARG_X8664) || defined(TARG_SL)
    /* At least for -m32, the alignment is not the same as the data
    /* At least for -m32, the alignment is not the same as the data
       type's natural size. (bug#2932)
       type's natural size. (bug#2932)
    */
    */
    if( TARGET_64BIT )
    if( TARGET_64BIT )
#endif // TARG_X8664
#endif // TARG_X8664
Line 597... Line 606...
 
 
    // =================== Array stride ======================
    // =================== Array stride ======================
    if (gs_tree_code(gs_type_size(gs_tree_type(type_tree))) == GS_INTEGER_CST) {
    if (gs_tree_code(gs_type_size(gs_tree_type(type_tree))) == GS_INTEGER_CST) {
      Set_ARB_const_stride (arb);
      Set_ARB_const_stride (arb);
      Set_ARB_stride_val (arb,
      Set_ARB_stride_val (arb,
        gs_get_integer_value (gs_type_size(gs_tree_type(type_tree)))
        gs_get_integer_value (gs_type_size_unit(gs_tree_type(type_tree))));
        / BITSPERBYTE);
 
    }
    }
#ifdef KEY /* bug 8346 */
#ifdef KEY /* bug 8346 */
    else if (!expanding_function_definition &&
    else if (!expanding_function_definition &&
             processing_function_prototype)
             processing_function_prototype)
    {
    {
Line 612... Line 620...
      Set_TY_is_incomplete (idx);
      Set_TY_is_incomplete (idx);
    }
    }
#endif
#endif
    else {
    else {
      WN *swn;
      WN *swn;
      swn = WGEN_Expand_Expr (gs_type_size(gs_tree_type(type_tree)));
      swn = WGEN_Expand_Expr (gs_type_size_unit(gs_tree_type(type_tree)));
      if (WN_opcode (swn) == OPC_U4I4CVT ||
      if (WN_opcode (swn) == OPC_U4I4CVT ||
          WN_opcode (swn) == OPC_U8I8CVT) {
          WN_opcode (swn) == OPC_U8I8CVT) {
        swn = WN_kid0 (swn);
        swn = WN_kid0 (swn);
      }
      }
#ifdef KEY
#ifdef KEY
      // In the event that swn operator is not
      // In the event that swn operator is not
      // OPR_LDID, save expr node swn
      // OPR_LDID, save expr node swn
      // and use LDID of that stored address as swn.
      // and use LDID of that stored address as swn.
      // Copied from Wfe_Save_Expr in wfe_expr.cxx
      // Copied from Wfe_Save_Expr in wfe_expr.cxx
      if (WN_operator (swn) != OPR_LDID) {
      if (WN_operator (swn) != OPR_LDID) {
        TY_IDX    ty_idx  =
 
          Get_TY (gs_tree_type (type_size));
        TYPE_ID   mtype   = WN_rtype(swn);
        TYPE_ID   mtype   = TY_mtype (ty_idx);
        TY_IDX    ty_idx  = MTYPE_To_TY(mtype);
        ST       *st;
        ST       *st;
        st = Gen_Temp_Symbol (ty_idx, "__save_expr");
        st = Gen_Temp_Symbol (ty_idx, "__save_expr");
#ifdef FE_GNU_4_2_0
#ifdef FE_GNU_4_2_0
        WGEN_add_pragma_to_enclosing_regions (WN_PRAGMA_LOCAL, st);
        WGEN_add_pragma_to_enclosing_regions (WN_PRAGMA_LOCAL, st);
#endif
#endif
Line 690... Line 698...
      }
      }
      ST *st;
      ST *st;
      TY_IDX ty_idx;
      TY_IDX ty_idx;
      WN *wn;
      WN *wn;
      if (WN_operator (uwn) != OPR_LDID) {
      if (WN_operator (uwn) != OPR_LDID) {
        ty_idx = Get_TY (gs_tree_type (gs_type_max_value (gs_type_domain (type_tree)) ) );
        ty_idx  = MTYPE_To_TY(WN_rtype(uwn));
        st = Gen_Temp_Symbol (ty_idx, "__vla_bound");
        st = Gen_Temp_Symbol (ty_idx, "__vla_bound");
#ifdef FE_GNU_4_2_0
#ifdef FE_GNU_4_2_0
          WGEN_add_pragma_to_enclosing_regions (WN_PRAGMA_LOCAL, st);
          WGEN_add_pragma_to_enclosing_regions (WN_PRAGMA_LOCAL, st);
#endif
#endif
        wn = WN_Stid (TY_mtype (ty_idx), 0, st, ty_idx, uwn);
        wn = WN_Stid (TY_mtype (ty_idx), 0, st, ty_idx, uwn);
Line 728... Line 736...
       }
       }
       else
       else
#endif
#endif
       {
       {
      WN *swn, *wn;
      WN *swn, *wn;
      swn = WGEN_Expand_Expr (type_size);
      swn = WGEN_Expand_Expr (gs_type_size_unit(type_tree));
      if (TY_size(TY_etype(ty))) {
      if (TY_size(TY_etype(ty))) {
        if (WN_opcode (swn) == OPC_U4I4CVT ||
        if (WN_opcode (swn) == OPC_U4I4CVT ||
            WN_opcode (swn) == OPC_U8I8CVT) {
            WN_opcode (swn) == OPC_U8I8CVT) {
          swn = WN_kid0 (swn);
          swn = WN_kid0 (swn);
        }
        }
Line 740... Line 748...
        // In the event that swn operator is not
        // In the event that swn operator is not
        // OPR_LDID, save expr node swn
        // OPR_LDID, save expr node swn
        // and use LDID of that stored address as swn.
        // and use LDID of that stored address as swn.
        // Copied from Wfe_Save_Expr in wfe_expr.cxx
        // Copied from Wfe_Save_Expr in wfe_expr.cxx
        if (WN_operator (swn) != OPR_LDID) {
        if (WN_operator (swn) != OPR_LDID) {
          TY_IDX    ty_idx  =
          TYPE_ID   mtype   = WN_rtype(swn);
            Get_TY (gs_tree_type (type_size));
          TY_IDX    ty_idx  = MTYPE_To_TY(mtype);
          TYPE_ID   mtype   = TY_mtype (ty_idx);
 
          ST       *st;
          ST       *st;
          st = Gen_Temp_Symbol (ty_idx, "__save_expr");
          st = Gen_Temp_Symbol (ty_idx, "__save_expr");
#ifdef FE_GNU_4_2_0
#ifdef FE_GNU_4_2_0
            WGEN_add_pragma_to_enclosing_regions (WN_PRAGMA_LOCAL, st);
            WGEN_add_pragma_to_enclosing_regions (WN_PRAGMA_LOCAL, st);
#endif
#endif
Line 759... Line 766...
        FmtAssert (WN_operator (swn) == OPR_LDID,
        FmtAssert (WN_operator (swn) == OPR_LDID,
          ("size operator for VLA not LDID"));
          ("size operator for VLA not LDID"));
        ST *st = WN_st (swn);
        ST *st = WN_st (swn);
        TY_IDX ty_idx = ST_type (st);
        TY_IDX ty_idx = ST_type (st);
        TYPE_ID mtype = TY_mtype (ty_idx);
        TYPE_ID mtype = TY_mtype (ty_idx);
        swn = WN_Div (mtype, swn, WN_Intconst (mtype, BITSPERBYTE));
 
        wn = WN_Stid (mtype, 0, st, ty_idx, swn);
        wn = WN_Stid (mtype, 0, st, ty_idx, swn);
        WGEN_Stmt_Append (wn, Get_Srcpos());
        WGEN_Stmt_Append (wn, Get_Srcpos());
      }
      }
#ifdef KEY /* bug 8346 */
#ifdef KEY /* bug 8346 */
      Clear_TY_is_incomplete (idx);
      Clear_TY_is_incomplete (idx);
Line 1893... Line 1900...
  if (gs_tree_code(decl_node) == GS_VAR_DECL && gs_decl_register(decl_node) &&
  if (gs_tree_code(decl_node) == GS_VAR_DECL && gs_decl_register(decl_node) &&
      gs_decl_asmreg(decl_node) >= 0) {
      gs_decl_asmreg(decl_node) >= 0) {
    extern PREG_NUM Map_Reg_To_Preg []; // defined in common/com/arch/config_targ.cxx
    extern PREG_NUM Map_Reg_To_Preg []; // defined in common/com/arch/config_targ.cxx
    int reg = gs_decl_asmreg(decl_node);
    int reg = gs_decl_asmreg(decl_node);
    PREG_NUM preg = Map_Reg_To_Preg [reg];
    PREG_NUM preg = Map_Reg_To_Preg [reg];
 
#if defined(TARG_SL)
 
    if (preg < 0 || preg > 31)
 
      ErrMsg (EC_Unimplemented_Feature, "Variable in Special register",
 
        Orig_Src_File_Name?Orig_Src_File_Name:Src_File_Name, lineno);
 
#endif
 
 
    FmtAssert (preg >= 0,
    FmtAssert (preg >= 0,
               ("mapping register %d to preg failed\n", reg));
               ("mapping register %d to preg failed\n", reg));
    TY_IDX ty_idx = ST_type (st);
    TY_IDX ty_idx = ST_type (st);
    Set_TY_is_volatile (ty_idx);
    Set_TY_is_volatile (ty_idx);
    Set_ST_type (st, ty_idx);
    Set_ST_type (st, ty_idx);