Working on my garbage collector...I need to be able to convert a
ConstantExpr to a plain int at link time.
At compile time, I use ContactExpr::getOffsetOf() to calculate the offsets
for pointer fields to be traced by the collector. Since the target machine
has not yet been selected at this point, we don't yet know what the exact
offset will be, so the expression cannot be flattened into a simple integer.
That's OK, however, because most of the time we're assembling constant
static data structures, so having a Constant is OK.
The problem arises, however, when that offset expression is used as part of
the metadata argument to llvm.gcroot(). Because of the way that the GC
lowering pass works, the output of the GC strategy has to be emitted via an
asm printer, which as far as I can tell, doesn't accept llvm::Constant as an
argument. (Even if it did, it would be no good, since I need to sort the
field offsets in ascending order, and you can't sort an array of
Constant*).
This is all happening at link time, which means that the target machine is
fully known by this point. So it ought to be possible to convert the field
offset expression (including the constant GEP) into a plain integer. Any
idea how to do this?
--
-- Talin
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20100918/c1897401/attachment.html>