[cfe-dev] Advice on __emit__ intrinsic
Daniel Wallin
daniel at boostpro.com
Tue Jun 7 05:33:59 PDT 2011
On Wed, Jun 1, 2011 at 4:35 PM, David Chisnall <csdavec at swan.ac.uk> wrote:
> On 1 Jun 2011, at 14:18, Daniel Wallin wrote:
>
>> I'm working on adding codegen support for the BCC __emit__ intrinsic:
>>
>> http://docwiki.embarcadero.com/RADStudio/en/Bcc_intrinsics
>>
>> Essentially, it allows you to insert a sequence of bytes verbatim to
>> the object file.
>>
>> __emit__(0xCC);
>>
>> would be equivalent to:
>>
>> asm(".byte 0xCC");
>>
>> The documentation doesn't seem to mention it, but it also allows you
>> to emit the address of a variable:
>>
>> __emit__(&x);
>>
>> Because of this I figure I need to add support for this on the llvm
>> level, but I'm not sure how to go about it. If anyone has any advice I
>> would appreciate it.
>
> I'm not sure that this needs anything extra in LLVM. The first form, as you say, is already supported by trivial inline ASM. The second looks like it's equivalent to:
>
> asm ("$0" : : "m"(&x))
Although that does expand to something, the result isn't something
that can be assembled:
-8(%rsp)
Doing something like:
.long -8(%rsp)
doesn't work either. I guess it needed to expand to just ".long -8".
Any more ideas? Any help would be appreciated!
--
Daniel Wallin
BoostPro Computing
http://www.boostpro.com
More information about the cfe-dev
mailing list