Skip to contentSkip to conversation

x86: explicit suffix in inline assembler (for clang)

PATCH In review Tim Deegan 2 participants 3 messages Feb 14, 2013

lore
Share & tools
lore

Tim Deegan

author
#0 lore raw

PATCH 1/1 x86: explicit suffix in inline assembler (for clang)

# HG changeset patch
# User Tim Deegan <[email protected]>
# Date 1360846113 0
# Node ID 500907997cb7b9c6973147d56cfd8a1a4c136c7e # Parent 4b01cc2c2c1f4836e7fb34a58bc13e125d67969e
x86: explicit suffix in inline assembler (for clang).

This fixes the clang build, and has no effect on gcc's output.

xen/arch/x86/time.c +1 -1
diff -r 4b01cc2c2c1f -r 500907997cb7 xen/arch/x86/time.c
@@ -127,7 +127,7 @@ static inline u64 scale_delta(u64 delta,
         delta <<= scale->shift;
 
     asm (
-        "mul %2 ; shrd $32,%1,%0"
+        "mulq %2 ; shrd $32,%1,%0"
         : "=a" (product), "=d" (delta)
         : "rm" (delta), "0" ((u64)scale->mul_frac) );
#1 lore raw
Quoted 16 lines
Quoted 1 line
Quoted 1 line · Tim Deegan

# HG changeset patch
# User Tim Deegan <[email protected]>
# Date 1360846113 0
# Node ID 500907997cb7b9c6973147d56cfd8a1a4c136c7e # Parent 4b01cc2c2c1f4836e7fb34a58bc13e125d67969e
x86: explicit suffix in inline assembler (for clang).

This fixes the clang build, and has no effect on gcc's output.

diff -r 4b01cc2c2c1f -r 500907997cb7 xen/arch/x86/time.c

xen/arch/x86/time.c static inline u64 scale_delta(u64 delta, · line 133

Quoted 8 lines
xen/arch/x86/time.c +1 -1
@@ -127,7 +127,7 @@ static inline u64 scale_delta(u64 delta,
         delta <<= scale->shift;
 
     asm (
-        "mul %2 ; shrd $32,%1,%0"
+        "mulq %2 ; shrd $32,%1,%0"
         : "=a" (product), "=d" (delta)
         : "rm" (delta), "0" ((u64)scale->mul_frac) );
 

I'll commit this as being benign, but what the heck? "mul" needs a suffix but "shrd" doesn't?

Jan

author
#2 lore raw
Quoted 18 lines · Jan Beulich
Quoted 18 lines
Quoted 1 line
Quoted 1 line · Tim Deegan

# HG changeset patch
# User Tim Deegan <[email protected]>
# Date 1360846113 0
# Node ID 500907997cb7b9c6973147d56cfd8a1a4c136c7e # Parent 4b01cc2c2c1f4836e7fb34a58bc13e125d67969e
x86: explicit suffix in inline assembler (for clang).

This fixes the clang build, and has no effect on gcc's output.

diff -r 4b01cc2c2c1f -r 500907997cb7 xen/arch/x86/time.c

xen/arch/x86/time.c +0 -0
@@ -127,7 +127,7 @@ static inline u64 scale_delta(u64 delta,
         delta <<= scale->shift;
 
Quoted 9 lines

xen/arch/x86/time.c static inline u64 scale_delta(u64 delta,

Quoted 6 lines
xen/arch/x86/time.c +1 -1
     asm (
-        "mul %2 ; shrd $32,%1,%0"
+        "mulq %2 ; shrd $32,%1,%0"
         : "=a" (product), "=d" (delta)
         : "rm" (delta), "0" ((u64)scale->mul_frac) );
 

I'll commit this as being benign, but what the heck? "mul" needs a suffix but "shrd" doesn't?

Quite. I presume it's because mul's first operand is implicit (and for some reason clang doesn't see the second operand being a u64 as enough to require the 64-bit version).

Tim.