Add wordSizeTransform yulOptimizerTests

This commit is contained in:
mingchuan 2019-04-29 23:55:57 +08:00
parent f7ccdb6447
commit 57fc4fde85
No known key found for this signature in database
GPG Key ID: 607CD25FA2D03651
4 changed files with 86 additions and 0 deletions

View File

@ -45,6 +45,7 @@
#include <libyul/optimiser/StackCompressor.h>
#include <libyul/optimiser/Suite.h>
#include <libyul/backends/evm/EVMDialect.h>
#include <libyul/backends/wasm/WordSizeTransform.h>
#include <libyul/AsmPrinter.h>
#include <libyul/AsmParser.h>
#include <libyul/AsmAnalysis.h>
@ -264,6 +265,13 @@ bool YulOptimizerTest::run(ostream& _stream, string const& _linePrefix, bool con
StackCompressor::run(m_dialect, *m_ast, true, maxIterations);
(BlockFlattener{})(*m_ast);
}
else if (m_optimizerStep == "wordSizeTransform")
{
disambiguate();
NameDispenser nameDispenser{*m_dialect, *m_ast}; // TODO: Support WasmDialect in yulOptimizerTest
ExpressionSplitter{*m_dialect, nameDispenser}(*m_ast);
WordSizeTransform::run(*m_ast, nameDispenser);
}
else if (m_optimizerStep == "fullSuite")
OptimiserSuite::run(m_dialect, *m_ast, *m_analysisInfo, true);
else

View File

@ -0,0 +1,18 @@
{
let val := 1234567890123456789012345678901234567890123456789012345678901234567890
val := 9876543219876543219876543219876543219876543219876543219876543219876543210
}
// ====
// step: wordSizeTransform
// ----
// {
// let val_1 := 196678011949
// let val_2 := 17592899865401375162
// let val_3 := 3392951883154430155
// let val_4 := 12452437124710337234
// val_1 := 1573424111353538
// val_2 := 11180339179422519519
// val_3 := 5225342777609112214
// val_4 := 12264064093151869674
// }

View File

@ -0,0 +1,43 @@
{
function swap(x, y) -> a, b
{
a := y
b := x
}
function main(v1, v2) -> r1, r2
{
let tmp := 11111111111111111111111111111111111111111111111111111111111111111111111111111
r1, r2 := swap(v1, tmp)
r1, r2 := swap(2222222222222222222222222222222222222222222222222222222222222222222, r2)
}
}
// ====
// step: wordSizeTransform
// ----
// {
// function swap(x_2, x_3, x_4, x_5, y_6, y_7, y_8, y_9) -> a_10, a_11, a_12, a_13, b_14, b_15, b_16, b_17
// {
// a_10 := y_6
// a_11 := y_7
// a_12 := y_8
// a_13 := y_9
// b_14 := x_2
// b_15 := x_3
// b_16 := x_4
// b_17 := x_5
// }
// function main(v1_18, v1_19, v1_20, v1_21, v2_22, v2_23, v2_24, v2_25) -> r1_26, r1_27, r1_28, r1_29, r2_30, r2_31, r2_32, r2_33
// {
// let tmp_34 := 1770102123480502530
// let tmp_35 := 591943673742124792
// let tmp_36 := 13663686148824196892
// let tmp_37 := 8198552921648689607
// r1_26, r1_27, r1_28, r1_29, r2_30, r2_31, r2_32, r2_33 := swap(v1_18, v1_19, v1_20, v1_21, tmp_34, tmp_35, tmp_36, tmp_37)
// let _1_38 := 354020424
// let _1_39 := 12840787883880108911
// let _1_40 := 12527970737989311368
// let _1_41 := 16397105843297379214
// r1_26, r1_27, r1_28, r1_29, r2_30, r2_31, r2_32, r2_33 := swap(_1_38, _1_39, _1_40, _1_41, r2_30, r2_31, r2_32, r2_33)
// }
// }

View File

@ -0,0 +1,17 @@
{
let x := add(999999999999999999999999999999999999999999999999999999999999999, 77777777777777777777777777777777777777777777777777777777777777)
}
// ====
// step: wordSizeTransform
// ----
// {
// let _1_3 := 12390
// let _1_4 := 13186919961226471680
// let _1_5 := 18324050535993369984
// let _1_6 := 15884696285694336113
// let _2_7 := 159309
// let _2_8 := 3525417123811528497
// let _2_9 := 6328259118096044006
// let _2_10 := 9223372036854775807
// let x_11, x_12, x_13, x_14 := add(_2_7, _2_8, _2_9, _2_10, _1_3, _1_4, _1_5, _1_6)
// }