blob: 7be1594fb1d0cc35161c17c1d3cbff815c836f26 [file] [log] [blame]
alan-bakerf67468c2019-11-25 15:51:49 -05001// Copyright 2019 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#ifndef CLSPV_LIB_BUILTINS_H_
16#define CLSPV_LIB_BUILTINS_H_
17
18#include "llvm/ADT/StringRef.h"
19#include "llvm/IR/Function.h"
20
21namespace clspv {
22
23// Returns true if the function is an OpenCL image builtin.
24bool IsImageBuiltin(llvm::StringRef name);
25inline bool IsImageBuiltin(llvm::Function *f) {
26 return IsImageBuiltin(f->getName());
27}
28
29// Returns true if the function is an OpenCL sampled image read.
30bool IsSampledImageRead(llvm::StringRef name);
31inline bool IsSampledImageRead(llvm::Function *f) {
32 return IsSampledImageRead(f->getName());
33}
34
35// Returns true if the function is an OpenCL sampled image read of float type.
36bool IsFloatSampledImageRead(llvm::StringRef name);
37inline bool IsFloatSampledImageRead(llvm::Function *f) {
38 return IsFloatSampledImageRead(f->getName());
39}
40
41// Returns true if the function is an OpenCL sampled image read of uint type.
42bool IsUintSampledImageRead(llvm::StringRef name);
43inline bool IsUintSampledImageRead(llvm::Function *f) {
44 return IsUintSampledImageRead(f->getName());
45}
46
47// Returns true if the function is an OpenCL sampled image read of int type.
48bool IsIntSampledImageRead(llvm::StringRef name);
49inline bool IsIntSampledImageRead(llvm::Function *f) {
50 return IsIntSampledImageRead(f->getName());
51}
52
53// Returns true if the function is an OpenCL image write.
54bool IsImageWrite(llvm::StringRef name);
55inline bool IsImageWrite(llvm::Function *f) {
56 return IsImageWrite(f->getName());
57}
58
59// Returns true if the function is an OpenCL image write of float type.
60bool IsFloatImageWrite(llvm::StringRef name);
61inline bool IsFloatImageWrite(llvm::Function *f) {
62 return IsFloatImageWrite(f->getName());
63}
64
65// Returns true if the function is an OpenCL image write of uint type.
66bool IsUintImageWrite(llvm::StringRef name);
67inline bool IsUintImageWrite(llvm::Function *f) {
68 return IsUintImageWrite(f->getName());
69}
70
71// Returns true if the function is an OpenCL image write of int type.
72bool IsIntImageWrite(llvm::StringRef name);
73inline bool IsIntImageWrite(llvm::Function *f) {
74 return IsIntImageWrite(f->getName());
75}
76
77// Returns true if the function is an OpenCL image height query.
78bool IsGetImageHeight(llvm::StringRef name);
79inline bool IsGetImageHeight(llvm::Function *f) {
80 return IsGetImageHeight(f->getName());
81}
82
83// Returns true if the function is an OpenCL image width query.
84bool IsGetImageWidth(llvm::StringRef name);
85inline bool IsGetImageWidth(llvm::Function *f) {
86 return IsGetImageWidth(f->getName());
87}
88
89} // namespace clspv
90
91#endif // CLSPV_LIB_BUILTINS_H_