Fabcoin Core  0.16.2
P2P Digital Currency
Endianness.cpp
Go to the documentation of this file.
1 #include "Endianness.h"
2 
4 #include <llvm/IR/IntrinsicInst.h>
5 #include <llvm/Support/Host.h>
7 
8 #include "Type.h"
9 
10 namespace dev
11 {
12 namespace eth
13 {
14 namespace jit
15 {
16 
18 {
19  if (llvm::sys::IsLittleEndianHost)
20  {
21  if (auto constant = llvm::dyn_cast<llvm::ConstantInt>(_value))
22  return _builder.getInt(constant->getValue().byteSwap());
23 
24  // OPT: Cache func declaration?
25  auto bswapFunc = llvm::Intrinsic::getDeclaration(_builder.GetInsertBlock()->getParent()->getParent(), llvm::Intrinsic::bswap, _value->getType());
26  return _builder.CreateCall(bswapFunc, _value);
27  }
28  return _value;
29 }
30 
31 }
32 }
33 }
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
Definition: Arith256.cpp:15
Config::Value_type Value
static llvm::Value * bswapIfLE(IRBuilder &_builder, llvm::Value *_word)
Definition: Endianness.cpp:17
llvm::IRBuilder<> IRBuilder