diff options
author | Eddie Hung <eddie@fpgeh.com> | 2019-06-28 09:59:47 -0700 |
---|---|---|
committer | Eddie Hung <eddie@fpgeh.com> | 2019-06-28 09:59:47 -0700 |
commit | 38d8806bd74b9bb448c7488ec571e197fe2f96d6 (patch) | |
tree | f4a9a72fdbef4db8575b1a4508a7aeac1373d55b /backends | |
parent | 524af2131741ae2c74a810cab3b925d5ce950e6e (diff) | |
download | yosys-38d8806bd74b9bb448c7488ec571e197fe2f96d6.tar.gz yosys-38d8806bd74b9bb448c7488ec571e197fe2f96d6.tar.bz2 yosys-38d8806bd74b9bb448c7488ec571e197fe2f96d6.zip |
Add generic __builtin_bswap32 function
Diffstat (limited to 'backends')
-rw-r--r-- | backends/aiger/xaiger.cc | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/backends/aiger/xaiger.cc b/backends/aiger/xaiger.cc index d373ca77e..eb3d47569 100644 --- a/backends/aiger/xaiger.cc +++ b/backends/aiger/xaiger.cc @@ -25,6 +25,21 @@ #elif defined(__APPLE__) #include <libkern/OSByteOrder.h> #define __builtin_bswap32 OSSwapInt32 +#elif !defined(__GNUC__) +#include <cstdint> +inline uint32_t __builtin_bswap32(uint32_t x) +{ + // https://stackoverflow.com/a/27796212 + register uint32_t value = number_to_be_reversed; + uint8_t lolo = (value >> 0) & 0xFF; + uint8_t lohi = (value >> 8) & 0xFF; + uint8_t hilo = (value >> 16) & 0xFF; + uint8_t hihi = (value >> 24) & 0xFF; + return (hihi << 24) + | (hilo << 16) + | (lohi << 8) + | (lolo << 0); +} #endif #include "kernel/yosys.h" |