Open64 (mfef90, whirl2f, and IR tools)
TAG: version-openad; SVN changeset: 916
|
00001 /* 00002 00003 Copyright (C) 2003 Rice University. 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 */ 00025 00026 #ifndef unparse_target_ftn_INCLUDED 00027 #define unparse_target_ftn_INCLUDED 00028 /* ==================================================================== 00029 * 00030 * 00031 * Revision history: 00032 * 06-Jun-03 - Original Version 00033 * 00034 * Description: 00035 * 00036 * Runtime tests for the Fortran target language. 00037 */ 00038 00039 #include "unparse_target.h" 00040 #include "whirl2f_common.h" 00041 #include "symtab.h" 00042 #include "intrn_info.h" 00043 #include "wutil.h" 00044 #include "token_names.h" 00045 00046 static const char * 00047 W2CF_Get_Ftn_St_Name(const ST *st, const char *original_name) 00048 { 00049 const char *extern_name; 00050 00051 char *name_ptr; 00052 00053 if (Stab_External_Linkage(st) && 00054 !Stab_Is_Based_At_Common_Or_Equivalence(st) && 00055 !(ST_sym_class(st) == CLASS_VAR && ST_is_namelist(st))) 00056 { 00057 /* Here we deal with a curiosity of the Fortran naming scheme for 00058 * external names: 00059 * 00060 * + If the name ends with a '_', the name was without the '_' 00061 * in the original Fortran source. 00062 * 00063 * + If the name ends without a '_', the name was with a '$' 00064 * suffix in the original Fortran source. 00065 * 00066 * + Unless the external name was a namelist variable, then even 00067 * though there isn't a trailing '_', don't emit a '$'. 00068 */ 00069 extern_name = name_ptr = 00070 strcpy(Get_Name_Buf_Slot(strlen(original_name)+2), original_name); 00071 00072 /* Get the last character */ 00073 while (name_ptr[1] != '\0') 00074 name_ptr++; 00075 00076 /* Correct the name-suffix */ 00077 if (extern_name[0] != '_' && name_ptr[0] == '_') 00078 { 00079 if (name_ptr[-1] == '_') 00080 name_ptr[-1] = '\0'; 00081 else 00082 name_ptr[0] = '\0'; 00083 } 00084 else if (!WN2F_F90_pu) 00085 { 00086 name_ptr[1] = '$'; 00087 name_ptr[2] = '\0'; 00088 } 00089 } 00090 else /* Not an external variable */ 00091 extern_name = original_name; 00092 00093 return extern_name; 00094 00095 } /* W2CF_Get_Ftn_St_Name */ 00096 00097 static const char *Ftn_Reserved_Ty_Name[] = 00098 { 00099 "split_st", /* compiler generated */ 00100 "__$w2c_predef_ld_union", /* compiler generated */ 00101 "__$w2c_predef_ldv_union" /* compiler generated */ 00102 }; /* Ftn_Reserved_Ty_Name */ 00103 00104 static const char *Ftn_Reserved_St_Name[] = 00105 { 00106 "TO DO" 00107 }; /* Ftn_Reserved_St_Names */ 00108 00109 #define NUM_FTN_TY_RNAMES (sizeof(Ftn_Reserved_Ty_Name)/sizeof(char *)) 00110 #define NUM_FTN_ST_RNAMES (sizeof(Ftn_Reserved_St_Name)/sizeof(char *)) 00111 00112 class Unparse_Target_FTN : public Unparse_Target { 00113 public: 00114 Unparse_Target_FTN () 00115 { 00116 reserved_ty_names = new Reserved_Name_Set (NUM_FTN_TY_RNAMES, Ftn_Reserved_Ty_Name); 00117 reserved_st_names = new Reserved_Name_Set (NUM_FTN_ST_RNAMES, Ftn_Reserved_St_Name); 00118 } 00119 00120 ~Unparse_Target_FTN () {}; 00121 00122 const char *Make_Valid_Name(const char *name, BOOL allow_dot) 00123 { return WHIRL2F_make_valid_name(name, WN2F_F90_pu && allow_dot); } 00124 00125 const char *Get_St_Name(const ST *st, const char *original_name) 00126 { return W2CF_Get_Ftn_St_Name (st, original_name); } 00127 00128 const char *Intrinsic_Name(INTRINSIC intr_opc) 00129 { 00130 const char *name; 00131 00132 Is_True(INTRINSIC_FIRST<=intr_opc && intr_opc<=INTRINSIC_LAST, 00133 ("Intrinsic Opcode (%d) out of range", intr_opc)); 00134 if (INTRN_specific_name(intr_opc) != NULL) 00135 name = INTRN_specific_name(intr_opc); 00136 else 00137 { 00138 /* ASSERT_WARN(FALSE, 00139 (DIAG_A_STRING, 00140 Concat2_Strings("Missing intrinsic name ", 00141 get_intrinsic_name(intr_opc)))); 00142 */ 00143 name = get_intrinsic_name(intr_opc); 00144 } 00145 00146 return name; 00147 00148 } 00149 00150 BOOL Avoid_Common_Suffix(void) 00151 { 00152 BOOL avoid = TRUE; 00153 return avoid; 00154 } 00155 00156 BOOL Reduce_Const_Ptr_Exprs(void) 00157 { 00158 return FALSE; 00159 } 00160 00161 BOOL Enter_Symtab_Pointee_Names(void) 00162 { 00163 return TRUE; 00164 } 00165 00166 BOOL Redeclare_File_Types (void) 00167 { 00168 return TRUE; 00169 } 00170 00171 BOOL Builtin_Type (TY_IDX ty) 00172 { 00173 return FALSE; /* Mimicking behavior of WHIRL2F. */ 00174 } 00175 00176 BOOL Is_Binary_Or_Tertiary_Op (char c) 00177 { 00178 return (c==PLUS || \ 00179 c==MINUS || \ 00180 c==MULTIPLY || \ 00181 c==DIVIDE || \ 00182 c==BITAND || \ 00183 c==BITOR || \ 00184 c==EQUAL || \ 00185 c==NOT || \ 00186 c==QUESTION_MARK || \ 00187 c==COLON || \ 00188 c==LESS_THAN || \ 00189 c==LARGER_THAN); 00190 } 00191 00192 /*------ Function type attributes ------*/ 00193 /*--------------------------------------*/ 00194 00195 BOOL Func_Return_Character(TY_IDX func_ty) 00196 { 00197 return TY_is_character(Ty_Table[TY_ret_type(func_ty)]); 00198 } /* Func_Return_Character */ 00199 00200 TY_IDX Func_Return_Type(TY_IDX func_ty) 00201 { 00202 return TY_ret_type(func_ty); 00203 } /* Func_Return_Type */ 00204 00205 BOOL Func_Return_To_Param(TY_IDX func_ty) 00206 { 00207 return TY_return_to_param(Ty_Table[func_ty]); 00208 } /* Func_Return_To_Param */ 00209 00210 00211 }; 00212 00213 #endif /* unparse_target_ftn_INCLUDED */