Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef unparse_target_c_INCLUDED
00027 #define unparse_target_c_INCLUDED
00028
00029
00030
00031
00032
00033
00034
00035
00036
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",
00048 "__cabs_s",
00049 "__cabsl_s",
00050 "__fcabs_s",
00051 "__qcabs_s",
00052 "exception",
00053 "_COMPLEX32",
00054 "_COMPLEX64",
00055 "_COMPLEXQD",
00056 "split_st",
00057 "__$w2c_predef_ld_union",
00058 "__$w2c_predef_ldv_union"
00059 };
00060
00061 static const char *C_Reserved_St_Name[] =
00062 {
00063 "__huge_val",
00064 "_lib_version",
00065 };
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
00150
00151
00152 BOOL Func_Return_Character(TY_IDX func_ty)
00153 {
00154 return FALSE;
00155 }
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 }
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 }
00168
00169
00170 };
00171
00172 #endif