diff options
author | Peter Mikkelsen <peter@pmikkelsen.com> | 2022-02-09 17:06:41 +0000 |
---|---|---|
committer | Peter Mikkelsen <peter@pmikkelsen.com> | 2022-02-09 17:06:41 +0000 |
commit | 36e45dfccb5e5321682c0ec24dead22cf40fcb16 (patch) | |
tree | 5b51a2f46d50c4ae2ae93e94bf337ca9af2f4348 /apl9.h | |
parent | e195d66a333102924bae452ba09dc20cba4e96e6 (diff) |
Make the array type a tiny bit smaller, by packing control information into a bit array
Diffstat (limited to 'apl9.h')
-rw-r--r-- | apl9.h | 26 |
1 files changed, 20 insertions, 6 deletions
@@ -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 |