CIRCT 20.0.0git
Loading...
Searching...
No Matches
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
16extern "C" {
17#endif
18
20
21MLIR_CAPI_EXPORTED void mlirMSFTRegisterPasses(void);
22
23// Values represented in `MSFT.td`.
24typedef int32_t CirctMSFTPrimitiveType;
25
26// Replace all uses of Value with new value.
27MLIR_CAPI_EXPORTED void circtMSFTReplaceAllUsesWith(MlirValue value,
28 MlirValue newValue);
29
30//===----------------------------------------------------------------------===//
31// MSFT Attributes.
32//===----------------------------------------------------------------------===//
33
34MLIR_CAPI_EXPORTED bool
36MLIR_CAPI_EXPORTED MlirAttribute circtMSFTPhysLocationAttrGet(
37 MlirContext, CirctMSFTPrimitiveType, uint64_t x, uint64_t y, uint64_t num);
38MLIR_CAPI_EXPORTED CirctMSFTPrimitiveType
40MLIR_CAPI_EXPORTED uint64_t circtMSFTPhysLocationAttrGetX(MlirAttribute);
41MLIR_CAPI_EXPORTED uint64_t circtMSFTPhysLocationAttrGetY(MlirAttribute);
42MLIR_CAPI_EXPORTED uint64_t circtMSFTPhysLocationAttrGetNum(MlirAttribute);
43
44MLIR_CAPI_EXPORTED MlirOperation circtMSFTGetInstance(MlirOperation root,
45 MlirAttribute path);
46
47MLIR_CAPI_EXPORTED bool circtMSFTAttributeIsAPhysicalBoundsAttr(MlirAttribute);
48MLIR_CAPI_EXPORTED
49MlirAttribute circtMSFTPhysicalBoundsAttrGet(MlirContext, uint64_t, uint64_t,
50 uint64_t, uint64_t);
51
52MLIR_CAPI_EXPORTED bool
54MLIR_CAPI_EXPORTED MlirAttribute
55circtMSFTLocationVectorAttrGet(MlirContext, MlirType type, intptr_t numElements,
56 MlirAttribute const *elements);
57MLIR_CAPI_EXPORTED MlirType circtMSFTLocationVectorAttrGetType(MlirAttribute);
58MLIR_CAPI_EXPORTED
59intptr_t circtMSFTLocationVectorAttrGetNumElements(MlirAttribute);
60MLIR_CAPI_EXPORTED MlirAttribute
61circtMSFTLocationVectorAttrGetElement(MlirAttribute attr, intptr_t pos);
62
63//===----------------------------------------------------------------------===//
64// PrimitiveDB.
65//===----------------------------------------------------------------------===//
66
67typedef struct {
68 void *ptr;
70
71MLIR_CAPI_EXPORTED CirctMSFTPrimitiveDB circtMSFTCreatePrimitiveDB(MlirContext);
72MLIR_CAPI_EXPORTED void circtMSFTDeletePrimitiveDB(CirctMSFTPrimitiveDB self);
73MLIR_CAPI_EXPORTED MlirLogicalResult circtMSFTPrimitiveDBAddPrimitive(
74 CirctMSFTPrimitiveDB, MlirAttribute locAndPrim);
75MLIR_CAPI_EXPORTED bool
77 MlirAttribute locAndPrim);
78
79//===----------------------------------------------------------------------===//
80// PlacementDB.
81//===----------------------------------------------------------------------===//
82
83typedef struct {
84 void *ptr;
86
87enum CirctMSFTDirection { NONE = 0, ASC = 1, DESC = 2 };
92
93MLIR_CAPI_EXPORTED CirctMSFTPlacementDB
95MLIR_CAPI_EXPORTED void circtMSFTDeletePlacementDB(CirctMSFTPlacementDB self);
96MLIR_CAPI_EXPORTED MlirOperation circtMSFTPlacementDBPlace(
97 CirctMSFTPlacementDB, MlirOperation inst, MlirAttribute loc,
98 MlirStringRef subpath, MlirLocation srcLoc);
99MLIR_CAPI_EXPORTED void
101MLIR_CAPI_EXPORTED MlirLogicalResult circtMSFTPlacementDBMovePlacement(
102 CirctMSFTPlacementDB, MlirOperation locOp, MlirAttribute newLoc);
103MLIR_CAPI_EXPORTED MlirOperation
105MLIR_CAPI_EXPORTED MlirAttribute circtMSFTPlacementDBGetNearestFreeInColumn(
106 CirctMSFTPlacementDB, CirctMSFTPrimitiveType prim, uint64_t column,
107 uint64_t nearestToY);
108
109typedef 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.
113MLIR_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
enum CirctMSFTDirection columns
Definition MSFT.h:89
enum CirctMSFTDirection rows
Definition MSFT.h:90