CIRCT 22.0.0git
Loading...
Searching...
No Matches
Arc.cpp
Go to the documentation of this file.
1//===- Arc.cpp - C interface for the Arc 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::arc;
18
19MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(Arc, arc, circt::arc::ArcDialect)
20
21void registerArcPasses() { circt::arc::registerPasses(); }
22
23//===----------------------------------------------------------------------===//
24// Type API.
25//===----------------------------------------------------------------------===//
26
27bool arcTypeIsAState(MlirType type) {
28 return llvm::isa<StateType>(unwrap(type));
29}
30
31MlirType arcStateTypeGet(MlirType innerType) {
32 return wrap(StateType::get(unwrap(innerType)));
33}
34
35MlirType arcStateTypeGetType(MlirType type) {
36 return wrap(llvm::cast<StateType>(unwrap(type)).getType());
37}
38
39unsigned arcStateTypeGetBitWidth(MlirType type) {
40 return llvm::cast<StateType>(unwrap(type)).getBitWidth();
41}
42
43unsigned arcStateTypeGetByteWidth(MlirType type) {
44 return llvm::cast<StateType>(unwrap(type)).getByteWidth();
45}
46
47bool arcTypeIsAMemory(MlirType type) {
48 return llvm::isa<MemoryType>(unwrap(type));
49}
50
51MlirType arcMemoryTypeGet(unsigned numWords, MlirType wordType,
52 MlirType addressType) {
53 return wrap(
54 MemoryType::get(unwrap(wordType).getContext(), numWords,
55 llvm::cast<mlir::IntegerType>(unwrap(wordType)),
56 llvm::cast<mlir::IntegerType>(unwrap(addressType))));
57}
58
59unsigned arcMemoryTypeGetNumWords(MlirType type) {
60 return llvm::cast<MemoryType>(unwrap(type)).getNumWords();
61}
62
63MlirType arcMemoryTypeGetWordType(MlirType type) {
64 return wrap(llvm::cast<MemoryType>(unwrap(type)).getWordType());
65}
66
67MlirType arcMemoryTypeGetAddressType(MlirType type) {
68 return wrap(llvm::cast<MemoryType>(unwrap(type)).getAddressType());
69}
70
71unsigned arcMemoryTypeGetStride(MlirType type) {
72 return llvm::cast<MemoryType>(unwrap(type)).getStride();
73}
74
75bool arcTypeIsAStorage(MlirType type) {
76 return llvm::isa<StorageType>(unwrap(type));
77}
78
79MlirType arcStorageTypeGet(MlirContext ctx) {
80 return wrap(StorageType::get(unwrap(ctx), 0));
81}
82
83MlirType arcStorageTypeGetWithSize(MlirContext ctx, unsigned size) {
84 return wrap(StorageType::get(unwrap(ctx), size));
85}
86
87unsigned arcStorageTypeGetSize(MlirType type) {
88 return llvm::cast<StorageType>(unwrap(type)).getSize();
89}
90
91bool arcTypeIsASimModelInstance(MlirType type) {
92 return llvm::isa<SimModelInstanceType>(unwrap(type));
93}
94
95MlirType arcSimModelInstanceTypeGet(MlirAttribute model) {
96 auto attr = llvm::cast<mlir::FlatSymbolRefAttr>(unwrap(model));
97 return wrap(SimModelInstanceType::get(attr.getContext(), attr));
98}
99
100MlirAttribute arcSimModelInstanceTypeGetModel(MlirType type) {
101 return wrap(llvm::cast<SimModelInstanceType>(unwrap(type)).getModel());
102}
MlirAttribute arcSimModelInstanceTypeGetModel(MlirType type)
Definition Arc.cpp:100
unsigned arcStateTypeGetByteWidth(MlirType type)
Definition Arc.cpp:43
MlirType arcStateTypeGetType(MlirType type)
Definition Arc.cpp:35
unsigned arcStorageTypeGetSize(MlirType type)
Definition Arc.cpp:87
MlirType arcMemoryTypeGetAddressType(MlirType type)
Definition Arc.cpp:67
unsigned arcMemoryTypeGetNumWords(MlirType type)
Definition Arc.cpp:59
MlirType arcMemoryTypeGetWordType(MlirType type)
Definition Arc.cpp:63
MlirType arcStorageTypeGetWithSize(MlirContext ctx, unsigned size)
Definition Arc.cpp:83
MlirType arcStorageTypeGet(MlirContext ctx)
Definition Arc.cpp:79
unsigned arcStateTypeGetBitWidth(MlirType type)
Definition Arc.cpp:39
void registerArcPasses()
Definition Arc.cpp:21
bool arcTypeIsAMemory(MlirType type)
Definition Arc.cpp:47
bool arcTypeIsASimModelInstance(MlirType type)
Definition Arc.cpp:91
unsigned arcMemoryTypeGetStride(MlirType type)
Definition Arc.cpp:71
bool arcTypeIsAState(MlirType type)
Definition Arc.cpp:27
bool arcTypeIsAStorage(MlirType type)
Definition Arc.cpp:75
MlirType arcStateTypeGet(MlirType innerType)
Definition Arc.cpp:31
MlirType arcMemoryTypeGet(unsigned numWords, MlirType wordType, MlirType addressType)
Definition Arc.cpp:51
MlirType arcSimModelInstanceTypeGet(MlirAttribute model)
Definition Arc.cpp:95
return wrap(CMemoryType::get(unwrap(ctx), baseType, numElements))
MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(CHIRRTL, chirrtl, circt::chirrtl::CHIRRTLDialect) MlirType chirrtlTypeGetCMemory(MlirContext ctx
static EvaluatorValuePtr unwrap(OMEvaluatorValue c)
Definition OM.cpp:111
Definition arc.py:1