Subversion Repositories Open64

[/] [trunk/] [osprey/] [be/] [com/] [data_layout.cxx] - Diff between revs 1950 and 2694

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

Rev 1950 Rev 2694
Line 97... Line 97...
#endif
#endif
#if defined(TARG_SL)
#if defined(TARG_SL)
#include <map>
#include <map>
#include <vector>
#include <vector>
#include "fb_whirl.h"
#include "fb_whirl.h"
 
#include "config_debug.h"
#endif
#endif
extern void Early_Terminate (INT status);
extern void Early_Terminate (INT status);
 
 
#ifdef TARG_MIPS
#if defined(TARG_MIPS) && !defined(TARG_SL)
#if defined(TARG_SL)
 
static BOOL inline Is_Target_32bit (void) { return TRUE; }
 
#else
 
//static BOOL inline Is_Target_64bit (void) { return TRUE; }
//static BOOL inline Is_Target_64bit (void) { return TRUE; }
static BOOL inline Is_Target_32bit (void) { return FALSE; }
static BOOL inline Is_Target_32bit (void) { return FALSE; }
#endif
 
#endif // TARG_MIPS
#endif // TARG_MIPS
 
 
#define ST_force_gprel(s) ST_gprel(s)
#define ST_force_gprel(s) ST_gprel(s)
 
 
ST *SP_Sym;
ST *SP_Sym;
Line 249... Line 246...
 
 
// bug fix for OSP_138
// bug fix for OSP_138
BOOL ST_has_Predefined_Named_Section (ST *, SECTION_IDX &);
BOOL ST_has_Predefined_Named_Section (ST *, SECTION_IDX &);
static void Allocate_Object_To_Predefined_Named_Section (ST *, SECTION_IDX);
static void Allocate_Object_To_Predefined_Named_Section (ST *, SECTION_IDX);
 
 
 
enum _sec_kind Get_Const_Var_Section()
 
{
 
#if defined(TARG_SL)
 
    return _SEC_DATA;
 
#else
 
