Browse Source

Fix u256 to APInt conversion

cl-refactor
Paweł Bylica 10 years ago
parent
commit
3f50913d95
  1. 8
      libevmjit/Type.cpp

8
libevmjit/Type.cpp

@ -43,9 +43,11 @@ llvm::ConstantInt* Constant::get(uint64_t _n)
llvm::ConstantInt* Constant::get(u256 _n) llvm::ConstantInt* Constant::get(u256 _n)
{ {
auto limbs = _n.backend().limbs(); auto& backend = _n.backend();
auto words = reinterpret_cast<uint64_t*>(limbs); auto words = reinterpret_cast<uint64_t*>(backend.limbs());
llvm::APInt n(256, 4, words); auto nWords = backend.limb_bits == 64 ? backend.size() : (backend.size() + 1) / 2;
llvm::APInt n(256, nWords, words);
assert(n.toString(10, false) == _n.str());
return static_cast<llvm::ConstantInt*>(llvm::ConstantInt::get(Type::i256, n)); return static_cast<llvm::ConstantInt*>(llvm::ConstantInt::get(Type::i256, n));
} }

Loading…
Cancel
Save