Browse Source

BYTE reimplementation

[Delivers #80911670]
cl-refactor
Paweł Bylica 10 years ago
parent
commit
607458b193
  1. 21
      libevmjit/Compiler.cpp

21
libevmjit/Compiler.cpp

@ -15,6 +15,7 @@
#include "Ext.h" #include "Ext.h"
#include "GasMeter.h" #include "GasMeter.h"
#include "Utils.h" #include "Utils.h"
#include "Endianness.h"
namespace dev namespace dev
{ {
@ -420,21 +421,11 @@ void Compiler::compileBasicBlock(BasicBlock& basicBlock, bytesConstRef bytecode,
const auto byteNum = stack.pop(); const auto byteNum = stack.pop();
auto value = stack.pop(); auto value = stack.pop();
/* //
if (byteNum < 32) - use select value = Endianness::toBE(m_builder, value);
{ auto bytes = m_builder.CreateBitCast(value, llvm::VectorType::get(Type::Byte, 32), "bytes");
value <<= byteNum*8 auto byte = m_builder.CreateExtractElement(bytes, byteNum, "byte");
value >>= 31*8 value = m_builder.CreateZExt(byte, Type::i256);
push value
}
else push 0
*/
// TODO: Shifting by 0 gives wrong results as of this bug http://llvm.org/bugs/show_bug.cgi?id=16439
auto shbits = m_builder.CreateShl(byteNum, Constant::get(3));
value = m_builder.CreateShl(value, shbits);
value = m_builder.CreateLShr(value, Constant::get(31 * 8));
auto byteNumValid = m_builder.CreateICmpULT(byteNum, Constant::get(32)); auto byteNumValid = m_builder.CreateICmpULT(byteNum, Constant::get(32));
value = m_builder.CreateSelect(byteNumValid, value, Constant::get(0)); value = m_builder.CreateSelect(byteNumValid, value, Constant::get(0));

Loading…
Cancel
Save