CIRCT  20.0.0git
MSFT.h
Go to the documentation of this file.
1 //===- MSFT.h - C interface for the MSFT 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_MSFT_H
10 #define CIRCT_C_DIALECT_MSFT_H
11 
12 #include "mlir-c/IR.h"
13 #include "mlir-c/Pass.h"
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
20 
21 MLIR_CAPI_EXPORTED void mlirMSFTRegisterPasses(void);
22 
23 // Values represented in `MSFT.td`.
24 typedef int32_t CirctMSFTPrimitiveType;
25 
26 // Replace all uses of Value with new value.
27 MLIR_CAPI_EXPORTED void circtMSFTReplaceAllUsesWith(MlirValue value,
28  MlirValue newValue);
29 
30 //===----------------------------------------------------------------------===//
31 // MSFT Attributes.
32 //===----------------------------------------------------------------------===//
33 
34 MLIR_CAPI_EXPORTED bool
36 MLIR_CAPI_EXPORTED MlirAttribute circtMSFTPhysLocationAttrGet(
37  MlirContext, CirctMSFTPrimitiveType, uint64_t x, uint64_t y, uint64_t num);
38 MLIR_CAPI_EXPORTED CirctMSFTPrimitiveType
40 MLIR_CAPI_EXPORTED uint64_t circtMSFTPhysLocationAttrGetX(MlirAttribute);
41 MLIR_CAPI_EXPORTED uint64_t circtMSFTPhysLocationAttrGetY(MlirAttribute);
42 MLIR_CAPI_EXPORTED uint64_t circtMSFTPhysLocationAttrGetNum(MlirAttribute);
43 
44 MLIR_CAPI_EXPORTED MlirOperation circtMSFTGetInstance(MlirOperation root,
45  MlirAttribute path);
46 
47 MLIR_CAPI_EXPORTED bool circtMSFTAttributeIsAPhysicalBoundsAttr(MlirAttribute);
48 MLIR_CAPI_EXPORTED
49 MlirAttribute circtMSFTPhysicalBoundsAttrGet(MlirContext, uint64_t, uint64_t,
50  uint64_t, uint64_t);
51 
52 MLIR_CAPI_EXPORTED bool
54 MLIR_CAPI_EXPORTED MlirAttribute
55 circtMSFTLocationVectorAttrGet(MlirContext, MlirType type, intptr_t numElements,
56  MlirAttribute const *elements);
57 MLIR_CAPI_EXPORTED MlirType circtMSFTLocationVectorAttrGetType(MlirAttribute);
58 MLIR_CAPI_EXPORTED
59 intptr_t circtMSFTLocationVectorAttrGetNumElements(MlirAttribute);
60 MLIR_CAPI_EXPORTED MlirAttribute
61 circtMSFTLocationVectorAttrGetElement(MlirAttribute attr, intptr_t pos);
62 
63 //===----------------------------------------------------------------------===//
64 // PrimitiveDB.
65 //===----------------------------------------------------------------------===//
66 
67 typedef struct {
68  void *ptr;
70 
71 MLIR_CAPI_EXPORTED CirctMSFTPrimitiveDB circtMSFTCreatePrimitiveDB(MlirContext);
72 MLIR_CAPI_EXPORTED void circtMSFTDeletePrimitiveDB(CirctMSFTPrimitiveDB self);
73 MLIR_CAPI_EXPORTED MlirLogicalResult circtMSFTPrimitiveDBAddPrimitive(
74  CirctMSFTPrimitiveDB, MlirAttribute locAndPrim);
75 MLIR_CAPI_EXPORTED bool
77  MlirAttribute locAndPrim);
78 
79 //===----------------------------------------------------------------------===//
80 // PlacementDB.
81 //===----------------------------------------------------------------------===//
82 
83 typedef struct {
84  void *ptr;
86 
87 enum CirctMSFTDirection { NONE = 0, ASC = 1, DESC = 2 };
88 typedef struct {
89  enum CirctMSFTDirection columns;
90  enum CirctMSFTDirection rows;
92 
93 MLIR_CAPI_EXPORTED CirctMSFTPlacementDB
95 MLIR_CAPI_EXPORTED void circtMSFTDeletePlacementDB(CirctMSFTPlacementDB self);
96 MLIR_CAPI_EXPORTED MlirOperation circtMSFTPlacementDBPlace(
97  CirctMSFTPlacementDB, MlirOperation inst, MlirAttribute loc,
98  MlirStringRef subpath, MlirLocation srcLoc);
99 MLIR_CAPI_EXPORTED void
101 MLIR_CAPI_EXPORTED MlirLogicalResult circtMSFTPlacementDBMovePlacement(
102  CirctMSFTPlacementDB, MlirOperation locOp, MlirAttribute newLoc);
103 MLIR_CAPI_EXPORTED MlirOperation
105 MLIR_CAPI_EXPORTED MlirAttribute circtMSFTPlacementDBGetNearestFreeInColumn(
106  CirctMSFTPlacementDB, CirctMSFTPrimitiveType prim, uint64_t column,
107  uint64_t nearestToY);
108 
109 typedef void (*CirctMSFTPlacementCallback)(MlirAttribute loc,
110  MlirOperation locOp, void *userData);
111 /// Walk all the placements within 'bounds' ([xmin, xmax, ymin, ymax], inclusive
112 /// on all sides), with -1 meaning unbounded.
113 MLIR_CAPI_EXPORTED void circtMSFTPlacementDBWalkPlacements(
115  CirctMSFTPrimitiveType primTypeFilter, CirctMSFTWalkOrder walkOrder,
116  void *userData);
117 
118 #ifdef __cplusplus
119 }
120 #endif
121 
122 #endif // CIRCT_C_DIALECT_MSFT_H
MlirType uint64_t numElements
Definition: CHIRRTL.cpp:30
MLIR_CAPI_EXPORTED uint64_t circtMSFTPhysLocationAttrGetNum(MlirAttribute)
Definition: MSFT.cpp:197
MLIR_CAPI_EXPORTED MlirType circtMSFTLocationVectorAttrGetType(MlirAttribute)
Definition: MSFT.cpp:227
MLIR_CAPI_EXPORTED CirctMSFTPlacementDB circtMSFTCreatePlacementDB(MlirModule top, CirctMSFTPrimitiveDB seed)
Definition: MSFT.cpp:70
MLIR_CAPI_EXPORTED CirctMSFTPrimitiveType circtMSFTPhysLocationAttrGetPrimitiveType(MlirAttribute)
Definition: MSFT.cpp:186
MLIR_CAPI_EXPORTED void circtMSFTDeletePlacementDB(CirctMSFTPlacementDB self)
Definition: MSFT.cpp:76
MLIR_CAPI_EXPORTED bool circtMSFTAttributeIsAPhysicalBoundsAttr(MlirAttribute)
Definition: MSFT.cpp:201
int32_t CirctMSFTPrimitiveType
Definition: MSFT.h:24
MLIR_CAPI_EXPORTED bool circtMSFTAttributeIsALocationVectorAttribute(MlirAttribute)
Definition: MSFT.cpp:212
MLIR_CAPI_EXPORTED MlirAttribute circtMSFTPlacementDBGetNearestFreeInColumn(CirctMSFTPlacementDB, CirctMSFTPrimitiveType prim, uint64_t column, uint64_t nearestToY)
Definition: MSFT.cpp:121
MLIR_CAPI_EXPORTED MlirAttribute circtMSFTLocationVectorAttrGet(MlirContext, MlirType type, intptr_t numElements, MlirAttribute const *elements)
Definition: MSFT.cpp:215
void(* CirctMSFTPlacementCallback)(MlirAttribute loc, MlirOperation locOp, void *userData)
Definition: MSFT.h:109
MLIR_CAPI_EXPORTED MlirOperation circtMSFTGetInstance(MlirOperation root, MlirAttribute path)
MLIR_DECLARE_CAPI_DIALECT_REGISTRATION(MSFT, msft)
MLIR_CAPI_EXPORTED intptr_t circtMSFTLocationVectorAttrGetNumElements(MlirAttribute)
Definition: MSFT.cpp:230
MLIR_CAPI_EXPORTED MlirLogicalResult circtMSFTPlacementDBMovePlacement(CirctMSFTPlacementDB, MlirOperation locOp, MlirAttribute newLoc)
Definition: MSFT.cpp:104
MLIR_CAPI_EXPORTED MlirAttribute circtMSFTLocationVectorAttrGetElement(MlirAttribute attr, intptr_t pos)
Definition: MSFT.cpp:233
MLIR_CAPI_EXPORTED void circtMSFTPlacementDBRemovePlacement(CirctMSFTPlacementDB, MlirOperation locOp)
Definition: MSFT.cpp:94
MLIR_CAPI_EXPORTED bool circtMSFTPrimitiveDBIsValidLocation(CirctMSFTPrimitiveDB, MlirAttribute locAndPrim)
Definition: MSFT.cpp:58
MLIR_CAPI_EXPORTED MlirOperation circtMSFTPlacementDBGetInstanceAt(CirctMSFTPlacementDB, MlirAttribute loc)
Definition: MSFT.cpp:117
MLIR_CAPI_EXPORTED CirctMSFTPrimitiveDB circtMSFTCreatePrimitiveDB(MlirContext)
Definition: MSFT.cpp:47
MLIR_CAPI_EXPORTED void circtMSFTDeletePrimitiveDB(CirctMSFTPrimitiveDB self)
Definition: MSFT.cpp:50
MLIR_CAPI_EXPORTED uint64_t circtMSFTPhysLocationAttrGetX(MlirAttribute)
Definition: MSFT.cpp:191
MLIR_CAPI_EXPORTED void circtMSFTPlacementDBWalkPlacements(CirctMSFTPlacementDB, CirctMSFTPlacementCallback, int64_t bounds[4], CirctMSFTPrimitiveType primTypeFilter, CirctMSFTWalkOrder walkOrder, void *userData)
Walk all the placements within 'bounds' ([xmin, xmax, ymin, ymax], inclusive on all sides),...
Definition: MSFT.cpp:131
MLIR_CAPI_EXPORTED MlirAttribute circtMSFTPhysicalBoundsAttrGet(MlirContext, uint64_t, uint64_t, uint64_t, uint64_t)
Definition: MSFT.cpp:205
CirctMSFTDirection
Definition: MSFT.h:87
@ ASC
Definition: MSFT.h:87
@ DESC
Definition: MSFT.h:87
@ NONE
Definition: MSFT.h:87
MLIR_CAPI_EXPORTED bool circtMSFTAttributeIsAPhysLocationAttribute(MlirAttribute)
Definition: MSFT.cpp:173
MLIR_CAPI_EXPORTED MlirAttribute circtMSFTPhysLocationAttrGet(MlirContext, CirctMSFTPrimitiveType, uint64_t x, uint64_t y, uint64_t num)
Definition: MSFT.cpp:176
MLIR_CAPI_EXPORTED MlirOperation circtMSFTPlacementDBPlace(CirctMSFTPlacementDB, MlirOperation inst, MlirAttribute loc, MlirStringRef subpath, MlirLocation srcLoc)
Definition: MSFT.cpp:80
MLIR_CAPI_EXPORTED MlirLogicalResult circtMSFTPrimitiveDBAddPrimitive(CirctMSFTPrimitiveDB, MlirAttribute locAndPrim)
Definition: MSFT.cpp:53
MLIR_CAPI_EXPORTED void mlirMSFTRegisterPasses(void)
Definition: MSFT.cpp:32
MLIR_CAPI_EXPORTED uint64_t circtMSFTPhysLocationAttrGetY(MlirAttribute)
Definition: MSFT.cpp:194
MLIR_CAPI_EXPORTED void circtMSFTReplaceAllUsesWith(MlirValue value, MlirValue newValue)
Definition: MSFT.cpp:37
Definition: msft.py:1