From 36e45dfccb5e5321682c0ec24dead22cf40fcb16 Mon Sep 17 00:00:00 2001 From: Peter Mikkelsen Date: Wed, 9 Feb 2022 17:06:41 +0000 Subject: Make the array type a tiny bit smaller, by packing control information into a bit array --- apl9.h | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'apl9.h') diff --git a/apl9.h b/apl9.h index 3f592d9..8135f39 100644 --- a/apl9.h +++ b/apl9.h @@ -83,14 +83,18 @@ struct Mixed }; }; +#define GetSize(a) ((u32int)(a->info & 0x00000000FFFFFFFF)) +#define GetRank(a) ((u8int)((a->info & 0x0000000F00000000) >> 32)) +#define GetType(a) ((u8int)((a->info & 0x000000F000000000) >> 36)) +#define GetStrand(a) ((u8int)((a->info & 0x0000010000000000) >> 40)) +#define SetSize(a,v) (a->info ^= ((u64int)GetSize(a)^v)) +#define SetRank(a,v) (a->info ^= ((u64int)(GetRank(a)^v) << 32)) +#define SetType(a,v) (a->info ^= ((u64int)(GetType(a)^v) << 36)) +#define SetStrand(a,v) (a->info ^= ((u64int)(GetStrand(a)^v) << 40)) + struct Array { - arrayDataType type; - int rank; - int *shape; - int size; - int stranded; /* 1 if build directly by stranding */ - int refs; /* reference counting */ + u32int *shape; union { char *rawdata; vlong *intdata; @@ -99,6 +103,16 @@ struct Array Mixed *mixeddata; Array **arraydata; }; + u64int info; + /* info is a bitmap of information, divided as follows: + * 0-31: 32 bits for size (max size = 4294967296) + * 32-35: 4 bits for the rank (max rank 15) + * 36-39: 4 bits for the type (16 options) + * 40: 1 bit for stranding + * 41-63: unused + * NOTE: should only be modified through the macros defined above + */ + ulong refs; }; struct Statement -- cgit v1.2.3