Rafael Espíndola via llvm-dev
2016-Oct-25 12:43 UTC
[llvm-dev] RFC: Absolute or "fixed address" symbols as immediate operands
On 24 October 2016 at 16:54, Peter Collingbourne via llvm-dev <llvm-dev at lists.llvm.org> wrote:> > > On Mon, Oct 24, 2016 at 1:36 PM, Friedman, Eli <efriedma at codeaurora.org> > wrote: >> >> On 10/24/2016 1:07 PM, Peter Collingbourne via llvm-dev wrote: >> >> On Mon, Oct 10, 2016 at 8:12 PM, Peter Collingbourne <peter at pcc.me.uk> >> wrote: >>> >>> The specific change I have in mind is to allow !range metadata on >>> GlobalObjects. This would >>> be similar to existing !range metadata, but it would apply to the >>> "address" of the attached GlobalObject, rather than any value loaded from >>> it. Its presence on a GlobalObject would also imply that the address of the >>> GlobalObject is "fixed" at link time. >> >> >> Going back to IR-level representation: here is an alternative >> representation based on a suggestion from Eli. >> >> Introduce a new type of GlobalValue called GlobalConstant. GlobalConstant >> would fit into the GlobalValue hierarchy like this: >> >> GlobalValue >> >> GlobalConstant >> GlobalPointer >> >> GlobalIndirectSymbol >> >> GlobalAlias >> GlobalIFunc >> >> GlobalObject >> >> Function >> GlobalVariable >> >> GlobalValue would no longer be assumed to be of pointer type. The >> getType() overload that takes a PointerType, as well as getValueType() would >> be moved down to GlobalPointer. (A nice side benefit of this is that it >> would help flush out cases where we are unnecessarily depending on global >> pointee types.) >> >> A GlobalConstant can either be a definition or a declaration. A definition >> would look like this: >> >> @foo = globalconst i32 42 >> >> >> This is equivalent to writing "foo = 42" in assembly? > > > Yes.Back in the day the idea was to use an alias whose ConstantExpr was just 42. Would that work? Cheers, Rafael
Rafael Espíndola via llvm-dev
2016-Oct-25 12:49 UTC
[llvm-dev] RFC: Absolute or "fixed address" symbols as immediate operands
>>> @foo = globalconst i32 42 >>> >>> >>> This is equivalent to writing "foo = 42" in assembly? >> >> >> Yes. > > > Back in the day the idea was to use an alias whose ConstantExpr was > just 42. Would that work?In fact, it already works: @foo = alias i64, inttoptr (i64 42 to i64*) produces foo = 42 Cheers, Rafael
Peter Collingbourne via llvm-dev
2016-Oct-25 18:29 UTC
[llvm-dev] RFC: Absolute or "fixed address" symbols as immediate operands
On Tue, Oct 25, 2016 at 5:49 AM, Rafael Espíndola < rafael.espindola at gmail.com> wrote:> >>> @foo = globalconst i32 42 > >>> > >>> > >>> This is equivalent to writing "foo = 42" in assembly? > >> > >> > >> Yes. > > > > > > Back in the day the idea was to use an alias whose ConstantExpr was > > just 42. Would that work? > > In fact, it already works: > > @foo = alias i64, inttoptr (i64 42 to i64*) > > produces > > foo = 42 > > Cheers, > Rafael >Right, I should have brought up that we can already use aliases for definitions -- that's what I've been using in my prototype. What I think we need to decide on here is a representation for declarations. From that, I think our representation for definitions should be clear. For example, I think that if we decide to require GlobalConstant to have a pointer type, it may be reasonable to use it only for declarations and to use GlobalAlias for definitions. This I think would be analogous to the current state where a GlobalAlias can be referenced by either a Function or a GlobalVariable. Thanks, -- -- Peter -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20161025/d1961833/attachment.html>
Possibly Parallel Threads
- RFC: Absolute or "fixed address" symbols as immediate operands
- RFC: Absolute or "fixed address" symbols as immediate operands
- RFC: Absolute or "fixed address" symbols as immediate operands
- RFC: Absolute or "fixed address" symbols as immediate operands
- RFC: Absolute or "fixed address" symbols as immediate operands