Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.59
 
1.60
 
MAIN:ragge:20071104175927
 
local.c
_>2929 
 3030 #include "pass1.h"
 3131 
<> 32+/*      this file contains code which is dependent on the target machine */
  33+
3234 /*
 3335  * Check if a constant is too large for a type.
 3436  */
     
 !
5658         return 0;
 5759 }
 5860 
<>59 -/*      this file contains code which is dependent on the target machine */
  61+#define IALLOC(sz)      (isinlining ? permalloc(sz) : tmpalloc(sz))
  62+/*
  63+ * Make a symtab entry for PIC use.
  64+ */
  65+static struct symtab *
  66+picsymtab(char *s, char *s2)
  67+{
  68+        struct symtab *sp = IALLOC(sizeof(struct symtab));
  69+        size_t len = strlen(s) + strlen(s2) + 1;
  70+        
  71+        sp->sname = IALLOC(len);
  72+        strlcpy(sp->sname, s, len);
  73+        strlcat(sp->sname, s2, len);
  74+        sp->sclass = EXTERN;
  75+        sp->slevel = 0;
  76+        return sp;
  77+}
6078 
<> 79+int gotnr; /* tempnum for GOT register */
  80+/*
  81+ * Create a reference for an extern variable.
  82+ */
  83+static NODE *
  84+picext(NODE *p)
  85+{
  86+        NODE *q, *r;
  87+
  88+        q = tempnode(gotnr, PTR|VOID, 0, MKSUE(VOID));
  89+        r = bcon(0);
  90+        r->n_sp = picsymtab(p->n_sp->sname, "@GOT");
  91+        q = buildtree(PLUS, q, r);
  92+        q = block(UMUL, q, 0, PTR|VOID, 0, MKSUE(VOID));
  93+        q = block(UMUL, q, 0, p->n_type, p->n_df, p->n_sue);
  94+        nfree(p);
  95+        return q;
  96+}
  97+
  98+/*
  99+ * Create a reference for a static variable.
  100+ */
  101+static NODE *
  102+picstatic(NODE *p)
  103+{
  104+        NODE *q, *r;
  105+
  106+        q = tempnode(gotnr, PTR|VOID, 0, MKSUE(VOID));
  107+        r = bcon(0);
  108+        if (p->n_sp->slevel > 0) {
  109+                char buf[32];
  110+                snprintf(buf, 32, LABFMT, (int)p->n_sp->soffset);
  111+                r->n_sp = picsymtab(buf, "@GOTOFF");
  112+        } else
  113+                r->n_sp = picsymtab(p->n_sp->sname, "@GOTOFF");
  114+        q = buildtree(PLUS, q, r);
  115+        q = block(UMUL, q, 0, p->n_type, p->n_df, p->n_sue);
  116+        nfree(p);
  117+        return q;
  118+}
  119+
61120 /* clocal() is called to do local transformations on
 62121  * an expression tree preparitory to its being
 63122  * written out in intermediate code.
     
 !
103162                         break;
 104163 
 105164                 case STATIC:
<>106 -                        if (q->slevel == 0)
 107 -                                break;
 108 -                        p->n_lval = 0;
 109 -                        p->n_sp = q;
  165+                        if (kflag == 0) {
  166+                                if (q->slevel == 0)
  167+                                        break;
  168+                                p->n_lval = 0;
  169+                        } else
  170+                                p = picstatic(p);
110171                         break;
 111172 
 112173                 case REGISTER:
     
 !
115176                         p->n_rval = q->soffset;
 116177                         break;
 117178 
<>118 -                        }
  179+                case EXTERN:
  180+                case EXTDEF:
  181+                        if (kflag == 0)
  182+                                break;
  183+                        if ((p->n_type & TMASK2) == FTN) {
  184+                                p->n_sp = picsymtab(q->sname, "@PLT");
  185+                        } else
  186+                                p = picext(p);
  187+                        break;
  188+                }
119189                 break;
 120190 
 121191         case STCALL:
     
 !
133203                         *l = *r;
 134204                         r->n_op = FUNARG; r->n_left = l; r->n_type = l->n_type;
 135205                 }
<> 206+                if (kflag == 0)
  207+                        break;
  208+                /* FALLTHROUGH */
  209+        case UCALL:
  210+        case USTCALL:
  211+                /* Add move node for GOT */
<_136212                 break;
 137213                 
 138214         case CBRANCH:
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-11-01 01:29 +0100