[FIRRTL] Move intrinsics into their own tablegen file

This commit is contained in:
Nandor Licker 2024-01-08 07:26:41 -08:00
parent 3ce5c8c5b9
commit 36eaec3fa1
3 changed files with 84 additions and 72 deletions

View File

@ -21,6 +21,7 @@ include "FIRRTLStructure.td"
include "FIRRTLDeclarations.td"
include "FIRRTLStatements.td"
include "FIRRTLExpressions.td"
include "FIRRTLIntrinsics.td"
// Types
include "FIRRTLTypes.td"

View File

@ -865,77 +865,6 @@ def Mux4CellIntrinsicOp : PrimOp<"int.mux4cell"> {
"`(` operands `)` attr-dict `:` functional-type(operands, $result)";
}
//===----------------------------------------------------------------------===//
// Verif and SV specific
//===----------------------------------------------------------------------===//
def IsXIntrinsicOp : FIRRTLOp<"int.isX",
[HasCustomSSAName, Pure]> {
let summary = "Test for 'x";
let description = [{
The `int.isX` expression checks that the operand is not a verilog literal
'x. FIRRTL doesn't have a notion of 'x per-se, but x can come in to the
system from external modules and from SV constructs. Verification
constructs need to explicitly test for 'x.
}];
let arguments = (ins FIRRTLBaseType:$arg);
let results = (outs NonConstUInt1Type:$result);
let hasFolder = 1;
let assemblyFormat = "$arg attr-dict `:` type($arg)";
}
def PlusArgsTestIntrinsicOp : FIRRTLOp<"int.plusargs.test",
[HasCustomSSAName, Pure]> {
let summary = "SystemVerilog `$test$plusargs` call";
let arguments = (ins StrAttr:$formatString);
let results = (outs NonConstUInt1Type:$found);
let assemblyFormat = "$formatString attr-dict";
}
def PlusArgsValueIntrinsicOp : FIRRTLOp<"int.plusargs.value",
[HasCustomSSAName, Pure]> {
let summary = "SystemVerilog `$value$plusargs` call";
let arguments = (ins StrAttr:$formatString);
let results = (outs NonConstUInt1Type:$found, AnyType:$result);
let assemblyFormat = "$formatString attr-dict `:` type($result)";
}
def HasBeenResetIntrinsicOp : FIRRTLOp<"int.has_been_reset", [Pure]> {
let summary = "Check that a proper reset has been seen.";
let description = [{
The result of `firrtl.int.has_been_reset` reads as 0 immediately after simulation
startup and after each power-cycle in a power-aware simulation. The result
remains 0 before and during reset and only switches to 1 after the reset is
deasserted again.
See the corresponding `verif.has_been_reset` operation.
}];
let arguments = (ins NonConstClockType:$clock, AnyResetType:$reset);
let results = (outs NonConstUInt1Type:$result);
let hasFolder = 1;
let assemblyFormat = "$clock `,` $reset attr-dict `:` type($reset)";
}
def FPGAProbeIntrinsicOp : FIRRTLOp<"int.fpga_probe", []> {
let summary = "Mark a value to be observed through FPGA debugging facilities";
let description = [{
The `firrtl.int.fpga_probe` intrinsic marks a value in
the IR to be made observable through FPGA debugging facilities. Most FPGAs
offer a form of signal observation or logic analyzer to debug a design. This
operation allows the IR to indicate which signals should be made observable
for debugging. Later FPGA-specific passes may then pick this information up
and materialize the necessary logic analyzers or tool scripts.
}];
let arguments = (ins AnyType:$input, NonConstClockType:$clock);
let results = (outs);
let assemblyFormat = "$clock `,` $input attr-dict `:` type($input)";
}
//===----------------------------------------------------------------------===//
// Verbatim
//===----------------------------------------------------------------------===//
@ -1012,7 +941,7 @@ def VerbatimWireOp : FIRRTLOp<"verbatim.wire",
//===----------------------------------------------------------------------===//
// This assumes operands are ground types without explicitly checking
class SameGroundTypeOperandConstness<string a, string b>
class SameGroundTypeOperandConstness<string a, string b>
: PredOpTrait<
"operand constness must match",
CPred<"isConst($" # a # ".getType()) == isConst($" # b # ".getType())">>;

View File

@ -0,0 +1,82 @@
//===- FIRRTLIntrinsics.td - FIRRTL intrinsic ops ----------*- tablegen -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This describes the MLIR ops for FIRRTL intrinsics.
//
//===----------------------------------------------------------------------===//
#ifndef CIRCT_DIALECT_FIRRTL_FIRRTLINTRINSICS_TD
#define CIRCT_DIALECT_FIRRTL_FIRRTLINTRINSICS_TD
def IsXIntrinsicOp : FIRRTLOp<"int.isX",
[HasCustomSSAName, Pure]> {
let summary = "Test for 'x";
let description = [{
The `int.isX` expression checks that the operand is not a verilog literal
'x. FIRRTL doesn't have a notion of 'x per-se, but x can come in to the
system from external modules and from SV constructs. Verification
constructs need to explicitly test for 'x.
}];
let arguments = (ins FIRRTLBaseType:$arg);
let results = (outs NonConstUInt1Type:$result);
let hasFolder = 1;
let assemblyFormat = "$arg attr-dict `:` type($arg)";
}
def PlusArgsTestIntrinsicOp : FIRRTLOp<"int.plusargs.test",
[HasCustomSSAName, Pure]> {
let summary = "SystemVerilog `$test$plusargs` call";
let arguments = (ins StrAttr:$formatString);
let results = (outs NonConstUInt1Type:$found);
let assemblyFormat = "$formatString attr-dict";
}
def PlusArgsValueIntrinsicOp : FIRRTLOp<"int.plusargs.value",
[HasCustomSSAName, Pure]> {
let summary = "SystemVerilog `$value$plusargs` call";
let arguments = (ins StrAttr:$formatString);
let results = (outs NonConstUInt1Type:$found, AnyType:$result);
let assemblyFormat = "$formatString attr-dict `:` type($result)";
}
def HasBeenResetIntrinsicOp : FIRRTLOp<"int.has_been_reset", [Pure]> {
let summary = "Check that a proper reset has been seen.";
let description = [{
The result of `firrtl.int.has_been_reset` reads as 0 immediately after simulation
startup and after each power-cycle in a power-aware simulation. The result
remains 0 before and during reset and only switches to 1 after the reset is
deasserted again.
See the corresponding `verif.has_been_reset` operation.
}];
let arguments = (ins NonConstClockType:$clock, AnyResetType:$reset);
let results = (outs NonConstUInt1Type:$result);
let hasFolder = 1;
let assemblyFormat = "$clock `,` $reset attr-dict `:` type($reset)";
}
def FPGAProbeIntrinsicOp : FIRRTLOp<"int.fpga_probe", []> {
let summary = "Mark a value to be observed through FPGA debugging facilities";
let description = [{
The `firrtl.int.fpga_probe` intrinsic marks a value in
the IR to be made observable through FPGA debugging facilities. Most FPGAs
offer a form of signal observation or logic analyzer to debug a design. This
operation allows the IR to indicate which signals should be made observable
for debugging. Later FPGA-specific passes may then pick this information up
and materialize the necessary logic analyzers or tool scripts.
}];
let arguments = (ins AnyType:$input, NonConstClockType:$clock);
let results = (outs);
let assemblyFormat = "$clock `,` $input attr-dict `:` type($input)";
}
#endif // CIRCT_DIALECT_FIRRTL_FIRRTLINTRINSICS_TD