@@ -17,6 +17,7 @@ include "aie/Dialect/AIE/IR/AIEInterfaces.td"
1717include "mlir/IR/OpBase.td"
1818include "mlir/IR/AttrTypeBase.td"
1919include "mlir/IR/EnumAttr.td"
20+ include "mlir/IR/BuiltinAttributes.td"
2021include "mlir/IR/SymbolInterfaces.td"
2122include "mlir/Interfaces/SideEffectInterfaces.td"
2223include "mlir/Interfaces/DataLayoutInterfaces.td"
@@ -527,7 +528,11 @@ def AIE_SelectOp: AIEX_Op<"select", []>, Results<(outs Index)> {
527528 ];
528529}
529530
530- def AIE_RuntimeSequenceOp : AIEX_Op<"runtime_sequence", [NoTerminator, HasParent<"AIE::DeviceOp">]> {
531+ def AIE_RuntimeSequenceOp : AIEX_Op<"runtime_sequence", [
532+ Symbol,
533+ NoTerminator,
534+ HasParent<"AIE::DeviceOp">,
535+ ]> {
531536 let summary = "Program the configuration co-processor of the AI Engine array";
532537 let description = [{
533538 Instructions in this operation allow for runtime (re-)configuration of the AI Engine array, such as configuring data movement buffer descriptors.
@@ -537,13 +542,69 @@ def AIE_RuntimeSequenceOp : AIEX_Op<"runtime_sequence", [NoTerminator, HasParent
537542 The input arguments are arguments passed in from the host at kernel invocation time. This may include buffers on the host.
538543 }];
539544 let arguments = (
540- ins OptionalAttr <SymbolNameAttr>:$sym_name
545+ ins DefaultValuedAttr <SymbolNameAttr, "getDefaultRuntimeSequenceName()" >:$sym_name
541546 );
542547 let regions = (region
543548 AnyRegion:$body
544549 );
545550 let hasCustomAssemblyFormat = 1;
546551 let hasVerifier = 1;
552+ let extraClassDeclaration = [{
553+ static llvm::StringRef getDefaultRuntimeSequenceName() { return "sequence"; }
554+ static RuntimeSequenceOp getForSymbolInDevice(AIE::DeviceOp module, llvm::StringRef symbol);
555+ static RuntimeSequenceOp getForSymbolInDeviceOrError(AIE::DeviceOp module, llvm::StringRef symbol);
556+ }];
557+ let extraClassDefinition = [{
558+ }];
559+ }
560+
561+ def AIE_ConfigureOp: AIEX_Op<"configure", [
562+ HasParent<"RuntimeSequenceOp">,
563+ NoTerminator
564+ ]>,
565+ Results<(outs Index:$result)>
566+ {
567+ let summary = "Set up a configuration (program memories, stream switches, etc.) on the NPU device.";
568+ let arguments = (
569+ ins FlatSymbolRefAttr:$symbol
570+ );
571+
572+ let assemblyFormat = [{
573+ $symbol regions attr-dict
574+ }];
575+
576+ let extraClassDeclaration = [{
577+ AIE::DeviceOp getReferencedDeviceOp();
578+ }];
579+
580+ let regions = (region
581+ AnyRegion:$body
582+ );
583+
584+ let hasVerifier = 1;
585+ }
586+
587+ def AIE_RunOp: AIEX_Op<"run", [HasParent<"ConfigureOp">]> {
588+ let arguments = (
589+ ins FlatSymbolRefAttr:$runtime_sequence_symbol,
590+ Variadic<AnyType>:$args
591+ );
592+
593+ let assemblyFormat = [{
594+ $runtime_sequence_symbol `(` $args `)` `:` `(` type($args) `)` attr-dict
595+ }];
596+
597+ let extraClassDeclaration = [{
598+ AIE::DeviceOp getCalleeDeviceOp();
599+ RuntimeSequenceOp getCalleeRuntimeSequenceOp();
600+ }];
601+
602+ let hasVerifier = 1;
603+
604+ let summary = "Execute a runtime sequence";
605+ let description = [{
606+ Executes an `aiex.runtime_sequence` with the given name and arguments by inlining its instructions at the call site.
607+ }];
547608}
548609
549610def AIE_NpuDmaMemcpyNdOp: AIEX_Op<"npu.dma_memcpy_nd", [
@@ -772,6 +833,9 @@ def AIE_NpuWrite32Op: AIEX_Op<"npu.write32", []> {
772833 If 'buffer' is not present and 'column' and 'row' are not present then
773834 'address' is interpreted as a full 32-bit address in the AIE array.
774835 }];
836+ let extraClassDeclaration = [{
837+ std::optional<uint32_t> getAbsoluteAddress();
838+ }];
775839}
776840
777841// MASKWRITE
@@ -798,6 +862,9 @@ def AIE_NpuMaskWrite32Op: AIEX_Op<"npu.maskwrite32", []> {
798862 If 'buffer' is not present and 'column' and 'row' are not present then
799863 'address' is interpreted as a full 32-bit address in the AIE array.
800864 }];
865+ let extraClassDeclaration = [{
866+ std::optional<uint32_t> getAbsoluteAddress();
867+ }];
801868}
802869
803870// BLOCKWRITE
@@ -823,6 +890,10 @@ def AIE_NpuBlockWriteOp: AIEX_Op<"npu.blockwrite", []> {
823890 If 'buffer' is not present and 'column' and 'row' are not present then
824891 'address' is interpreted as a full 32-bit address in the AIE array.
825892 }];
893+ let extraClassDeclaration = [{
894+ std::optional<uint32_t> getAbsoluteAddress();
895+ mlir::DenseIntElementsAttr getDataWords();
896+ }];
826897}
827898
828899// OP_SYNC
0 commit comments