| 425 | } |
| 426 | |
| 427 | Phaser::CommandLineDescription Phaser::buildCommandLineDescription() |
| 428 | { |
| 429 | unsigned const lineLength = po::options_description::m_default_line_length; |
| 430 | unsigned const minDescriptionLength = lineLength - 23; |
| 431 | |
| 432 | po::options_description keywordDescription( |
| 433 | "yul-phaser, a tool for finding the best sequence of Yul optimisation phases.\n" |
| 434 | "\n" |
| 435 | "Usage: yul-phaser [options] <file>\n" |
| 436 | "Reads <file> as Yul code and tries to find the best order in which to run optimisation" |
| 437 | " phases using a genetic algorithm.\n" |
| 438 | "Example:\n" |
| 439 | "yul-phaser program.yul\n" |
| 440 | "\n" |
| 441 | "Allowed options", |
| 442 | lineLength, |
| 443 | minDescriptionLength |
| 444 | ); |
| 445 | |
| 446 | po::options_description generalDescription("GENERAL", lineLength, minDescriptionLength); |
| 447 | generalDescription.add_options() |
| 448 | ("help", "Show help message and exit.") |
| 449 | ("input-files", po::value<std::vector<std::string>>()->required()->value_name("<PATH>"), "Input files.") |
| 450 | ( |
| 451 | "prefix", |
| 452 | po::value<std::string>()->value_name("<CHROMOSOME>")->default_value(""), |
| 453 | "Initial optimisation steps automatically applied to every input program.\n" |
| 454 | "The result is treated as if it was the actual input, i.e. the steps are not considered " |
| 455 | "a part of the chromosomes and cannot be mutated. The values of relative metric values " |
| 456 | "are also relative to the fitness of a program with these steps applied rather than the " |
| 457 | "fitness of the original program.\n" |
| 458 | "Note that phaser always adds a 'hgo' prefix to ensure that chromosomes can " |
| 459 | "contain arbitrary optimisation steps. This implicit prefix cannot be changed or " |
| 460 | "or removed using this option. The value given here is applied after it." |
| 461 | ) |
| 462 | ("seed", po::value<uint32_t>()->value_name("<NUM>"), "Seed for the random number generator.") |
| 463 | ( |
| 464 | "rounds", |
| 465 | po::value<size_t>()->value_name("<NUM>"), |
| 466 | "The number of rounds after which the algorithm should stop. (default=no limit)." |
| 467 | ) |
| 468 | ( |
| 469 | "mode", |
| 470 | po::value<PhaserMode>()->value_name("<NAME>")->default_value(PhaserMode::RunAlgorithm), |
| 471 | ( |
| 472 | "Mode of operation. The default is to run the algorithm but you can also tell phaser " |
| 473 | "to do something else with its parameters, e.g. just print the optimised programs and exit.\n" |
| 474 | "\n" |
| 475 | "AVAILABLE MODES:\n" |
| 476 | "* " + toString(PhaserMode::RunAlgorithm) + "\n" + |
| 477 | "* " + toString(PhaserMode::PrintOptimisedPrograms) + "\n" + |
| 478 | "* " + toString(PhaserMode::PrintOptimisedASTs) |
| 479 | ).c_str() |
| 480 | ) |
| 481 | ; |
| 482 | keywordDescription.add(generalDescription); |
| 483 | |
| 484 | po::options_description algorithmDescription("ALGORITHM", lineLength, minDescriptionLength); |