CIRCT  20.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  uint64_t dataDelay);
25 MLIR_CAPI_EXPORTED MlirType circtESIChannelGetInner(MlirType channelType);
26 MLIR_CAPI_EXPORTED uint32_t circtESIChannelGetSignaling(MlirType channelType);
27 MLIR_CAPI_EXPORTED uint64_t circtESIChannelGetDataDelay(MlirType channelType);
28 
29 MLIR_CAPI_EXPORTED bool circtESITypeIsAnAnyType(MlirType type);
30 MLIR_CAPI_EXPORTED MlirType circtESIAnyTypeGet(MlirContext);
31 
32 MLIR_CAPI_EXPORTED bool circtESITypeIsAListType(MlirType type);
33 MLIR_CAPI_EXPORTED MlirType circtESIListTypeGet(MlirType inner);
34 MLIR_CAPI_EXPORTED MlirType
35 circtESIListTypeGetElementType(MlirType channelType);
36 
37 MLIR_CAPI_EXPORTED void circtESIAppendMlirFile(MlirModule,
38  MlirStringRef fileName);
39 MLIR_CAPI_EXPORTED MlirOperation circtESILookup(MlirModule,
40  MlirStringRef symbol);
41 
42 //===----------------------------------------------------------------------===//
43 // Channel bundles
44 //===----------------------------------------------------------------------===//
45 
46 // NOLINTNEXTLINE(modernize-use-using)
47 typedef struct {
48  MlirIdentifier name;
49  unsigned direction;
50  MlirType channelType; // MUST be ChannelType.
52 
53 MLIR_CAPI_EXPORTED bool circtESITypeIsABundleType(MlirType type);
54 MLIR_CAPI_EXPORTED MlirType circtESIBundleTypeGet(
55  MlirContext, size_t numChannels,
56  const CirctESIBundleTypeBundleChannel *channels, bool resettable);
57 MLIR_CAPI_EXPORTED bool circtESIBundleTypeGetResettable(MlirType bundle);
58 MLIR_CAPI_EXPORTED size_t circtESIBundleTypeGetNumChannels(MlirType bundle);
59 MLIR_CAPI_EXPORTED CirctESIBundleTypeBundleChannel
60 circtESIBundleTypeGetChannel(MlirType bundle, size_t idx);
61 
62 //===----------------------------------------------------------------------===//
63 // Services
64 //===----------------------------------------------------------------------===//
65 
66 typedef MlirLogicalResult (*CirctESIServiceGeneratorFunc)(
67  MlirOperation serviceImplementReqOp, MlirOperation declOp,
68  MlirOperation recordOp, void *userData);
69 MLIR_CAPI_EXPORTED void circtESIRegisterGlobalServiceGenerator(
70  MlirStringRef impl_type, CirctESIServiceGeneratorFunc, void *userData);
71 
72 //===----------------------------------------------------------------------===//
73 // AppID
74 //===----------------------------------------------------------------------===//
75 
76 MLIR_CAPI_EXPORTED bool circtESIAttributeIsAnAppIDAttr(MlirAttribute);
77 MLIR_CAPI_EXPORTED
78 MlirAttribute circtESIAppIDAttrGet(MlirContext, MlirStringRef name,
79  uint64_t index);
80 MLIR_CAPI_EXPORTED
81 MlirAttribute circtESIAppIDAttrGetNoIdx(MlirContext ctxt, MlirStringRef name);
82 MLIR_CAPI_EXPORTED MlirStringRef circtESIAppIDAttrGetName(MlirAttribute attr);
83 MLIR_CAPI_EXPORTED bool circtESIAppIDAttrGetIndex(MlirAttribute attr,
84  uint64_t *index);
85 
86 MLIR_CAPI_EXPORTED bool circtESIAttributeIsAnAppIDPathAttr(MlirAttribute);
87 MLIR_CAPI_EXPORTED
88 MlirAttribute circtESIAppIDAttrPathGet(MlirContext, MlirAttribute root,
89  intptr_t numElements,
90  MlirAttribute const *elements);
91 MLIR_CAPI_EXPORTED MlirAttribute
92 circtESIAppIDAttrPathGetRoot(MlirAttribute attr);
93 MLIR_CAPI_EXPORTED uint64_t
94 circtESIAppIDAttrPathGetNumComponents(MlirAttribute attr);
95 MLIR_CAPI_EXPORTED MlirAttribute
96 circtESIAppIDAttrPathGetComponent(MlirAttribute attr, uint64_t index);
97 
98 // NOLINTNEXTLINE(modernize-use-using)
99 typedef struct {
100  void *ptr;
102 
103 /// Create an index of appids through which to do appid lookups efficiently.
104 MLIR_CAPI_EXPORTED CirctESIAppIDIndex circtESIAppIDIndexGet(MlirOperation root);
105 
106 /// Free an AppIDIndex.
107 MLIR_CAPI_EXPORTED void circtESIAppIDIndexFree(CirctESIAppIDIndex);
108 
109 MLIR_CAPI_EXPORTED MlirAttribute
111 
112 MLIR_CAPI_EXPORTED
114  MlirOperation fromMod,
115  MlirAttribute appid,
116  MlirLocation loc);
117 
118 #ifdef __cplusplus
119 }
120 #endif
121 
122 #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:46
MLIR_CAPI_EXPORTED MlirType circtESIBundleTypeGet(MlirContext, size_t numChannels, const CirctESIBundleTypeBundleChannel *channels, bool resettable)
Definition: ESI.cpp:108
MLIR_CAPI_EXPORTED MlirAttribute circtESIAppIDAttrGet(MlirContext, MlirStringRef name, uint64_t index)
Definition: ESI.cpp:144
MLIR_CAPI_EXPORTED bool circtESIBundleTypeGetResettable(MlirType bundle)
Definition: ESI.cpp:122
MLIR_CAPI_EXPORTED bool circtESITypeIsAnAnyType(MlirType type)
Definition: ESI.cpp:53
MLIR_CAPI_EXPORTED void circtESIRegisterGlobalServiceGenerator(MlirStringRef impl_type, CirctESIServiceGeneratorFunc, void *userData)
Definition: ESI.cpp:90
MlirLogicalResult(* CirctESIServiceGeneratorFunc)(MlirOperation serviceImplementReqOp, MlirOperation declOp, MlirOperation recordOp, void *userData)
Definition: ESI.h:66
MLIR_CAPI_EXPORTED MlirOperation circtESILookup(MlirModule, MlirStringRef symbol)
Definition: ESI.cpp:86
MLIR_CAPI_EXPORTED MlirAttribute circtESIAppIDIndexGetChildAppIDsOf(CirctESIAppIDIndex, MlirOperation)
Definition: ESI.cpp:205
MLIR_CAPI_EXPORTED MlirType circtESIChannelGetInner(MlirType channelType)
Definition: ESI.cpp:43
MLIR_CAPI_EXPORTED CirctESIBundleTypeBundleChannel circtESIBundleTypeGetChannel(MlirType bundle, size_t idx)
Definition: ESI.cpp:128
MLIR_CAPI_EXPORTED void registerESIPasses(void)
Definition: ESI.cpp:27
MLIR_CAPI_EXPORTED void circtESIAppIDIndexFree(CirctESIAppIDIndex)
Free an AppIDIndex.
Definition: ESI.cpp:200
MLIR_CAPI_EXPORTED MlirAttribute circtESIAppIDAttrGetNoIdx(MlirContext ctxt, MlirStringRef name)
Definition: ESI.cpp:149
MLIR_CAPI_EXPORTED uint64_t circtESIAppIDAttrPathGetNumComponents(MlirAttribute attr)
Definition: ESI.cpp:180
MLIR_CAPI_EXPORTED void circtESIAppendMlirFile(MlirModule, MlirStringRef fileName)
Definition: ESI.cpp:73
MLIR_CAPI_EXPORTED MlirAttribute circtESIAppIDIndexGetAppIDPath(CirctESIAppIDIndex, MlirOperation fromMod, MlirAttribute appid, MlirLocation loc)
Definition: ESI.cpp:211
MLIR_CAPI_EXPORTED MlirStringRef circtESIAppIDAttrGetName(MlirAttribute attr)
Definition: ESI.cpp:153
MLIR_CAPI_EXPORTED MlirType circtESIChannelTypeGet(MlirType inner, uint32_t signaling, uint64_t dataDelay)
Definition: ESI.cpp:33
MLIR_CAPI_EXPORTED bool circtESITypeIsAChannelType(MlirType type)
Definition: ESI.cpp:29
MLIR_CAPI_EXPORTED size_t circtESIBundleTypeGetNumChannels(MlirType bundle)
Definition: ESI.cpp:125
MLIR_CAPI_EXPORTED MlirType circtESIListTypeGetElementType(MlirType channelType)
Definition: ESI.cpp:69
MLIR_CAPI_EXPORTED MlirType circtESIAnyTypeGet(MlirContext)
Definition: ESI.cpp:56
MLIR_CAPI_EXPORTED MlirAttribute circtESIAppIDAttrPathGetComponent(MlirAttribute attr, uint64_t index)
Definition: ESI.cpp:183
MLIR_DECLARE_CAPI_DIALECT_REGISTRATION(ESI, esi)
MLIR_CAPI_EXPORTED uint64_t circtESIChannelGetDataDelay(MlirType channelType)
Definition: ESI.cpp:49
MLIR_CAPI_EXPORTED MlirAttribute circtESIAppIDAttrPathGet(MlirContext, MlirAttribute root, intptr_t numElements, MlirAttribute const *elements)
Definition: ESI.cpp:168
MLIR_CAPI_EXPORTED MlirType circtESIListTypeGet(MlirType inner)
Definition: ESI.cpp:64
MLIR_CAPI_EXPORTED bool circtESITypeIsABundleType(MlirType type)
Definition: ESI.cpp:105
MLIR_CAPI_EXPORTED bool circtESIAppIDAttrGetIndex(MlirAttribute attr, uint64_t *index)
Definition: ESI.cpp:156
MLIR_CAPI_EXPORTED MlirAttribute circtESIAppIDAttrPathGetRoot(MlirAttribute attr)
Definition: ESI.cpp:177
MLIR_CAPI_EXPORTED bool circtESIAttributeIsAnAppIDPathAttr(MlirAttribute)
Definition: ESI.cpp:164
MLIR_CAPI_EXPORTED CirctESIAppIDIndex circtESIAppIDIndexGet(MlirOperation root)
Create an index of appids through which to do appid lookups efficiently.
Definition: ESI.cpp:192
MLIR_CAPI_EXPORTED bool circtESIAttributeIsAnAppIDAttr(MlirAttribute)
Definition: ESI.cpp:140
MLIR_CAPI_EXPORTED bool circtESITypeIsAListType(MlirType type)
Definition: ESI.cpp:60
Definition: esi.py:1
void * ptr
Definition: ESI.h:100
MlirIdentifier name
Definition: ESI.h:48