CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
110 lines
4.9 KiB
C
110 lines
4.9 KiB
C
// clang-format off
|
|
/*
|
|
#include <stdlib.h>
|
|
#include <stdint.h>
|
|
|
|
#define MASK32LO 0x00000000FFFFFFFFLLU
|
|
#define MASK16LO 0x0000FFFF0000FFFFLLU
|
|
#define MASK8LO 0x00FF00FF00FF00FFLLU
|
|
#define MASK4LO 0x0F0F0F0F0F0F0F0FLLU
|
|
#define MASK2LO 0x3333333333333333LLU
|
|
#define MASK1LO 0x5555555555555555LLU
|
|
|
|
#define SWAP32(X,TYPE) (((X&((TYPE) MASK32LO))<<32) | (((X)>>32)&((TYPE) MASK32LO)))
|
|
#define SWAP16(X,TYPE) (((X&((TYPE) MASK16LO))<<16) | (((X)>>16)&((TYPE) MASK16LO)))
|
|
#define SWAP8(X,TYPE) (((X&((TYPE) MASK8LO ))<< 8) | (((X)>> 8)&((TYPE) MASK8LO)))
|
|
#define SWAP4(X,TYPE) (((X&((TYPE) MASK4LO ))<< 4) | (((X)>> 4)&((TYPE) MASK4LO)))
|
|
#define SWAP2(X,TYPE) (((X&((TYPE) MASK2LO ))<< 2) | (((X)>> 2)&((TYPE) MASK2LO)))
|
|
#define SWAP1(X,TYPE) (((X&((TYPE) MASK1LO ))<< 1) | (((X)>> 1)&((TYPE) MASK1LO)))
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////
|
|
// scalar
|
|
///////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
uint8_t llvm_bitreverse_i8(uint8_t A) {
|
|
A=SWAP4(A,uint8_t);
|
|
A=SWAP2(A,uint8_t);
|
|
A=SWAP1(A,uint8_t);
|
|
return A;
|
|
}
|
|
|
|
uint16_t llvm_bitreverse_i16(uint16_t A) {
|
|
A=SWAP8(A,uint16_t);
|
|
A=SWAP4(A,uint16_t);
|
|
A=SWAP2(A,uint16_t);
|
|
A=SWAP1(A,uint16_t);
|
|
return A;
|
|
}
|
|
|
|
uint32_t llvm_bitreverse_i32(uint32_t A) {
|
|
A=SWAP16(A,uint32_t);
|
|
A=SWAP8(A,uint32_t);
|
|
A=SWAP4(A,uint32_t);
|
|
A=SWAP2(A,uint32_t);
|
|
A=SWAP1(A,uint32_t);
|
|
return A;
|
|
}
|
|
|
|
uint64_t llvm_bitreverse_i64(uint64_t A) {
|
|
A=SWAP32(A,uint64_t);
|
|
A=SWAP16(A,uint64_t);
|
|
A=SWAP8(A,uint64_t);
|
|
A=SWAP4(A,uint64_t);
|
|
A=SWAP2(A,uint64_t);
|
|
A=SWAP1(A,uint64_t);
|
|
return A;
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////
|
|
// vector
|
|
///////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
#define GEN_VECTOR_BITREVERSE(LENGTH) \
|
|
typedef uint8_t uint8_t ## LENGTH __attribute__((ext_vector_type(LENGTH))); \
|
|
typedef uint16_t uint16_t ## LENGTH __attribute__((ext_vector_type(LENGTH))); \
|
|
typedef uint32_t uint32_t ## LENGTH __attribute__((ext_vector_type(LENGTH))); \
|
|
typedef uint64_t uint64_t ## LENGTH __attribute__((ext_vector_type(LENGTH))); \
|
|
\
|
|
uint8_t ## LENGTH llvm_bitreverse_v ## LENGTH ## i8 (uint8_t ## LENGTH A) { \
|
|
A=SWAP4(A,uint8_t); \
|
|
A=SWAP2(A,uint8_t); \
|
|
A=SWAP1(A,uint8_t); \
|
|
return A; \
|
|
} \
|
|
\
|
|
uint16_t ## LENGTH llvm_bitreverse_v ## LENGTH ## i16(uint16_t ## LENGTH A) { \
|
|
A=SWAP8(A,uint16_t); \
|
|
A=SWAP4(A,uint16_t); \
|
|
A=SWAP2(A,uint16_t); \
|
|
A=SWAP1(A,uint16_t); \
|
|
return A; \
|
|
} \
|
|
\
|
|
uint32_t ## LENGTH llvm_bitreverse_v ## LENGTH ## i32(uint32_t ## LENGTH A) { \
|
|
A=SWAP16(A,uint32_t); \
|
|
A=SWAP8(A,uint32_t); \
|
|
A=SWAP4(A,uint32_t); \
|
|
A=SWAP2(A,uint32_t); \
|
|
A=SWAP1(A,uint32_t); \
|
|
return A; \
|
|
} \
|
|
\
|
|
uint64_t ## LENGTH llvm_bitreverse_v ## LENGTH ## i64(uint64_t ## LENGTH A) { \
|
|
A=SWAP32(A,uint64_t); \
|
|
A=SWAP16(A,uint64_t); \
|
|
A=SWAP8(A,uint64_t); \
|
|
A=SWAP4(A,uint64_t); \
|
|
A=SWAP2(A,uint64_t); \
|
|
A=SWAP1(A,uint64_t); \
|
|
return A; \
|
|
}
|
|
|
|
GEN_VECTOR_BITREVERSE(2)
|
|
GEN_VECTOR_BITREVERSE(3)
|
|
GEN_VECTOR_BITREVERSE(4)
|
|
GEN_VECTOR_BITREVERSE(8)
|
|
GEN_VECTOR_BITREVERSE(16)
|
|
|
|
*/
|
|
// clang-format on
|