Quick Search:

Mode

Context

Displaying 3 lines of context. None | Less | More | Full

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.46
 
1.47
 
MAIN:ragge:20110821090748
 
local2.c
_>4242 static int regoff[MAXREGS];
 4343 static TWORD ftype;
 4444 char *rbyte[], *rshort[], *rlong[];
<> 45+static int needframe;
4546 
 4647 /*
 4748  * Print out the prolog assembler.
     
 !
5253 {
 5354         int i;
 5455 
<>55 -        /* XXX should look if there is any need to emit this */
5656         printf("\tpushq %%rbp\n");
 5757         printf("\tmovq %%rsp,%%rbp\n");
 5858         addto = (addto+15) & ~15; /* 16-byte aligned */
     
 !
8585         return addto;
 8686 }
 8787 
<> 88+/*
  89+ * Traverse a tree to check if we need to emit a frame at all.
  90+ * We emit it if:
  91+ * - any function call
  92+ * - rsp or rbp referenced
  93+ * Return 1 if frame is needed, 0 otherwise.
  94+ */
  95+static int
  96+chkf(NODE *p)
  97+{
  98+        int o = p->n_op;
  99+
  100+        if ((o == REG || o == OREG) && (regno(p) == RBP || regno(p) == RSP))
  101+                return 1;
  102+        if (callop(o))
  103+                return 1;
  104+        if (optype(o) == UTYPE)
  105+                return chkf(p->n_left);
  106+        else if (optype(o) == BITYPE)
  107+                return chkf(p->n_left) || chkf(p->n_right);
  108+        return 0;
  109+}
  110+
  111+static int
  112+chkframe(struct interpass_prolog *ipp)
  113+{
  114+        struct interpass *ip;
  115+
  116+        DLIST_FOREACH(ip, &ipp->ipp_ip, qelem) {
  117+                if (ip->type == IP_EPILOG)
  118+                        break;
  119+                if (ip->type == IP_NODE) {
  120+                        if (chkf(ip->ip_node))
  121+                                return 1;
  122+                }
  123+        }
  124+        return 0;
  125+}
  126+
88127 void
 89128 prologue(struct interpass_prolog *ipp)
 90129 {
 91130         int addto;
 92131 
 93132         ftype = ipp->ipp_type;
 94133 
<> 134+        if (xdeljumps)
  135+                needframe = chkframe(ipp);
  136+
95137 #ifdef LANG_F77
 96138         if (ipp->ipp_vis)
 97139                 printf("        .globl %s\n", ipp->ipp_name);
     
 !
103145          * add to the stack.
 104146          */
 105147         addto = offcalc(ipp);
<>106 -        prtprolog(ipp, addto);
  148+        if (addto)
  149+                needframe = 1;
  150+        if (needframe)
  151+                prtprolog(ipp, addto);
107152 }
 108153 
 109154 void
     
 !
114159         if (ipp->ipp_ip.ip_lbl == 0)
 115160                 return; /* no code needs to be generated */
 116161 
<>117 -        /* return from function code */
 118 -        for (i = 0; i < MAXREGS; i++)
 119 -                if (TESTBIT(ipp->ipp_regs, i))
 120 -                        fprintf(stdout, "       movq -%d(%s),%s\n",
 121 -                            regoff[i], rnames[FPREG], rnames[i]);
  162+        if (needframe) {
  163+                /* return from function code */
  164+                for (i = 0; i < MAXREGS; i++)
  165+                        if (TESTBIT(ipp->ipp_regs, i))
  166+                                fprintf(stdout, "       movq -%d(%s),%s\n",
  167+                                    regoff[i], rnames[FPREG], rnames[i]);
122168 
<>123 -        /* struct return needs special treatment */
 124 -        if (ftype == STRTY || ftype == UNIONTY) {
 125 -                printf("        movl 8(%%ebp),%%eax\n");
 126 -                printf("        leave\n");
 127 -                printf("        ret $%d\n", 4);
 128 -        } else {
 129 -                printf("        leave\n");
 130 -                printf("        ret\n");
 131 -        }
  169+                /* struct return needs special treatment */
  170+                if (ftype == STRTY || ftype == UNIONTY) {
  171+                        printf("        movl 8(%%ebp),%%eax\n");
  172+                        printf("        leave\n");
  173+                        printf("        ret $%d\n", 4);
  174+                } else {
  175+                        printf("        leave\n");
  176+                        printf("        ret\n");
  177+                }
  178+        } else
  179+                printf("\tret\n");
  180+
<_132181 #ifndef MACHOABI
 133182         printf("\t.size %s,.-%s\n", ipp->ipp_name, ipp->ipp_name);
 134183 #endif
FishEye: Open Source License registered to PCC.
Your maintenance has expired. You can renew your license at http://www.atlassian.com/fisheye/renew
Atlassian FishEye, CVS analysis. (Version:1.6.3 Build:build-336 2008-11-04) - Administration - Page generated 2014-09-23 04:22 +0200