blob: fdaa7cb9cfa0e477bcccf889a835ea5688e87b47 [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
alan-baker75090e42020-02-20 11:21:04 -050053// Returns true if the function is an OpenCL image read.
54bool IsUnsampledImageRead(llvm::StringRef name);
55inline bool IsUnsampledImageRead(llvm::Function *f) {
56 return IsUnsampledImageRead(f->getName());
57}
58
59// Returns true if the function is an OpenCL image read of float type.
60bool IsFloatUnsampledImageRead(llvm::StringRef name);
61inline bool IsFloatUnsampledImageRead(llvm::Function *f) {
62 return IsFloatUnsampledImageRead(f->getName());
63}
64
65// Returns true if the function is an OpenCL image read of uint type.
66bool IsUintUnsampledImageRead(llvm::StringRef name);
67inline bool IsUintUnsampledImageRead(llvm::Function *f) {
68 return IsUintUnsampledImageRead(f->getName());
69}
70
71// Returns true if the function is an OpenCL image read of int type.
72bool IsIntUnsampledImageRead(llvm::StringRef name);
73inline bool IsIntUnsampledImageRead(llvm::Function *f) {
74 return IsIntUnsampledImageRead(f->getName());
75}
76
alan-bakerf67468c2019-11-25 15:51:49 -050077// Returns true if the function is an OpenCL image write.
78bool IsImageWrite(llvm::StringRef name);
79inline bool IsImageWrite(llvm::Function *f) {
80 return IsImageWrite(f->getName());
81}
82
83// Returns true if the function is an OpenCL image write of float type.
84bool IsFloatImageWrite(llvm::StringRef name);
85inline bool IsFloatImageWrite(llvm::Function *f) {
86 return IsFloatImageWrite(f->getName());
87}
88
89// Returns true if the function is an OpenCL image write of uint type.
90bool IsUintImageWrite(llvm::StringRef name);
91inline bool IsUintImageWrite(llvm::Function *f) {
92 return IsUintImageWrite(f->getName());
93}
94
95// Returns true if the function is an OpenCL image write of int type.
96bool IsIntImageWrite(llvm::StringRef name);
97inline bool IsIntImageWrite(llvm::Function *f) {
98 return IsIntImageWrite(f->getName());
99}
100
101// Returns true if the function is an OpenCL image height query.
102bool IsGetImageHeight(llvm::StringRef name);
103inline bool IsGetImageHeight(llvm::Function *f) {
104 return IsGetImageHeight(f->getName());
105}
106
107// Returns true if the function is an OpenCL image width query.
108bool IsGetImageWidth(llvm::StringRef name);
109inline bool IsGetImageWidth(llvm::Function *f) {
110 return IsGetImageWidth(f->getName());
111}
112
alan-bakerce179f12019-12-06 19:02:22 -0500113// Returns true if the function is an OpenCL image depth query.
114bool IsGetImageDepth(llvm::StringRef name);
115inline bool IsGetImageDepth(llvm::Function *f) {
116 return IsGetImageDepth(f->getName());
117}
118
119// Returns true if the function is an OpenCL image dim query.
120bool IsGetImageDim(llvm::StringRef name);
121inline bool IsGetImageDim(llvm::Function *f) {
122 return IsGetImageDim(f->getName());
123}
124
125// Returns true if the function is an OpenCL image query.
126bool IsImageQuery(llvm::StringRef name);
127inline bool IsImageQuery(llvm::Function *f) {
128 return IsImageQuery(f->getName());
129}
130
alan-bakerf67468c2019-11-25 15:51:49 -0500131} // namespace clspv
132
133#endif // CLSPV_LIB_BUILTINS_H_