]> git.lizzy.rs Git - plan9front.git/commitdiff
6c: extern register fix (import from patch/6c-extreg)
authorcinap_lenrek <cinap_lenrek@gmx.de>
Tue, 18 Sep 2012 16:18:43 +0000 (18:18 +0200)
committercinap_lenrek <cinap_lenrek@gmx.de>
Tue, 18 Sep 2012 16:18:43 +0000 (18:18 +0200)
to make it easy to use normal libraries (such as libdraw, libsec, and libmp)
with the kernel, which uses extern register, don't stray into the external
register set when allocating values to registers.

amd64/include/u.h
sys/src/cmd/6c/reg.c
sys/src/cmd/6c/txt.c
sys/src/cmd/6l/span.c

index feb121703c75e06dade84cfc63dbc0b211f470dd..8dce5066fcb92b2e4ba821abdbfd14a4db0c5f7c 100644 (file)
@@ -10,7 +10,7 @@ typedef unsigned long long uintptr;
 typedef unsigned long  usize;
 typedef        ushort          Rune;
 typedef union FPdbleword FPdbleword;
-typedef uvlong         jmp_buf[2];
+typedef uintptr                jmp_buf[2];
 #define        JMPBUFSP        0
 #define        JMPBUFPC        1
 #define        JMPBUFDPC       0
index 32b9abf5db9054879de7c33ba0c9d5b72907f4b5..43e21a4f37d506a5be3ac413890e6d36172e27bd 100644 (file)
@@ -50,6 +50,8 @@ regopt(Prog *p)
        lastr = R;
        nvar = 0;
        regbits = RtoB(D_SP) | RtoB(D_AX) | RtoB(D_X0);
+       if(REGEXT)
+               regbits |= RtoB(REGEXT) | RtoB(REGEXT-1);
        for(z=0; z<BITS; z++) {
                externs.b[z] = 0;
                params.b[z] = 0;
index 24ac1db46f7795cf031419fcf9ba19f4f947547a..e3b9a9ee5baaf80c5849156c45e642bc0013e620 100644 (file)
@@ -1,5 +1,7 @@
 #include "gc.h"
 
+static int     resvreg[nelem(reg)];
+
 void
 ginit(void)
 {
@@ -94,6 +96,7 @@ ginit(void)
        if(0)
                com64init();
 
+       memset(reg, 0, sizeof(reg));
        for(i=0; i<nelem(reg); i++) {
                reg[i] = 1;
                if(i >= D_AX && i <= D_R15 && i != D_SP)
@@ -101,6 +104,10 @@ ginit(void)
                if(i >= D_X0 && i <= D_X7)
                        reg[i] = 0;
        }
+       /* keep two external registers */
+       reg[REGEXT] = 1;
+       reg[REGEXT-1] = 1;
+       memmove(resvreg, reg, sizeof(resvreg));
 }
 
 void
@@ -111,10 +118,10 @@ gclean(void)
 
        reg[D_SP]--;
        for(i=D_AX; i<=D_R15; i++)
-               if(reg[i])
+               if(reg[i] && !resvreg[i])
                        diag(Z, "reg %R left allocated", i);
        for(i=D_X0; i<=D_X7; i++)
-               if(reg[i])
+               if(reg[i] && !resvreg[i])
                        diag(Z, "reg %R left allocated", i);
        while(mnstring)
                outstring("", 1L);
@@ -179,7 +186,7 @@ nareg(void)
 
        n = 0;
        for(i=D_AX; i<=D_R15; i++)
-               if(reg[i] == 0)
+               if(reg[i] == 0 && !resvreg[i])
                        n++;
        return n;
 }
@@ -337,7 +344,7 @@ regalloc(Node *n, Node *tn, Node *o)
                                goto out;
                }
                for(i=D_AX; i<=D_R15; i++)
-                       if(reg[i] == 0)
+                       if(reg[i] == 0 && !resvreg[i])
                                goto out;
                diag(tn, "out of fixed registers");
                goto err;
@@ -350,7 +357,7 @@ regalloc(Node *n, Node *tn, Node *o)
                                goto out;
                }
                for(i=D_X0; i<=D_X7; i++)
-                       if(reg[i] == 0)
+                       if(reg[i] == 0 && !resvreg[i])
                                goto out;
                diag(tn, "out of float registers");
                goto out;
index 78399a2b3b68e745f15c1b16c7466a86836f2ef1..ec36e1490bac748474d2d10955fe9a067fa58ef7 100644 (file)
@@ -668,6 +668,9 @@ asmandsz(Adr *a, int r, int rex, int m64)
 
        rex &= (0x40 | Rxr);
        v = a->offset;
+       if ((vlong)v != a->offset) 
+               print("asmandsz: Trying to emit %#ullx and 32 bits is not sufficient\n",
+                       a->offset);
        t = a->type;
        if(a->index != D_NONE) {
                if(t >= D_INDIR) {