llvm / llvm/llvm-project

DynamicAPInt is missing a conversion function back to APInt

Open
#186,744 0 comments 0 reactions 0 assignees View on GitHub
enhancement llvm:adt
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Code builder/generator APIs work on APInt, not on DynamicAPInt. Once I do computations on DynamicAPInt values, I need to convert them back to the appropriately sized APInt. There's a constructor taking an APInt value, but not the other way around. There's a conversion function back to `int64_t`, but that won't work if I want to create an `int128_t` (or maybe 2 `int64_t` to initialize an array).

Right now I have to convert `DynamicAPInt` to a string and then from a string to another `APInt`. This is less than optimal. `DynamicAPInt` already stores an `APInt` internally so it'd be trivial for the class to just have a conversion function that copies such value.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.