blob: a9a59f852e63fb5f75543adc11658f564c8e1309 [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
59llvm::cl::opt<bool> show_ids("show-ids", llvm::cl::init(false),
60 llvm::cl::desc("Show SPIR-V IDs for functions"));
61
62} // namespace
63
64namespace clspv {
65namespace Option {
66
67bool DistinctKernelDescriptorSets() { return distinct_kernel_descriptor_sets; }
68bool F16BitStorage() { return f16bit_storage; }
69bool HackInserts() { return hack_inserts; }
70bool HackUndef() { return hack_undef; }
71bool PodArgsInUniformBuffer() { return pod_ubo; }
72bool ShowIDs() { return show_ids; }
73
74} // namespace Option
75} // namespace clspv