David Neto | 482550a | 2018-03-24 05:21:07 -0700 | [diff] [blame] | 1 | // Copyright 2018 The Clspv Authors. All rights reserved. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | // This translation unit defines all Clspv command line option variables. |
| 16 | |
| 17 | #include <llvm/Support/CommandLine.h> |
| 18 | |
| 19 | namespace { |
| 20 | // By default, reuse the same descriptor set number for all arguments. |
| 21 | // To turn that off, use -distinct-kernel-descriptor-sets |
| 22 | llvm::cl::opt<bool> distinct_kernel_descriptor_sets( |
| 23 | "distinct-kernel-descriptor-sets", llvm::cl::init(false), |
| 24 | llvm::cl::desc( |
| 25 | "Each kernel uses its own descriptor set for its arguments")); |
| 26 | |
| 27 | // TODO(dneto): As per Neil Henning suggestion, might not need this if |
| 28 | // you can trace the pointer back far enough to see that it's 32-bit |
| 29 | // aligned. However, even in the vstore_half case, you'll probably get |
| 30 | // better performance if you can rely on SPV_KHR_16bit_storage since in |
| 31 | // the alternate case you're using a (relaxed) atomic, and therefore |
| 32 | // have to write through to the cache. |
| 33 | llvm::cl::opt<bool> f16bit_storage( |
| 34 | "f16bit_storage", llvm::cl::init(false), |
| 35 | llvm::cl::desc("Assume the target supports SPV_KHR_16bit_storage")); |
| 36 | |
David Neto | b6e2e06 | 2018-04-25 10:32:06 -0400 | [diff] [blame] | 37 | llvm::cl::opt<bool> hack_initializers( |
| 38 | "hack-initializers", llvm::cl::init(false), |
| 39 | llvm::cl::desc( |
| 40 | "At the start of each kernel, explicitly write the initializer " |
| 41 | "value for a compiler-generated variable containing the workgroup " |
| 42 | "size. Required by some drivers to make the get_global_size builtin " |
| 43 | "function work when used with non-constant dimension index.")); |
| 44 | |
David Neto | 482550a | 2018-03-24 05:21:07 -0700 | [diff] [blame] | 45 | llvm::cl::opt<bool> hack_inserts( |
| 46 | "hack-inserts", llvm::cl::init(false), |
| 47 | llvm::cl::desc( |
| 48 | "Avoid all single-index OpCompositInsert instructions " |
| 49 | "into struct types by using complete composite construction and " |
| 50 | "extractions")); |
| 51 | |
| 52 | // Some drivers don't like to see constant composite values constructed |
| 53 | // from scalar Undef values. Replace numeric scalar and vector Undef with |
| 54 | // corresponding OpConstantNull. We need to keep Undef for image values, |
| 55 | // for example. In the LLVM domain, image values are passed as pointer to |
| 56 | // struct. |
| 57 | // See https://github.com/google/clspv/issues/95 |
| 58 | llvm::cl::opt<bool> hack_undef( |
| 59 | "hack-undef", llvm::cl::init(false), |
| 60 | llvm::cl::desc("Use OpConstantNull instead of OpUndef for floating point, " |
| 61 | "integer, or vectors of them")); |
| 62 | |
| 63 | llvm::cl::opt<bool> |
| 64 | pod_ubo("pod-ubo", llvm::cl::init(false), |
| 65 | llvm::cl::desc("POD kernel arguments are in uniform buffers")); |
| 66 | |
David Neto | 8508264 | 2018-03-24 06:55:20 -0700 | [diff] [blame] | 67 | llvm::cl::opt<bool> module_constants_in_storage_buffer( |
| 68 | "module-constants-in-storage-buffer", llvm::cl::init(false), |
| 69 | llvm::cl::desc( |
| 70 | "Module-scope __constants are collected into a single storage buffer. " |
| 71 | "The binding and initialization data are reported in the descriptor " |
| 72 | "map.")); |
| 73 | |
David Neto | 482550a | 2018-03-24 05:21:07 -0700 | [diff] [blame] | 74 | llvm::cl::opt<bool> show_ids("show-ids", llvm::cl::init(false), |
| 75 | llvm::cl::desc("Show SPIR-V IDs for functions")); |
| 76 | |
| 77 | } // namespace |
| 78 | |
| 79 | namespace clspv { |
| 80 | namespace Option { |
| 81 | |
| 82 | bool DistinctKernelDescriptorSets() { return distinct_kernel_descriptor_sets; } |
| 83 | bool F16BitStorage() { return f16bit_storage; } |
David Neto | b6e2e06 | 2018-04-25 10:32:06 -0400 | [diff] [blame] | 84 | bool HackInitializers() { return hack_initializers; } |
David Neto | 482550a | 2018-03-24 05:21:07 -0700 | [diff] [blame] | 85 | bool HackInserts() { return hack_inserts; } |
| 86 | bool HackUndef() { return hack_undef; } |
David Neto | 8508264 | 2018-03-24 06:55:20 -0700 | [diff] [blame] | 87 | bool ModuleConstantsInStorageBuffer() { return module_constants_in_storage_buffer; } |
David Neto | 482550a | 2018-03-24 05:21:07 -0700 | [diff] [blame] | 88 | bool PodArgsInUniformBuffer() { return pod_ubo; } |
| 89 | bool ShowIDs() { return show_ids; } |
| 90 | |
| 91 | } // namespace Option |
| 92 | } // namespace clspv |