blob: cb53cde6ab8ecbd6a20f11029e7ffb31a7f9b273 [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
37llvm::cl::opt<bool> hack_inserts(
38 "hack-inserts", llvm::cl::init(false),
39 llvm::cl::desc(
40 "Avoid all single-index OpCompositInsert instructions "
41 "into struct types by using complete composite construction and "
42 "extractions"));
43
44// Some drivers don't like to see constant composite values constructed
45// from scalar Undef values. Replace numeric scalar and vector Undef with
46// corresponding OpConstantNull. We need to keep Undef for image values,
47// for example. In the LLVM domain, image values are passed as pointer to
48// struct.
49// See https://github.com/google/clspv/issues/95
50llvm::cl::opt<bool> hack_undef(
51 "hack-undef", llvm::cl::init(false),
52 llvm::cl::desc("Use OpConstantNull instead of OpUndef for floating point, "
53 "integer, or vectors of them"));
54
55llvm::cl::opt<bool>
56 pod_ubo("pod-ubo", llvm::cl::init(false),
57 llvm::cl::desc("POD kernel arguments are in uniform buffers"));
58
David Neto85082642018-03-24 06:55:20 -070059llvm::cl::opt<bool> module_constants_in_storage_buffer(
60 "module-constants-in-storage-buffer", llvm::cl::init(false),
61 llvm::cl::desc(
62 "Module-scope __constants are collected into a single storage buffer. "
63 "The binding and initialization data are reported in the descriptor "
64 "map."));
65
David Neto482550a2018-03-24 05:21:07 -070066llvm::cl::opt<bool> show_ids("show-ids", llvm::cl::init(false),
67 llvm::cl::desc("Show SPIR-V IDs for functions"));
68
69} // namespace
70
71namespace clspv {
72namespace Option {
73
74bool DistinctKernelDescriptorSets() { return distinct_kernel_descriptor_sets; }
75bool F16BitStorage() { return f16bit_storage; }
76bool HackInserts() { return hack_inserts; }
77bool HackUndef() { return hack_undef; }
David Neto85082642018-03-24 06:55:20 -070078bool ModuleConstantsInStorageBuffer() { return module_constants_in_storage_buffer; }
David Neto482550a2018-03-24 05:21:07 -070079bool PodArgsInUniformBuffer() { return pod_ubo; }
80bool ShowIDs() { return show_ids; }
81
82} // namespace Option
83} // namespace clspv