aboutsummaryrefslogtreecommitdiffhomepage
path: root/ir
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2025-12-11 20:43:24 +0100
committerlemon <lsof@mailbox.org>2025-12-11 20:43:24 +0100
commit88652eeb10cd9381aafb2d55e9474bb0799630b1 (patch)
tree2ba02aa77ce8357e29ddb502aee18109a90bd136 /ir
parent2bbdb7a6b8204ae3caa5235c4ba637834036a299 (diff)
rename arraylength macro -> countof
Diffstat (limited to 'ir')
-rw-r--r--ir/abi0.c4
-rw-r--r--ir/intrin.c6
-rw-r--r--ir/ir.c28
-rw-r--r--ir/optmem.c2
-rw-r--r--ir/regalloc.c4
5 files changed, 22 insertions, 22 deletions
diff --git a/ir/abi0.c b/ir/abi0.c
index 00090e3..1547722 100644
--- a/ir/abi0.c
+++ b/ir/abi0.c
@@ -253,7 +253,7 @@ void
abi0_call(struct function *fn, struct instr *ins, struct block *blk, int *curi)
{
union ref retmem;
- struct abiargsvec abiargs = {VINIT(abiargsbuf, arraylength(abiargsbuf))};
+ struct abiargsvec abiargs = {VINIT(abiargsbuf, countof(abiargsbuf))};
bool sretarghidden = 0;
int ni, nf, ns, vararg, nret = 0;
struct call *call = &calltab.p[ins->r.i];
@@ -363,7 +363,7 @@ abi0(struct function *fn)
{
uint nparam = typedata[fn->fnty.dat].nmemb;
const union type *paramty = typedata[fn->fnty.dat].param;
- struct abiargsvec abiargs = {VINIT(abiargsbuf, arraylength(abiargsbuf))};
+ struct abiargsvec abiargs = {VINIT(abiargsbuf, countof(abiargsbuf))};
int rvovar = -1;
int ni = 0, nf = 0, ns = 0, istart = 0;
uchar r2off;
diff --git a/ir/intrin.c b/ir/intrin.c
index 8c1a128..cd2865a 100644
--- a/ir/intrin.c
+++ b/ir/intrin.c
@@ -50,7 +50,7 @@ lowerintrin(struct function *fn)
{
struct block *blk = fn->entry;
static struct arg argsbuf[64];
- vec_of(struct arg) args = VINIT(argsbuf, arraylength(argsbuf));
+ vec_of(struct arg) args = VINIT(argsbuf, countof(argsbuf));
do {
for (int i = 0; i < blk->ins.n; ++i) {
@@ -58,7 +58,7 @@ lowerintrin(struct function *fn)
if (ins->op == Oarg)
vpush(&args, ((struct arg){ &ins->r, &ins->l }));
else if (ins->op == Ocall)
- vinit(&args, argsbuf, arraylength(argsbuf));
+ vinit(&args, argsbuf, countof(argsbuf));
else if (ins->op == Ointrin) {
int arg0 = i - args.n;
assert(calltab.p[ins->r.i].narg == args.n);
@@ -67,7 +67,7 @@ lowerintrin(struct function *fn)
delinstr(blk, arg0);
else
abi0_call(fn, ins, blk, &i);
- vinit(&args, argsbuf, arraylength(argsbuf));
+ vinit(&args, argsbuf, countof(argsbuf));
}
}
assert(args.n == 0);
diff --git a/ir/ir.c b/ir/ir.c
index 4a092b3..dbd6206 100644
--- a/ir/ir.c
+++ b/ir/ir.c
@@ -43,13 +43,13 @@ irinit(struct function *fn)
ninstr = 0;
instrfreelist = -1;
- vinit(&calltab, callsbuf, arraylength(callsbuf));
+ vinit(&calltab, callsbuf, countof(callsbuf));
for (int i = 0; i < phitab.n; ++i) xbfree(phitab.p[i]);
- vinit(&phitab, phisbuf, arraylength(phisbuf));
- if (!dattab.p) vinit(&dattab, datsbuf, arraylength(datsbuf));
- if (naddrht >= arraylength(addrht)/2)
+ vinit(&phitab, phisbuf, countof(phisbuf));
+ if (!dattab.p) vinit(&dattab, datsbuf, countof(datsbuf));
+ if (naddrht >= countof(addrht)/2)
memset(addrht, naddrht = 0, sizeof addrht);
- if (nconht >= arraylength(conht)/2)
+ if (nconht >= countof(conht)/2)
memset(conht, nconht = 0, sizeof conht);
if (!type2cls[TYINT]) {
for (int i = TYBOOL; i <= TYUVLONG; ++i) {
@@ -75,9 +75,9 @@ static int
addaddr(const struct addr *addr)
{
uint h = hashb(0, addr, sizeof *addr);
- uint i = h, n = arraylength(addrht);
+ uint i = h, n = countof(addrht);
for (;; ++i) {
- i &= arraylength(addrht) - 1;
+ i &= countof(addrht) - 1;
if (!addrht[i].base.bits && !addrht[i].index.bits) {
addrht[i] = *addr;
++naddrht;
@@ -93,10 +93,10 @@ static int
addcon(const struct xcon *con)
{
uint h = hashb(0, con, sizeof *con);
- uint i = h, n = arraylength(conht);
+ uint i = h, n = countof(conht);
assert(con->issym || con->isdat || con->cls);
for (;; ++i) {
- i &= arraylength(conht) - 1;
+ i &= countof(conht) - 1;
if (!conht[i].issym && !conht[i].isdat && !conht[i].cls) {
conht[i] = *con;
++nconht;
@@ -346,7 +346,7 @@ allocinstr(void)
t = instrfreelist;
memcpy(&instrfreelist, &instrtab[t], sizeof(int));
} else {
- assert(ninstr < arraylength(instrtab));
+ assert(ninstr < countof(instrtab));
t = ninstr++;
}
if (instruse[t] != instrusebuf[t])
@@ -361,11 +361,11 @@ adduse(struct block *ublk, int ui, union ref r) {
struct use user = { ublk, ui };
if (r.t != RTMP) return;
- if (instrnuse[r.i] < arraylength(instrusebuf[r.i])) {
+ if (instrnuse[r.i] < countof(instrusebuf[r.i])) {
instruse[r.i][instrnuse[r.i]++] = user;
- } else if (instrnuse[r.i] == arraylength(*instrusebuf)) {
+ } else if (instrnuse[r.i] == countof(*instrusebuf)) {
struct use *use = NULL;
- xbgrow(&use, arraylength(*instrusebuf) + 2);
+ xbgrow(&use, countof(*instrusebuf) + 2);
memcpy(use, instruse[r.i], sizeof(*instrusebuf));
use[instrnuse[r.i]++] = user;
instruse[r.i] = use;
@@ -389,7 +389,7 @@ deluse(struct block *ublk, int ui, union ref r) {
return 0;
Shrink:
- if (instrnuse[r.i] == arraylength(*instrusebuf) + 1) {
+ if (instrnuse[r.i] == countof(*instrusebuf) + 1) {
struct use *use = instruse[r.i];
instruse[r.i] = instrusebuf[r.i];
memcpy(instruse[r.i], use, sizeof *instrusebuf);
diff --git a/ir/optmem.c b/ir/optmem.c
index 3f5852b..7bd0d1a 100644
--- a/ir/optmem.c
+++ b/ir/optmem.c
@@ -234,7 +234,7 @@ mem2reg(struct function *fn)
FREQUIRE(FNUSE);
- if (fn->nblk <= 64 * arraylength(bsbuf[0])) {
+ if (fn->nblk <= 64 * countof(bsbuf[0])) {
sb.sealed = bsbuf[0];
sb.marked = bsbuf[1];
memset(bsbuf[0], 0, BSSIZE(fn->nblk) * sizeof *bsbuf[0]);
diff --git a/ir/regalloc.c b/ir/regalloc.c
index cf40266..9abd3c6 100644
--- a/ir/regalloc.c
+++ b/ir/regalloc.c
@@ -82,7 +82,7 @@ fixlive(struct function *fn)
struct bitset definedbuf[4] = {0};
struct bitset *defined = definedbuf;
- if (BSSIZE(ninstr) >= arraylength(definedbuf))
+ if (BSSIZE(ninstr) >= countof(definedbuf))
defined = xcalloc(sizeof *defined * BSSIZE(ninstr));
npendingphi = 0;
@@ -1241,7 +1241,7 @@ regalloc(struct function *fn)
fn->regusage = 0;
fn->stksiz = alignup(fn->stksiz, 8);
fn->isleaf = 1;
- vinit(&stkslotrefs, stkslotrefsbuf, arraylength(stkslotrefsbuf));
+ vinit(&stkslotrefs, stkslotrefsbuf, countof(stkslotrefsbuf));
/* put into reverse post order */
sortrpo(fn);