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

[IR] Update how tile's with partial info are printed #1021

Merged
merged 2 commits into from
Jan 13, 2025
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
22 changes: 16 additions & 6 deletions compiler/plugins/target/AMD-AIE/iree-amd-aie/IR/AMDAIEOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1419,16 +1419,26 @@ SmallVector<AMDAIE::NpuDmaCpyNdOp> NpuDmaWaitOp::getDmaOps() {
// AMDAIE_TileOp
//===----------------------------------------------------------------------===//

// Example: if the column is an integer value (3) and the row is not, the SSA
// value might be `%tile_3_r`, where the `_r` denotes that the row is not known.
void TileOp::getAsmResultNames(function_ref<void(Value, StringRef)> setNameFn) {
std::optional<int64_t> iCol = getConstantIntValue(getCol());
std::optional<int64_t> iRow = getConstantIntValue(getRow());
std::string name{"tile"};
if (iCol.has_value() && iRow.has_value()) {
std::string sCol = std::to_string(iCol.value());
std::string sRow = std::to_string(iRow.value());
name += "_" + sCol + "_" + sRow;
std::ostringstream name;
name << "tile";

auto add = [&](std::optional<int64_t> maybeValue, char unknown) {
if (maybeValue.has_value()) {
name << '_' << maybeValue.value();
} else {
name << '_' << unknown;
}
};
if (iCol.has_value() || iRow.has_value()) {
add(iCol, 'c');
add(iRow, 'r');
}
setNameFn(getResult(), name);
setNameFn(getResult(), name.str());
}

bool TileOp::hasStaticLocation() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -503,20 +503,28 @@ func.func @reference_to() {

// -----

// Test that if the row and column are statically known, the tile operation is
// Test that if the row OR column is statically known, the tile operation is
// printed with the row and column in the SSA value.
func.func @tile_a_b(%i : index) {
%c2 = arith.constant 2: index
%c3 = arith.constant 3 : index
amdaie.workgroup {

// CHECK: %tile_2_3 = amdaie.tile
%t_23 = amdaie.tile(%c2, %c3)

// CHECK: %tile_2_3_0 = amdaie.tile
%t_231 = amdaie.tile(%c2, %c3)
// CHECK: %tile = amdaie.tile

// CHECK: %tile_c_3 = amdaie.tile
%t_i3 = amdaie.tile(%i, %c3)
// CHECK: %tile_1 = amdaie.tile

// CHECK: %tile_2_r = amdaie.tile
%t_2i = amdaie.tile(%c2, %i)

// CHECK: %tile = amdaie.tile
%t_uu = amdaie.tile(%i, %i)

amdaie.controlcode {
amdaie.end
}
Expand Down
Loading