diff options
| author | 2026-03-02 17:52:57 +0100 | |
|---|---|---|
| committer | 2026-03-02 17:52:57 +0100 | |
| commit | f2285400e65dafe730a073b3ca92494d72c7295b (patch) | |
| tree | d5a96f09fbd0402ada3c39165a9d2d8202ee8e5d /test | |
| parent | a498f851ef2f50c9b8ac47e238137af52b54057d (diff) | |
add bswap16/32/64
- frontend: __builtin_bswapX intrinsics
- backend: ObswapX instructions
Diffstat (limited to 'test')
| -rw-r--r-- | test/08-bit.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/test/08-bit.c b/test/08-bit.c index 5854cad..1a157e2 100644 --- a/test/08-bit.c +++ b/test/08-bit.c @@ -1,6 +1,7 @@ /* EXPECT: expect 6, -4, 7, -1 6, -4, 7, -1 +CEFA CDAB3412 AA000000000000FF */ int xor(int a) { @@ -37,6 +38,10 @@ struct s2 bitfcopy2(struct s2 x) { return (struct s2){x.a}; } +int bswap16(int x) { return __builtin_bswap16(x); } +int bswap32(int x) { return __builtin_bswap32(x); } +long long bswap64(long long x) { return __builtin_bswap64(x); } + int main(int p) { extern int printf(const char *, ...); @@ -50,6 +55,7 @@ int main(int p) { foo.a = xor(foo.a |= 3); printf("expect %d, -4, 7, %d\n", 5+p, (short)((-1|3)^3|555)); printf(" %d, %d, %lld, %d\n", foo.x, foo.k+=1, foo.h, foo.a); + printf("%X %X %llX\n", bswap16(0xFACE), bswap32(0x1234ABCD), bswap64(0xFF000000000000AAll)); int x = 42, *a = &x, |