blob: 7421f5156a2ea8a69ebdb99e7cb399865ab00008 [file] [log] [blame]
David Neto482550a2018-03-24 05:21:07 -07001// 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
19namespace {
20// By default, reuse the same descriptor set number for all arguments.
21// To turn that off, use -distinct-kernel-descriptor-sets
22llvm::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.
33llvm::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 Netob6e2e062018-04-25 10:32:06 -040037llvm::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 Neto482550a2018-03-24 05:21:07 -070045llvm::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
58llvm::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
63llvm::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 Neto85082642018-03-24 06:55:20 -070067llvm::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 Neto482550a2018-03-24 05:21:07 -070074llvm::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
79namespace clspv {
80namespace Option {
81
82bool DistinctKernelDescriptorSets() { return distinct_kernel_descriptor_sets; }
83bool F16BitStorage() { return f16bit_storage; }
David Netob6e2e062018-04-25 10:32:06 -040084bool HackInitializers() { return hack_initializers; }
David Neto482550a2018-03-24 05:21:07 -070085bool HackInserts() { return hack_inserts; }
86bool HackUndef() { return hack_undef; }
David Neto85082642018-03-24 06:55:20 -070087bool ModuleConstantsInStorageBuffer() { return module_constants_in_storage_buffer; }
David Neto482550a2018-03-24 05:21:07 -070088bool PodArgsInUniformBuffer() { return pod_ubo; }
89bool ShowIDs() { return show_ids; }
90
91} // namespace Option
92} // namespace clspv