#pragma once
#include <liblangutil/Exceptions.h>
#include <cstddef>
#include <string>
namespace solidity::frontend
{
enum class OptimisationPreset
{
None,
Minimal,
Standard,
Full,
};
struct OptimiserSettings
{
static char constexpr DefaultYulOptimiserSteps[] =
"dhfoDgvulfnTUtnIf" "["
"xa[r]EscLM" "cCTUtTOntnfDIul" "Lcul" "Vcul [j]"
"Tpeul" "xa[rul]" "xa[r]cL" "gvif" "CTUca[r]LSsTFOtfDnca[r]Iulc" "]"
"jmul[jul] VcTOcul jmul";
static OptimiserSettings none()
{
return {};
}
static OptimiserSettings minimal()
{
OptimiserSettings s = none();
s.runJumpdestRemover = true;
s.runPeephole = true;
return s;
}
static OptimiserSettings standard()
{
OptimiserSettings s;
s.runOrderLiterals = true;
s.runInliner = true;
s.runJumpdestRemover = true;
s.runPeephole = true;
s.runDeduplicate = true;
s.runCSE = true;
s.runConstantOptimiser = true;
s.runYulOptimiser = true;
s.optimizeStackAllocation = true;
return s;
}
static OptimiserSettings full()
{
return standard();
}
static OptimiserSettings preset(OptimisationPreset _preset)
{
switch (_preset)
{
case OptimisationPreset::None: return none();
case OptimisationPreset::Minimal: return minimal();
case OptimisationPreset::Standard: return standard();
case OptimisationPreset::Full: return full();
default: solAssert(false, "");
}
}
bool operator==(OptimiserSettings const& _other) const
{
return
runOrderLiterals == _other.runOrderLiterals &&
runInliner == _other.runInliner &&
runJumpdestRemover == _other.runJumpdestRemover &&
runPeephole == _other.runPeephole &&
runDeduplicate == _other.runDeduplicate &&
runCSE == _other.runCSE &&
runConstantOptimiser == _other.runConstantOptimiser &&
optimizeStackAllocation == _other.optimizeStackAllocation &&
runYulOptimiser == _other.runYulOptimiser &&
yulOptimiserSteps == _other.yulOptimiserSteps &&
expectedExecutionsPerDeployment == _other.expectedExecutionsPerDeployment;
}
bool runOrderLiterals = false;
bool runInliner = false;
bool runJumpdestRemover = false;
bool runPeephole = false;
bool runDeduplicate = false;
bool runCSE = false;
bool runConstantOptimiser = false;
bool optimizeStackAllocation = false;
bool runYulOptimiser = false;
std::string yulOptimiserSteps = DefaultYulOptimiserSteps;
size_t expectedExecutionsPerDeployment = 200;
};
}