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
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #define __STDC_LIMIT_MACROS
00043 #include <stdint.h>
00044 #include "defs.h"
00045 #include "symtab.h"
00046 #include "targ_sim.h"
00047 #include "lwn_util.h"
00048
00049 #include "ipa_option.h"
00050 #include "ipa_cg.h"
00051 #include "ipo_defs.h"
00052 #include "ipo_parent.h"
00053 #include "ipo_dce.h"
00054
00055
00056
00057
00058 static UINT32
00059 Compute_Return_Pregs(TY_IDX callee_ty)
00060 {
00061 PREG_NUM Reg1, Reg2;
00062 TYPE_ID ty1, ty2;
00063 TY_IDX typ;
00064
00065 #ifdef KEY
00066 BOOL ret_via_first_arg = FALSE;
00067 #endif
00068
00069
00070 if (typ = Tylist_Table[TY_tylist(Ty_Table[callee_ty])])
00071 if (TY_kind(typ) != KIND_VOID) {
00072
00073 if (WHIRL_Return_Info_On) {
00074
00075 RETURN_INFO return_info = Get_Return_Info (typ, Use_Simulated);
00076
00077 if (RETURN_INFO_count(return_info) <= 2) {
00078
00079 ty1 = RETURN_INFO_mtype (return_info, 0);
00080 ty2 = RETURN_INFO_mtype (return_info, 1);
00081 Reg1 = RETURN_INFO_preg (return_info, 0);
00082 Reg2 = RETURN_INFO_preg (return_info, 1);
00083 #ifdef KEY
00084 ret_via_first_arg = RETURN_INFO_return_via_first_arg (return_info);
00085 #endif
00086 }
00087
00088 else
00089 Fail_FmtAssertion ("Compute_Return_Pregs: more than 2 return registers");
00090 }
00091
00092 else {
00093 Get_Return_Mtypes(typ, Use_Simulated, &ty1, &ty2);
00094 Get_Return_Pregs(ty1, ty2, &Reg1, &Reg2);
00095 }
00096
00097 if (Reg1 && Reg2)
00098 return 2;
00099 else if (Reg1 || Reg2
00100 #ifdef KEY
00101 || ret_via_first_arg
00102 #endif
00103 )
00104 return 1;
00105 }
00106
00107 return 0;
00108 }
00109
00110
00111
00112
00113 BOOL
00114 Delete_Call (IPA_NODE *caller, const IPA_NODE *callee, IPA_EDGE *edge,
00115 IPA_CALL_GRAPH* cg)
00116 {
00117 IPA_NODE_CONTEXT context (caller);
00118 cg->Map_Callsites (caller);
00119 WN* call = edge->Whirl_Node();
00120 WN* b = WN_Get_Parent(call, Parent_Map, Current_Map_Tab);
00121
00122 if ((WN_operator(b) != OPR_BLOCK))
00123 return FALSE;
00124
00125 UINT32 Reg_count = (WN_operator (call) == OPR_ICALL) ?
00126 Compute_Return_Pregs (WN_ty (call)) :
00127 Compute_Return_Pregs (ST_pu_type (WN_st (call)));
00128
00129 if (Reg_count) {
00130 for (INT i = 0; i < Reg_count; ++i) {
00131 WN* stid = WN_next(call);
00132 if (stid && (WN_operator(stid) == OPR_STID)) {
00133 if ((WN_operator(WN_kid0(stid)) == OPR_LDID) &&
00134 (ST_sclass(WN_st(WN_kid0(stid))) == SCLASS_REG) &&
00135 Preg_Is_Dedicated(WN_offset(WN_kid0(stid)))) {
00136 WN_EXTRACT_FromBlock(b, stid);
00137 }
00138 }
00139 }
00140 }
00141 WN_EXTRACT_FromBlock(b, call);
00142 if (Trace_IPA || Trace_Perf) {
00143 fprintf (TFile, "%s called from ", DEMANGLE(ST_name(callee->Func_ST())));
00144 fprintf (TFile, "%s deleted\n", DEMANGLE(ST_name(caller->Func_ST())));
00145 }
00146 return TRUE;
00147 }