This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] misc bswap fixes





This will pick "bswap" word from __builtin_bswap. You should probably use scan-assembler-not "builtin_bswap".

int foo (int a)
{
 int b;

b = __builtin_bswap (a);

There is no __builtin_bswap() builtin function,  only
__builtin_bswap32() and __builtin_bswap64(). The test "passes" only
due to above problem.

Heh. And none of us noticed the first time. Good catch.


+(define_insn "bswapsi2"
+  [(set (match_operand:SI 0 "register_operand" "=r")
+       (bswap:SI (match_operand:SI 1 "register_operand" "0")))
+   (clobber (reg:CC FLAGS_REG))]
+  "!TARGET_64BIT && TARGET_BSWAP"
+  "bswap\t%1"

bswap\t%0

+ [(set_attr "prefix_0f" "1")])

Does this patern need to be disabled on 64 bits? IMO it can still be
used with 32bit argument.


Not as far as I know, bswap operates on the entire register and registers are 64-bit
on x86_64.


BTW: I wonder, why there is no bswaphi2 pattern. Intel recommends xchg
instruction to swap bytes in HImode argument. The relevant pattern
could be defined like:

(define_insn "bswaphi2"
 [(set (match_operand:HI 0 "register_operand" "=G")
       (bswap:HI (match_operand:HI 1 "register_operand" "0")))]
 ""
 "xchg\t%b0, %h0")

I'm sure that linux's __be16 and __le16 data could find some use for
this pattern.

Mostly because I hadn't done it yet. There's no support for builtin_bswap16 yet.
If you feel like supporting writing the rest of the support...


-eric


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]