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_c_INCLUDED 00027 #define unparse_target_c_INCLUDED 00028 /* ==================================================================== 00029 * 00030 * 00031 * Revision history: 00032 * 06-Jun-03 - Original Version 00033 * 00034 * Description: 00035 * 00036 * Runtime tests for the C target language. 00037 */ 00038 00039 #include "unparse_target.h" 00040 #include "whirl2c_common.h" 00041 #include "intrn_info.h" 00042 #include "token_names.h" 00043 #include "ty2c.h" 00044 00045 static const char *C_Reserved_Ty_Name[] = 00046 { 00047 "_h_val", /* <math.h> */ 00048 "__cabs_s", /* <math.h> */ 00049 "__cabsl_s", /* <math.h> */ 00050 "__fcabs_s", /* <math.h> */ 00051 "__qcabs_s", /* <math.h> */ 00052 "exception", /* <math.h> */ 00053 "_COMPLEX32", /* <whirl2c.h> */ 00054 "_COMPLEX64", /* <whirl2c.h> */ 00055 "_COMPLEXQD", /* <whirl2c.h> */ 00056 "split_st", /* compiler generated */ 00057 "__$w2c_predef_ld_union", /* compiler generated */ 00058 "__$w2c_predef_ldv_union" /* compiler generated */ 00059 }; /* C_Reserved_Ty_Name */ 00060 00061 static const char *C_Reserved_St_Name[] = 00062 { 00063 "__huge_val", /* <math.h> */ 00064 "_lib_version", /* <math.h> */ 00065 }; /* C_Reserved_St_Name */ 00066 00067 #define NUM_C_TY_RNAMES (sizeof(C_Reserved_Ty_Name)/sizeof(char *)) 00068 #define NUM_C_ST_RNAMES (sizeof(C_Reserved_St_Name)/sizeof(char *)) 00069 00070 class Unparse_Target_C : public Unparse_Target { 00071 public: 00072 Unparse_Target_C () 00073 { 00074 reserved_ty_names = new Reserved_Name_Set (NUM_C_TY_RNAMES, C_Reserved_Ty_Name); 00075 reserved_st_names = new Reserved_Name_Set (NUM_C_ST_RNAMES, C_Reserved_St_Name); 00076 } 00077 00078 ~Unparse_Target_C () {}; 00079 00080 const char *Make_Valid_Name(const char *name, BOOL allow_dot) 00081 { return WHIRL2C_make_valid_c_name(name); } 00082 00083 const char *Get_St_Name(const ST *st, const char *original_name) 00084 { return original_name; } 00085 00086 const char *Intrinsic_Name(INTRINSIC intr_opc) 00087 { 00088 const char *name; 00089 00090 Is_True(INTRINSIC_FIRST<=intr_opc && intr_opc<=INTRINSIC_LAST, 00091 ("Intrinsic Opcode (%d) out of range", intr_opc)); 00092 if (INTRN_c_name(intr_opc) != NULL) 00093 name = INTRN_c_name(intr_opc); 00094 else if (INTRN_rt_name(intr_opc) != NULL) 00095 name = INTRN_rt_name(intr_opc); 00096 else 00097 { 00098 Is_True(FALSE, 00099 ("Expected \"high_level\" or \"rt\" name in WN_intrinsic_name()")); 00100 name = 00101 Concat3_Strings("<INTR: ", Number_as_String(intr_opc, "%lld"), ">"); 00102 } 00103 00104 return name; 00105 } 00106 00107 BOOL Avoid_Common_Suffix(void) 00108 { 00109 return FALSE; 00110 } 00111 00112 BOOL Reduce_Const_Ptr_Exprs(void) 00113 { 00114 return TRUE; 00115 } 00116 00117 BOOL Enter_Symtab_Pointee_Names(void) 00118 { 00119 return FALSE; 00120 } 00121 00122 BOOL Redeclare_File_Types (void) 00123 { 00124 return FALSE; 00125 } 00126 00127 BOOL Builtin_Type (TY_IDX ty) 00128 { 00129 return TY2C_builtin(ty); 00130 } 00131 00132 BOOL Is_Binary_Or_Tertiary_Op (char c) 00133 { 00134 return (c==PLUS || \ 00135 c==MINUS || \ 00136 c==MULTIPLY || \ 00137 c==DIVIDE || \ 00138 c==BITAND || \ 00139 c==BITOR || \ 00140 c==MODULUS || \ 00141 c==EQUAL || \ 00142 c==NOT || \ 00143 c==QUESTION_MARK || \ 00144 c==COLON || \ 00145 c==LESS_THAN || \ 00146 c==LARGER_THAN); 00147 } 00148 00149 /*------ Function type attributes ------*/ 00150 /*--------------------------------------*/ 00151 00152 BOOL Func_Return_Character(TY_IDX func_ty) 00153 { 00154 return FALSE; 00155 } /* Func_Return_Character */ 00156 00157 TY_IDX Func_Return_Type(TY_IDX func_ty) 00158 { 00159 return TY_is_character(Ty_Table[TY_ret_type(func_ty)]) ? 00160 Void_Type : TY_ret_type(func_ty); 00161 } /* Func_Return_Type */ 00162 00163 BOOL Func_Return_To_Param(TY_IDX func_ty) 00164 { 00165 return TY_return_to_param(Ty_Table[func_ty]) && 00166 !TY_is_character(Ty_Table[TY_ret_type(func_ty)]); 00167 } /* Func_Return_To_Param */ 00168 00169 00170 }; 00171 00172 #endif /* unparse_target_c_INCLUDED */