Rafael Espíndola <rafael.espindola at gmail.com> writes:> Now that aliases can have any expressions, can't you use something like > > @data = private global [2 x i32] [i32 42, i32 43] > @symbol = alias getelementptr ([2 x i32]* @data, i32 0, i32 1) > > This produces > > .Ldata: > .long 42 # 0x2a > .long 43 # 0x2b > ... > .globl symbol > symbol = .Ldata+4 > > That is, in the object file there is only one symbol (named symbol) > and it is at offset 4. >How would one define the body of the function `symbol` in this case? Cheers, - Ben -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 472 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140720/ce7a33e3/attachment.sig>
On 20 July 2014 18:18, Ben Gamari <bgamari.foss at gmail.com> wrote:> Rafael Espíndola <rafael.espindola at gmail.com> writes: > >> Now that aliases can have any expressions, can't you use something like >> >> @data = private global [2 x i32] [i32 42, i32 43] >> @symbol = alias getelementptr ([2 x i32]* @data, i32 0, i32 1) >> >> This produces >> >> .Ldata: >> .long 42 # 0x2a >> .long 43 # 0x2b >> ... >> .globl symbol >> symbol = .Ldata+4 >> >> That is, in the object file there is only one symbol (named symbol) >> and it is at offset 4. >> > How would one define the body of the function `symbol` in this case?I don't think it would work. For LLVM generated "data" (like function bodies) it seems something like the prefix feature is what is needed. Cheers, Rafael
Rafael Espíndola <rafael.espindola at gmail.com> writes:> On 20 July 2014 18:18, Ben Gamari <bgamari.foss at gmail.com> wrote: >> Rafael Espíndola <rafael.espindola at gmail.com> writes: >> >>> Now that aliases can have any expressions, can't you use something like >>> >>> @data = private global [2 x i32] [i32 42, i32 43] >>> @symbol = alias getelementptr ([2 x i32]* @data, i32 0, i32 1) >>> >>> This produces >>> >>> .Ldata: >>> .long 42 # 0x2a >>> .long 43 # 0x2b >>> ... >>> .globl symbol >>> symbol = .Ldata+4 >>> >>> That is, in the object file there is only one symbol (named symbol) >>> and it is at offset 4. >>> >> How would one define the body of the function `symbol` in this case? > > I don't think it would work. For LLVM generated "data" (like function > bodies) it seems something like the prefix feature is what is needed. >I suspected this was the case. Is a rework of prefix support likely to make it in for 3.5? Cheers, - Ben -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 472 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140723/67d01b94/attachment.sig>