xref: /llvm-project/compiler-rt/lib/builtins/bswapsi2.c (revision 0ba22f51d128bee9d69756c56c4678097270e10b)
1*0ba22f51SPetr Hosek //===-- bswapsi2.c - Implement __bswapsi2 ---------------------------------===//
2*0ba22f51SPetr Hosek //
3*0ba22f51SPetr Hosek // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*0ba22f51SPetr Hosek // See https://llvm.org/LICENSE.txt for license information.
5*0ba22f51SPetr Hosek // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*0ba22f51SPetr Hosek //
7*0ba22f51SPetr Hosek //===----------------------------------------------------------------------===//
8*0ba22f51SPetr Hosek //
9*0ba22f51SPetr Hosek // This file implements __bswapsi2 for the compiler_rt library.
10*0ba22f51SPetr Hosek //
11*0ba22f51SPetr Hosek //===----------------------------------------------------------------------===//
128779ea7aSDimitry Andric 
138779ea7aSDimitry Andric #include "int_lib.h"
148779ea7aSDimitry Andric 
__bswapsi2(uint32_t u)158779ea7aSDimitry Andric COMPILER_RT_ABI uint32_t __bswapsi2(uint32_t u) {
16082b89b2SPetr Hosek   return ((((u)&0xff000000) >> 24) |
178779ea7aSDimitry Andric           (((u)&0x00ff0000) >> 8)  |
188779ea7aSDimitry Andric           (((u)&0x0000ff00) << 8)  |
198779ea7aSDimitry Andric           (((u)&0x000000ff) << 24));
208779ea7aSDimitry Andric }
21