Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cd] Bump CIRCT from firtool-1.64.0 to firtool-1.65.0 #3811

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions circtpanamabinding/includeFunctions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ mlirOperationStateAddResults
mlirOperationStateAddAttributes
mlirOperationStateEnableResultTypeInference
mlirOperationGetResult
mlirOperationGetAttributeByName
mlirOperationSetInherentAttributeByName
mlirRegionCreate
mlirOperationCreate
Expand Down Expand Up @@ -108,6 +109,12 @@ chirrtlTypeGetCMemoryPort
hwInnerRefAttrGet
hwInnerSymAttrGet

hwInstanceGraphGet
hwInstanceGraphGetTopLevelNode
hwInstanceGraphForEachNode
hwInstanceGraphNodeEqual
hwInstanceGraphNodeGetModuleOp

# circtFirtoolOptions
circtFirtoolOptionsCreateDefault
circtFirtoolOptionsDestroy
Expand Down
2 changes: 2 additions & 0 deletions circtpanamabinding/includeStructs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ FIRRTLClassElement
CirctFirtoolFirtoolOptions
OMEvaluator
OMEvaluatorValue
HWInstanceGraph
HWInstanceGraphNode
1 change: 1 addition & 0 deletions circtpanamabinding/includeTypedefs.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
MlirStringCallback
HWInstanceGraphNodeCallback
2 changes: 1 addition & 1 deletion etc/circt.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "firtool-1.64.0"
"version": "firtool-1.65.0"
}
32 changes: 29 additions & 3 deletions lit/tests/Property/Good.sc
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,30 @@ args.head match {
case _ =>
}

