Skip to content

[mlir][GPUDialect] Add cmdOption suffix consumer in GpuModuleToBinary Pass #127646

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

Merged
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
6 changes: 6 additions & 0 deletions mlir/include/mlir/Dialect/GPU/IR/CompilationInterfaces.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ class TargetOptions {
std::pair<llvm::BumpPtrAllocator, SmallVector<const char *>>
tokenizeCmdOptions() const;

/// Returns a tokenization of the substr of the command line options that
/// starts with `startsWith` and ends with end of the command line options and
/// consumes it.
std::pair<llvm::BumpPtrAllocator, SmallVector<const char *>>
tokenizeAndRemoveSuffixCmdOptions(llvm::StringRef startsWith);

/// Returns the compilation target.
CompilationTarget getCompilationTarget() const;

Expand Down
12 changes: 12 additions & 0 deletions mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2591,6 +2591,18 @@ TargetOptions::tokenizeCmdOptions() const {
return tokenizeCmdOptions(cmdOptions);
}

std::pair<llvm::BumpPtrAllocator, SmallVector<const char *>>
TargetOptions::tokenizeAndRemoveSuffixCmdOptions(llvm::StringRef startsWith) {
size_t startPos = cmdOptions.find(startsWith);
if (startPos == std::string::npos)
return {llvm::BumpPtrAllocator(), SmallVector<const char *>()};

auto tokenized =
tokenizeCmdOptions(cmdOptions.substr(startPos + startsWith.size()));
cmdOptions.resize(startPos);
return tokenized;
}

MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::gpu::TargetOptions)

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