6#ifndef JLM_HLS_BACKEND_RHLS2FIRRTL_RHLSTOFIRRTLCONVERTER_HPP
7#define JLM_HLS_BACKEND_RHLS2FIRRTL_RHLSTOFIRRTLCONVERTER_HPP
18#include <mlir/IR/Builders.h>
19#include <mlir/IR/BuiltinOps.h>
20#include <mlir/IR/BuiltinTypes.h>
21#include <mlir/IR/Verifier.h>
23#include <circt/Dialect/FIRRTL/FIREmitter.h>
24#include <circt/Dialect/FIRRTL/FIRParser.h>
25#include <circt/Dialect/FIRRTL/FIRRTLDialect.h>
26#include <circt/Dialect/FIRRTL/FIRRTLOps.h>
27#include <circt/Dialect/FIRRTL/FIRRTLTypes.h>
28#include <circt/Dialect/FIRRTL/Namespace.h>
29#include <circt/Support/LLVM.h>
48 return "MLIR/FIRRTL generator";
55 Context_->getOrLoadDialect<circt::firrtl::FIRRTLDialect>();
69 circt::firrtl::CircuitOp
89 std::unique_ptr<mlir::ModuleOp>
95 std::unique_ptr<mlir::ModuleOp>
module =
96 std::make_unique<mlir::ModuleOp>(mlir::ModuleOp::create(Builder_->getUnknownLoc()));
97 module->push_back(circuit);
105 std::unordered_map<std::string, circt::firrtl::FModuleLike>
modules;
107 circt::firrtl::FModuleOp
109 circt::firrtl::FModuleLike
111 circt::firrtl::FModuleLike
114 circt::firrtl::FModuleOp
116 circt::firrtl::FModuleOp
118 circt::firrtl::FModuleOp
120 circt::firrtl::FModuleOp
122 circt::firrtl::FModuleOp
130 circt::firrtl::FModuleOp
138 circt::firrtl::FModuleOp
140 circt::firrtl::FModuleOp
142 circt::firrtl::FModuleOp
144 circt::firrtl::FModuleOp
146 circt::firrtl::FModuleOp
148 circt::firrtl::FModuleOp
150 circt::firrtl::FModuleOp
152 circt::firrtl::FModuleOp
154 circt::firrtl::FModuleOp
156 circt::firrtl::FModuleOp
158 circt::firrtl::FModuleOp
160 circt::firrtl::FModuleOp
162 circt::firrtl::FModuleOp
164 circt::firrtl::FModuleOp
166 circt::firrtl::FExtModuleOp
180 ::llvm::SmallVector<circt::firrtl::PortInfo> *
ports,
183 circt::firrtl::FIRRTLBaseType type);
184 circt::firrtl::BundleType
186 circt::firrtl::SubfieldOp
188 circt::firrtl::SubfieldOp
199 Connect(mlir::Block *
body, mlir::Value sink, mlir::Value source);
201 circt::firrtl::BitsPrimOp
202 AddBitsOp(mlir::Block *
body, mlir::Value value,
int high,
int low);
203 circt::firrtl::AndPrimOp
205 circt::firrtl::NodeOp
206 AddNodeOp(mlir::Block *
body, mlir::Value value, std::string name);
207 circt::firrtl::XorPrimOp
209 circt::firrtl::OrPrimOp
211 circt::firrtl::NotPrimOp
213 circt::firrtl::AddPrimOp
215 circt::firrtl::SubPrimOp
217 circt::firrtl::MulPrimOp
219 circt::firrtl::DivPrimOp
221 circt::firrtl::DShrPrimOp
223 circt::firrtl::DShlPrimOp
225 circt::firrtl::RemPrimOp
227 circt::firrtl::EQPrimOp
229 circt::firrtl::NEQPrimOp
231 circt::firrtl::GTPrimOp
233 circt::firrtl::GEQPrimOp
235 circt::firrtl::LTPrimOp
237 circt::firrtl::LEQPrimOp
239 circt::firrtl::MuxPrimOp
241 circt::firrtl::AsSIntPrimOp
243 circt::firrtl::AsUIntPrimOp
245 circt::firrtl::PadPrimOp
247 circt::firrtl::CvtPrimOp
249 circt::firrtl::WireOp
251 circt::firrtl::WhenOp
253 circt::firrtl::InstanceOp
255 circt::firrtl::ConstantOp
257 circt::firrtl::InvalidValueOp
262 circt::firrtl::BitsPrimOp
273 circt::firrtl::BundleType::BundleElement
275 circt::firrtl::BundleType::BundleElement
281 circt::firrtl::FModuleOp
283 circt::firrtl::IntType
285 circt::firrtl::IntType
287 circt::firrtl::FIRRTLBaseType
const rvsdg::LambdaNode * get_hls_lambda(llvm::LlvmRvsdgModule &rm)
circt::firrtl::InstanceOp AddInstanceOp(mlir::Block *circuitBody, jlm::rvsdg::Node *node)
RhlsToFirrtlConverter(const RhlsToFirrtlConverter &)=delete
circt::firrtl::GEQPrimOp AddGeqOp(mlir::Block *body, mlir::Value first, mlir::Value second)
circt::firrtl::FModuleOp MlirGenBuffer(const jlm::rvsdg::SimpleNode *node)
mlir::BlockArgument GetPort(circt::firrtl::FModuleOp &module, std::string portName)
circt::firrtl::FModuleOp MlirGenHlsMemReq(const jlm::rvsdg::SimpleNode *node)
circt::firrtl::EQPrimOp AddEqOp(mlir::Block *body, mlir::Value first, mlir::Value second)
circt::firrtl::LTPrimOp AddLtOp(mlir::Block *body, mlir::Value first, mlir::Value second)
circt::firrtl::BitsPrimOp AddBitsOp(mlir::Block *body, mlir::Value value, int high, int low)
void check_module(circt::firrtl::FModuleOp &module)
RhlsToFirrtlConverter & operator=(const RhlsToFirrtlConverter &)=delete
circt::firrtl::XorPrimOp AddXorOp(mlir::Block *body, mlir::Value first, mlir::Value second)
std::unique_ptr<::mlir::MLIRContext > Context_
circt::firrtl::FModuleOp MlirGenNDMux(const jlm::rvsdg::SimpleNode *node)
circt::firrtl::BundleType GetBundleType(const circt::firrtl::FIRRTLBaseType &type)
circt::firrtl::BitsPrimOp DropMSBs(mlir::Block *body, mlir::Value value, int amount)
circt::firrtl::WireOp AddWireOp(mlir::Block *body, std::string name, int size)
void AddMemResPort(::llvm::SmallVector< circt::firrtl::PortInfo > *ports)
circt::firrtl::RemPrimOp AddRemOp(mlir::Block *body, mlir::Value first, mlir::Value second)
std::string ToString(llvm::LlvmRvsdgModule &rvsdgModule)
std::unordered_map< std::string, circt::firrtl::FModuleLike > modules
circt::firrtl::FModuleOp MlirGenFork(const jlm::rvsdg::SimpleNode *node)
circt::firrtl::FModuleOp nodeToModule(const jlm::rvsdg::Node *node, bool mem=false)
void WriteModuleToFile(const circt::firrtl::FModuleOp fModuleOp, const rvsdg::Node *node)
rvsdg::Output * TraceStructuralOutput(rvsdg::StructuralOutput *out)
circt::firrtl::NodeOp AddNodeOp(mlir::Block *body, mlir::Value value, std::string name)
circt::firrtl::FModuleOp MlirGenTrigger(const jlm::rvsdg::SimpleNode *node)
circt::firrtl::DShrPrimOp AddDShrOp(mlir::Block *body, mlir::Value first, mlir::Value second)
circt::firrtl::NEQPrimOp AddNeqOp(mlir::Block *body, mlir::Value first, mlir::Value second)
circt::firrtl::FModuleOp MlirGenPrint(const jlm::rvsdg::SimpleNode *node)
circt::firrtl::FModuleOp MlirGenHlsMemResp(const jlm::rvsdg::SimpleNode *node)
circt::firrtl::BundleType::BundleElement GetReadyElement()
std::string GetText(llvm::LlvmRvsdgModule &) override
circt::firrtl::BundleType::BundleElement GetValidElement()
void AddResetPort(::llvm::SmallVector< circt::firrtl::PortInfo > *ports)
circt::firrtl::FModuleOp MlirGenStateGate(const jlm::rvsdg::SimpleNode *node)
const circt::firrtl::FIRVersion DefaultFIRVersion_
void InitializeMemReq(circt::firrtl::FModuleOp module)
circt::firrtl::FModuleOp MlirGenSink(const jlm::rvsdg::SimpleNode *node)
void Connect(mlir::Block *body, mlir::Value sink, mlir::Value source)
circt::firrtl::FModuleOp MlirGenHlsStore(const jlm::rvsdg::SimpleNode *node)
circt::firrtl::FIRRTLBaseType GetFirrtlType(const jlm::rvsdg::Type *type)
void AddMemReqPort(::llvm::SmallVector< circt::firrtl::PortInfo > *ports)
circt::firrtl::DShlPrimOp AddDShlOp(mlir::Block *body, mlir::Value first, mlir::Value second)
void WriteCircuitToFile(const circt::firrtl::CircuitOp circuit, std::string name)
bool IsIdentityMapping(const rvsdg::MatchOperation &op)
circt::firrtl::CircuitOp MlirGen(const rvsdg::LambdaNode *lamdaNode)
circt::firrtl::FModuleOp MlirGenSimpleNode(const jlm::rvsdg::SimpleNode *node)
mlir::BlockArgument GetResetSignal(circt::firrtl::FModuleOp module)
std::string toString(const circt::firrtl::CircuitOp circuit)
circt::firrtl::ConstantOp GetConstant(mlir::Block *body, int size, int value)
circt::firrtl::InvalidValueOp GetInvalid(mlir::Block *body, int size)
RhlsToFirrtlConverter & operator=(RhlsToFirrtlConverter &&)=delete
mlir::BlockArgument GetOutPort(circt::firrtl::FModuleOp &module, size_t portNr)
circt::firrtl::FModuleOp MlirGenBranch(const jlm::rvsdg::SimpleNode *node)
circt::firrtl::SubPrimOp AddSubOp(mlir::Block *body, mlir::Value first, mlir::Value second)
circt::firrtl::PadPrimOp AddPadOp(mlir::Block *body, mlir::Value value, int amount)
circt::firrtl::MuxPrimOp AddMuxOp(mlir::Block *body, mlir::Value select, mlir::Value high, mlir::Value low)
circt::firrtl::WhenOp AddWhenOp(mlir::Block *body, mlir::Value condition, bool elseStatment)
circt::firrtl::AsUIntPrimOp AddAsUIntOp(mlir::Block *body, mlir::Value value)
circt::firrtl::FModuleOp MlirGenPredicationBuffer(const jlm::rvsdg::SimpleNode *node)
circt::firrtl::NotPrimOp AddNotOp(mlir::Block *body, mlir::Value first)
circt::firrtl::FModuleOp MlirGenAddrQueue(const jlm::rvsdg::SimpleNode *node)
circt::firrtl::GTPrimOp AddGtOp(mlir::Block *body, mlir::Value first, mlir::Value second)
circt::firrtl::FExtModuleOp MlirGenExtModule(const jlm::rvsdg::SimpleNode *node)
void AddClockPort(::llvm::SmallVector< circt::firrtl::PortInfo > *ports)
std::string extension() override
circt::firrtl::FModuleOp MlirGenHlsDLoad(const jlm::rvsdg::SimpleNode *node)
circt::firrtl::FModuleOp MlirGenLoopConstBuffer(const jlm::rvsdg::SimpleNode *node)
circt::firrtl::OrPrimOp AddOrOp(mlir::Block *body, mlir::Value first, mlir::Value second)
circt::firrtl::IntType GetIntType(int size)
std::unique_ptr< mlir::ModuleOp > ConvertToMduleOp(llvm::LlvmRvsdgModule &rvsdgModule)
circt::firrtl::MulPrimOp AddMulOp(mlir::Block *body, mlir::Value first, mlir::Value second)
circt::firrtl::LEQPrimOp AddLeqOp(mlir::Block *body, mlir::Value first, mlir::Value second)
circt::firrtl::FModuleOp MlirGenHlsLocalMem(const jlm::rvsdg::SimpleNode *node)
std::string GetModuleName(const rvsdg::Node *node)
jlm::rvsdg::Output * TraceArgument(rvsdg::RegionArgument *arg)
std::unique_ptr<::mlir::OpBuilder > Builder_
circt::firrtl::AsSIntPrimOp AddAsSIntOp(mlir::Block *body, mlir::Value value)
circt::firrtl::FModuleOp MlirGenDMux(const jlm::rvsdg::SimpleNode *node)
circt::firrtl::DivPrimOp AddDivOp(mlir::Block *body, mlir::Value first, mlir::Value second)
circt::firrtl::FModuleOp MlirGenHlsLoad(const jlm::rvsdg::SimpleNode *node)
RhlsToFirrtlConverter(RhlsToFirrtlConverter &&)=delete
circt::firrtl::AddPrimOp AddAddOp(mlir::Block *body, mlir::Value first, mlir::Value second)
mlir::BlockArgument GetInPort(circt::firrtl::FModuleOp &module, size_t portNr)
circt::firrtl::CvtPrimOp AddCvtOp(mlir::Block *body, mlir::Value value)
circt::firrtl::SubfieldOp GetSubfield(mlir::Block *body, mlir::Value value, int index)
mlir::OpResult GetInstancePort(circt::firrtl::InstanceOp &instance, std::string portName)
mlir::BlockArgument GetClockSignal(circt::firrtl::FModuleOp module)
circt::firrtl::AndPrimOp AddAndOp(mlir::Block *body, mlir::Value first, mlir::Value second)
void ConnectInvalid(mlir::Block *body, mlir::Value value)
circt::firrtl::FModuleOp MlirGenMem(const jlm::rvsdg::SimpleNode *node)
void AddBundlePort(::llvm::SmallVector< circt::firrtl::PortInfo > *ports, circt::firrtl::Direction direction, std::string name, circt::firrtl::FIRRTLBaseType type)
Represents the argument of a region.
Represent acyclic RVSDG subgraphs.
NodeType * TryGetOwnerNode(const rvsdg::Input &input) noexcept
Checks if this is an input to a node of specified type.