Re: [patch 5/8] Immediate Values - x86 Optimization (update)

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Mathieu Desnoyers
Date: Tuesday, November 13, 2007 - 3:02 pm

* H. Peter Anvin (hpa@zytor.com) wrote:

This is what I was pointing out in this previous message :
http://lkml.org/lkml/2007/10/20/92

"I am still trying to figure out if we must assume that gas will produce
different length opcodes for mov instructions. The choice is:
- Either I use a "r" constraint and let gcc produce the instructions,
  that I need to assume to have correct size so I can align their
  immediate values (therefore, taking the offset from the end of the
  instruction will not help). Here, if gas changes its behavior
  dramatically for a given immediate value size, it will break.

- Second choice is to stick to a particular register, choosing the one
  with the less side-effect, and encoding the instruction ourselves. I
  start to think that this second solution might be safer, even though
  we wouldn't let the compiler select the register which has the less
  impact by itself."

Andi seemed to trust gas stability and you answered:

"The comment was referring to x86-64, but I incorrectly remembered that 
applying to "movq $imm,%reg" as opposed to loading from an absolute 
address.  gas actually has a special opcode (movabs) for the 64-bit 
version of the latter variant, which is only available with %rax and its 
subregisters.

Nevermind, in other words.  It's still true, though, that the immediate 
will always be the last thing in the instruction -- that's a fixture of 
the instruction format."

So, in the end, is there a way to make x86_64 use a fixed-size opcode
for the 1, 2, 4 and 8 bytes load immediates or we will have to force the
use of a specific register ?

(and we can't take a pointer from the end of the instruction, because we
need to align the immediate value correctly)

Mathieu

-- 
Mathieu Desnoyers
Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[patch 5/8] Immediate Values - x86 Optimization, Mathieu Desnoyers, (Tue Nov 13, 11:58 am)
Re: [patch 5/8] Immediate Values - x86 Optimization, H. Peter Anvin, (Tue Nov 13, 12:07 pm)
Re: [patch 5/8] Immediate Values - x86 Optimization, Mathieu Desnoyers, (Tue Nov 13, 12:24 pm)
Re: [patch 5/8] Immediate Values - x86 Optimization, H. Peter Anvin, (Tue Nov 13, 12:36 pm)
Re: [patch 5/8] Immediate Values - x86 Optimization, Mathieu Desnoyers, (Tue Nov 13, 12:45 pm)
Re: [patch 5/8] Immediate Values - x86 Optimization, H. Peter Anvin, (Tue Nov 13, 12:56 pm)
Re: [patch 5/8] Immediate Values - x86 Optimization (update), Mathieu Desnoyers, (Tue Nov 13, 1:40 pm)
Re: [patch 5/8] Immediate Values - x86 Optimization (update), Mathieu Desnoyers, (Tue Nov 13, 3:02 pm)
Re: [patch 5/8] Immediate Values - x86 Optimization (update), Mathieu Desnoyers, (Tue Nov 13, 5:34 pm)
Re: [patch 5/8] Immediate Values - x86 Optimization (update 2), Mathieu Desnoyers, (Tue Nov 13, 6:44 pm)
Re: [patch 5/8] Immediate Values - x86 Optimization (update 2), Mathieu Desnoyers, (Wed Nov 14, 7:16 am)
[PATCH] Immediate Values x86 Optimization Declare Discarde ..., Mathieu Desnoyers, (Wed Nov 14, 11:52 am)
[PATCH] Add __discard section to x86, Mathieu Desnoyers, (Wed Nov 14, 12:16 pm)
Re: [PATCH] Add __discard section to x86, H. Peter Anvin, (Wed Nov 14, 12:33 pm)
Re: [patch 5/8] Immediate Values - x86 Optimization, Rusty Russell, (Wed Nov 14, 8:08 pm)
Re: [patch 5/8] Immediate Values - x86 Optimization, Mathieu Desnoyers, (Wed Nov 14, 9:06 pm)
Re: [patch 5/8] Immediate Values - x86 Optimization, Rusty Russell, (Wed Nov 14, 9:45 pm)
Re: [patch 5/8] Immediate Values - x86 Optimization, Mathieu Desnoyers, (Wed Nov 14, 10:37 pm)
Re: [patch 5/8] Immediate Values - x86 Optimization (simpl ..., Mathieu Desnoyers, (Fri Nov 16, 7:03 am)
Re: [patch 5/8] Immediate Values - x86 Optimization (simpl ..., Mathieu Desnoyers, (Mon Nov 19, 12:15 pm)
Re: [patch 5/8] Immediate Values - x86 Optimization (simpl ..., Mathieu Desnoyers, (Tue Nov 20, 10:02 am)