Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
12 changes: 11 additions & 1 deletion mlir/include/mlir/Target/SPIRV/Serialization.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,17 @@ struct SerializationOptions {
/// tool. This saved file is later used for validation.
bool saveModuleForValidation = false;
/// A prefix prepended to the file used when `saveModuleForValidation`
/// is set to `true`.
/// is set to `true`. This can either be a file prefix, or a relative or
/// or an absolute path followed by the prefix. For example:
///
/// * "foo" - Create files with a `foo` prefix in the current working
/// directory. For example: `foo0`, `foo1` ... `fooN`.
///
/// * "my/dir/foo" - Create files in `my/dir` with a `foo` prefix. The
/// `my/dir` need to exists. For example: `foo0`, `foo1` ... `fooN`
/// will be created and stored in `/my/dir`.
///
/// * "/home/user/my/dir" - Same as above but using an absolute path.
std::string validationFilePrefix = "";
};

Expand Down
3 changes: 1 addition & 2 deletions mlir/lib/Target/SPIRV/TranslateRegistration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@ void registerToSPIRVTranslation() {
"is used to generate separate binaries for validation, where "
"`--split-input-file` normally combines all outputs into one. The "
"one combined output (`-o`) is still written. Created files need to "
"be "
"removed manually once processed."),
"be removed manually once processed."),
llvm::cl::init(""));

TranslateFromMLIRRegistration toBinary(
Expand Down
29 changes: 29 additions & 0 deletions mlir/test/Target/SPIRV/mlir-translate.mlir
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// COM: Check that `--spirv-save-validation-files-with-prefix` generates
// COM: a correct number of files.

// REQUIRES: shell
// RUN: rm -rf %t
// RUN: mkdir %t
// RUN: mlir-translate --serialize-spirv --no-implicit-module --split-input-file --spirv-save-validation-files-with-prefix=%t/foo %s
// RUN: ls %t | wc -l | FileCheck %s
// RUN: rm -rf %t

// CHECK: 4

spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader, Linkage], []> {
}

// -----

spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader, Linkage], []> {
}

// -----

spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader, Linkage], []> {
}

// -----

spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader, Linkage], []> {
}