Skip to content

Commit

Permalink
[WIP] remove chesshack
Browse files Browse the repository at this point in the history
  • Loading branch information
makslevental committed Sep 27, 2024
1 parent 14966e8 commit 426559e
Showing 1 changed file with 3 additions and 31 deletions.
34 changes: 3 additions & 31 deletions compiler/plugins/target/AMD-AIE/iree-amd-aie/Target/XCLBinGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -943,30 +943,6 @@ static LogicalResult generateXCLBin(
return runTool(xclbinutilBin.value().string(), flags, verbose);
}

static std::string chesshack(const std::string &input) {
std::string result(input);
static const std::unordered_map<std::string, std::string> substitutions{
{"memory\\(none\\)", "readnone"},
{"memory\\(read\\)", "readonly"},
{"memory\\(write\\)", "writeonly"},
{"memory\\(argmem: readwrite\\)", "argmemonly"},
{"memory\\(argmem: read\\)", "argmemonly readonly"},
{"memory\\(argmem: write\\)", "argmemonly writeonly"},
{"memory\\(inaccessiblemem: write\\)", "inaccessiblememonly writeonly"},
{"memory\\(inaccessiblemem: readwrite\\)", "inaccessiblememonly"},
{"memory\\(inaccessiblemem: read\\)", "inaccessiblememonly readonly"},
{"memory(argmem: readwrite, inaccessiblemem: readwrite)",
"inaccessiblemem_or_argmemonly"},
{"memory(argmem: read, inaccessiblemem: read)",
"inaccessiblemem_or_argmemonly readonly"},
{"memory(argmem: write, inaccessiblemem: write)",
"inaccessiblemem_or_argmemonly writeonly"},
};
for (const auto &pair : substitutions)
result = std::regex_replace(result, std::regex(pair.first), pair.second);
return result;
}

// A pass which removes the alignment attribute from llvm load operations, if
// the alignment is less than 4 (2 or 1).
//
Expand All @@ -988,8 +964,7 @@ static std::string chesshack(const std::string &input) {
// also https://jira.xilinx.com/projects/AIECC/issues/AIECC-589
namespace {
struct RemoveAlignment2FromLLVMLoadPass
: public PassWrapper<RemoveAlignment2FromLLVMLoadPass,
OperationPass<ModuleOp>> {
: PassWrapper<RemoveAlignment2FromLLVMLoadPass, OperationPass<ModuleOp>> {
void runOnOperation() override {
getOperation().walk([](Operation *op) {
if (auto loadOp = dyn_cast<LLVM::LoadOp>(op)) {
Expand All @@ -1004,7 +979,6 @@ struct RemoveAlignment2FromLLVMLoadPass
});
}

public:
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(
RemoveAlignment2FromLLVMLoadPass);
};
Expand Down Expand Up @@ -1059,13 +1033,11 @@ static LogicalResult generateUnifiedObject(

std::string errorMessage;
if (useChess) {
Path inputLLChessHackedFile = tempDir / "input.chesshacked.ll";
std::string inputLLChessHackedStr = inputLLStr;
FailureOr<Path> maybeVitisDir = findVitis(vitisDir, npuVersion);
if (failed(maybeVitisDir)) return failure();
FailureOr<Path> chessIntrinsicsObjFile = assembleStringUsingChess(
/*inputFileStr=*/inputLLChessHackedStr,
/*inputFileName=*/"input.chesshacked.ll",
/*inputFileStr=*/inputLLStr,
/*inputFileName=*/"input.ll",
/*outputFileName=*/outputFile,
/*outputDir=*/tempDir,
/*extraArgs*/ std::vector<std::string>{},
Expand Down

0 comments on commit 426559e

Please sign in to comment.