class PropertyTest extends RawModule {
class PropertyTest extends Module {
val i = IO(Input(UInt(8.W)))
val o = IO(Output(UInt(8.W)))

val m = Module(new Module {
val i = IO(Input(UInt(8.W)))
val r = RegNext(i)
val o = IO(Output(UInt(8.W)))
val p = IO(Output(Property[Int]()))
p := Property(789)
o := r
val nested = Module(new Module {
val i = IO(Input(UInt(8.W)))
val r = RegNext(i)
val o = IO(Output(UInt(8.W)))
val p = IO(Output(Property[Int]()))
p := Property(789)
o := r
})
nested.i := i
o := nested.o
})
m.i := i
o := m.o

val p = IO(Output(Property[Path]()))
p := Property(Path(i))
Expand All @@ -54,5 +76,9 @@ args.head match {
// CHECK-NEXT: .b => { [ [ prim{omInteger{456}} ] ] }
// CHECK-NEXT: .p => { path{OMReferenceTarget:~PropertyTest|PropertyTest>i} }
obj.foreachField((name, value) => println(s".$name => { ${value.display} }"))
case _ =>
}

// CHECK: module{_1_Anon}
// CHECK-NEXT: module{PropertyTest_Anon}
// CHECK-NEXT: module{PropertyTest}
converter.foreachHwModule(name => println(s"module{$name}"))
}
15 changes: 15 additions & 0 deletions panamaconverter/src/PanamaCIRCTConverter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,21 @@ class PanamaCIRCTConverter(val circt: PanamaCIRCT, fos: Option[FirtoolOptions])
def passManager(): PanamaCIRCTPassManager = new PanamaCIRCTPassManager(circt, mlirRootModule, fos)
def om(): PanamaCIRCTOM = new PanamaCIRCTOM(circt, mlirRootModule)

def foreachHwModule(callback: String => Unit) = {
val instanceGraph = circt.hwInstanceGraphGet(circt.mlirModuleGetOperation(mlirRootModule))
val topLevelNode = circt.hwInstanceGraphGetTopLevelNode(instanceGraph)
circt.hwInstanceGraphForEachNode(
instanceGraph,
node => {
if (!circt.hwInstanceGraphNodeEqual(node, topLevelNode)) {
val moduleOp = circt.hwInstanceGraphNodeGetModuleOp(node)
val moduleName = circt.mlirStringAttrGetValue(circt.mlirOperationGetAttributeByName(moduleOp, "sym_name"))
callback(moduleName)
}
}
)
}

def visitCircuit(name: String): Unit = {
val firCircuit = util
.OpBuilder("firrtl.circuit", circt.mlirModuleGetBody(mlirRootModule), circt.unkLoc)
Expand Down
55 changes: 55 additions & 0 deletions panamalib/src/PanamaCIRCT.scala
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ class PanamaCIRCT {
CAPI.mlirOperationGetResult(arena, operation.get, pos)
)

def mlirOperationGetAttributeByName(op: MlirOperation, name: String) = MlirAttribute(
CAPI.mlirOperationGetAttributeByName(arena, op.get, newString(name).get)
)

def mlirOperationSetInherentAttributeByName(op: MlirOperation, name: String, attr: MlirAttribute): Unit =
CAPI.mlirOperationSetInherentAttributeByName(op.get, newString(name).get, attr.get)

Expand Down Expand Up @@ -480,6 +484,33 @@ class PanamaCIRCT {
def hwInnerSymAttrGet(symName: String) =
MlirAttribute(CAPI.hwInnerSymAttrGet(arena, mlirStringAttrGet(symName).get))

def hwInstanceGraphGet(operation: MlirOperation) = HWInstanceGraph(CAPI.hwInstanceGraphGet(arena, operation.get))

def hwInstanceGraphGetTopLevelNode(instanceGraph: HWInstanceGraph) = HWInstanceGraphNode(
CAPI.hwInstanceGraphGetTopLevelNode(arena, instanceGraph.get)
)

def hwInstanceGraphForEachNode(instaceGraph: HWInstanceGraph, callback: HWInstanceGraphNode => Unit) = {
val cb = HWInstanceGraphNodeCallback(
circt.HWInstanceGraphNodeCallback.allocate(
new circt.HWInstanceGraphNodeCallback {
def apply(node: MemorySegment, userData: MemorySegment) = {
callback(HWInstanceGraphNode(node))
}
},
arena
)
)
CAPI.hwInstanceGraphForEachNode(instaceGraph.get, cb.get, NULL)
}

def hwInstanceGraphNodeEqual(lhs: HWInstanceGraphNode, rhs: HWInstanceGraphNode) =
CAPI.hwInstanceGraphNodeEqual(lhs.get, rhs.get)

def hwInstanceGraphNodeGetModuleOp(node: HWInstanceGraphNode) = MlirOperation(
CAPI.hwInstanceGraphNodeGetModuleOp(arena, node.get)
)

//
// OM C-API
//
Expand Down Expand Up @@ -757,6 +788,30 @@ object OMEvaluatorValue {
private[panamalib] def apply(ptr: MemorySegment) = new OMEvaluatorValue(ptr)
}

final case class HWInstanceGraph(ptr: MemorySegment) extends ForeignType[MemorySegment] {
private[panamalib] def get = ptr
private[panamalib] val sizeof = circt.HWInstanceGraph.sizeof().toInt
}
object HWInstanceGraph {
private[panamalib] def apply(ptr: MemorySegment) = new HWInstanceGraph(ptr)
}

final case class HWInstanceGraphNode(ptr: MemorySegment) extends ForeignType[MemorySegment] {
private[panamalib] def get = ptr
private[panamalib] val sizeof = circt.HWInstanceGraphNode.sizeof().toInt
}
object HWInstanceGraphNode {
private[panamalib] def apply(ptr: MemorySegment) = new HWInstanceGraphNode(ptr)
}

final case class HWInstanceGraphNodeCallback(ptr: MemorySegment) extends ForeignType[MemorySegment] {
private[panamalib] def get = ptr
private[panamalib] val sizeof = CAPI.C_POINTER.byteSize().toInt
}
object HWInstanceGraphNodeCallback {
private[panamalib] def apply(ptr: MemorySegment) = new HWInstanceGraphNodeCallback(ptr)
}

//
// MLIR & CIRCT Enums
//
Expand Down
Loading