mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Use native shift instructions on Constantinople
This commit is contained in:
1 parent
5cce2e552b
commit
22bfd3da41
3 files changed
+20
-4
No files matched your search
@@ -1265,13 +1265,19 @@ void CompilerUtils::cleanHigherOrderBits(IntegerType const& _typeOnStack)
|
||||
void CompilerUtils::leftShiftNumberOnStack(unsigned _bits)
|
||||
{
|
||||
solAssert(_bits < 256, "");
|
||||
m_context << (u256(1) << _bits) << Instruction::MUL;
|
||||
if (m_context.evmVersion().hasBitwiseShifting())
|
||||
m_context << _bits << Instruction::SHL;
|
||||
else
|
||||
m_context << (u256(1) << _bits) << Instruction::MUL;
|
||||
}
|
||||
|
||||
void CompilerUtils::rightShiftNumberOnStack(unsigned _bits, bool _isSigned)
|
||||
{
|
||||
solAssert(_bits < 256, "");
|
||||
m_context << (u256(1) << _bits) << Instruction::SWAP1 << (_isSigned ? Instruction::SDIV : Instruction::DIV);
|
||||
if (m_context.evmVersion().hasBitwiseShifting())
|
||||
m_context << _bits << (_isSigned ? Instruction::SAR : Instruction::SHR);
|
||||
else
|
||||
m_context << (u256(1) << _bits) << Instruction::SWAP1 << (_isSigned ? Instruction::SDIV : Instruction::DIV);
|
||||
}
|
||||
|
||||
unsigned CompilerUtils::prepareMemoryStore(Type const& _type, bool _padToWords)
|
||||
|
||||
Reference in new issue
Block a user