• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2016 Google Inc.
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 #ifndef SOURCE_SPIRV_TARGET_ENV_H_
16 #define SOURCE_SPIRV_TARGET_ENV_H_
17 
18 #include <string>
19 #include <utility>
20 #include <vector>
21 
22 #include "spirv-tools/libspirv.h"
23 
24 // Returns true if |env| is a VULKAN environment, false otherwise.
25 bool spvIsVulkanEnv(spv_target_env env);
26 
27 // Returns true if |env| is an OPENCL environment, false otherwise.
28 bool spvIsOpenCLEnv(spv_target_env env);
29 
30 // Returns true if |env| is an OPENGL environment, false otherwise.
31 bool spvIsOpenGLEnv(spv_target_env env);
32 
33 // Returns true if |env| is an implemented/valid environment, false otherwise.
34 bool spvIsValidEnv(spv_target_env env);
35 
36 // Returns the version number for the given SPIR-V target environment.
37 uint32_t spvVersionForTargetEnv(spv_target_env env);
38 
39 // Returns a string to use in logging messages that indicates the class of
40 // environment, i.e. "Vulkan", "OpenCL", etc.
41 std::string spvLogStringForEnv(spv_target_env env);
42 
43 // Returns a formatted list of all SPIR-V target environment names that
44 // can be parsed by spvParseTargetEnv.
45 // |pad| is the number of space characters that the beginning of each line
46 //       except the first one will be padded with.
47 // |wrap| is the max length of lines the user desires. Word-wrapping will
48 //        occur to satisfy this limit.
49 std::string spvTargetEnvList(const int pad, const int wrap);
50 
51 // Reads the target environment from the header comments of disassembly. Returns
52 // true if valid name found, false otherwise.
53 bool spvReadEnvironmentFromText(const std::vector<char>& text,
54                                 spv_target_env* env);
55 
56 #endif  // SOURCE_SPIRV_TARGET_ENV_H_
57