CIRCT  19.0.0git
ESI.h
Go to the documentation of this file.
1 //===- ESI.h - C interface for the ESI dialect --------------------*- C -*-===//
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 
9 #ifndef CIRCT_C_DIALECT_ESI_H
10 #define CIRCT_C_DIALECT_ESI_H
11 
12 #include "mlir-c/IR.h"
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
19 MLIR_CAPI_EXPORTED void registerESIPasses(void);
20 
21 MLIR_CAPI_EXPORTED bool circtESITypeIsAChannelType(MlirType type);
22 MLIR_CAPI_EXPORTED MlirType circtESIChannelTypeGet(MlirType inner,
23  uint32_t signaling);
24 MLIR_CAPI_EXPORTED MlirType circtESIChannelGetInner(MlirType channelType);
25 MLIR_CAPI_EXPORTED uint32_t circtESIChannelGetSignaling(MlirType channelType);
26 
27 MLIR_CAPI_EXPORTED bool circtESITypeIsAnAnyType(MlirType type);
28 MLIR_CAPI_EXPORTED MlirType circtESIAnyTypeGet(MlirContext);
29 
30 MLIR_CAPI_EXPORTED bool circtESITypeIsAListType(MlirType type);
31 MLIR_CAPI_EXPORTED MlirType circtESIListTypeGet(MlirType inner);
32 MLIR_CAPI_EXPORTED MlirType
33 circtESIListTypeGetElementType(MlirType channelType);
34 
35 MLIR_CAPI_EXPORTED void circtESIAppendMlirFile(MlirModule,
36  MlirStringRef fileName);
37 MLIR_CAPI_EXPORTED MlirOperation circtESILookup(MlirModule,
38  MlirStringRef symbol);
39 
40 //===----------------------------------------------------------------------===//
41 // Channel bundles
42 //===----------------------------------------------------------------------===//
43 
44 // NOLINTNEXTLINE(modernize-use-using)
45 typedef struct {
46  MlirIdentifier name;
47  unsigned direction;
48  MlirType channelType; // MUST be ChannelType.
50 
51 MLIR_CAPI_EXPORTED bool circtESITypeIsABundleType(MlirType type);
52 MLIR_CAPI_EXPORTED MlirType circtESIBundleTypeGet(
53  MlirContext, size_t numChannels,
54  const CirctESIBundleTypeBundleChannel *channels, bool resettable);
55 MLIR_CAPI_EXPORTED bool circtESIBundleTypeGetResettable(MlirType bundle);
56 MLIR_CAPI_EXPORTED size_t circtESIBundleTypeGetNumChannels(MlirType bundle);
57 MLIR_CAPI_EXPORTED CirctESIBundleTypeBundleChannel
58 circtESIBundleTypeGetChannel(MlirType bundle, size_t idx);
59 
60 //===----------------------------------------------------------------------===//
61 // Services
62 //===----------------------------------------------------------------------===//
63 
64 typedef MlirLogicalResult (*CirctESIServiceGeneratorFunc)(
65  MlirOperation serviceImplementReqOp, MlirOperation declOp,
66  MlirOperation recordOp, void *userData);
67 MLIR_CAPI_EXPORTED void circtESIRegisterGlobalServiceGenerator(
68  MlirStringRef impl_type, CirctESIServiceGeneratorFunc, void *userData);
69 
70 //===----------------------------------------------------------------------===//
71 // AppID
72 //===----------------------------------------------------------------------===//
73 
74 MLIR_CAPI_EXPORTED bool circtESIAttributeIsAnAppIDAttr(MlirAttribute);
75 MLIR_CAPI_EXPORTED
76 MlirAttribute circtESIAppIDAttrGet(MlirContext, MlirStringRef name,
77  uint64_t index);
78 MLIR_CAPI_EXPORTED
79 MlirAttribute circtESIAppIDAttrGetNoIdx(MlirContext ctxt, MlirStringRef name);
80 MLIR_CAPI_EXPORTED MlirStringRef circtESIAppIDAttrGetName(MlirAttribute attr);
81 MLIR_CAPI_EXPORTED bool circtESIAppIDAttrGetIndex(MlirAttribute attr,
82  uint64_t *index);
83 
84 MLIR_CAPI_EXPORTED bool circtESIAttributeIsAnAppIDPathAttr(MlirAttribute);
85 MLIR_CAPI_EXPORTED
86 MlirAttribute circtESIAppIDAttrPathGet(MlirContext, MlirAttribute root,
87  intptr_t numElements,
88  MlirAttribute const *elements);
89 MLIR_CAPI_EXPORTED MlirAttribute
90 circtESIAppIDAttrPathGetRoot(MlirAttribute attr);
91 MLIR_CAPI_EXPORTED uint64_t
92 circtESIAppIDAttrPathGetNumComponents(MlirAttribute attr);
93 MLIR_CAPI_EXPORTED MlirAttribute
94 circtESIAppIDAttrPathGetComponent(MlirAttribute attr, uint64_t index);
95 
96 // NOLINTNEXTLINE(modernize-use-using)
97 typedef struct {
98  void *ptr;
100 
101 /// Create an index of appids through which to do appid lookups efficiently.
102 MLIR_CAPI_EXPORTED CirctESIAppIDIndex circtESIAppIDIndexGet(MlirOperation root);
103 
104 /// Free an AppIDIndex.
105 MLIR_CAPI_EXPORTED void circtESIAppIDIndexFree(CirctESIAppIDIndex);
106 
107 MLIR_CAPI_EXPORTED MlirAttribute
109 
110 MLIR_CAPI_EXPORTED
112  MlirOperation fromMod,
113  MlirAttribute appid,
114  MlirLocation loc);
115 
116 #ifdef __cplusplus
117 }
118 #endif
119 
120 #endif // CIRCT_C_DIALECT_ESI_H
MlirType uint64_t numElements
Definition: CHIRRTL.cpp:30
MLIR_CAPI_EXPORTED uint32_t circtESIChannelGetSignaling(MlirType channelType)
Definition: ESI.cpp:44
MLIR_CAPI_EXPORTED MlirType circtESIBundleTypeGet(MlirContext, size_t numChannels, const CirctESIBundleTypeBundleChannel *channels, bool resettable)
Definition: ESI.cpp:103
MLIR_CAPI_EXPORTED MlirAttribute circtESIAppIDAttrGet(MlirContext, MlirStringRef name, uint64_t index)
Definition: ESI.cpp:139
MLIR_CAPI_EXPORTED bool circtESIBundleTypeGetResettable(MlirType bundle)
Definition: ESI.cpp:117
MLIR_CAPI_EXPORTED bool circtESITypeIsAnAnyType(MlirType type)
Definition: ESI.cpp:48
MLIR_CAPI_EXPORTED void circtESIRegisterGlobalServiceGenerator(MlirStringRef impl_type, CirctESIServiceGeneratorFunc, void *userData)
Definition: ESI.cpp:85
MlirLogicalResult(* CirctESIServiceGeneratorFunc)(MlirOperation serviceImplementReqOp, MlirOperation declOp, MlirOperation recordOp, void *userData)
Definition: ESI.h:64
MLIR_CAPI_EXPORTED MlirOperation circtESILookup(MlirModule, MlirStringRef symbol)
Definition: ESI.cpp:81
MLIR_CAPI_EXPORTED MlirAttribute circtESIAppIDIndexGetChildAppIDsOf(CirctESIAppIDIndex, MlirOperation)
Definition: ESI.cpp:200
MLIR_CAPI_EXPORTED MlirType circtESIChannelTypeGet(MlirType inner, uint32_t signaling)
Definition: ESI.cpp:33
MLIR_CAPI_EXPORTED MlirType circtESIChannelGetInner(MlirType channelType)
Definition: ESI.cpp:41
MLIR_CAPI_EXPORTED CirctESIBundleTypeBundleChannel circtESIBundleTypeGetChannel(MlirType bundle, size_t idx)
Definition: ESI.cpp:123
MLIR_CAPI_EXPORTED void registerESIPasses(void)
Definition: ESI.cpp:27
MLIR_CAPI_EXPORTED void circtESIAppIDIndexFree(CirctESIAppIDIndex)
Free an AppIDIndex.
Definition: ESI.cpp:195
MLIR_CAPI_EXPORTED MlirAttribute circtESIAppIDAttrGetNoIdx(MlirContext ctxt, MlirStringRef name)
Definition: ESI.cpp:144
MLIR_CAPI_EXPORTED uint64_t circtESIAppIDAttrPathGetNumComponents(MlirAttribute attr)
Definition: ESI.cpp:175
MLIR_CAPI_EXPORTED void circtESIAppendMlirFile(MlirModule, MlirStringRef fileName)
Definition: ESI.cpp:68
MLIR_CAPI_EXPORTED MlirAttribute circtESIAppIDIndexGetAppIDPath(CirctESIAppIDIndex, MlirOperation fromMod, MlirAttribute appid, MlirLocation loc)
Definition: ESI.cpp:206
MLIR_CAPI_EXPORTED MlirStringRef circtESIAppIDAttrGetName(MlirAttribute attr)
Definition: ESI.cpp:148
MLIR_CAPI_EXPORTED bool circtESITypeIsAChannelType(MlirType type)
Definition: ESI.cpp:29
MLIR_CAPI_EXPORTED size_t circtESIBundleTypeGetNumChannels(MlirType bundle)
Definition: ESI.cpp:120
MLIR_CAPI_EXPORTED MlirType circtESIListTypeGetElementType(MlirType channelType)
Definition: ESI.cpp:64
MLIR_CAPI_EXPORTED MlirType circtESIAnyTypeGet(MlirContext)
Definition: ESI.cpp:51
MLIR_CAPI_EXPORTED MlirAttribute circtESIAppIDAttrPathGetComponent(MlirAttribute attr, uint64_t index)
Definition: ESI.cpp:178
MLIR_DECLARE_CAPI_DIALECT_REGISTRATION(ESI, esi)
MLIR_CAPI_EXPORTED MlirAttribute circtESIAppIDAttrPathGet(MlirContext, MlirAttribute root, intptr_t numElements, MlirAttribute const *elements)
Definition: ESI.cpp:163
MLIR_CAPI_EXPORTED MlirType circtESIListTypeGet(MlirType inner)
Definition: ESI.cpp:59
MLIR_CAPI_EXPORTED bool circtESITypeIsABundleType(MlirType type)
Definition: ESI.cpp:100
MLIR_CAPI_EXPORTED bool circtESIAppIDAttrGetIndex(MlirAttribute attr, uint64_t *index)
Definition: ESI.cpp:151
MLIR_CAPI_EXPORTED MlirAttribute circtESIAppIDAttrPathGetRoot(MlirAttribute attr)
Definition: ESI.cpp:172
MLIR_CAPI_EXPORTED bool circtESIAttributeIsAnAppIDPathAttr(MlirAttribute)
Definition: ESI.cpp:159
MLIR_CAPI_EXPORTED CirctESIAppIDIndex circtESIAppIDIndexGet(MlirOperation root)
Create an index of appids through which to do appid lookups efficiently.
Definition: ESI.cpp:187
MLIR_CAPI_EXPORTED bool circtESIAttributeIsAnAppIDAttr(MlirAttribute)
Definition: ESI.cpp:135
MLIR_CAPI_EXPORTED bool circtESITypeIsAListType(MlirType type)
Definition: ESI.cpp:55
Definition: esi.py:1
void * ptr
Definition: ESI.h:98
MlirIdentifier name
Definition: ESI.h:46