mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Initial IR generator.
This commit is contained in:
@@ -121,6 +121,7 @@ static string const g_strHelp = "help";
|
||||
static string const g_strInputFile = "input-file";
|
||||
static string const g_strInterface = "interface";
|
||||
static string const g_strYul = "yul";
|
||||
static string const g_strIR = "ir";
|
||||
static string const g_strLicense = "license";
|
||||
static string const g_strLibraries = "libraries";
|
||||
static string const g_strLink = "link";
|
||||
@@ -166,6 +167,7 @@ static string const g_argGas = g_strGas;
|
||||
static string const g_argHelp = g_strHelp;
|
||||
static string const g_argInputFile = g_strInputFile;
|
||||
static string const g_argYul = g_strYul;
|
||||
static string const g_argIR = g_strIR;
|
||||
static string const g_argLibraries = g_strLibraries;
|
||||
static string const g_argLink = g_strLink;
|
||||
static string const g_argMachine = g_strMachine;
|
||||
@@ -293,6 +295,20 @@ void CommandLineInterface::handleOpcode(string const& _contract)
|
||||
}
|
||||
}
|
||||
|
||||
void CommandLineInterface::handleIR(string const& _contractName)
|
||||
{
|
||||
if (m_args.count(g_argIR))
|
||||
{
|
||||
if (m_args.count(g_argOutputDir))
|
||||
createFile(m_compiler->filesystemFriendlyName(_contractName) + ".yul", m_compiler->yulIR(_contractName));
|
||||
else
|
||||
{
|
||||
sout() << "IR: " << endl;
|
||||
sout() << m_compiler->yulIR(_contractName) << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CommandLineInterface::handleBytecode(string const& _contract)
|
||||
{
|
||||
if (m_args.count(g_argOpcodes))
|
||||
@@ -685,6 +701,7 @@ Allowed options)",
|
||||
(g_argBinary.c_str(), "Binary of the contracts in hex.")
|
||||
(g_argBinaryRuntime.c_str(), "Binary of the runtime part of the contracts in hex.")
|
||||
(g_argAbi.c_str(), "ABI specification of the contracts.")
|
||||
(g_argIR.c_str(), "Intermediate Representation (IR) of all contracts (EXPERIMENTAL).")
|
||||
(g_argSignatureHashes.c_str(), "Function signature hashes of the contracts.")
|
||||
(g_argNatspecUser.c_str(), "Natspec user documentation of all contracts.")
|
||||
(g_argNatspecDev.c_str(), "Natspec developer documentation of all contracts.")
|
||||
@@ -907,6 +924,8 @@ bool CommandLineInterface::processInput()
|
||||
m_compiler->setEVMVersion(m_evmVersion);
|
||||
// TODO: Perhaps we should not compile unless requested
|
||||
|
||||
m_compiler->enableIRGeneration(m_args.count(g_argIR));
|
||||
|
||||
OptimiserSettings settings = m_args.count(g_argOptimize) ? OptimiserSettings::standard() : OptimiserSettings::minimal();
|
||||
settings.expectedExecutionsPerDeployment = m_args[g_argOptimizeRuns].as<unsigned>();
|
||||
settings.runYulOptimiser = m_args.count(g_strOptimizeYul);
|
||||
@@ -1369,6 +1388,7 @@ void CommandLineInterface::outputCompilationResults()
|
||||
handleGasEstimation(contract);
|
||||
|
||||
handleBytecode(contract);
|
||||
handleIR(contract);
|
||||
handleSignatureHashes(contract);
|
||||
handleMetadata(contract);
|
||||
handleABI(contract);
|
||||
|
||||
@@ -65,6 +65,7 @@ private:
|
||||
void handleAst(std::string const& _argStr);
|
||||
void handleBinary(std::string const& _contract);
|
||||
void handleOpcode(std::string const& _contract);
|
||||
void handleIR(std::string const& _contract);
|
||||
void handleBytecode(std::string const& _contract);
|
||||
void handleSignatureHashes(std::string const& _contract);
|
||||
void handleMetadata(std::string const& _contract);
|
||||
|
||||
Reference in New Issue
Block a user