Commit fa32e922 authored by Austin Clements's avatar Austin Clements

[dev.power64] gc: convert Bits to a uint64 array

So far all of our architectures have had at most 32 registers,
so we've been able to use entry 0 in the Bits uint32 array
directly as a register mask.  Power64 has 64 registers, so
this converts Bits to a uint64 array so we can continue to use
entry 0 directly as a register mask on Power64.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/169060043
parent a5e1e159
...@@ -63,8 +63,8 @@ enum ...@@ -63,8 +63,8 @@ enum
uint32 BLOAD(Reg*); uint32 BLOAD(Reg*);
uint32 BSTORE(Reg*); uint32 BSTORE(Reg*);
uint32 LOAD(Reg*); uint64 LOAD(Reg*);
uint32 STORE(Reg*); uint64 STORE(Reg*);
*/ */
// A Reg is a wrapper around a single Prog (one instruction) that holds // A Reg is a wrapper around a single Prog (one instruction) that holds
...@@ -145,7 +145,7 @@ void synch(Reg*, Bits); ...@@ -145,7 +145,7 @@ void synch(Reg*, Bits);
uint32 allreg(uint32, Rgn*); uint32 allreg(uint32, Rgn*);
void paint1(Reg*, int); void paint1(Reg*, int);
uint32 paint2(Reg*, int); uint32 paint2(Reg*, int);
void paint3(Reg*, int, int32, int); void paint3(Reg*, int, uint32, int);
void addreg(Adr*, int); void addreg(Adr*, int);
void dumpit(char *str, Flow *r0, int); void dumpit(char *str, Flow *r0, int);
...@@ -156,10 +156,10 @@ void peep(Prog*); ...@@ -156,10 +156,10 @@ void peep(Prog*);
void excise(Flow*); void excise(Flow*);
int copyu(Prog*, Adr*, Adr*); int copyu(Prog*, Adr*, Adr*);
int32 RtoB(int); uint32 RtoB(int);
int32 FtoB(int); uint32 FtoB(int);
int BtoR(int32); int BtoR(uint32);
int BtoF(int32); int BtoF(uint32);
/* /*
* prog.c * prog.c
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
#include "opt.h" #include "opt.h"
#define NREGVAR 32 #define NREGVAR 32
#define REGBITS ((uint32)0xffffffff) #define REGBITS ((uint64)0xffffffffull)
/*c2go enum { /*c2go enum {
NREGVAR = 32, NREGVAR = 32,
REGBITS = 0xffffffff, REGBITS = 0xffffffff,
...@@ -86,7 +86,7 @@ setaddrs(Bits bit) ...@@ -86,7 +86,7 @@ setaddrs(Bits bit)
i = bnum(bit); i = bnum(bit);
node = var[i].node; node = var[i].node;
n = var[i].name; n = var[i].name;
bit.b[i/32] &= ~(1L<<(i%32)); biclr(&bit, i);
// disable all pieces of that variable // disable all pieces of that variable
for(i=0; i<nvar; i++) { for(i=0; i<nvar; i++) {
...@@ -425,7 +425,7 @@ loop2: ...@@ -425,7 +425,7 @@ loop2:
if(debug['R'] > 1) if(debug['R'] > 1)
print("\n"); print("\n");
paint1(r, i); paint1(r, i);
bit.b[i/32] &= ~(1L<<(i%32)); biclr(&bit, i);
if(change <= 0) { if(change <= 0) {
if(debug['R']) if(debug['R'])
print("%L $%d: %Q\n", print("%L $%d: %Q\n",
...@@ -570,7 +570,7 @@ walkvardef(Node *n, Reg *r, int active) ...@@ -570,7 +570,7 @@ walkvardef(Node *n, Reg *r, int active)
break; break;
for(v=n->opt; v!=nil; v=v->nextinnode) { for(v=n->opt; v!=nil; v=v->nextinnode) {
bn = v - var; bn = v - var;
r1->act.b[bn/32] |= 1L << (bn%32); biset(&r1->act, bn);
} }
if(r1->f.prog->as == ABL) if(r1->f.prog->as == ABL)
break; break;
...@@ -606,7 +606,7 @@ addsplits(void) ...@@ -606,7 +606,7 @@ addsplits(void)
~(r->calahead.b[z] & addrs.b[z]); ~(r->calahead.b[z] & addrs.b[z]);
while(bany(&bit)) { while(bany(&bit)) {
i = bnum(bit); i = bnum(bit);
bit.b[i/32] &= ~(1L << (i%32)); biclr(&bit, i);
} }
} }
} }
...@@ -972,10 +972,10 @@ prop(Reg *r, Bits ref, Bits cal) ...@@ -972,10 +972,10 @@ prop(Reg *r, Bits ref, Bits cal)
for(z=0; z<BITS; z++) { for(z=0; z<BITS; z++) {
if(cal.b[z] == 0) if(cal.b[z] == 0)
continue; continue;
for(i=0; i<32; i++) { for(i=0; i<64; i++) {
if(z*32+i >= nvar || ((cal.b[z]>>i)&1) == 0) if(z*64+i >= nvar || ((cal.b[z]>>i)&1) == 0)
continue; continue;
v = var+z*32+i; v = var+z*64+i;
if(v->node->opt == nil) // v represents fixed register, not Go variable if(v->node->opt == nil) // v represents fixed register, not Go variable
continue; continue;
...@@ -991,10 +991,10 @@ prop(Reg *r, Bits ref, Bits cal) ...@@ -991,10 +991,10 @@ prop(Reg *r, Bits ref, Bits cal)
// This will set the bits at most twice, keeping the overall loop linear. // This will set the bits at most twice, keeping the overall loop linear.
v1 = v->node->opt; v1 = v->node->opt;
j = v1 - var; j = v1 - var;
if(v == v1 || ((cal.b[j/32]>>(j&31))&1) == 0) { if(v == v1 || !btest(&cal, j)) {
for(; v1 != nil; v1 = v1->nextinnode) { for(; v1 != nil; v1 = v1->nextinnode) {
j = v1 - var; j = v1 - var;
cal.b[j/32] |= 1<<(j&31); biset(&cal, j);
} }
} }
} }
...@@ -1115,10 +1115,10 @@ paint1(Reg *r, int bn) ...@@ -1115,10 +1115,10 @@ paint1(Reg *r, int bn)
Reg *r1; Reg *r1;
Prog *p; Prog *p;
int z; int z;
uint32 bb; uint64 bb;
z = bn/32; z = bn/64;
bb = 1L<<(bn%32); bb = 1LL<<(bn%64);
if(r->act.b[z] & bb) if(r->act.b[z] & bb)
return; return;
for(;;) { for(;;) {
...@@ -1193,10 +1193,10 @@ paint2(Reg *r, int bn) ...@@ -1193,10 +1193,10 @@ paint2(Reg *r, int bn)
{ {
Reg *r1; Reg *r1;
int z; int z;
uint32 bb, vreg; uint64 bb, vreg;
z = bn/32; z = bn/64;
bb = 1L << (bn%32); bb = 1LL << (bn%64);
vreg = regbits; vreg = regbits;
if(!(r->act.b[z] & bb)) if(!(r->act.b[z] & bb))
return vreg; return vreg;
...@@ -1240,15 +1240,15 @@ paint2(Reg *r, int bn) ...@@ -1240,15 +1240,15 @@ paint2(Reg *r, int bn)
} }
void void
paint3(Reg *r, int bn, int32 rb, int rn) paint3(Reg *r, int bn, uint32 rb, int rn)
{ {
Reg *r1; Reg *r1;
Prog *p; Prog *p;
int z; int z;
uint32 bb; uint64 bb;
z = bn/32; z = bn/64;
bb = 1L << (bn%32); bb = 1LL << (bn%64);
if(r->act.b[z] & bb) if(r->act.b[z] & bb)
return; return;
for(;;) { for(;;) {
...@@ -1333,7 +1333,7 @@ addreg(Adr *a, int rn) ...@@ -1333,7 +1333,7 @@ addreg(Adr *a, int rn)
* 10 R10 * 10 R10
* 12 R12 * 12 R12
*/ */
int32 uint32
RtoB(int r) RtoB(int r)
{ {
if(r >= REGTMP-2 && r != 12) // excluded R9 and R10 for m and g, but not R12 if(r >= REGTMP-2 && r != 12) // excluded R9 and R10 for m and g, but not R12
...@@ -1342,7 +1342,7 @@ RtoB(int r) ...@@ -1342,7 +1342,7 @@ RtoB(int r)
} }
int int
BtoR(int32 b) BtoR(uint32 b)
{ {
b &= 0x11fcL; // excluded R9 and R10 for m and g, but not R12 b &= 0x11fcL; // excluded R9 and R10 for m and g, but not R12
if(b == 0) if(b == 0)
...@@ -1357,7 +1357,7 @@ BtoR(int32 b) ...@@ -1357,7 +1357,7 @@ BtoR(int32 b)
* ... ... * ... ...
* 31 F15 * 31 F15
*/ */
int32 uint32
FtoB(int f) FtoB(int f)
{ {
...@@ -1367,7 +1367,7 @@ FtoB(int f) ...@@ -1367,7 +1367,7 @@ FtoB(int f)
} }
int int
BtoF(int32 b) BtoF(uint32 b)
{ {
b &= 0xfffc0000L; b &= 0xfffc0000L;
......
...@@ -63,8 +63,8 @@ enum ...@@ -63,8 +63,8 @@ enum
uint32 BLOAD(Reg*); uint32 BLOAD(Reg*);
uint32 BSTORE(Reg*); uint32 BSTORE(Reg*);
uint32 LOAD(Reg*); uint64 LOAD(Reg*);
uint32 STORE(Reg*); uint64 STORE(Reg*);
*/ */
// A Reg is a wrapper around a single Prog (one instruction) that holds // A Reg is a wrapper around a single Prog (one instruction) that holds
...@@ -141,7 +141,7 @@ void synch(Reg*, Bits); ...@@ -141,7 +141,7 @@ void synch(Reg*, Bits);
uint32 allreg(uint32, Rgn*); uint32 allreg(uint32, Rgn*);
void paint1(Reg*, int); void paint1(Reg*, int);
uint32 paint2(Reg*, int); uint32 paint2(Reg*, int);
void paint3(Reg*, int, int32, int); void paint3(Reg*, int, uint32, int);
void addreg(Adr*, int); void addreg(Adr*, int);
void dumpone(Flow*, int); void dumpone(Flow*, int);
void dumpit(char*, Flow*, int); void dumpit(char*, Flow*, int);
...@@ -153,10 +153,10 @@ void peep(Prog*); ...@@ -153,10 +153,10 @@ void peep(Prog*);
void excise(Flow*); void excise(Flow*);
int copyu(Prog*, Adr*, Adr*); int copyu(Prog*, Adr*, Adr*);
int32 RtoB(int); uint32 RtoB(int);
int32 FtoB(int); uint32 FtoB(int);
int BtoR(int32); int BtoR(uint32);
int BtoF(int32); int BtoF(uint32);
/* /*
* prog.c * prog.c
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#include "opt.h" #include "opt.h"
#define NREGVAR 32 /* 16 general + 16 floating */ #define NREGVAR 32 /* 16 general + 16 floating */
#define REGBITS ((uint32)0xffffffff) #define REGBITS ((uint64)0xffffffffull)
/*c2go enum { /*c2go enum {
NREGVAR = 32, NREGVAR = 32,
REGBITS = 0xffffffff, REGBITS = 0xffffffff,
...@@ -71,7 +71,7 @@ setaddrs(Bits bit) ...@@ -71,7 +71,7 @@ setaddrs(Bits bit)
i = bnum(bit); i = bnum(bit);
node = var[i].node; node = var[i].node;
n = var[i].name; n = var[i].name;
bit.b[i/32] &= ~(1L<<(i%32)); biclr(&bit, i);
// disable all pieces of that variable // disable all pieces of that variable
for(i=0; i<nvar; i++) { for(i=0; i<nvar; i++) {
...@@ -364,7 +364,7 @@ loop2: ...@@ -364,7 +364,7 @@ loop2:
rgp->varno = i; rgp->varno = i;
change = 0; change = 0;
paint1(r, i); paint1(r, i);
bit.b[i/32] &= ~(1L<<(i%32)); biclr(&bit, i);
if(change <= 0) if(change <= 0)
continue; continue;
rgp->cost = change; rgp->cost = change;
...@@ -477,7 +477,7 @@ walkvardef(Node *n, Reg *r, int active) ...@@ -477,7 +477,7 @@ walkvardef(Node *n, Reg *r, int active)
break; break;
for(v=n->opt; v!=nil; v=v->nextinnode) { for(v=n->opt; v!=nil; v=v->nextinnode) {
bn = v - var; bn = v - var;
r1->act.b[bn/32] |= 1L << (bn%32); biset(&r1->act, bn);
} }
if(r1->f.prog->as == ACALL) if(r1->f.prog->as == ACALL)
break; break;
...@@ -822,10 +822,10 @@ prop(Reg *r, Bits ref, Bits cal) ...@@ -822,10 +822,10 @@ prop(Reg *r, Bits ref, Bits cal)
for(z=0; z<BITS; z++) { for(z=0; z<BITS; z++) {
if(cal.b[z] == 0) if(cal.b[z] == 0)
continue; continue;
for(i=0; i<32; i++) { for(i=0; i<64; i++) {
if(z*32+i >= nvar || ((cal.b[z]>>i)&1) == 0) if(z*64+i >= nvar || ((cal.b[z]>>i)&1) == 0)
continue; continue;
v = var+z*32+i; v = var+z*64+i;
if(v->node->opt == nil) // v represents fixed register, not Go variable if(v->node->opt == nil) // v represents fixed register, not Go variable
continue; continue;
...@@ -841,10 +841,10 @@ prop(Reg *r, Bits ref, Bits cal) ...@@ -841,10 +841,10 @@ prop(Reg *r, Bits ref, Bits cal)
// This will set the bits at most twice, keeping the overall loop linear. // This will set the bits at most twice, keeping the overall loop linear.
v1 = v->node->opt; v1 = v->node->opt;
j = v1 - var; j = v1 - var;
if(v == v1 || ((cal.b[j/32]>>(j&31))&1) == 0) { if(v == v1 || !btest(&cal, j)) {
for(; v1 != nil; v1 = v1->nextinnode) { for(; v1 != nil; v1 = v1->nextinnode) {
j = v1 - var; j = v1 - var;
cal.b[j/32] |= 1UL<<(j&31); biset(&cal, j);
} }
} }
} }
...@@ -959,10 +959,10 @@ paint1(Reg *r, int bn) ...@@ -959,10 +959,10 @@ paint1(Reg *r, int bn)
{ {
Reg *r1; Reg *r1;
int z; int z;
uint32 bb; uint64 bb;
z = bn/32; z = bn/64;
bb = 1L<<(bn%32); bb = 1LL<<(bn%64);
if(r->act.b[z] & bb) if(r->act.b[z] & bb)
return; return;
for(;;) { for(;;) {
...@@ -1061,10 +1061,10 @@ paint2(Reg *r, int bn) ...@@ -1061,10 +1061,10 @@ paint2(Reg *r, int bn)
{ {
Reg *r1; Reg *r1;
int z; int z;
uint32 bb, vreg, x; uint64 bb, vreg, x;
z = bn/32; z = bn/64;
bb = 1L << (bn%32); bb = 1LL << (bn%64);
vreg = regbits; vreg = regbits;
if(!(r->act.b[z] & bb)) if(!(r->act.b[z] & bb))
return vreg; return vreg;
...@@ -1117,15 +1117,15 @@ paint2(Reg *r, int bn) ...@@ -1117,15 +1117,15 @@ paint2(Reg *r, int bn)
} }
void void
paint3(Reg *r, int bn, int32 rb, int rn) paint3(Reg *r, int bn, uint32 rb, int rn)
{ {
Reg *r1; Reg *r1;
Prog *p; Prog *p;
int z; int z;
uint32 bb; uint64 bb;
z = bn/32; z = bn/64;
bb = 1L << (bn%32); bb = 1LL << (bn%64);
if(r->act.b[z] & bb) if(r->act.b[z] & bb)
return; return;
for(;;) { for(;;) {
...@@ -1198,7 +1198,7 @@ addreg(Adr *a, int rn) ...@@ -1198,7 +1198,7 @@ addreg(Adr *a, int rn)
ostats.ncvtreg++; ostats.ncvtreg++;
} }
int32 uint32
RtoB(int r) RtoB(int r)
{ {
...@@ -1208,7 +1208,7 @@ RtoB(int r) ...@@ -1208,7 +1208,7 @@ RtoB(int r)
} }
int int
BtoR(int32 b) BtoR(uint32 b)
{ {
b &= 0xffffL; b &= 0xffffL;
if(nacl) if(nacl)
...@@ -1224,7 +1224,7 @@ BtoR(int32 b) ...@@ -1224,7 +1224,7 @@ BtoR(int32 b)
* ... * ...
* 31 X15 * 31 X15
*/ */
int32 uint32
FtoB(int f) FtoB(int f)
{ {
if(f < D_X0 || f > D_X15) if(f < D_X0 || f > D_X15)
...@@ -1233,7 +1233,7 @@ FtoB(int f) ...@@ -1233,7 +1233,7 @@ FtoB(int f)
} }
int int
BtoF(int32 b) BtoF(uint32 b)
{ {
b &= 0xFFFF0000L; b &= 0xFFFF0000L;
......
...@@ -63,8 +63,8 @@ enum ...@@ -63,8 +63,8 @@ enum
uint32 BLOAD(Reg*); uint32 BLOAD(Reg*);
uint32 BSTORE(Reg*); uint32 BSTORE(Reg*);
uint32 LOAD(Reg*); uint64 LOAD(Reg*);
uint32 STORE(Reg*); uint64 STORE(Reg*);
*/ */
// A Reg is a wrapper around a single Prog (one instruction) that holds // A Reg is a wrapper around a single Prog (one instruction) that holds
...@@ -159,7 +159,7 @@ void synch(Reg*, Bits); ...@@ -159,7 +159,7 @@ void synch(Reg*, Bits);
uint32 allreg(uint32, Rgn*); uint32 allreg(uint32, Rgn*);
void paint1(Reg*, int); void paint1(Reg*, int);
uint32 paint2(Reg*, int); uint32 paint2(Reg*, int);
void paint3(Reg*, int, int32, int); void paint3(Reg*, int, uint32, int);
void addreg(Adr*, int); void addreg(Adr*, int);
void dumpone(Flow*, int); void dumpone(Flow*, int);
void dumpit(char*, Flow*, int); void dumpit(char*, Flow*, int);
...@@ -171,10 +171,10 @@ void peep(Prog*); ...@@ -171,10 +171,10 @@ void peep(Prog*);
void excise(Flow*); void excise(Flow*);
int copyu(Prog*, Adr*, Adr*); int copyu(Prog*, Adr*, Adr*);
int32 RtoB(int); uint32 RtoB(int);
int32 FtoB(int); uint32 FtoB(int);
int BtoR(int32); int BtoR(uint32);
int BtoF(int32); int BtoF(uint32);
/* /*
* prog.c * prog.c
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#include "opt.h" #include "opt.h"
#define NREGVAR 16 /* 8 integer + 8 floating */ #define NREGVAR 16 /* 8 integer + 8 floating */
#define REGBITS ((uint32)0xffff) #define REGBITS ((uint64)0xffffull)
/*c2go enum { /*c2go enum {
NREGVAR = 16, NREGVAR = 16,
REGBITS = (1<<NREGVAR) - 1, REGBITS = (1<<NREGVAR) - 1,
...@@ -71,7 +71,7 @@ setaddrs(Bits bit) ...@@ -71,7 +71,7 @@ setaddrs(Bits bit)
i = bnum(bit); i = bnum(bit);
node = var[i].node; node = var[i].node;
n = var[i].name; n = var[i].name;
bit.b[i/32] &= ~(1L<<(i%32)); biclr(&bit, i);
// disable all pieces of that variable // disable all pieces of that variable
for(i=0; i<nvar; i++) { for(i=0; i<nvar; i++) {
...@@ -336,7 +336,7 @@ loop2: ...@@ -336,7 +336,7 @@ loop2:
rgp->varno = i; rgp->varno = i;
change = 0; change = 0;
paint1(r, i); paint1(r, i);
bit.b[i/32] &= ~(1L<<(i%32)); biclr(&bit, i);
if(change <= 0) if(change <= 0)
continue; continue;
rgp->cost = change; rgp->cost = change;
...@@ -446,7 +446,7 @@ walkvardef(Node *n, Reg *r, int active) ...@@ -446,7 +446,7 @@ walkvardef(Node *n, Reg *r, int active)
break; break;
for(v=n->opt; v!=nil; v=v->nextinnode) { for(v=n->opt; v!=nil; v=v->nextinnode) {
bn = v - var; bn = v - var;
r1->act.b[bn/32] |= 1L << (bn%32); biset(&r1->act, bn);
} }
if(r1->f.prog->as == ACALL) if(r1->f.prog->as == ACALL)
break; break;
...@@ -788,10 +788,10 @@ prop(Reg *r, Bits ref, Bits cal) ...@@ -788,10 +788,10 @@ prop(Reg *r, Bits ref, Bits cal)
for(z=0; z<BITS; z++) { for(z=0; z<BITS; z++) {
if(cal.b[z] == 0) if(cal.b[z] == 0)
continue; continue;
for(i=0; i<32; i++) { for(i=0; i<64; i++) {
if(z*32+i >= nvar || ((cal.b[z]>>i)&1) == 0) if(z*64+i >= nvar || ((cal.b[z]>>i)&1) == 0)
continue; continue;
v = var+z*32+i; v = var+z*64+i;
if(v->node->opt == nil) // v represents fixed register, not Go variable if(v->node->opt == nil) // v represents fixed register, not Go variable
continue; continue;
...@@ -807,10 +807,10 @@ prop(Reg *r, Bits ref, Bits cal) ...@@ -807,10 +807,10 @@ prop(Reg *r, Bits ref, Bits cal)
// This will set the bits at most twice, keeping the overall loop linear. // This will set the bits at most twice, keeping the overall loop linear.
v1 = v->node->opt; v1 = v->node->opt;
j = v1 - var; j = v1 - var;
if(v == v1 || ((cal.b[j/32]>>(j&31))&1) == 0) { if(v == v1 || !btest(&cal, j)) {
for(; v1 != nil; v1 = v1->nextinnode) { for(; v1 != nil; v1 = v1->nextinnode) {
j = v1 - var; j = v1 - var;
cal.b[j/32] |= 1<<(j&31); biset(&cal, j);
} }
} }
} }
...@@ -926,10 +926,10 @@ paint1(Reg *r, int bn) ...@@ -926,10 +926,10 @@ paint1(Reg *r, int bn)
Reg *r1; Reg *r1;
Prog *p; Prog *p;
int z; int z;
uint32 bb; uint64 bb;
z = bn/32; z = bn/64;
bb = 1L<<(bn%32); bb = 1LL<<(bn%64);
if(r->act.b[z] & bb) if(r->act.b[z] & bb)
return; return;
for(;;) { for(;;) {
...@@ -1038,10 +1038,10 @@ paint2(Reg *r, int bn) ...@@ -1038,10 +1038,10 @@ paint2(Reg *r, int bn)
{ {
Reg *r1; Reg *r1;
int z; int z;
uint32 bb, vreg, x; uint64 bb, vreg, x;
z = bn/32; z = bn/64;
bb = 1L << (bn%32); bb = 1LL << (bn%64);
vreg = regbits; vreg = regbits;
if(!(r->act.b[z] & bb)) if(!(r->act.b[z] & bb))
return vreg; return vreg;
...@@ -1094,15 +1094,15 @@ paint2(Reg *r, int bn) ...@@ -1094,15 +1094,15 @@ paint2(Reg *r, int bn)
} }
void void
paint3(Reg *r, int bn, int32 rb, int rn) paint3(Reg *r, int bn, uint32 rb, int rn)
{ {
Reg *r1; Reg *r1;
Prog *p; Prog *p;
int z; int z;
uint32 bb; uint64 bb;
z = bn/32; z = bn/64;
bb = 1L << (bn%32); bb = 1LL << (bn%64);
if(r->act.b[z] & bb) if(r->act.b[z] & bb)
return; return;
for(;;) { for(;;) {
...@@ -1175,7 +1175,7 @@ addreg(Adr *a, int rn) ...@@ -1175,7 +1175,7 @@ addreg(Adr *a, int rn)
ostats.ncvtreg++; ostats.ncvtreg++;
} }
int32 uint32
RtoB(int r) RtoB(int r)
{ {
...@@ -1185,7 +1185,7 @@ RtoB(int r) ...@@ -1185,7 +1185,7 @@ RtoB(int r)
} }
int int
BtoR(int32 b) BtoR(uint32 b)
{ {
b &= 0xffL; b &= 0xffL;
...@@ -1194,7 +1194,7 @@ BtoR(int32 b) ...@@ -1194,7 +1194,7 @@ BtoR(int32 b)
return bitno(b) + D_AX; return bitno(b) + D_AX;
} }
int32 uint32
FtoB(int f) FtoB(int f)
{ {
if(f < D_X0 || f > D_X7) if(f < D_X0 || f > D_X7)
...@@ -1203,7 +1203,7 @@ FtoB(int f) ...@@ -1203,7 +1203,7 @@ FtoB(int f)
} }
int int
BtoF(int32 b) BtoF(uint32 b)
{ {
b &= 0xFF00L; b &= 0xFF00L;
if(b == 0) if(b == 0)
......
...@@ -95,11 +95,11 @@ int ...@@ -95,11 +95,11 @@ int
bnum(Bits a) bnum(Bits a)
{ {
int i; int i;
int32 b; uint64 b;
for(i=0; i<BITS; i++) for(i=0; i<BITS; i++)
if(b = a.b[i]) if(b = a.b[i])
return 32*i + bitno(b); return 64*i + bitno(b);
fatal("bad in bnum"); fatal("bad in bnum");
return 0; return 0;
} }
...@@ -110,27 +110,35 @@ blsh(uint n) ...@@ -110,27 +110,35 @@ blsh(uint n)
Bits c; Bits c;
c = zbits; c = zbits;
c.b[n/32] = 1L << (n%32); c.b[n/64] = 1LL << (n%64);
return c; return c;
} }
/*
int int
bset(Bits a, uint n) btest(Bits *a, uint n)
{ {
if(a.b[n/32] & (1L << (n%32))) return (a->b[n/64] & (1LL << (n%64))) != 0;
return 1; }
return 0;
void
biset(Bits *a, uint n)
{
a->b[n/64] |= 1LL << (n%64);
}
void
biclr(Bits *a, uint n)
{
a->b[n/64] &= ~(1LL << (n%64));
} }
*/
int int
bitno(int32 b) bitno(uint64 b)
{ {
int i; int i;
for(i=0; i<32; i++) for(i=0; i<64; i++)
if(b & (1L<<i)) if(b & (1LL<<i))
return i; return i;
fatal("bad in bitno"); fatal("bad in bitno");
return 0; return 0;
...@@ -157,7 +165,7 @@ Qconv(Fmt *fp) ...@@ -157,7 +165,7 @@ Qconv(Fmt *fp)
if(var[i].offset != 0) if(var[i].offset != 0)
fmtprint(fp, "%+lld", (vlong)var[i].offset); fmtprint(fp, "%+lld", (vlong)var[i].offset);
} }
bits.b[i/32] &= ~(1L << (i%32)); biclr(&bits, i);
} }
return 0; return 0;
} }
...@@ -704,13 +704,13 @@ enum ...@@ -704,13 +704,13 @@ enum
Ecomplit = 1<<11, // type in composite literal Ecomplit = 1<<11, // type in composite literal
}; };
#define BITS 5 #define BITS 3
#define NVAR (BITS*sizeof(uint32)*8) #define NVAR (BITS*sizeof(uint64)*8)
typedef struct Bits Bits; typedef struct Bits Bits;
struct Bits struct Bits
{ {
uint32 b[BITS]; uint64 b[BITS];
}; };
EXTERN Bits zbits; EXTERN Bits zbits;
...@@ -1027,12 +1027,14 @@ int Qconv(Fmt *fp); ...@@ -1027,12 +1027,14 @@ int Qconv(Fmt *fp);
Bits band(Bits a, Bits b); Bits band(Bits a, Bits b);
int bany(Bits *a); int bany(Bits *a);
int beq(Bits a, Bits b); int beq(Bits a, Bits b);
int bitno(int32 b); int bitno(uint64 b);
Bits blsh(uint n); Bits blsh(uint n);
Bits bnot(Bits a); Bits bnot(Bits a);
int bnum(Bits a); int bnum(Bits a);
Bits bor(Bits a, Bits b); Bits bor(Bits a, Bits b);
int bset(Bits a, uint n); int btest(Bits *a, uint n);
void biset(Bits *a, uint n);
void biclr(Bits *a, uint n);
/* /*
* bv.c * bv.c
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment