1 //===----- SemaOpenCL.h --- Semantic Analysis for OpenCL constructs -------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 /// \file 9 /// This file declares semantic analysis routines for OpenCL. 10 /// 11 //===----------------------------------------------------------------------===// 12 13 #ifndef LLVM_CLANG_SEMA_SEMAOPENCL_H 14 #define LLVM_CLANG_SEMA_SEMAOPENCL_H 15 16 #include "clang/Sema/SemaBase.h" 17 18 namespace clang { 19 class Decl; 20 class ParsedAttr; 21 22 class SemaOpenCL : public SemaBase { 23 public: 24 SemaOpenCL(Sema &S); 25 26 void handleNoSVMAttr(Decl *D, const ParsedAttr &AL); 27 void handleAccessAttr(Decl *D, const ParsedAttr &AL); 28 29 // Handles intel_reqd_sub_group_size. 30 void handleSubGroupSize(Decl *D, const ParsedAttr &AL); 31 32 // Performs semantic analysis for the read/write_pipe call. 33 // \param S Reference to the semantic analyzer. 34 // \param Call A pointer to the builtin call. 35 // \return True if a semantic error has been found, false otherwise. 36 bool checkBuiltinRWPipe(CallExpr *Call); 37 38 // Performs a semantic analysis on the {work_group_/sub_group_ 39 // /_}reserve_{read/write}_pipe 40 // \param S Reference to the semantic analyzer. 41 // \param Call The call to the builtin function to be analyzed. 42 // \return True if a semantic error was found, false otherwise. 43 bool checkBuiltinReserveRWPipe(CallExpr *Call); 44 45 bool checkSubgroupExt(CallExpr *Call); 46 47 // Performs a semantic analysis on {work_group_/sub_group_ 48 // /_}commit_{read/write}_pipe 49 // \param S Reference to the semantic analyzer. 50 // \param Call The call to the builtin function to be analyzed. 51 // \return True if a semantic error was found, false otherwise. 52 bool checkBuiltinCommitRWPipe(CallExpr *Call); 53 54 // Performs a semantic analysis on the call to built-in Pipe 55 // Query Functions. 56 // \param S Reference to the semantic analyzer. 57 // \param Call The call to the builtin function to be analyzed. 58 // \return True if a semantic error was found, false otherwise. 59 bool checkBuiltinPipePackets(CallExpr *Call); 60 61 // OpenCL v2.0 s6.13.9 - Address space qualifier functions. 62 // Performs semantic analysis for the to_global/local/private call. 63 // \param S Reference to the semantic analyzer. 64 // \param BuiltinID ID of the builtin function. 65 // \param Call A pointer to the builtin call. 66 // \return True if a semantic error has been found, false otherwise. 67 bool checkBuiltinToAddr(unsigned BuiltinID, CallExpr *Call); 68 69 /// OpenCL C v2.0, s6.13.17 - Enqueue kernel function contains four different 70 /// overload formats specified in Table 6.13.17.1. 71 /// int enqueue_kernel(queue_t queue, 72 /// kernel_enqueue_flags_t flags, 73 /// const ndrange_t ndrange, 74 /// void (^block)(void)) 75 /// int enqueue_kernel(queue_t queue, 76 /// kernel_enqueue_flags_t flags, 77 /// const ndrange_t ndrange, 78 /// uint num_events_in_wait_list, 79 /// clk_event_t *event_wait_list, 80 /// clk_event_t *event_ret, 81 /// void (^block)(void)) 82 /// int enqueue_kernel(queue_t queue, 83 /// kernel_enqueue_flags_t flags, 84 /// const ndrange_t ndrange, 85 /// void (^block)(local void*, ...), 86 /// uint size0, ...) 87 /// int enqueue_kernel(queue_t queue, 88 /// kernel_enqueue_flags_t flags, 89 /// const ndrange_t ndrange, 90 /// uint num_events_in_wait_list, 91 /// clk_event_t *event_wait_list, 92 /// clk_event_t *event_ret, 93 /// void (^block)(local void*, ...), 94 /// uint size0, ...) 95 bool checkBuiltinEnqueueKernel(CallExpr *TheCall); 96 97 /// OpenCL C v2.0, s6.13.17.6 - Check the argument to the 98 /// get_kernel_work_group_size 99 /// and get_kernel_preferred_work_group_size_multiple builtin functions. 100 bool checkBuiltinKernelWorkGroupSize(CallExpr *TheCall); 101 102 bool checkBuiltinNDRangeAndBlock(CallExpr *TheCall); 103 }; 104 105 } // namespace clang 106 107 #endif // LLVM_CLANG_SEMA_SEMAOPENCL_H 108