CIRCT 23.0.0git
Loading...
Searching...
No Matches
Seq.cpp
Go to the documentation of this file.
1//===- Seq.cpp - C interface for the Seq 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
14#include "mlir/CAPI/IR.h"
15#include "mlir/CAPI/Registration.h"
16#include "mlir/CAPI/Support.h"
17
18using namespace circt::seq;
19
20MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(Sequential, seq, circt::seq::SeqDialect)
21
22void registerSeqPasses() { circt::seq::registerPasses(); }
23
24bool seqTypeIsAClock(MlirType type) {
25 return llvm::isa<ClockType>(unwrap(type));
26}
27
28MlirType seqClockTypeGet(MlirContext ctx) {
29 return wrap(ClockType::get(unwrap(ctx)));
30}
31
32bool seqTypeIsAImmutable(MlirType type) {
33 return llvm::isa<ImmutableType>(unwrap(type));
34}
35
36MlirType seqImmutableTypeGet(MlirType innerType) {
37 return wrap(ImmutableType::get(unwrap(innerType)));
38}
39
40MlirType seqImmutableTypeGetInnerType(MlirType type) {
41 return wrap(llvm::cast<ImmutableType>(unwrap(type)).getInnerType());
42}
43
44bool seqTypeIsAHLMem(MlirType type) {
45 return llvm::isa<HLMemType>(unwrap(type));
46}
47
48MlirType seqHLMemTypeGet(MlirContext ctx, intptr_t rank, const int64_t *shape,
49 MlirType elementType) {
50 llvm::SmallVector<int64_t> shapeVec(shape, shape + rank);
51 return wrap(HLMemType::get(unwrap(ctx), shapeVec, unwrap(elementType)));
52}
53
54MlirType seqHLMemTypeGetElementType(MlirType type) {
55 return wrap(llvm::cast<HLMemType>(unwrap(type)).getElementType());
56}
57
58intptr_t seqHLMemTypeGetRank(MlirType type) {
59 return llvm::cast<HLMemType>(unwrap(type)).getRank();
60}
61
62const int64_t *seqHLMemTypeGetShape(MlirType type) {
63 return llvm::cast<HLMemType>(unwrap(type)).getShape().data();
64}
65
66bool seqTypeIsAFirMem(MlirType type) {
67 return llvm::isa<FirMemType>(unwrap(type));
68}
69
70MlirType seqFirMemTypeGet(MlirContext ctx, uint64_t depth, uint32_t width,
71 const uint32_t *maskWidth) {
72 std::optional<uint32_t> maskOpt;
73 if (maskWidth)
74 maskOpt = *maskWidth;
75 return wrap(FirMemType::get(unwrap(ctx), depth, width, maskOpt));
76}
77
78uint64_t seqFirMemTypeGetDepth(MlirType type) {
79 return llvm::cast<FirMemType>(unwrap(type)).getDepth();
80}
81
82uint32_t seqFirMemTypeGetWidth(MlirType type) {
83 return llvm::cast<FirMemType>(unwrap(type)).getWidth();
84}
85
86bool seqFirMemTypeHasMask(MlirType type) {
87 return llvm::cast<FirMemType>(unwrap(type)).getMaskWidth().has_value();
88}
89
90uint32_t seqFirMemTypeGetMaskWidth(MlirType type) {
91 return llvm::cast<FirMemType>(unwrap(type)).getMaskWidth().value_or(0);
92}
return wrap(CMemoryType::get(unwrap(ctx), baseType, numElements))
MlirType elementType
Definition CHIRRTL.cpp:29
MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(CHIRRTL, chirrtl, circt::chirrtl::CHIRRTLDialect) MlirType chirrtlTypeGetCMemory(MlirContext ctx
static EvaluatorValuePtr unwrap(OMEvaluatorValue c)
Definition OM.cpp:111
void registerSeqPasses()
Definition Seq.cpp:22
MlirType seqHLMemTypeGet(MlirContext ctx, intptr_t rank, const int64_t *shape, MlirType elementType)
Creates a seq HLMem type.
Definition Seq.cpp:48
uint32_t seqFirMemTypeGetWidth(MlirType type)
Gets the width of a FirMem type.
Definition Seq.cpp:82
MlirType seqImmutableTypeGet(MlirType innerType)
Creates a seq immutable type.
Definition Seq.cpp:36
bool seqFirMemTypeHasMask(MlirType type)
Returns true if the FirMem type has a mask width defined.
Definition Seq.cpp:86
MlirType seqImmutableTypeGetInnerType(MlirType type)
Creates a seq immutable type.
Definition Seq.cpp:40
uint64_t seqFirMemTypeGetDepth(MlirType type)
Gets the depth of a FirMem type.
Definition Seq.cpp:78
bool seqTypeIsAHLMem(MlirType type)
If the type is a HLMemType.
Definition Seq.cpp:44
intptr_t seqHLMemTypeGetRank(MlirType type)
Gets the rank of an HLMem type.
Definition Seq.cpp:58
const int64_t * seqHLMemTypeGetShape(MlirType type)
Gets a pointer to the shape array of an HLMem type The array length is equal to the rank.
Definition Seq.cpp:62
bool seqTypeIsAFirMem(MlirType type)
If the type is a FirMem type.
Definition Seq.cpp:66
MlirType seqHLMemTypeGetElementType(MlirType type)
Gets the element type of an HLMem type.
Definition Seq.cpp:54
MlirType seqClockTypeGet(MlirContext ctx)
Creates an seq clock type.
Definition Seq.cpp:28
bool seqTypeIsAImmutable(MlirType type)
If the type is an immutable type.
Definition Seq.cpp:32
MlirType seqFirMemTypeGet(MlirContext ctx, uint64_t depth, uint32_t width, const uint32_t *maskWidth)
Creates a seq FirMem type.
Definition Seq.cpp:70
uint32_t seqFirMemTypeGetMaskWidth(MlirType type)
Gets the mask width of a FirMem type Behavior is undefined if seqFirMemTypeHasMask returns false.
Definition Seq.cpp:90
bool seqTypeIsAClock(MlirType type)
If the type is an clock type.
Definition Seq.cpp:24
Definition seq.py:1