    return _SEC_RDATA;
 
#endif
 
}
 
 
extern BOOL
extern BOOL
Is_Allocated (ST *st)
Is_Allocated (ST *st)
{
{
  ST *base;
  ST *base;
  INT64 ofst;
  INT64 ofst;
Line 1067... Line 1073...
    switch (ST_sclass(st)) {
    switch (ST_sclass(st)) {
    case SCLASS_DGLOBAL:
    case SCLASS_DGLOBAL:
    case SCLASS_FSTATIC:
    case SCLASS_FSTATIC:
    case SCLASS_PSTATIC:
    case SCLASS_PSTATIC:
      // must be initialized
      // must be initialized
          if (ST_is_constant(st)) sec = _SEC_RDATA;
      if (ST_is_constant(st)) sec = Get_Const_Var_Section();
            // bug fix for OSP_129
            // bug fix for OSP_129
      else if ( ST_is_initialized(st) )
      else if ( ST_is_initialized(st) )
        sec = _SEC_DATA;
        sec = _SEC_DATA;
      else
      else
              sec = _SEC_BSS; // if data is not initialized, it's still in BSS
              sec = _SEC_BSS; // if data is not initialized, it's still in BSS
      break;
      break;
    case SCLASS_UGLOBAL:
    case SCLASS_UGLOBAL:
#ifdef KEY
#ifdef KEY
          if (ST_is_constant(st) && // bug 4743
          if (ST_is_constant(st) && // bug 4743
          !ST_is_weak_symbol(st)) { // bug 4823
          !ST_is_weak_symbol(st)) { // bug 4823
        sec = _SEC_RDATA;
        sec = Get_Const_Var_Section();
      } else
      } else
#endif
#endif
#if defined(TARG_SL)
#if defined(TARG_SL)
      if (name != _SEC_BSS) {
      if (name != _SEC_BSS) {
        DevWarn("change user specified section symbol to be initialized");
        DevWarn("change user specified section symbol to be initialized");
Line 2544... Line 2550...
Is_String_Literal (ST *st)
Is_String_Literal (ST *st)
{
{
  if (ST_class(st) == CLASS_CONST && TCON_ty(STC_val(st)) == MTYPE_STR) {
  if (ST_class(st) == CLASS_CONST && TCON_ty(STC_val(st)) == MTYPE_STR) {
    return TRUE;
    return TRUE;
  }
  }
 
#ifndef TARG_SL
  /* sometimes strings are in const array vars */
  /* sometimes strings are in const array vars */
  else if (ST_class(st) == CLASS_VAR && ST_is_const_var(st)
  else if (ST_class(st) == CLASS_VAR && ST_is_const_var(st)
    && ST_is_initialized(st)
    && ST_is_initialized(st)
    && TY_kind(ST_type(st)) == KIND_ARRAY
    && TY_kind(ST_type(st)) == KIND_ARRAY
    && TY_mtype(TY_AR_etype(ST_type(st))) == MTYPE_U1 )
    && TY_mtype(TY_AR_etype(ST_type(st))) == MTYPE_U1 )
  {
  {
    return TRUE;
    return TRUE;
  }
  }
 
#endif
  return FALSE;
  return FALSE;
}
}
 
 
/* ====================================================================
/* ====================================================================
 *
 *
Line 2587... Line 2595...
   }
   }
 
 
   newsec = Corresponding_Short_Section (sec);
   newsec = Corresponding_Short_Section (sec);
   if (newsec == sec) return sec; // won't be shortened
   if (newsec == sec) return sec; // won't be shortened
 
 
#ifdef TARG_X8664
#if defined (TARG_X8664) || defined (TARG_SL)
   /* bug#539
   /* bug#539
      Do not generate gprel load/store to <newsec> if <newsec> is not gprel.
      Do not generate gprel load/store to <newsec> if <newsec> is not gprel.
    */
    */
   if( !SEC_is_gprel( newsec ) ){
   if( !SEC_is_gprel( newsec ) ){
     return sec;
     return sec;
Line 2699... Line 2707...
     Is_True( IS_POW2(align), ("Alignment %d must be power of 2",align));
     Is_True( IS_POW2(align), ("Alignment %d must be power of 2",align));
 
 
  block = Get_Section_ST (sec, align, SCLASS_UNKNOWN /* cause varies */);
  block = Get_Section_ST (sec, align, SCLASS_UNKNOWN /* cause varies */);
  max_size = SEC_max_sec_size(sec);
  max_size = SEC_max_sec_size(sec);
  if ( Trace_Frame ) {
  if ( Trace_Frame ) {
    fprintf(TFile, "Allocating %s to %s", ST_name(st), ST_name(block));
    fprintf(TFile, "Allocating %s to %s\n", ST_name(st), ST_name(block));
  }
  }
  ST_Block_Merge (block, st, 0, 0, max_size);
  ST_Block_Merge (block, st, 0, 0, max_size);
}
}
 
 


Line 3064... Line 3072...
 *
 *
 * =====================================================================
 * =====================================================================
 */
 */
static void
static void
Allocate_Object_To_Predefined_Named_Section(ST *st, SECTION_IDX sec_idx) {
Allocate_Object_To_Predefined_Named_Section(ST *st, SECTION_IDX sec_idx) {
 
  // bug fix 572: for extern st, we should not allocate them.
 
  if (ST_class(st) == CLASS_FUNC) {
 
     if (ST_sclass(st) == SCLASS_EXTERN) {
 
         return;
 
     }
 
  } else if (ST_class(st) == CLASS_VAR) {
 
     if (ST_sclass(st) == SCLASS_EXTERN) {
 
         return;
 
     }
 
  } else
 
     FmtAssert(FALSE, ("unexpected section attribute"));
 
 
  Clear_ST_has_named_section(st); // Clear st's flag for ST_HAS_NAMED_SECTION
  Clear_ST_has_named_section(st); // Clear st's flag for ST_HAS_NAMED_SECTION
  Set_ST_base_idx(st,ST_st_idx(st));  // Set st's base index equel to st index
  Set_ST_base_idx(st,ST_st_idx(st));  // Set st's base index equel to st index
  Set_ST_ofst(st,0);      // Set st's offset to 0
  Set_ST_ofst(st,0);      // Set st's offset to 0
 
 
  // if object was supposed to go into bss,
  // if object was supposed to go into bss,
Line 3308... Line 3328...
#ifdef TARG_X8664
#ifdef TARG_X8664
      if (Gen_PIC_Shared)
      if (Gen_PIC_Shared)
  sec = _SEC_DATA_REL_RO; // bug 6925
  sec = _SEC_DATA_REL_RO; // bug 6925
      else
      else
#endif
#endif
      sec = _SEC_RDATA;
  sec = Get_Const_Var_Section();
    }
    }
 
 
#ifdef TARG_SL
#ifdef TARG_SL
    else if (ST_in_vbuf(st)) {
    else if (ST_in_vbuf(st)) {
      sec = Get_Vbuf_Section(st);
      sec = Get_Vbuf_Section(st);