CIRCT 21.0.0git
Loading...
Searching...
No Matches
RtgTool.cpp
Go to the documentation of this file.
1//===- RtgTool.cpp - C Interface for the rtgtool --------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include "circt-c/RtgTool.h"
10
12#include "mlir/CAPI/Pass.h"
13#include <string>
14
15using namespace circt;
16using namespace circt::rtg;
17
18//===----------------------------------------------------------------------===//
19// Tool Option API.
20//===----------------------------------------------------------------------===//
21
22DEFINE_C_API_PTR_METHODS(CirctRtgToolOptions, RtgToolOptions)
23
24CirctRtgToolOptions circtRtgToolOptionsCreateDefault(unsigned seed) {
25 auto *options = new RtgToolOptions(seed);
26 return wrap(options);
27}
28
29void circtRtgToolOptionsDestroy(CirctRtgToolOptions options) {
30 delete unwrap(options);
31}
32
33void circtRtgToolOptionsSetOutputFormat(CirctRtgToolOptions options,
36 switch (format) {
38 converted = RtgToolOptions::OutputFormat::MLIR;
39 break;
41 converted = RtgToolOptions::OutputFormat::ElaboratedMLIR;
42 break;
44 converted = RtgToolOptions::OutputFormat::ASM;
45 break;
46 }
47
48 unwrap(options)->setOutputFormat(converted);
49}
50
51void circtRtgToolOptionsSetSeed(CirctRtgToolOptions options, unsigned seed) {
52 unwrap(options)->setSeed(seed);
53}
54
55void circtRtgToolOptionsSetVerifyPasses(CirctRtgToolOptions options,
56 bool enable) {
57 unwrap(options)->setVerifyPasses(enable);
58}
59
60void circtRtgToolOptionsSetVerbosePassExecution(CirctRtgToolOptions options,
61 bool enable) {
62 unwrap(options)->setVerbosePassExecution(enable);
63}
64
66 CirctRtgToolOptions options, unsigned numInstr,
67 const void **unsupportedInstructions) {
68 SmallVector<std::string> instr;
69 for (unsigned i = 0; i < numInstr; ++i)
70 instr.push_back(
71 reinterpret_cast<std::string *>(unsupportedInstructions)[i]);
72 unwrap(options)->setUnsupportedInstructions(std::move(instr));
73}
74
76 CirctRtgToolOptions options, const char *unsupportedInstruction) {
77 unwrap(options)->addUnsupportedInstruction(
78 std::string(unsupportedInstruction));
79}
80
82 CirctRtgToolOptions options, const char *filename) {
83 unwrap(options)->setUnsupportedInstructionsFile(std::string(filename));
84}
85
86void circtRtgToolOptionsSetSplitOutput(CirctRtgToolOptions options,
87 bool enable) {
88 unwrap(options)->setSplitOutput(enable);
89}
90
91void circtRtgToolOptionsSetOutputPath(CirctRtgToolOptions options,
92 const char *path) {
93 unwrap(options)->setOutputPath(std::string(path));
94}
95
96//===----------------------------------------------------------------------===//
97// Pipeline Population API.
98//===----------------------------------------------------------------------===//
99
100void circtRtgToolRandomizerPipeline(MlirPassManager pm,
101 CirctRtgToolOptions options) {
103}
DEFINE_C_API_PTR_METHODS(CirctFirtoolFirtoolOptions, circt::firtool::FirtoolOptions) CirctFirtoolFirtoolOptions circtFirtoolOptionsCreateDefault()
Definition Firtool.cpp:18
return wrap(CMemoryType::get(unwrap(ctx), baseType, numElements))
static EvaluatorValuePtr unwrap(OMEvaluatorValue c)
Definition OM.cpp:113
void circtRtgToolOptionsSetUnsupportedInstructions(CirctRtgToolOptions options, unsigned numInstr, const void **unsupportedInstructions)
Definition RtgTool.cpp:65
void circtRtgToolOptionsSetVerbosePassExecution(CirctRtgToolOptions options, bool enable)
Definition RtgTool.cpp:60
void circtRtgToolOptionsSetOutputPath(CirctRtgToolOptions options, const char *path)
Definition RtgTool.cpp:91
void circtRtgToolOptionsDestroy(CirctRtgToolOptions options)
Definition RtgTool.cpp:29
void circtRtgToolOptionsSetSplitOutput(CirctRtgToolOptions options, bool enable)
Definition RtgTool.cpp:86
void circtRtgToolOptionsSetSeed(CirctRtgToolOptions options, unsigned seed)
Definition RtgTool.cpp:51
void circtRtgToolOptionsSetOutputFormat(CirctRtgToolOptions options, CirctRtgToolOutputFormat format)
Definition RtgTool.cpp:33
void circtRtgToolRandomizerPipeline(MlirPassManager pm, CirctRtgToolOptions options)
Definition RtgTool.cpp:100
void circtRtgToolOptionsSetUnsupportedInstructionsFile(CirctRtgToolOptions options, const char *filename)
Definition RtgTool.cpp:81
void circtRtgToolOptionsAddUnsupportedInstruction(CirctRtgToolOptions options, const char *unsupportedInstruction)
Definition RtgTool.cpp:75
void circtRtgToolOptionsSetVerifyPasses(CirctRtgToolOptions options, bool enable)
Definition RtgTool.cpp:55
CirctRtgToolOptions circtRtgToolOptionsCreateDefault(unsigned seed)
Definition RtgTool.cpp:24
@ CIRCT_RTGTOOL_OUTPUT_FORMAT_ASM
Definition RtgTool.h:36
@ CIRCT_RTGTOOL_OUTPUT_FORMAT_ELABORATED_MLIR
Definition RtgTool.h:35
@ CIRCT_RTGTOOL_OUTPUT_FORMAT_MLIR
Definition RtgTool.h:34
enum CiretRtgToolOutputFormat CirctRtgToolOutputFormat
The set of options used to control the behavior of the RTG tool.
void populateRandomizerPipeline(mlir::PassManager &pm, const RtgToolOptions &options)
Populates the passes necessary to lower IR with RTG randomization operations to fully elaborated IR (...
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.