CIRCT 20.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 char **unsupportedInstructions) {
68 SmallVector<std::string> instr;
69 for (unsigned i = 0; i < numInstr; ++i)
70 instr.push_back(std::string(unsupportedInstructions[i]));
71 unwrap(options)->setUnsupportedInstructions(std::move(instr));
72}
73
75 CirctRtgToolOptions options, const char *unsupportedInstruction) {
76 unwrap(options)->addUnsupportedInstruction(
77 std::string(unsupportedInstruction));
78}
79
81 CirctRtgToolOptions options, const char *filename) {
82 unwrap(options)->setUnsupportedInstructionsFile(std::string(filename));
83}
84
85//===----------------------------------------------------------------------===//
86// Pipeline Population API.
87//===----------------------------------------------------------------------===//
88
89void circtRtgToolRandomizerPipeline(MlirPassManager pm,
90 CirctRtgToolOptions options) {
92}
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 circtRtgToolOptionsSetVerbosePassExecution(CirctRtgToolOptions options, bool enable)
Definition RtgTool.cpp:60
void circtRtgToolOptionsSetUnsupportedInstructions(CirctRtgToolOptions options, unsigned numInstr, const char **unsupportedInstructions)
Definition RtgTool.cpp:65
void circtRtgToolOptionsDestroy(CirctRtgToolOptions options)
Definition RtgTool.cpp:29
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:89
void circtRtgToolOptionsSetUnsupportedInstructionsFile(CirctRtgToolOptions options, const char *filename)
Definition RtgTool.cpp:80
void circtRtgToolOptionsAddUnsupportedInstruction(CirctRtgToolOptions options, const char *unsupportedInstruction)
Definition RtgTool.cpp:74
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.