mirror of
				https://github.com/ethereum/solidity
				synced 2023-10-03 13:03:40 +00:00 
			
		
		
		
	Dialect setting for yul optimizer tests.
This commit is contained in:
		
							parent
							
								
									12dac24871
								
							
						
					
					
						commit
						1e59c19166
					
				| @ -60,6 +60,7 @@ | ||||
| #include <libyul/backends/evm/EVMDialect.h> | ||||
| #include <libyul/backends/evm/EVMMetrics.h> | ||||
| #include <libyul/backends/wasm/WordSizeTransform.h> | ||||
| #include <libyul/backends/wasm/WasmDialect.h> | ||||
| #include <libyul/AsmPrinter.h> | ||||
| #include <libyul/AsmParser.h> | ||||
| #include <libyul/AsmAnalysis.h> | ||||
| @ -98,12 +99,24 @@ YulOptimizerTest::YulOptimizerTest(string const& _filename) | ||||
| 	file.exceptions(ios::badbit); | ||||
| 
 | ||||
| 	m_source = parseSourceAndSettings(file); | ||||
| 	if (m_settings.count("yul")) | ||||
| 	if (m_settings.count("dialect")) | ||||
| 	{ | ||||
| 		m_yul = true; | ||||
| 		m_validatedSettings["yul"] = "true"; | ||||
| 		m_settings.erase("yul"); | ||||
| 		auto dialectName = m_settings["dialect"]; | ||||
| 		if (dialectName == "yul") | ||||
| 			m_dialect = &Dialect::yul(); | ||||
| 		else if (dialectName == "ewasm") | ||||
| 			m_dialect = &WasmDialect::instance(); | ||||
| 		else if (dialectName == "evm") | ||||
| 			m_dialect = &EVMDialect::strictAssemblyForEVMObjects(dev::test::Options::get().evmVersion()); | ||||
| 		else | ||||
| 			BOOST_THROW_EXCEPTION(runtime_error("Invalid dialect " + dialectName)); | ||||
| 
 | ||||
| 		m_validatedSettings["dialect"] = dialectName; | ||||
| 		m_settings.erase("dialect"); | ||||
| 	} | ||||
| 	else | ||||
| 		m_dialect = &EVMDialect::strictAssemblyForEVMObjects(dev::test::Options::get().evmVersion()); | ||||
| 
 | ||||
