Skip to content

Arbitrary-precision bit array type #226

Description

@ktbarrett

Per #209, we need an arbitrary-precision integer type for very large integer-like types. Using a library like LLVM would be great, but is a huge dependency, so instead we will roll our own arbitrary-precision integer type.

We will keep it simple for now by taking advantage of the fact that very large bit arrays almost never do any arithmetic, only bit manipulation: shifting and bitwise operators. Additionally, we will need it to support equality and formatting (decimal, hex, binary, octal). Shifting shouldn't override >> operator, but instead have free functions so we can choose between signed extending or 0 extending shifts.

Examples:

detail::BigInt<347> val;  // 347 bit integer
shift_right_arith(val, 121);
val & 0xFF;

This type will be implemented using an array of uint64_ts. Even signed values will be stored in this format.

Open Questions

  • Do we need signed vs unsigned?
  • How can we design this so we can swap the entire thing out with APInt at some point in the future?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions