[LLVMdev] Use SEGMENT_REG in X86 calling convention
Chen Li
meloli87 at gmail.com
Sat Feb 22 14:21:17 PST 2014
Hi Tim,
Thanks for the suggestions.
Currently all I need is actually to read the value from one of the segment registers (specifically the GS register). And based on the LLVM X86 Language Extensions, annotating a pointer with address space #256 can codegen relative to the GS register. So I guess this approach seems to be easier and cleaner than hacking the LLVM internal?
Best,
Chen
On Feb 22, 2014, at 12:04 AM, Tim Northover <t.p.northover at gmail.com> wrote:
> Hi Chen,
>
>> Does anyone have any idea on how to fix it or the correct way to use the
>> segment register?
>
> At the moment LLVM only uses segment registers passively, where the
> actual value in the register isn't changed by LLVM (for example
> thread-local storage access is via %fs on Linux, but that value is set
> by the OS when the thread is created and we don't need to worry about
> it).
>
> Because of that, we don't have infrastructure in place for actually
> shuffling values around them and you should probably expect to have to
> add bits yourself as you go along.
>
> You've discovered copyPhysReg (you'll have to implement a copy
> yourself, probably with push/pop like EFLAGS since there's no direct
> seg/seg move instruction). You'll probably eventually need to be able
> to spill & restore them too, if lots of moves are going on (the
> storeRegToStackSlot and loadRegFromStackSlot functions).
>
> Depending on what you're trying to do that may be everything, or you
> may meet even more worlds of pain later on.
>
> Good luck!
>
> Tim.
More information about the llvm-dev
mailing list