| 	if (m_settings.count("step")) | ||||
| 	{ | ||||
| 		m_validatedSettings["step"] = m_settings["step"]; | ||||
| @ -350,7 +363,7 @@ TestCase::TestResult YulOptimizerTest::run(ostream& _stream, string const& _line | ||||
| 		return TestResult::FatalError; | ||||
| 	} | ||||
| 
 | ||||
| 	m_obtainedResult = AsmPrinter{m_yul}(*m_ast) + "\n"; | ||||
| 	m_obtainedResult = AsmPrinter{m_dialect->flavour == AsmFlavour::Yul}(*m_ast) + "\n"; | ||||
| 
 | ||||
| 	if (m_optimizerStep != m_validatedSettings["step"]) | ||||
| 	{ | ||||
| @ -406,7 +419,7 @@ bool YulOptimizerTest::parse(ostream& _stream, string const& _linePrefix, bool c | ||||
| { | ||||
| 	AssemblyStack stack( | ||||
| 		dev::test::Options::get().evmVersion(), | ||||
| 		m_yul ? AssemblyStack::Language::Yul : AssemblyStack::Language::StrictAssembly, | ||||
| 		m_dialect->flavour == AsmFlavour::Yul ? AssemblyStack::Language::Yul : AssemblyStack::Language::StrictAssembly, | ||||
| 		dev::solidity::OptimiserSettings::none() | ||||
| 	); | ||||
| 	if (!stack.parseAndAnalyze("", m_source) || !stack.errors().empty()) | ||||
| @ -415,7 +428,6 @@ bool YulOptimizerTest::parse(ostream& _stream, string const& _linePrefix, bool c | ||||
| 		printErrors(_stream, stack.errors()); | ||||
| 		return false; | ||||
| 	} | ||||
| 	m_dialect = m_yul ? &Dialect::yul() : &EVMDialect::strictAssemblyForEVMObjects(dev::test::Options::get().evmVersion()); | ||||
| 	m_ast = stack.parserResult()->code; | ||||
| 	m_analysisInfo = stack.parserResult()->analysisInfo; | ||||
| 	return true; | ||||
|  | ||||
| @ -71,7 +71,6 @@ private: | ||||
| 	static void printErrors(std::ostream& _stream, langutil::ErrorList const& _errors); | ||||
| 
 | ||||
| 	std::string m_source; | ||||
| 	bool m_yul = false; | ||||
| 	std::string m_optimizerStep; | ||||
| 	std::string m_expectation; | ||||
| 
 | ||||
|  | ||||
| @ -8,7 +8,7 @@ | ||||
| } | ||||
| // ==== | ||||
| // step: disambiguator | ||||
| // yul: true | ||||
| // dialect: yul | ||||
| // ---- | ||||
| // { | ||||
| //     { let a:u256, b:u256 } | ||||
|  | ||||
| @ -8,7 +8,7 @@ | ||||
| } | ||||
| // ==== | ||||
| // step: disambiguator | ||||
| // yul: true | ||||
| // dialect: yul | ||||
| // ---- | ||||
| // { | ||||
| //     { | ||||
|  | ||||
| @ -7,7 +7,7 @@ | ||||
| } | ||||
| // ==== | ||||
| // step: disambiguator | ||||
| // yul: true | ||||
| // dialect: yul | ||||
| // ---- | ||||
| // { | ||||
| //     { let a:u256, b:u256, c:u256 } | ||||
|  | ||||
| @ -1,7 +1,7 @@ | ||||
| { { let aanteuhdaoneudbrgkjiuaothduiathudaoeuh:u256 } { let aanteuhdaoneudbrgkjiuaothduiathudaoeuh:u256 } } | ||||
| // ==== | ||||
| // step: disambiguator | ||||
| // yul: true | ||||
| // dialect: yul | ||||
| // ---- | ||||
| // { | ||||
| //     { | ||||
|  | ||||
| @ -1,6 +1,6 @@ | ||||
| { } | ||||
| // ==== | ||||
| // step: disambiguator | ||||
| // yul: true | ||||
| // dialect: yul | ||||
| // ---- | ||||
| // { } | ||||
|  | ||||
| @ -9,7 +9,7 @@ | ||||
| } | ||||
| // ==== | ||||
| // step: disambiguator | ||||
| // yul: true | ||||
| // dialect: yul | ||||
| // ---- | ||||
| // { | ||||
| //     { let a:u256, b:u256, c:u256 } | ||||
|  | ||||
| @ -1,7 +1,7 @@ | ||||
| { { let a:u256 } { let a:u256 } } | ||||
| // ==== | ||||
| // step: disambiguator | ||||
| // yul: true | ||||
| // dialect: yul | ||||
| // ---- | ||||
| // { | ||||
| //     { let a:u256 } | ||||
|  | ||||
| @ -1,7 +1,7 @@ | ||||
| { { let a:u256 let a_1:u256 } { let a:u256 } } | ||||
| // ==== | ||||
| // step: disambiguator | ||||
| // yul: true | ||||
| // dialect: yul | ||||
| // ---- | ||||
| // { | ||||
| //     { | ||||
|  | ||||
| @ -7,7 +7,7 @@ | ||||
| } | ||||
| // ==== | ||||
| // step: disambiguator | ||||
| // yul: true | ||||
| // dialect: yul | ||||
| // ---- | ||||
| // { | ||||
| //     { | ||||
|  | ||||
| @ -4,7 +4,7 @@ | ||||
| } | ||||
| // ==== | ||||
| // step: expressionInliner | ||||
| // yul: true | ||||
| // dialect: yul | ||||
| // ---- | ||||
| // { | ||||
| //     function f() -> x:u256 | ||||
|  | ||||
| @ -4,7 +4,7 @@ | ||||
| } | ||||
| // ==== | ||||
| // step: expressionInliner | ||||
| // yul: true | ||||
| // dialect: yul | ||||
| // ---- | ||||
| // { | ||||
| //     function f(a:u256) -> x:u256 | ||||
|  | ||||
| @ -1,7 +1,7 @@ | ||||
| { let a:u256 { } function f() -> x:bool { let b:u256 := 4:u256 {} for {} f() {} {} } } | ||||
| // ==== | ||||
| // step: functionGrouper | ||||
| // yul: true | ||||
| // dialect: yul | ||||
| // ---- | ||||
| // { | ||||
| //     { | ||||
|  | ||||
| @ -6,7 +6,7 @@ | ||||
| } | ||||
| // ==== | ||||
| // step: functionGrouper | ||||
| // yul: true | ||||
| // dialect: yul | ||||
| // ---- | ||||
| // { | ||||
| //     { | ||||
|  | ||||
| @ -10,7 +10,7 @@ | ||||
| } | ||||
| // ==== | ||||
| // step: functionGrouper | ||||
| // yul: true | ||||
| // dialect: yul | ||||
| // ---- | ||||
| // { | ||||
| //     { let a:u256 } | ||||
|  | ||||
| @ -3,7 +3,7 @@ | ||||
| } | ||||
| // ==== | ||||
| // step: functionGrouper | ||||
| // yul: true | ||||
| // dialect: yul | ||||
| // ---- | ||||
| // { | ||||
| //     { let a:u256 } | ||||
|  | ||||
| @ -9,7 +9,7 @@ | ||||
| } | ||||
| // ==== | ||||
| // step: functionHoister | ||||
| // yul: true | ||||
| // dialect: yul | ||||
| // ---- | ||||
| // { | ||||
| //     let a:u256 | ||||
|  | ||||
| @ -7,7 +7,7 @@ | ||||
| } | ||||
| // ==== | ||||
| // step: functionHoister | ||||
| // yul: true | ||||
| // dialect: yul | ||||
| // ---- | ||||
| // { | ||||
| //     let a:u256 | ||||
|  | ||||
| @ -8,7 +8,7 @@ | ||||
| } | ||||
| // ==== | ||||
| // step: functionHoister | ||||
| // yul: true | ||||
| // dialect: yul | ||||
| // ---- | ||||
| // { | ||||
| //     let a:u256 | ||||
|  | ||||
| @ -4,7 +4,7 @@ | ||||
| } | ||||
| // ==== | ||||
| // step: functionHoister | ||||
| // yul: true | ||||
| // dialect: yul | ||||
| // ---- | ||||
| // { | ||||
| //     let a:u256 | ||||
|  | ||||
| @ -9,7 +9,7 @@ | ||||
| } | ||||
| // ==== | ||||
| // step: mainFunction | ||||
| // yul: true | ||||
| // dialect: yul | ||||
| // ---- | ||||
| // { | ||||
| //     function main() | ||||
|  | ||||
| @ -7,7 +7,7 @@ | ||||
| } | ||||
| // ==== | ||||
| // step: mainFunction | ||||
| // yul: true | ||||
| // dialect: yul | ||||
| // ---- | ||||
| // { | ||||
| //     function main() | ||||
|  | ||||
| @ -8,7 +8,7 @@ | ||||
| } | ||||
| // ==== | ||||
| // step: mainFunction | ||||
| // yul: true | ||||
| // dialect: yul | ||||
| // ---- | ||||
| // { | ||||
| //     function main() | ||||
|  | ||||
| @ -4,7 +4,7 @@ | ||||
| } | ||||
| // ==== | ||||
| // step: mainFunction | ||||
| // yul: true | ||||
| // dialect: yul | ||||
| // ---- | ||||
| // { | ||||
| //     function main() | ||||
|  | ||||
| @ -1,7 +1,7 @@ | ||||
| {} | ||||
| // ==== | ||||
| // step: mainFunction | ||||
| // yul: true | ||||
| // dialect: yul | ||||
| // ---- | ||||
| // { | ||||
| //     function main() | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user