base: add bitvec256 type

This commit is contained in:
Nigel Tao committed 2023-10-12 21:26:53 +11:00
1 parent 310f5011b5
commit e0636e3255
7 files changed
+62

No files matched your search

+1
View File
@@ -6,6 +6,7 @@
The LICENSE has changed from a single license (Apache 2) to a dual license
(Apache 2 or MIT, at your option).
- Added `base.bitvec256`.
- Added `compact_retaining` and `history_retain_length`.
- Added `example/toy-aux-image`.
- Added `get_quirk(key: u32) u64`.
+3
View File
@@ -191,6 +191,9 @@ wuffs_base__u64__sat_sub_indirect(uint64_t* x, uint64_t y) {
#define wuffs_base__utility__sign_extend_rshift_u64(a, n) \
((uint64_t)(((int64_t)(a)) >> (n)))
#define wuffs_base__utility__make_bitvec256(e00, e01, e02, e03) \
wuffs_base__make_bitvec256(e00, e01, e02, e03)
// ---------------- Slices and Tables
// wuffs_base__slice_u8__prefix returns up to the first up_to bytes of s.
+21
View File
@@ -820,6 +820,27 @@ wuffs_base__multiply_u64(uint64_t x, uint64_t y) {
// --------
typedef struct wuffs_base__bitvec256__struct {
// elements_u64[0] holds the LSBs (least significant bits) and
// elements_u64[3] holds the MSBs (most significant bits).
uint64_t elements_u64[4];
} wuffs_base__bitvec256;
static inline wuffs_base__bitvec256 //
wuffs_base__make_bitvec256(uint64_t e00,
uint64_t e01,
uint64_t e02,
uint64_t e03) {
wuffs_base__bitvec256 res;
res.elements_u64[0] = e00;
res.elements_u64[1] = e01;
res.elements_u64[2] = e02;
res.elements_u64[3] = e03;
return res;
}
// --------
// The "defined(__clang__)" isn't redundant. While vanilla clang defines
// __GNUC__, clang-cl (which mimics MSVC's cl.exe) does not.
#if (defined(__GNUC__) || defined(__clang__)) && (__SIZEOF_LONG__ == 8)
+3
View File
@@ -284,6 +284,8 @@ var Types = []string{
"u32",
"u64",
"bitvec256",
"empty_struct",
"bool",
"utility",
@@ -374,6 +376,7 @@ var funcsOther = [...]string{
"utility.empty_rect_ii_u32() rect_ii_u32",
"utility.empty_rect_ie_u32() rect_ie_u32",
"utility.empty_slice_u8() slice u8",
"utility.make_bitvec256(e00: u64, e01: u64, e02: u64, e03: u64) bitvec256",
"utility.make_pixel_format(repr: u32) pixel_format",
"utility.make_range_ii_u32(min_incl: u32, max_incl: u32) range_ii_u32",
"utility.make_range_ie_u32(min_incl: u32, max_excl: u32) range_ie_u32",
+4
View File
@@ -42,6 +42,8 @@ var (
typeExprU32 = a.NewTypeExpr(0, t.IDBase, t.IDU32, nil, nil, nil)
typeExprU64 = a.NewTypeExpr(0, t.IDBase, t.IDU64, nil, nil, nil)
typeExprBitvec256 = a.NewTypeExpr(0, t.IDBase, t.IDBitvec256, nil, nil, nil)
typeExprEmptyStruct = a.NewTypeExpr(0, t.IDBase, t.IDEmptyStruct, nil, nil, nil)
typeExprBool = a.NewTypeExpr(0, t.IDBase, t.IDBool, nil, nil, nil)
typeExprUtility = a.NewTypeExpr(0, t.IDBase, t.IDUtility, nil, nil, nil)
@@ -111,6 +113,8 @@ var builtInTypeMap = typeMap{
t.IDU32: typeExprU32,
t.IDU64: typeExprU64,
t.IDBitvec256: typeExprBitvec256,
t.IDEmptyStruct: typeExprEmptyStruct,
t.IDBool: typeExprBool,
t.IDUtility: typeExprUtility,
+6
View File
@@ -467,6 +467,9 @@ const (
IDU32 = ID(0x116)
IDU64 = ID(0x117)
IDBitvec128 = ID(0x118)
IDBitvec256 = ID(0x119)
IDBase = ID(0x120)
IDBool = ID(0x121)
IDEmptyIOReader = ID(0x122)
@@ -910,6 +913,9 @@ var builtInsByID = [nBuiltInIDs]string{
IDU32: "u32",
IDU64: "u64",
IDBitvec128: "bitvec128",
IDBitvec256: "bitvec256",
IDBase: "base",
IDBool: "bool",
IDEmptyIOReader: "empty_io_reader",
+24
View File
@@ -1091,6 +1091,27 @@ wuffs_base__multiply_u64(uint64_t x, uint64_t y) {
// --------
typedef struct wuffs_base__bitvec256__struct {
// elements_u64[0] holds the LSBs (least significant bits) and
// elements_u64[3] holds the MSBs (most significant bits).
uint64_t elements_u64[4];
} wuffs_base__bitvec256;
static inline wuffs_base__bitvec256 //
wuffs_base__make_bitvec256(uint64_t e00,
uint64_t e01,
uint64_t e02,
uint64_t e03) {
wuffs_base__bitvec256 res;
res.elements_u64[0] = e00;
res.elements_u64[1] = e01;
res.elements_u64[2] = e02;
res.elements_u64[3] = e03;
return res;
}
// --------
// The "defined(__clang__)" isn't redundant. While vanilla clang defines
// __GNUC__, clang-cl (which mimics MSVC's cl.exe) does not.
#if (defined(__GNUC__) || defined(__clang__)) && (__SIZEOF_LONG__ == 8)
@@ -13758,6 +13779,9 @@ wuffs_base__u64__sat_sub_indirect(uint64_t* x, uint64_t y) {
#define wuffs_base__utility__sign_extend_rshift_u64(a, n) \
((uint64_t)(((int64_t)(a)) >> (n)))
#define wuffs_base__utility__make_bitvec256(e00, e01, e02, e03) \
wuffs_base__make_bitvec256(e00, e01, e02, e03)
// ---------------- Slices and Tables
// wuffs_base__slice_u8__prefix returns up to the first up_to bytes of s.