CIRCT  18.0.0git
SV.cpp
Go to the documentation of this file.
1 //===- SVDialect.cpp - C Interface for the SV Dialect -------------------===//
2 //
3 // Implements a C Interface for the SV Dialect
4 //
5 //===----------------------------------------------------------------------===//
6 
7 #include "circt-c/Dialect/SV.h"
11 #include "mlir/CAPI/IR.h"
12 #include "mlir/CAPI/Registration.h"
13 #include "mlir/CAPI/Support.h"
14 
15 using namespace circt::sv;
16 
18 MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(SystemVerilog, sv, SVDialect)
19 
20 bool svAttrIsASVAttributeAttr(MlirAttribute cAttr) {
21  return unwrap(cAttr).isa<SVAttributeAttr>();
22 }
23 
24 MlirAttribute svSVAttributeAttrGet(MlirContext cCtxt, MlirStringRef cName,
25  MlirStringRef cExpression,
26  bool emitAsComment) {
27  mlir::MLIRContext *ctxt = unwrap(cCtxt);
28  mlir::StringAttr expr;
29  if (cExpression.data != nullptr)
30  expr = mlir::StringAttr::get(ctxt, unwrap(cExpression));
31  return wrap(
33  expr, mlir::BoolAttr::get(ctxt, emitAsComment)));
34 }
35 
36 MlirStringRef svSVAttributeAttrGetName(MlirAttribute cAttr) {
37  return wrap(unwrap(cAttr).cast<SVAttributeAttr>().getName().getValue());
38 }
39 
40 MlirStringRef svSVAttributeAttrGetExpression(MlirAttribute cAttr) {
41  auto expr = unwrap(cAttr).cast<SVAttributeAttr>().getExpression();
42  if (expr)
43  return wrap(expr.getValue());
44  return {nullptr, 0};
45 }
46 
47 bool svSVAttributeAttrGetEmitAsComment(MlirAttribute attribute) {
48  return unwrap(attribute)
49  .cast<SVAttributeAttr>()
50  .getEmitAsComment()
51  .getValue();
52 }
return wrap(CMemoryType::get(unwrap(ctx), baseType, numElements))
MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(CHIRRTL, chirrtl, circt::chirrtl::CHIRRTLDialect) MlirType chirrtlTypeGetCMemory(MlirContext ctx
static void registerPasses()
Definition: CIRCTModule.cpp:37
static EvaluatorValuePtr unwrap(OMEvaluatorValue c)
Definition: OM.cpp:100
MlirStringRef svSVAttributeAttrGetName(MlirAttribute cAttr)
Definition: SV.cpp:36
bool svAttrIsASVAttributeAttr(MlirAttribute cAttr)
Definition: SV.cpp:20
void registerSVPasses()
Definition: SV.cpp:17
bool svSVAttributeAttrGetEmitAsComment(MlirAttribute attribute)
Definition: SV.cpp:47
MlirStringRef svSVAttributeAttrGetExpression(MlirAttribute cAttr)
Definition: SV.cpp:40
MlirAttribute svSVAttributeAttrGet(MlirContext cCtxt, MlirStringRef cName, MlirStringRef cExpression, bool emitAsComment)
Definition: SV.cpp:24
Direction get(bool isOutput)
Returns an output direction if isOutput is true, otherwise returns an input direction.
Definition: CalyxOps.cpp:53
StringAttr getName(ArrayAttr names, size_t idx)
Return the name at the specified index of the ArrayAttr or null if it cannot be determined.
Definition: sv.py:1