summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorSteven Perron <stevenperron@google.com>2017-12-19 15:08:54 -0500
committerDavid Neto <dneto@google.com>2017-12-20 17:56:03 -0500
commit7505d2422551e5dbc2bf4e0ffccfdc5ca5ce1925 (patch)
tree9da46712617b6d8ac459023d8bf64b5f420caa35 /tools
parentc9a881ecc6f304b586bf13f54a7cff7119b04070 (diff)
Update the legalization passes.
Changes the set of optimizations done for legalization. While doing this, I added documentation to explain why we want each optimization. A new option "--legalize-hlsl" is added so the legalization passes can be easily run from the command line. The legalize option implies skip-validation.
Diffstat (limited to 'tools')
-rw-r--r--tools/opt/opt.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp
index 34ab4cb1..1eab922e 100644
--- a/tools/opt/opt.cpp
+++ b/tools/opt/opt.cpp
@@ -48,6 +48,12 @@ std::string GetListOfPassesAsString(const spvtools::Optimizer& optimizer) {
return ss.str();
}
+std::string GetLegalizationPasses() {
+ spvtools::Optimizer optimizer(SPV_ENV_UNIVERSAL_1_2);
+ optimizer.RegisterLegalizationPasses();
+ return GetListOfPassesAsString(optimizer);
+}
+
std::string GetOptimizationPasses() {
spvtools::Optimizer optimizer(SPV_ENV_UNIVERSAL_1_2);
optimizer.RegisterPerformancePasses();
@@ -140,6 +146,14 @@ Options (in lexicographical order):
Exhaustively inline all function calls in entry point call tree
functions. Currently does not inline calls to functions with
early return in a loop.
+ --legalize-hlsl
+ Runs a series of optimizations that attempts to take SPIR-V
+ generated by and HLSL front-end and generate legal Vulkan SPIR-V.
+ The optimizations are:
+ %s
+
+ Note this does not guarantee legal code. This option implies
+ --skip-validation.
--local-redundancy-elimination
Looks for instructions in the same basic block that compute the
same value, and deletes the redundant ones.
@@ -234,8 +248,8 @@ Options (in lexicographical order):
--version
Display optimizer version information.
)",
- program, program, GetOptimizationPasses().c_str(),
- GetSizePasses().c_str());
+ program, program, GetLegalizationPasses().c_str(),
+ GetOptimizationPasses().c_str(), GetSizePasses().c_str());
}
// Reads command-line flags the file specified in |oconfig_flag|. This string
@@ -421,6 +435,9 @@ OptStatus ParseFlags(int argc, const char** argv, Optimizer* optimizer,
optimizer->RegisterPerformancePasses();
} else if (0 == strcmp(cur_arg, "-Os")) {
optimizer->RegisterSizePasses();
+ } else if (0 == strcmp(cur_arg, "--legalize-hlsl")) {
+ *skip_validator = true;
+ optimizer->RegisterLegalizationPasses();
} else if (0 == strncmp(cur_arg, "-Oconfig=", sizeof("-Oconfig=") - 1)) {
OptStatus status =
ParseOconfigFlag(argv[0], cur_arg, optimizer, in_file, out_file);