lkml.org 
[lkml]   [2007]   [Sep]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [patch 4/7] Immediate Values - i386 Optimization
Jeremy Fitzhardinge wrote:
> Mathieu Desnoyers wrote:
>
>> +#define immediate_read(name) \
>> + ({ \
>> + __typeof__(name##__immediate) value; \
>> + switch (sizeof(value)) { \
>> + case 1: \
>> + asm ( ".section __immediate, \"a\", @progbits;\n\t" \
>> + ".long %1, (0f)+1, 1;\n\t" \
>> + ".previous;\n\t" \
>> + "0:\n\t" \
>> + "mov %2,%0;\n\t" \
>
> Given that you're relying on the exact instruction that this mov
> generates, it might be better to explicitly put the opcodes in with
> .byte. That way you're protected from the assembler deciding to
> generate some other form of the instruction (for whatever reason). I
> guess substituting in different registers would be a pain.

Allowing different registers should be doable, but if so, one would have
to put 0: at the *end* of the instruction and use (0f)-4 instead, since
the non-%eax forms are one byte longer.

This also seems "safer", since an imm32 is always the last thing in the
instruction.

-hpa

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2007-09-19 00:19    [W:0.080 / U:6.480 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site