-
Notifications
You must be signed in to change notification settings - Fork 616
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
14 changed files
with
461 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package chisel3.internal.panama.circt | ||
|
||
import chisel3.internal._ | ||
|
||
class PanamaCIRCTOM private[chisel3](circt: PanamaCIRCT, mlirModule: MlirModule) extends CIRCTOM { | ||
def evaluator(): CIRCTOMEvaluator = new PanamaCIRCTOMEvaluator(circt, mlirModule) | ||
|
||
def newBasePathEmpty(): CIRCTOMEvaluatorValue = new PanamaCIRCTOMEvaluatorValueBasePath(circt, circt.omEvaluatorBasePathGetEmpty()) | ||
} | ||
|
||
class PanamaCIRCTOMEvaluator private[chisel3](circt: PanamaCIRCT, mlirModule: MlirModule) extends CIRCTOMEvaluator { | ||
val evaluator = circt.omEvaluatorNew(mlirModule) | ||
|
||
def instantiate(className: String, actualParams: Seq[CIRCTOMEvaluatorValue]): CIRCTOMObject = { | ||
val params = actualParams.map(_.asInstanceOf[PanamaCIRCTOMEvaluatorValue].value) | ||
|
||
val value = circt.omEvaluatorInstantiate(evaluator, className, params) | ||
assert(!circt.omEvaluatorObjectIsNull(value)) | ||
new PanamaCIRCTOMObject(circt, value) | ||
} | ||
} | ||
|
||
abstract class PanamaCIRCTOMEvaluatorValue extends CIRCTOMEvaluatorValue { | ||
val value: OMEvaluatorValue | ||
} | ||
object PanamaCIRCTOMEvaluatorValue { | ||
def newValue(circt: PanamaCIRCT, value: OMEvaluatorValue): PanamaCIRCTOMEvaluatorValue = { | ||
if (circt.omEvaluatorValueIsAObject(value)) { | ||
throw new Exception("TODO") | ||
} else if (circt.omEvaluatorValueIsAPrimitive(value)) { | ||
new PanamaCIRCTOMEvaluatorValuePrimitive(circt, value) | ||
} else if (circt.omEvaluatorValueIsAList(value)) { | ||
new PanamaCIRCTOMEvaluatorValueList(circt, value) | ||
} else if (circt.omEvaluatorValueIsATuple(value)) { | ||
new PanamaCIRCTOMEvaluatorValueTuple(circt, value) | ||
} else if (circt.omEvaluatorValueIsAMap(value)) { | ||
new PanamaCIRCTOMEvaluatorValueMap(circt, value) | ||
} else if (circt.omEvaluatorValueIsABasePath(value)) { | ||
new PanamaCIRCTOMEvaluatorValueBasePath(circt, value) | ||
} else if (circt.omEvaluatorValueIsAPath(value)) { | ||
new PanamaCIRCTOMEvaluatorValuePath(circt, value) | ||
} else { | ||
throw new Exception("unknown OMEvaluatorValue type") | ||
} | ||
} | ||
} | ||
|
||
class PanamaCIRCTOMEvaluatorValueList private[chisel3](circt: PanamaCIRCT, val value: OMEvaluatorValue) extends PanamaCIRCTOMEvaluatorValue { | ||
val numElements: Int = circt.omEvaluatorListGetNumElements(value) | ||
def getElement(index: Int) = PanamaCIRCTOMEvaluatorValue.newValue(circt, circt.omEvaluatorListGetElement(value, index)) | ||
} | ||
|
||
class PanamaCIRCTOMEvaluatorValueTuple private[chisel3](circt: PanamaCIRCT, val value: OMEvaluatorValue) extends PanamaCIRCTOMEvaluatorValue { | ||
val numElements: Int = circt.omEvaluatorTupleGetNumElements(value) | ||
def getElement(index: Int) = PanamaCIRCTOMEvaluatorValue.newValue(circt, circt.omEvaluatorTupleGetElement(value, index)) | ||
} | ||
|
||
class PanamaCIRCTOMEvaluatorValueMap private[chisel3](circt: PanamaCIRCT, val value: OMEvaluatorValue) extends PanamaCIRCTOMEvaluatorValue { | ||
val tpe: MlirType = circt.omEvaluatorMapGetType(value) | ||
val keys: MlirAttribute = circt.omEvaluatorMapGetKeys(value) | ||
def getElement(attr: MlirAttribute) = PanamaCIRCTOMEvaluatorValue.newValue(circt, circt.omEvaluatorMapGetElement(value, attr)) | ||
} | ||
|
||
class PanamaCIRCTOMEvaluatorValueBasePath private[chisel3](circt: PanamaCIRCT, val value: OMEvaluatorValue) extends PanamaCIRCTOMEvaluatorValue {} | ||
|
||
class PanamaCIRCTOMEvaluatorValuePath private[chisel3](circt: PanamaCIRCT, val value: OMEvaluatorValue) extends PanamaCIRCTOMEvaluatorValue { | ||
def asString(): String = circt.omEvaluatorPathGetAsString(value) | ||
} | ||
|
||
class PanamaCIRCTOMEvaluatorValuePrimitive private[chisel3](circt: PanamaCIRCT, val value: OMEvaluatorValue) extends PanamaCIRCTOMEvaluatorValue { | ||
val primitive: MlirAttribute = circt.omEvaluatorValueGetPrimitive(value) | ||
} | ||
|
||
class PanamaCIRCTOMObject private[chisel3](circt: PanamaCIRCT, value: OMEvaluatorValue) extends CIRCTOMObject { | ||
def field(name: String): CIRCTOMEvaluatorValue = PanamaCIRCTOMEvaluatorValue.newValue(circt, circt.omEvaluatorObjectGetField(value, name)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package chisel3.internal.panama.circt | ||
|
||
import chisel3.internal._ | ||
|
||
class PanamaCIRCTPassManager private[chisel3](circt: PanamaCIRCT, mlirModule: MlirModule) extends CIRCTPassManager { | ||
val pm = circt.mlirPassManagerCreate() | ||
val options = circt.firtoolOptionsCreateDefault() // TODO: Make it configurable from CIRCTPassManager | ||
|
||
private def isSuccess(result: MlirLogicalResult): Boolean = circt.mlirLogicalResultIsSuccess(result) | ||
|
||
def populatePreprocessTransforms(): Boolean = isSuccess(circt.firtoolPopulatePreprocessTransforms(pm, options)) | ||
def populateCHIRRTLToLowFIRRTL(): Boolean = isSuccess(circt.firtoolPopulateCHIRRTLToLowFIRRTL(pm, options, mlirModule, "-")) | ||
def populateLowFIRRTLToHW(): Boolean = isSuccess(circt.firtoolPopulateLowFIRRTLToHW(pm, options)) | ||
def populateLowHWToSV(): Boolean = isSuccess(circt.firtoolPopulateHWToSV(pm, options)) | ||
def populateExportVerilog(callback: String => Unit): Boolean = isSuccess(circt.firtoolPopulateExportVerilog(pm, options, callback)) | ||
def populateExportSplitVerilog(directory: String): Boolean = isSuccess(circt.firtoolPopulateExportSplitVerilog(pm, options, directory)) | ||
def populateFinalizeIR(): Boolean = isSuccess(circt.firtoolPopulateFinalizeIR(pm, options)) | ||
|
||
def run(): Boolean = isSuccess(circt.mlirPassManagerRunOnOp(pm, circt.mlirModuleGetOperation(mlirModule))) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package chisel3.internal | ||
|
||
abstract class CIRCTOM { | ||
def evaluator(): CIRCTOMEvaluator | ||
|
||
def newBasePathEmpty(): CIRCTOMEvaluatorValue | ||
} | ||
|
||
abstract class CIRCTOMEvaluator { | ||
def instantiate(name: String, actualParams: Seq[CIRCTOMEvaluatorValue]): CIRCTOMObject | ||
} | ||
|
||
abstract class CIRCTOMEvaluatorValue {} | ||
|
||
abstract class CIRCTOMObject { | ||
def field(name: String): CIRCTOMEvaluatorValue | ||
} |
15 changes: 15 additions & 0 deletions
15
core/src/main/scala/chisel3/internal/CIRCTPassManager.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package chisel3.internal | ||
|
||
abstract class CIRCTPassManager { | ||
def populatePreprocessTransforms(): Boolean | ||
def populateCHIRRTLToLowFIRRTL(): Boolean | ||
def populateLowFIRRTLToHW(): Boolean | ||
def populateLowHWToSV(): Boolean | ||
def populateExportVerilog(callback: String => Unit): Boolean | ||
def populateExportSplitVerilog(directory: String): Boolean | ||
def populateFinalizeIR(): Boolean | ||
|
||
def run(): Boolean; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters