Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
ec70801
[VPTO] Support TPush/TPop bridge via PTO-ISA C++ template wrapper
kuri780 Aug 13, 2026
2fcbeca
test(vpto): validate FIFO TPush/TPop tile data consumption end to end
kuri780 Aug 13, 2026
f86b780
docs(designs): record VPTO TPush/TPop bridge research
kuri780 Aug 13, 2026
f997577
docs(designs): add VPTO TPush/TPop bridge implementation notes
kuri780 Aug 13, 2026
2ac33cc
docs(designs): fix pipe input description in bridge implementation notes
kuri780 Aug 13, 2026
1b45982
[VPTO] Size pipe bridge storage via wrapper-provided TPipe sizeof
kuri780 Aug 13, 2026
12f9955
[VPTO] Drop pipe-bridge finish and redundant pop wait
kuri780 Aug 13, 2026
f05623c
docs(designs): add VPTO TPush/TPop bridge presentation report
kuri780 Aug 13, 2026
dc2d83f
[VPTO] Generalize C++ interface bridge: family pass and generic lower…
kuri780 Aug 21, 2026
e177d8b
[VPTO] Complete Phase 0 bridge generalization and pass validation
kuri780 Aug 21, 2026
8d52719
docs(designs): record Phase 0 bridge generalization implementation
kuri780 Aug 21, 2026
9e675a7
[VPTO] Whitelist-driven bridge routing with residual diagnostics (Pha…
kuri780 Aug 23, 2026
bfe87b5
docs(designs): record Phase 1 whitelist-driven bridge routing
kuri780 Aug 23, 2026
129f81c
[VPTO] Parameter-generalized pipe bridge with in-compiler wrapper gen…
kuri780 Aug 23, 2026
7dcf7e3
docs(designs): record Phase 2 parameter-generalized bridge with wrapp…
kuri780 Aug 23, 2026
9231405
[VPTO] Second interface family: cube MATMUL bridge via family pass + …
kuri780 Aug 23, 2026
60e311f
docs(designs): record Phase 3 second interface family (cube MATMUL) b…
kuri780 Aug 23, 2026
1790261
[VPTO] Formal bridge whitelist channel with built-in default and tmpl…
kuri780 Aug 24, 2026
b6152ec
docs(designs): record Phase 4 formal whitelist channel and tmpl_map c…
kuri780 Aug 24, 2026
ddf2627
[VPTO] EmitC-bridge token parity lit test and permanent fifo variant …
kuri780 Aug 24, 2026
af54ea0
docs(designs): record post-Phase-4 parity guard and variant case form…
kuri780 Aug 24, 2026
ef46eea
[VPTO] Probe loop fifo consumption and guard multi-pop rebind with di…
kuri780 Aug 24, 2026
a1d3751
docs(designs): record loop fifo consumption probe and rebind guards
kuri780 Aug 24, 2026
b4174ac
[VPTO] Bridge TMatmul entry variants, tmpl_map-driven typedefs, and n…
kuri780 Aug 24, 2026
6c89ffe
docs(designs): record TMatmul variant wiring, tmpl_map driving, and s…
kuri780 Aug 24, 2026
b4a88e9
test(lit): align with mainline after bridge rebase
kuri780 Aug 24, 2026
e627efe
chore: slim the bridge PR footprint
kuri780 Aug 24, 2026
16db0be
chore: drop the bridge design doc from the PR
kuri780 Aug 24, 2026
173a5de
feat(vpto-bridge): declarative lowering channel replaces the matmul f…
kuri780 Aug 24, 2026
5652657
feat(vpto-print): PrintOp verifier + shared format analysis (IR layer)
kuri780 Aug 24, 2026
4ada3d6
[VPTO] Lower print/tprint to CCE printf wrapper shims in LLVM emission
kuri780 Aug 25, 2026
d7bd6e6
feat(vpto-print): ObjectEmission links cce::printf wrapper + driver-m…
kuri780 Aug 25, 2026
96f3d4b
docs(designs): VPTO C++ bridge generalization design and PR summary
kuri780 Aug 25, 2026
b34b73a
Revert "feat(vpto-print): ObjectEmission links cce::printf wrapper + …
kuri780 Aug 25, 2026
833c9ed
Revert "[VPTO] Lower print/tprint to CCE printf wrapper shims in LLVM…
kuri780 Aug 25, 2026
2d9ed59
Revert "feat(vpto-print): PrintOp verifier + shared format analysis (…
kuri780 Aug 25, 2026
c019f43
feat(vpto-bridge): 白名单 lowering 缺省声明式、wrapper 字段驱动分派
kuri780 Aug 25, 2026
f980004
feat(vpto-bridge): generic declarative wrapper renderer + whitelist w…
kuri780 Aug 25, 2026
4325273
test(lit): migrate bridge lit to the declarative wrapper schema
kuri780 Aug 25, 2026
975ce1d
docs(designs): refresh bridge PR summary for the declarative renderer
kuri780 Aug 25, 2026
8ed99c4
feat(vpto-bridge): register pto.tadd via whitelist only, zero C++
kuri780 Aug 25, 2026
72901e8
test(e2e): vec-add-bridge simulator case for the whitelist-only tadd
kuri780 Aug 25, 2026
b772bf6
docs(designs): record vec-add-bridge e2e in the capability matrix
kuri780 Aug 25, 2026
833f8b3
docs(designs): finalize the bridge PR summary against current impleme…
kuri780 Aug 25, 2026
80bbcae
docs(designs): trim schema examples to required fields, add field qui…
kuri780 Aug 25, 2026
b2cd56f
feat(vpto-bridge): default call, core guard and abi param names from …
kuri780 Aug 25, 2026
3c249e3
docs(designs): sync schema quick-reference with the convention defaults
kuri780 Aug 25, 2026
7289f16
docs(designs): rework bridge summary into a result-focused design digest
kuri780 Aug 25, 2026
db3a077
chore(vpto-bridge): keep review focused on pipe family
kuri780 Aug 27, 2026
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
6 changes: 6 additions & 0 deletions include/PTO/IR/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ mlir_tablegen(PTOAttrs.cpp.inc -gen-attrdef-defs -attrdefs-dialect=pto)
mlir_tablegen(PTOEnums.h.inc -gen-enum-decls)
mlir_tablegen(PTOEnums.cpp.inc -gen-enum-defs)

# 生成 Attribute Interfaces 定义
set(LLVM_TARGET_DEFINITIONS PTOAttrInterfaces.td)
mlir_tablegen(PTOAttrInterfaces.h.inc -gen-attr-interface-decls)
mlir_tablegen(PTOAttrInterfaces.cpp.inc -gen-attr-interface-defs)
set(LLVM_TARGET_DEFINITIONS PTOOps.td)

# ============================================================
# 2. 处理 Interfaces (防止下个报错)
# ============================================================
Expand Down
2 changes: 2 additions & 0 deletions include/PTO/IR/PTO.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
// PTO Attributes
//===----------------------------------------------------------------------===//

#include "PTO/IR/PTOAttrInterfaces.h.inc"

#define GET_ATTRDEF_CLASSES
#include "PTO/IR/PTOAttrs.h.inc"

Expand Down
51 changes: 51 additions & 0 deletions include/PTO/IR/PTOAttrInterfaces.td
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Copyright (c) 2026 Huawei Technologies Co., Ltd.
// This program is free software, you can redistribute it and/or modify it under the terms and conditions of
// CANN Open Software License Agreement Version 2.0 (the "License").
// Please refer to the License for details. You may not use this file except in compliance with the License.
// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
// See LICENSE in the root of the software repository for the full text of the License.

//===- PTOAttrInterfaces.td - PTO attribute interfaces ------*- tablegen -*-===//
//===----------------------------------------------------------------------===//
//
// This is the definition file for PTO dialect attribute interfaces.
//
//===----------------------------------------------------------------------===//

#ifndef MLIR_DIALECT_PTO_IR_PTOATTRINTERFACES
#define MLIR_DIALECT_PTO_IR_PTOATTRINTERFACES

include "mlir/IR/AttrTypeBase.td"
include "mlir/IR/OpBase.td"

//===----------------------------------------------------------------------===//
// Enum token reflection
//===----------------------------------------------------------------------===//

// Implemented by PTO enum attributes that can feed a VPTO bridge template
// token. This MLIR build has no generic C++ runtime base for TableGen enum
// attributes, so the declarative bridge lowering reflects the enum case
// through this interface instead of knowing each attribute class: it
// assembles `EnumType::Case` spellings from the whitelist `enum_type`
// prefix and the enumerator symbol exposed here.
def PTO_EnumTokenAttr : AttrInterface<"EnumTokenAttr"> {
let cppNamespace = "::mlir::pto";
let description = [{
An attribute whose value is one case of a PTO enum and can be rendered
as a C++ template token by the declarative VPTO bridge lowering.
}];
let methods = [
InterfaceMethod<
/*desc=*/[{
Returns the C++ enumerator symbol of the attribute's enum case
(e.g. "Partial" for `pto::AccPhase::Partial`).
}],
/*retTy=*/"llvm::StringRef",
/*methodName=*/"getEnumCaseSymbol",
/*args=*/(ins)
>,
];
}

#endif // MLIR_DIALECT_PTO_IR_PTOATTRINTERFACES
4 changes: 3 additions & 1 deletion include/PTO/IR/PTOAttrs.td
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#define MLIR_DIALECT_PTO_IR_PTOATTRS

include "PTO/IR/PTODialect.td"
include "PTO/IR/PTOAttrInterfaces.td"

include "mlir/Dialect/LLVMIR/LLVMOpBase.td"
include "mlir/IR/AttrTypeBase.td"
Expand Down Expand Up @@ -867,7 +868,8 @@ def PTO_AccPhaseEnum : PTO_I32Enum<
I32EnumAttrCase<"Final", 3, "final">
]>;

def PTO_AccPhaseAttr : EnumAttr<PTO_Dialect, PTO_AccPhaseEnum, "acc_phase"> {
def PTO_AccPhaseAttr : EnumAttr<PTO_Dialect, PTO_AccPhaseEnum, "acc_phase",
[DeclareAttrInterfaceMethods<PTO_EnumTokenAttr>]> {
let summary = "TMATMUL / TMATMUL_ACC accumulation phase attribute";
}

Expand Down
45 changes: 45 additions & 0 deletions include/PTO/IR/PTOOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -2677,6 +2677,51 @@ def TFreeOp : PTO_TOp<"tfree", [
}];
}

//===----------------------------------------------------------------------===//
// C++ Interface Bridge Ops
//===----------------------------------------------------------------------===//
//
// These internal ops form the generic VPTO C++ interface bridge. A
// family-specific pass
// (e.g. the TPipe family pass) rewrites its internal ops into bridge ops
// carrying only the wrapper callee name and ABI values. The generic bridge
// lowering pass then mechanically converts them into calls to wrapper
// functions whose implementations come from externally compiled device
// bitcode linked into the VPTO device module.

def BridgeCallOp : PTO_Op<"bridge_call", [
DeclareOpInterfaceMethods<MemoryEffectsOpInterface>
]> {
let summary = "Generic call into an externally linked C++ wrapper entry";

let arguments = (ins
StrAttr:$callee,
OptionalAttr<StrAttr>:$storage_size_callee,
Variadic<AnyType>:$args
);

let results = (outs Variadic<AnyType>:$results);

let assemblyFormat = [{
$callee
(`{` `storage_size_callee` `=` $storage_size_callee^ `}`)?
(`(` $args^ `:` type($args) `)`)?
attr-dict
(`->` type($results)^)?
}];
}

def BridgeIntToPtrOp : PTO_Op<"bridge_inttoptr"> {
let summary = "Generic bridge address materialization (i64 to PTO pointer)";

let arguments = (ins SignlessIntegerLike:$addr);
let results = (outs AnyType:$result);

let assemblyFormat = [{
$addr attr-dict `:` type($addr) `->` type($result)
}];
}

//===----------------------------------------------------------------------===//
// Synchronization Ops
//===----------------------------------------------------------------------===//
Expand Down
82 changes: 82 additions & 0 deletions include/PTO/Transforms/PTOCppTokens.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
// Copyright (c) 2026 Huawei Technologies Co., Ltd.
// This program is free software, you can redistribute it and/or modify it under the terms and conditions of
// CANN Open Software License Agreement Version 2.0 (the "License").
// You may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.huawei.com/
// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A
// PARTICULAR PURPOSE.
// See LICENSE in the root of the software repository for the full text of the License.

//===- PTOCppTokens.h - shared PTO-ISA C++ token mappings -------*- C++ -*-===//
//===----------------------------------------------------------------------===//
//
// Single source of truth for the pure mappings from IR facts (element
// types, enums, integer attribute values) to PTO-ISA C++ spellings. Both
// the EmitC backend and the VPTO C++ interface bridge render the same
// pto-isa template tokens; they share these mapping functions and keep
// their own assembly logic (which template arguments to emit, how the
// tokens are consumed).
//
// Every builder takes a `qualifier` prefix that is prepended to the
// pto-isa constant/type spelling: the bridge passes "pto::" (the wrapper
// is a standalone translation unit and always spells fully qualified
// names), the EmitC backend passes an empty string (its output relies on
// the surrounding namespace context).
//
//===----------------------------------------------------------------------===//

#ifndef MLIR_DIALECT_PTO_TRANSFORMS_PTOCPPTOKENS_H
#define MLIR_DIALECT_PTO_TRANSFORMS_PTOCPPTOKENS_H

#include "PTO/IR/PTO.h"
#include "mlir/IR/Types.h"
#include "mlir/Support/LLVM.h"
#include "mlir/Support/LogicalResult.h"
#include "llvm/ADT/StringRef.h"
#include <string>

namespace mlir {
namespace pto {

/// Builds the C++ element type token (e.g. "float", "half", "int8_t") for
/// an MLIR element type. Falls back to "float" for unrecognized types.
std::string getPTOCppElementTypeToken(Type elementType);

/// Builds the `TileSplitAxis::TILE_*` token for a split value (0..4).
/// Fails for values outside that range.
FailureOr<std::string> getPTOCppTileSplitToken(int64_t split,
llvm::StringRef qualifier);

/// Builds the `Direction::DIR_*` token for a local pipe dir_mask (1=C2V,
/// 2=V2C, 3=BOTH). The L2G2L "_GM" variants are an EmitC-side extension
/// and are not part of this core mapping. Fails for other masks.
FailureOr<std::string> getPTOCppDirectionToken(int8_t dirMask,
llvm::StringRef qualifier);

/// Builds the `TileType::*` token for a local tile address space. Fails
/// for address spaces with no TileType mapping (e.g. global memory);
/// callers apply their own fallback policy for those.
FailureOr<std::string> getPTOCppTileTypeToken(AddressSpace addressSpace,
llvm::StringRef qualifier);

/// Builds the `BLayout::*` token. Fails for values outside the closed set.
FailureOr<std::string> getPTOCppBLayoutToken(BLayout bLayout,
llvm::StringRef qualifier);

/// Builds the `SLayout::*` token. Fails for values outside the closed set.
FailureOr<std::string> getPTOCppSLayoutToken(SLayout sLayout,
llvm::StringRef qualifier);

/// Renders the `TPipe<flagBase, Direction, slotSize, slotNum, localSlotNum,
/// nosplit>` spelling; `dirTok` is an already rendered direction token.
std::string renderTPipeSpelling(int32_t flagBase, llvm::StringRef dirTok,
int32_t slotSize, int32_t slotNum,
int32_t localSlotNum, bool nosplit,
llvm::StringRef qualifier);

} // namespace pto
} // namespace mlir

#endif // MLIR_DIALECT_PTO_TRANSFORMS_PTOCPPTOKENS_H
4 changes: 4 additions & 0 deletions include/PTO/Transforms/Passes.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ std::unique_ptr<Pass> createPTOValidatePhysicalSectionBoundariesPass();
std::unique_ptr<Pass> createPTOMaterializeTileOpSectionsPass();
std::unique_ptr<Pass> createVPTOSplitCVModulePass();
std::unique_ptr<Pass> createVPTONormalizeContainerPass();
std::unique_ptr<Pass> createPTOLowerPipeFamilyOpsPass();
std::unique_ptr<Pass> createPTOLowerDeclarativeBridgeOpsPass();
std::unique_ptr<Pass> createVPTOBridgeLoweringPass();
std::unique_ptr<Pass> createVPTOBridgeWrapperGenPass();
std::unique_ptr<Pass> createPTOVerifyTFreePass();

// Creates a pass for ...
Expand Down
103 changes: 103 additions & 0 deletions include/PTO/Transforms/Passes.td
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,109 @@ def PTOMaterializeTileOpSections
];
}

def PTOLowerPipeFamilyOps : Pass<"pto-lower-pipe-family-ops", "mlir::func::FuncOp"> {
let summary = "Lower internal TPipe ops into generic VPTO bridge ops";
let description = [{
TPipe family pass of the VPTO C++ interface bridge. It rewrites the
internal pipe ops (pto.initialize_l2l_pipe / pto.tpush / pto.tpop /
pto.tfree) and the tile handles they consume (pto.alloc_tile /
pto.declare_tile / pto.tile_buf_addr) into generic pto.bridge_call /
pto.bridge_inttoptr ops that carry only wrapper callee names and ABI
values. All pipe family semantics (config validation, storage handle
flow, and the runtime rebinding of a declared tile to the FIFO slot
returned by TPOP) are resolved here so that the generic bridge lowering
stays family-agnostic.
}];
let constructor = "mlir::pto::createPTOLowerPipeFamilyOpsPass()";
let options = [
Option<"whitelistPath", "whitelist-path", "std::string",
/*default=*/"\"\"",
"Path to the VPTO bridge whitelist YAML; falls back to the "
"PTOAS_VPTO_BRIDGE_WHITELIST environment variable, "
"then to the built-in default whitelist">
];
let dependentDialects = [
"mlir::pto::PTODialect",
"mlir::arith::ArithDialect"
];
}

