aboutsummaryrefslogtreecommitdiff
path: root/tools/opt/opt.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/opt/opt.cpp')
-rw-r--r--tools/opt/opt.cpp114
1 files changed, 6 insertions, 108 deletions
diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp
index 66f92286..6999b39a 100644
--- a/tools/opt/opt.cpp
+++ b/tools/opt/opt.cpp
@@ -79,18 +79,6 @@ std::string GetSizePasses() {
return GetListOfPassesAsString(optimizer);
}
-std::string GetVulkanToWebGPUPasses() {
- spvtools::Optimizer optimizer(SPV_ENV_VULKAN_1_1);
- optimizer.RegisterVulkanToWebGPUPasses();
- return GetListOfPassesAsString(optimizer);
-}
-
-std::string GetWebGPUToVulkanPasses() {
- spvtools::Optimizer optimizer(SPV_ENV_WEBGPU_0);
- optimizer.RegisterWebGPUToVulkanPasses();
- return GetListOfPassesAsString(optimizer);
-}
-
void PrintUsage(const char* program) {
std::string target_env_list = spvTargetEnvList(16, 80);
// NOTE: Please maintain flags in lexicographical order.
@@ -239,10 +227,6 @@ Options (in lexicographical order):)",
values, providing guarantees that satisfy Vulkan's
robustBufferAccess rules.)");
printf(R"(
- --generate-webgpu-initializers
- Adds initial values to OpVariable instructions that are missing
- them, due to their storage type requiring them for WebGPU.)");
- printf(R"(
--if-conversion
Convert if-then-else like assignments into OpSelect.)");
printf(R"(
@@ -261,11 +245,6 @@ Options (in lexicographical order):)",
option --relax-logical-pointer to the validator.)",
GetLegalizationPasses().c_str());
printf(R"(
- --legalize-vector-shuffle
- Converts any usages of 0xFFFFFFFF for the literals in
- OpVectorShuffle to a literal 0. This is done since 0xFFFFFFFF is
- forbidden in WebGPU.)");
- printf(R"(
--local-redundancy-elimination
Looks for instructions in the same basic block that compute the
same value, and deletes the redundant ones.)");
@@ -463,13 +442,6 @@ Options (in lexicographical order):)",
Forwards this option to the validator. See the validator help
for details.)");
printf(R"(
- --split-invalid-unreachable
- Attempts to legalize for WebGPU cases where an unreachable
- merge-block is also a continue-target by splitting it into two
- separate blocks. There exist legal, for Vulkan, instances of this
- pattern that cannot be converted into legal WebGPU, so this
- conversion may not succeed.)");
- printf(R"(
--skip-validation
Will not validate the SPIR-V before optimizing. If the SPIR-V
is invalid, the optimizer may fail or generate incorrect code.
@@ -513,39 +485,15 @@ Options (in lexicographical order):)",
removes them from the vector. Note this would still leave around
lots of dead code that a pass of ADCE will be able to remove.)");
printf(R"(
- --vulkan-to-webgpu
- Turns on the prescribed passes for converting from Vulkan to
- WebGPU and sets the target environment to webgpu0. Other passes
- may be turned on via additional flags, but such combinations are
- not tested.
- Using --target-env with this flag is not allowed.
-
- This flag is the equivalent of passing in --target-env=webgpu0
- and specifying the following optimization code names:
- %s
-
- NOTE: This flag is a WIP and its behaviour is subject to change.)",
- GetVulkanToWebGPUPasses().c_str());
- printf(R"(
- --webgpu-to-vulkan
- Turns on the prescribed passes for converting from WebGPU to
- Vulkan and sets the target environment to vulkan1.1. Other passes
- may be turned on via additional flags, but such combinations are
- not tested.
- Using --target-env with this flag is not allowed.
-
- This flag is the equivalent of passing in --target-env=vulkan1.1
- and specifying the following optimization code names:
- %s
-
- NOTE: This flag is a WIP and its behaviour is subject to change.)",
- GetWebGPUToVulkanPasses().c_str());
- printf(R"(
--workaround-1209
Rewrites instructions for which there are known driver bugs to
avoid triggering those bugs.
Current workarounds: Avoid OpUnreachable in loops.)");
printf(R"(
+ --workgroup-scalar-block-layout
+ Forwards this option to the validator. See the validator help
+ for details.)");
+ printf(R"(
--wrap-opkill
Replaces all OpKill instructions in functions that can be called
from a continue construct with a function call to a function
@@ -714,9 +662,6 @@ OptStatus ParseFlags(int argc, const char** argv,
spvtools::ValidatorOptions* validator_options,
spvtools::OptimizerOptions* optimizer_options) {
std::vector<std::string> pass_flags;
- bool target_env_set = false;
- bool vulkan_to_webgpu_set = false;
- bool webgpu_to_vulkan_set = false;
for (int argi = 1; argi < argc; ++argi) {
const char* cur_arg = argv[argi];
if ('-' == cur_arg[0]) {
@@ -781,19 +726,6 @@ OptStatus ParseFlags(int argc, const char** argv,
max_id_bound);
} else if (0 == strncmp(cur_arg,
"--target-env=", sizeof("--target-env=") - 1)) {
- target_env_set = true;
- if (vulkan_to_webgpu_set) {
- spvtools::Error(opt_diagnostic, nullptr, {},
- "--vulkan-to-webgpu defines the target environment, "
- "so --target-env cannot be set at the same time");
- return {OPT_STOP, 1};
- }
- if (webgpu_to_vulkan_set) {
- spvtools::Error(opt_diagnostic, nullptr, {},
- "--webgpu-to-vulkan defines the target environment, "
- "so --target-env cannot be set at the same time");
- return {OPT_STOP, 1};
- }
const auto split_flag = spvtools::utils::SplitFlagArgs(cur_arg);
const auto target_env_str = split_flag.second.c_str();
spv_target_env target_env;
@@ -803,42 +735,6 @@ OptStatus ParseFlags(int argc, const char** argv,
return {OPT_STOP, 1};
}
optimizer->SetTargetEnv(target_env);
- } else if (0 == strcmp(cur_arg, "--vulkan-to-webgpu")) {
- vulkan_to_webgpu_set = true;
- if (target_env_set) {
- spvtools::Error(opt_diagnostic, nullptr, {},
- "--vulkan-to-webgpu defines the target environment, "
- "so --target-env cannot be set at the same time");
- return {OPT_STOP, 1};
- }
- if (webgpu_to_vulkan_set) {
- spvtools::Error(opt_diagnostic, nullptr, {},
- "Cannot use both --webgpu-to-vulkan and "
- "--vulkan-to-webgpu at the same time, invoke twice "
- "if you are wanting to go to and from");
- return {OPT_STOP, 1};
- }
-
- optimizer->SetTargetEnv(SPV_ENV_VULKAN_1_1);
- optimizer->RegisterVulkanToWebGPUPasses();
- } else if (0 == strcmp(cur_arg, "--webgpu-to-vulkan")) {
- webgpu_to_vulkan_set = true;
- if (target_env_set) {
- spvtools::Error(opt_diagnostic, nullptr, {},
- "--webgpu-to-vulkan defines the target environment, "
- "so --target-env cannot be set at the same time");
- return {OPT_STOP, 1};
- }
- if (vulkan_to_webgpu_set) {
- spvtools::Error(opt_diagnostic, nullptr, {},
- "Cannot use both --webgpu-to-vulkan and "
- "--vulkan-to-webgpu at the same time, invoke twice "
- "if you are wanting to go to and from");
- return {OPT_STOP, 1};
- }
-
- optimizer->SetTargetEnv(SPV_ENV_WEBGPU_0);
- optimizer->RegisterWebGPUToVulkanPasses();
} else if (0 == strcmp(cur_arg, "--validate-after-all")) {
optimizer->SetValidateAfterAll(true);
} else if (0 == strcmp(cur_arg, "--before-hlsl-legalization")) {
@@ -849,6 +745,8 @@ OptStatus ParseFlags(int argc, const char** argv,
validator_options->SetRelaxBlockLayout(true);
} else if (0 == strcmp(cur_arg, "--scalar-block-layout")) {
validator_options->SetScalarBlockLayout(true);
+ } else if (0 == strcmp(cur_arg, "--workgroup-scalar-block-layout")) {
+ validator_options->SetWorkgroupScalarBlockLayout(true);
} else if (0 == strcmp(cur_arg, "--skip-block-layout")) {
validator_options->SetSkipBlockLayout(true);
} else if (0 == strcmp(cur_arg, "--relax-struct-store")) {