12 static always_inline
int cris_swap(const int mode
, int x
)
16 case N
: asm ("swapn\t%0\n" : "+r" (x
) : "0" (x
)); break;
17 case W
: asm ("swapw\t%0\n" : "+r" (x
) : "0" (x
)); break;
18 case B
: asm ("swapb\t%0\n" : "+r" (x
) : "0" (x
)); break;
19 case R
: asm ("swapr\t%0\n" : "+r" (x
) : "0" (x
)); break;
20 case B
|R
: asm ("swapbr\t%0\n" : "+r" (x
) : "0" (x
)); break;
21 case W
|R
: asm ("swapwr\t%0\n" : "+r" (x
) : "0" (x
)); break;
22 case W
|B
: asm ("swapwb\t%0\n" : "+r" (x
) : "0" (x
)); break;
23 case W
|B
|R
: asm ("swapwbr\t%0\n" : "+r" (x
) : "0" (x
)); break;
24 case N
|R
: asm ("swapnr\t%0\n" : "+r" (x
) : "0" (x
)); break;
25 case N
|B
: asm ("swapnb\t%0\n" : "+r" (x
) : "0" (x
)); break;
26 case N
|B
|R
: asm ("swapnbr\t%0\n" : "+r" (x
) : "0" (x
)); break;
27 case N
|W
: asm ("swapnw\t%0\n" : "+r" (x
) : "0" (x
)); break;
35 /* Made this a macro to be able to pick up the location of the errors. */
36 #define verify_swap(mode, val, expected, n, z) \
40 r = cris_swap(mode, val); \
41 cris_tst_mov_cc(n, z); \
48 /* Some of these numbers are borrowed from GDB's cris sim
50 if (cris_swap(N
, 0) != 0xffffffff)
52 if (cris_swap(W
, 0x12345678) != 0x56781234)
54 if (cris_swap(B
, 0x12345678) != 0x34127856)
57 verify_swap(R
, 0x78134452, 0x1ec8224a, 0, 0);
58 verify_swap(B
, 0x78134452, 0x13785244, 0, 0);
59 verify_swap(B
|R
, 0x78134452, 0xc81e4a22, 1, 0);
60 verify_swap(W
, 0x78134452, 0x44527813, 0, 0);
61 verify_swap(W
|R
, 0x78134452, 0x224a1ec8, 0, 0);
62 verify_swap(W
|B
|R
, 0x78134452, 0x4a22c81e, 0, 0);
63 verify_swap(N
, 0x78134452, 0x87ecbbad, 1, 0);
64 verify_swap(N
|R
, 0x78134452, 0xe137ddb5, 1, 0);
65 verify_swap(N
|B
, 0x78134452, 0xec87adbb, 1, 0);
66 verify_swap(N
|B
|R
, 0x78134452, 0x37e1b5dd, 0, 0);
67 verify_swap(N
|W
, 0x78134452, 0xbbad87ec, 1, 0);
68 verify_swap(N
|B
|R
, 0xffffffff, 0, 0, 1);