def PTOLowerDeclarativeBridgeOps : Pass<"pto-lower-declarative-bridge-ops", "mlir::func::FuncOp"> {
let summary = "Lower whitelist-routed ops through the declarative VPTO "
"bridge channel";
let description = [{
Declarative lowering channel of the VPTO C++ interface bridge, and the
default channel of every whitelist entry. It rewrites each entry into a
void pto.bridge_call using only the whitelist description: each abi row
binds a wrapper argument to an IR operand position whose planned
alloc_tile address becomes the i64 call argument, and the wrapper
specialization is collected from the operand tile types (keyed by the
abi role) plus optional enum attributes. Ops needing family semantics
(storage lifecycle, address rebinding) opt out with `lowering: custom`
and stay on their family pass. Routing is whitelist driven: unrouted
ops keep flowing through their regular non-bridge lowering path.
}];
let constructor = "mlir::pto::createPTOLowerDeclarativeBridgeOpsPass()";
let options = [
Option<"whitelistPath", "whitelist-path", "std::string",
/*default=*/"\"\"",
"Path to the VPTO bridge whitelist YAML; falls back to the "
"PTOAS_VPTO_BRIDGE_WHITELIST environment variable, "
"then to the built-in default whitelist">
];
let dependentDialects = [
"mlir::pto::PTODialect"
];
}

def VPTOBridgeLowering : Pass<"vpto-bridge-lowering", "ModuleOp"> {
let summary = "Lower generic bridge ops into C++ wrapper calls";
let description = [{
Generic bridge lowering pass of the VPTO C++ interface bridge. It knows
nothing about individual PTO-ISA interface families: it validates each
pto.bridge_call against the bridge whitelist and mechanically lowers it
into a call to the wrapper entry, materializing the wrapper declaration
at module level. Entries carrying storage_size_callee additionally
synthesize the stateful-object pattern (size query + stack storage).
pto.bridge_inttoptr is lowered to llvm.inttoptr.
}];
let constructor = "mlir::pto::createVPTOBridgeLoweringPass()";
let options = [
Option<"whitelistPath", "whitelist-path", "std::string",
/*default=*/"\"\"",
"Path to the VPTO bridge whitelist YAML; falls back to the "
"PTOAS_VPTO_BRIDGE_WHITELIST environment variable, "
"then to the built-in default whitelist">
];
let dependentDialects = [
"mlir::pto::PTODialect",
"mlir::func::FuncDialect",
"mlir::LLVM::LLVMDialect"
];
}

def VPTOBridgeWrapperGen : Pass<"pto-emit-vpto-bridge-wrapper", "ModuleOp"> {
let summary = "Render the VPTO bridge wrapper source from the collected spec";
let description = [{
Wrapper generation pass of the VPTO C++ interface bridge. It reads the
pipe bridge specialization collected by the family passes in the
`pto.vpto.bridge.spec` module attribute (TPipe/Tile/split C++ template
tokens plus the whitelist wrapper entry names), renders the complete
bridge wrapper C++ source, and stores it in the
`pto.vpto.bridge.wrapper_source` module attribute for object emission to
compile and link. The spec attribute is removed once rendered. Modules
without a bridge spec are left untouched.
}];
let constructor = "mlir::pto::createVPTOBridgeWrapperGenPass()";
let options = [
Option<"whitelistPath", "whitelist-path", "std::string",
/*default=*/"\"\"",
"Path to the VPTO bridge whitelist YAML; falls back to the "
"PTOAS_VPTO_BRIDGE_WHITELIST environment variable, "
"then to the built-in default whitelist">
];
}

def VPTOSplitCVModule : Pass<"vpto-split-cv-module", "ModuleOp"> {
let summary = "Split a VPTO module with cube/vector sections into kernel modules";
let description = [{
Expand Down
3 changes: 2 additions & 1 deletion include/PTO/Transforms/TileOpExpansionUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ inline bool isTileLibExpandableOp(Operation *op) {
}
return !isa<TReshapeOp, TSyncOp, TAllocToAivOp, TAllocToAicOp,
TPushToAivOp, TPushToAicOp, TPopFromAicOp, TPopFromAivOp,
TFreeFromAicOp, TFreeFromAivOp>(op);
TFreeFromAicOp, TFreeFromAivOp, TAllocOp, TPushOp, TPopOp,
TFreeOp>(op);
}

} // namespace mlir::pto
Expand Down
Loading
Loading