13#include "mlir/Bindings/Python/NanobindAdaptors.h"
15#include <nanobind/nanobind.h>
22class PyRtgToolOptions {
25 bool verifyPasses,
bool verbosePassExecution,
26 const std::vector<std::string> &unsupportedInstructions,
27 const std::string &unsupportedInstructionsFile,
28 bool splitOutput,
const std::string &outputPath)
30 setOutputFormat(outputFormat);
31 setVerifyPasses(verifyPasses);
32 setVerbosePassExecution(verbosePassExecution);
33 setUnsupportedInstructions(unsupportedInstructions);
34 setUnsupportedInstructionsFile(unsupportedInstructionsFile);
35 setSplitOutput(splitOutput);
36 setOutputPath(outputPath);
40 operator CirctRtgToolOptions()
const {
return options; }
41 CirctRtgToolOptions
get()
const {
return options; }
49 void setVerifyPasses(
bool enable) {
53 void setVerbosePassExecution(
bool enable) {
58 setUnsupportedInstructions(
const std::vector<std::string> &instructions) {
60 options, instructions.size(),
61 reinterpret_cast<const void **
>(
62 const_cast<std::string *
>(instructions.data())));
65 void addUnsupportedInstruction(
const std::string &instruction) {
69 void setUnsupportedInstructionsFile(
const std::string &filename) {
74 void setSplitOutput(
bool enable) {
78 void setOutputPath(
const std::string &path) {
83 CirctRtgToolOptions options;
89 m.doc() =
"RTGTool Python native extension";
91 nb::enum_<CirctRtgToolOutputFormat>(m,
"OutputFormat")
96 nb::class_<PyRtgToolOptions>(m,
"Options")
98 const std::vector<std::string> &,
const std::string &,
bool,
99 const std::string &>(),
102 nb::arg(
"verify_passes") =
true,
103 nb::arg(
"verbose_pass_execution") =
false,
104 nb::arg(
"unsupported_instructions") = std::vector<const char *>(),
105 nb::arg(
"unsupported_instructions_file") =
"",
106 nb::arg(
"split_output") =
false, nb::arg(
"output_path") =
"")
107 .def(
"set_output_format", &PyRtgToolOptions::setOutputFormat,
108 "Specify the output format of the tool", nb::arg(
"format"))
109 .def(
"set_seed", &PyRtgToolOptions::setSeed,
110 "Specify the seed for all RNGs used in the tool", nb::arg(
"seed"))
111 .def(
"set_verify_passes", &PyRtgToolOptions::setVerifyPasses,
112 "Specify whether the verifiers should be run after each pass",
114 .def(
"set_verbose_pass_execution",
115 &PyRtgToolOptions::setVerbosePassExecution,
116 "Specify whether passes should run in verbose mode",
118 .def(
"set_unsupported_instructions",
119 &PyRtgToolOptions::setUnsupportedInstructions,
120 "Set the list of of instructions unsupported by the assembler",
121 nb::arg(
"instructions"))
122 .def(
"add_unsupported_instruction",
123 &PyRtgToolOptions::addUnsupportedInstruction,
124 "Add the instruction given by name to the list of instructions not "
125 "supported by the assembler",
126 nb::arg(
"instruction_name"))
127 .def(
"set_unsupported_instructions_file",
128 &PyRtgToolOptions::setUnsupportedInstructionsFile,
129 "Register a file containing a comma-separated list of instruction "
130 "names which are not supported by the assembler.",
132 .def(
"set_split_output", &PyRtgToolOptions::setSplitOutput,
133 "Determines whether each test should be emitted to a separate file.",
135 .def(
"output_path", &PyRtgToolOptions::setOutputPath,
136 "The path of a file to be emitted to or a directory if "
137 "'split_output' is enabled.",
138 nb::arg(
"filename"));
140 m.def(
"populate_randomizer_pipeline",
141 [](MlirPassManager pm,
const PyRtgToolOptions &options) {
Direction get(bool isOutput)
Returns an output direction if isOutput is true, otherwise returns an input direction.
void populateDialectRTGToolSubmodule(nanobind::module_ &m)
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.