浏览代码

[i386] Use memory address constraints in __bswap_16s() and __bswap_64s()

Minimise code size by forcing the use of memory addresses for
__bswap_16s() and __bswap_64s().  (__bswap_32s() cannot avoid loading the
value into a register.)

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 13 年前
父节点
当前提交
732bea2f88
共有 1 个文件被更改,包括 3 次插入4 次删除
  1. 3
    4
      src/arch/i386/include/bits/byteswap.h

+ 3
- 4
src/arch/i386/include/bits/byteswap.h 查看文件

19
 
19
 
20
 static inline __attribute__ (( always_inline )) void
20
 static inline __attribute__ (( always_inline )) void
21
 __bswap_16s ( uint16_t *x ) {
21
 __bswap_16s ( uint16_t *x ) {
22
-	__asm__ ( "rorw $8, %0" : "=g" ( *x ) : "0" ( *x ) );
22
+	__asm__ ( "rorw $8, %0" : "+m" ( *x ) );
23
 }
23
 }
24
 
24
 
25
 static inline __attribute__ (( always_inline, const )) uint32_t
25
 static inline __attribute__ (( always_inline, const )) uint32_t
63
 		  "xchgl %2,%1\n\t"
63
 		  "xchgl %2,%1\n\t"
64
 		  "bswapl %2\n\t"
64
 		  "bswapl %2\n\t"
65
 		  "movl %2,%0\n\t"
65
 		  "movl %2,%0\n\t"
66
-		  : "=g" ( dwords->low ), "=g" ( dwords->high ),
67
-		    "=r" ( discard )
68
-		  : "0" ( dwords->low ), "1" ( dwords->high ) );
66
+		  : "+m" ( dwords->low ), "+m" ( dwords->high ),
67
+		    "=r" ( discard ) );
69
 }
68
 }
70
 
69
 
71
 #endif /* _BITS_BYTESWAP_H */
70
 #endif /* _BITS_BYTESWAP_H */

正在加载...
取消
保存