Skip to content

Commit 360630b

Browse files
authored
[mlir][GPUDialect] Add cmdOption suffix consumer in GpuModuleToBinary Pass (#127646)
Add cmdOption suffix consumer function in GpuModuleToBinary Pass, which can tokenize and remove a specific suffix of cmdOption.
1 parent 5d4eb08 commit 360630b

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

mlir/include/mlir/Dialect/GPU/IR/CompilationInterfaces.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@ class TargetOptions {
7979
std::pair<llvm::BumpPtrAllocator, SmallVector<const char *>>
8080
tokenizeCmdOptions() const;
8181

82+
/// Returns a tokenization of the substr of the command line options that
83+
/// starts with `startsWith` and ends with end of the command line options and
84+
/// consumes it.
85+
std::pair<llvm::BumpPtrAllocator, SmallVector<const char *>>
86+
tokenizeAndRemoveSuffixCmdOptions(llvm::StringRef startsWith);
87+
8288
/// Returns the compilation target.
8389
CompilationTarget getCompilationTarget() const;
8490

mlir/lib/Dialect/GPU/IR/GPUDialect.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2591,6 +2591,18 @@ TargetOptions::tokenizeCmdOptions() const {
25912591
return tokenizeCmdOptions(cmdOptions);
25922592
}
25932593

2594+
std::pair<llvm::BumpPtrAllocator, SmallVector<const char *>>
2595+
TargetOptions::tokenizeAndRemoveSuffixCmdOptions(llvm::StringRef startsWith) {
2596+
size_t startPos = cmdOptions.find(startsWith);
2597+
if (startPos == std::string::npos)
2598+
return {llvm::BumpPtrAllocator(), SmallVector<const char *>()};
2599+
2600+
auto tokenized =
2601+
tokenizeCmdOptions(cmdOptions.substr(startPos + startsWith.size()));
2602+
cmdOptions.resize(startPos);
2603+
return tokenized;
2604+
}
2605+
25942606
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::gpu::TargetOptions)
25952607

25962608
#include "mlir/Dialect/GPU/IR/GPUOpInterfaces.cpp.inc"

0 commit comments

Comments
 (0)