Open64 (mfef90, whirl2f, and IR tools)  TAG: version-openad; SVN changeset: 916
weak.cxx
Go to the documentation of this file.
00001 /*
00002 
00003   Copyright (C) 2000, 2001 Silicon Graphics, Inc.  All Rights Reserved.
00004 
00005   This program is free software; you can redistribute it and/or modify it
00006   under the terms of version 2 of the GNU General Public License as
00007   published by the Free Software Foundation.
00008 
00009   This program is distributed in the hope that it would be useful, but
00010   WITHOUT ANY WARRANTY; without even the implied warranty of
00011   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
00012 
00013   Further, this software is distributed without any warranty that it is
00014   free of the rightful claim of any third person regarding infringement 
00015   or the like.  Any license provided herein, whether implied or 
00016   otherwise, applies only to this software file.  Patent licenses, if 
00017   any, provided herein do not apply to combinations of this program with 
00018   other software, or any other product whatsoever.  
00019 
00020   You should have received a copy of the GNU General Public License along
00021   with this program; if not, write the Free Software Foundation, Inc., 59
00022   Temple Place - Suite 330, Boston MA 02111-1307, USA.
00023 
00024   Contact information:  Silicon Graphics, Inc., 1600 Amphitheatre Pky,
00025   Mountain View, CA 94043, or:
00026 
00027   http://www.sgi.com
00028 
00029   For further information regarding this notice, see:
00030 
00031   http://oss.sgi.com/projects/GenInfo/NoticeExplan
00032 
00033 */
00034 
00035 
00036 // This file contains only Linux-specific code and should be entirely
00037 // #ifdef'd out for Irix.
00038 
00039 #if defined(__linux__) || defined(_GCC_NO_PRAGMAWEAK) || defined(__CYGWIN__)
00040 
00041 // Work around the "undefined weak symbol" bug in Linux.
00042 //
00043 // The run-time linker in Linux only resolves undefined weak symbols once
00044 // at start-up time of a process.  When such symbols cannot be resolved, it
00045 // (correctly) sets their addresses to zero.  However, if later a DSO is
00046 // linked in via "dlopen", and if now this DSO defines some of the
00047 // previously undefined weak symbols, the Linux run-time linker should, but
00048 // in this case does not, update their addresses.
00049 //
00050 // A workaround is to *not* reference these weak symbol directly but always 
00051 // through a pointer, and explicitly initialized the pointer when the DSO
00052 // is linked in.  For example:
00053 //
00054 // In the main program where the symbol (my_data) is referenced:
00055 //
00056 // #ifdef __linux__
00057 // int* my_data_p;
00058 // #define my_data (*my_data_p)
00059 // #else
00060 // extern int my_data;
00061 // #pragma weak my_data
00062 // #endif
00063 //
00064 // In the dso where the symbol is defined:
00065 //
00066 // int my_data;
00067 //
00068 // #ifdef __linux__
00069 // extern int* my_data_p;
00070 // void __init ()
00071 // {
00072 //     my_data_p = &my_data;
00073 // }
00074 //
00075 // __init() is a special function the Linux linker recognizes and places in 
00076 // .init section (or equivalent?) of the dso.  The runtime linker will call 
00077 // this function upon mapping in this dso.
00078 
00079 #include "defs.h"
00080 #include "wn.h"
00081 #include "pu_info.h"
00082 #include "ir_bwrite.h"
00083 
00084 // ----------------------------------------------------------------------
00085 // symbols defined in lno.so:
00086 // from be/lno/lnodriver.h
00087 
00088 void (*lno_main_p) (INT, char**, INT, char**);
00089 void (*Lno_Init_p) ();
00090 void (*Lno_Fini_p) ();
00091 WN* (*Perform_Loop_Nest_Optimization_p) (PU_Info*, WN*, WN*, BOOL);
00092 
00093 // ----------------------------------------------------------------------
00094 // symbols defined in ipl.so:
00095 // from ipa/local/ipl_main.cxx
00096 
00097 void (*Ipl_Extra_Output_p) (Output_File *);
00098 void (*Ipl_Init_p) ();
00099 void (*Ipl_Fini_p) ();
00100 void (*ipl_main_p) (INT, char **);
00101 
00102 // ----------------------------------------------------------------------
00103 // symbols from whirl2c.so 
00104 
00105 void (*W2C_Cleanup_p)(void);
00106 void (*W2C_Fini_p)(void);
00107 void (*W2C_Init_p)(void);
00108 const char * (*W2C_Object_Name_p)(const ST *func_st);
00109 void (*W2C_Mark_Loads_p)(void);
00110 void (*W2C_Nomark_Loads_p)(void);
00111 void (*W2C_Outfile_Fini_p)(BOOL emit_global_decls);
00112 void (*W2C_Outfile_Init_p)(BOOL emit_global_decls);
00113 void (*W2C_Outfile_Translate_Pu_p)(WN *pu, BOOL emit_global_decls);
00114 void (*W2C_Pop_PU_p)(void);
00115 void (*W2C_Process_Command_Line_p)(INT phase_argc, char * const
00116   phase_argv[], INT argc, char * const argv[]);
00117 void (*W2C_Push_PU_p)(const WN *pu, WN *body_part_of_interest);
00118 void (*W2C_Set_Prompf_Emission_p)(const WN_MAP *construct_map);
00119 void (*W2C_Set_Frequency_Map_p)(WN_MAP frequency_map);
00120 const char *(*W2C_Get_Transformed_Src_Path_p)(void);
00121 void (*W2C_Set_Purple_Emission_p)(void);
00122 void (*W2C_Reset_Purple_Emission_p)(void);
00123 BOOL (*W2C_Should_Emit_Nested_PUs_p)(void);
00124 void (*W2C_Translate_Global_Defs_p)(FILE *outfile);
00125 void (*W2C_Translate_Global_Types_p)(FILE *outfile);
00126 void (*W2C_Translate_Istore_Lhs_p)(char *strbuf,
00127   UINT bufsize, const WN* lhs, mINT64 istore_ofst, TY_IDX istore_addr_ty,
00128   TYPE_ID istore_mtype);
00129 void (*W2C_Translate_Purple_Main_p)(FILE *outfile, const WN *pu,
00130   const char *region_name);
00131 void (*W2C_Translate_Stid_Lhs_p)(char *strbuf, UINT bufsize,
00132   const ST *stid_st, mINT64 stid_ofst, TY_IDX stid_ty, TYPE_ID stid_mtype);
00133 void (*W2C_Translate_Wn_p)(FILE *outfile, const WN *wn);
00134 void (*W2C_Translate_Wn_Str_p)(char *strbuf, UINT bufsize, const
00135   WN *wn);
00136 
00137 
00138 // ----------------------------------------------------------------------
00139 // symbols from whirl2f.so  
00140 
00141 void (*W2F_Cleanup_p)(void);
00142 void (*W2F_Def_ST_p)(FILE *outfile, ST *st);
00143 void (*W2F_Fini_p)(void);
00144 void (*W2F_Init_p)(void);
00145 void (*W2F_Mark_Loads_p)(void);
00146 void (*W2F_Nomark_Loads_p)(void);
00147 const char * (*W2F_Object_Name_p)(ST *func_st);
00148 void (*W2F_Outfile_Fini_p)(void);
00149 void (*W2F_Outfile_Init_p)(void);
00150 void (*W2F_Outfile_Translate_Pu_p)(WN *pu);
00151 void (*W2F_Pop_PU_p)(void);
00152 void (*W2F_Process_Command_Line_p)(INT phase_argc, char *phase_argv[], 
00153   INT argc, char *argv[]);
00154 void (*W2F_Push_PU_p)(WN *pu, WN *body_part_of_interest);
00155 void (*W2F_Set_Prompf_Emission_p)(WN_MAP *construct_map);
00156 void (*W2F_Set_Frequency_Map_p)(WN_MAP frequency_map);
00157 const char * (*W2F_Get_Transformed_Src_Path_p)(void);
00158 void (*W2F_Reset_Purple_Emission_p)(void);
00159 void (*W2F_Set_Purple_Emission_p)(void);
00160 BOOL (*W2F_Should_Emit_Nested_PUs_p)(void);
00161 void (*W2F_Translate_Istore_Lhs_p)(char *strbuf, UINT bufsize,
00162   WN* lhs, mINT64 istore_ofst, TY_IDX istore_addr_ty, TYPE_ID istore_mtype);
00163 void (*W2F_Translate_Purple_Main_p)(FILE *outfile, WN *pu, 
00164   const char *region_name);
00165 void (*W2F_Translate_Stid_Lhs_p)(char *strbuf, UINT bufsize, 
00166   ST *stid_st, mINT64 stid_ofst, TY_IDX stid_ty, TYPE_ID stid_mtype);
00167 void (*W2F_Translate_Wn_p)(FILE *outfile, WN *wn);
00168 void (*W2F_Translate_Wn_Str_p)(char *strbuf, UINT bufsize, WN *wn);
00169 
00170 #endif // __linux__
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines