CIRCT 20.0.0git
Loading...
Searching...
No Matches
SV.cpp
Go to the documentation of this file.
1//===- SV.cpp - C interface for the SV dialect ----------------------------===//
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
13#include "mlir/CAPI/IR.h"
14#include "mlir/CAPI/Registration.h"
15#include "mlir/CAPI/Support.h"
16
17using namespace circt::sv;
18
20MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(SystemVerilog, sv, SVDialect)
21
22bool svAttrIsASVAttributeAttr(MlirAttribute cAttr) {
23 return llvm::isa<SVAttributeAttr>(unwrap(cAttr));
24}
25
26MlirAttribute svSVAttributeAttrGet(MlirContext cCtxt, MlirStringRef cName,
27 MlirStringRef cExpression,
28 bool emitAsComment) {
29 mlir::MLIRContext *ctxt = unwrap(cCtxt);
30 mlir::StringAttr expr;
31 if (cExpression.data != nullptr)
32 expr = mlir::StringAttr::get(ctxt, unwrap(cExpression));
33 return wrap(
34 SVAttributeAttr::get(ctxt, mlir::StringAttr::get(ctxt, unwrap(cName)),
35 expr, mlir::BoolAttr::get(ctxt, emitAsComment)));
36}
37
38MlirStringRef svSVAttributeAttrGetName(MlirAttribute cAttr) {
39 return wrap(llvm::cast<SVAttributeAttr>(unwrap(cAttr)).getName().getValue());
40}
41
42MlirStringRef svSVAttributeAttrGetExpression(MlirAttribute cAttr) {
43 auto expr = llvm::cast<SVAttributeAttr>(unwrap(cAttr)).getExpression();
44 if (expr)
45 return wrap(expr.getValue());
46 return {nullptr, 0};
47}
48
49bool svSVAttributeAttrGetEmitAsComment(MlirAttribute attribute) {
50 return llvm::cast<SVAttributeAttr>(unwrap(attribute))
51 .getEmitAsComment()
52 .getValue();
53}
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()
static EvaluatorValuePtr unwrap(OMEvaluatorValue c)
Definition OM.cpp:113
MlirStringRef svSVAttributeAttrGetName(MlirAttribute cAttr)
Definition SV.cpp:38
bool svAttrIsASVAttributeAttr(MlirAttribute cAttr)
Definition SV.cpp:22
void registerSVPasses()
Definition SV.cpp:19
bool svSVAttributeAttrGetEmitAsComment(MlirAttribute attribute)
Definition SV.cpp:49
MlirStringRef svSVAttributeAttrGetExpression(MlirAttribute cAttr)
Definition SV.cpp:42
MlirAttribute svSVAttributeAttrGet(MlirContext cCtxt, MlirStringRef cName, MlirStringRef cExpression, bool emitAsComment)
Definition SV.cpp:26
Definition sv.py:1