Merge pull request #8679 from ethereum/bitOpsForYul

[Sol->Yul] Implement bit operations.
This commit is contained in:
Leonardo 2020-04-16 09:08:19 +02:00 committed by GitHub
commit 0f7a5e8062
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 0 deletions

View File

@ -1537,6 +1537,15 @@ string IRGeneratorForStatements::binaryOperation(
case Token::Mod:
fun = m_utils.checkedIntModFunction(*type);
break;
case Token::BitOr:
fun = "or";
break;
case Token::BitXor:
fun = "xor";
break;
case Token::BitAnd:
fun = "and";
break;
default:
break;
}

View File

@ -0,0 +1,19 @@
contract test {
uint8 x;
uint v;
function f() public returns (uint x, uint y, uint z) {
uint16 a;
uint32 b;
assembly {
a := 0x0f0f0f0f0f
b := 0xff0fff0fff
}
x = a & b;
y = a | b;
z = a ^ b;
}
}
// ====
// compileViaYul: also
// ----
// f() -> 3855, 268374015, 268370160