[llvm-dev] DIEnumerator *createEnumerator(StringRef Name, int64_t Val); // add APInt Val overload

Robinson, Paul via llvm-dev llvm-dev at lists.llvm.org
Mon Dec 4 10:25:28 PST 2017


Can we add an overload to createEnumerator to accept an APInt?

You might find it tricky to extend the metadata in a way that allowed passing an APInt down to the DWARF emitter.  But, leaving aside that implementation detail, it looks like you have a valid use-case for proposing a patch that supports it.
--paulr

From: llvm-dev [mailto:llvm-dev-bounces at lists.llvm.org] On Behalf Of Andrew Kelley via llvm-dev
Sent: Saturday, December 02, 2017 9:35 PM
To: LLVM Dev
Subject: [llvm-dev] DIEnumerator *createEnumerator(StringRef Name, int64_t Val); // add APInt Val overload

In the Zig frontend, users can set the types of enums like this:
const Foo = enum (u64) {
    A = 18446744073709551615,
    B = 1,
    C = 2,
};

I cannot use the DebugInfo API
DIEnumerator *createEnumerator(StringRef Name, int64_t Val);
because 18446744073709551615 is outside the range of int64_t.

Even if this accepted an unsigned int, Zig frontend can do this:

const Bar = enum(u128) {
    A = 340282366920938463463374607431768211455,
    B = 1,
    C = 2,
};

Now we're *really* out of luck.

I read the Dwarf 4 spec, and it supports arbitrary integer values for enumerator constants.

Can we add an overload to createEnumerator to accept an APInt?

Regards,
Andrew
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20171204/15cffdf2/attachment.html>


More information about the llvm-dev mailing list