clang 23.0.0git
SemaAMDGPU.h
Go to the documentation of this file.
1//===----- SemaAMDGPU.h --- AMDGPU target-specific routines ---*- C++ -*---===//
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 functions specific to AMDGPU.
10///
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_CLANG_SEMA_SEMAAMDGPU_H
14#define LLVM_CLANG_SEMA_SEMAAMDGPU_H
15
16#include "clang/AST/ASTFwd.h"
17#include "clang/Sema/SemaBase.h"
18#include "llvm/ADT/SmallPtrSet.h"
19
20namespace clang {
22class Expr;
23class ParsedAttr;
24
25class SemaAMDGPU : public SemaBase {
26 llvm::SmallPtrSet<Expr *, 32> ExpandedPredicates;
27 llvm::SmallPtrSet<FunctionDecl *, 32> PotentiallyUnguardedBuiltinUsers;
28
29public:
30 SemaAMDGPU(Sema &S);
31
32 bool CheckAMDGCNBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
33
34 /// Emits a diagnostic if the \p E is not an atomic ordering encoded in the C
35 /// ABI format, or if the atomic ordering is not valid for the operation type
36 /// as defined by \p MayLoad and \p MayStore. \returns true if a diagnostic
37 /// was emitted.
38 bool checkAtomicOrderingCABIArg(Expr *E, bool MayLoad, bool MayStore);
39
40 bool checkCoopAtomicFunctionCall(CallExpr *TheCall, bool IsStore);
41 bool checkAVLoadStore(CallExpr *TheCall, bool IsStore);
42 bool checkAtomicMonitorLoad(CallExpr *TheCall);
43
44 bool checkMovDPPFunctionCall(CallExpr *TheCall, unsigned NumArgs,
45 unsigned NumDataArgs);
46
47 /// Create an AMDGPUWavesPerEUAttr attribute.
48 AMDGPUFlatWorkGroupSizeAttr *
50 Expr *Max);
51
52 /// addAMDGPUFlatWorkGroupSizeAttr - Adds an amdgpu_flat_work_group_size
53 /// attribute to a particular declaration.
55 Expr *Min, Expr *Max);
56
57 /// Create an AMDGPUWavesPerEUAttr attribute.
58 AMDGPUWavesPerEUAttr *
60 Expr *Max);
61
62 /// addAMDGPUWavePersEUAttr - Adds an amdgpu_waves_per_eu attribute to a
63 /// particular declaration.
65 Expr *Min, Expr *Max);
66
67 /// Create an AMDGPUMaxNumWorkGroupsAttr attribute.
68 AMDGPUMaxNumWorkGroupsAttr *
70 Expr *YExpr, Expr *ZExpr);
71
72 /// addAMDGPUMaxNumWorkGroupsAttr - Adds an amdgpu_max_num_work_groups
73 /// attribute to a particular declaration.
75 Expr *XExpr, Expr *YExpr, Expr *ZExpr);
76
77 void handleAMDGPUWavesPerEUAttr(Decl *D, const ParsedAttr &AL);
78 void handleAMDGPUNumSGPRAttr(Decl *D, const ParsedAttr &AL);
79 void handleAMDGPUNumVGPRAttr(Decl *D, const ParsedAttr &AL);
82
83 /// Expand a valid use of the feature identification builtins into its
84 /// corresponding sequence of instructions.
86 bool IsPredicate(Expr *E) const;
87 /// Diagnose unguarded usages of AMDGPU builtins and recommend guarding with
88 /// __builtin_amdgcn_is_invocable
92};
93} // namespace clang
94
95#endif // LLVM_CLANG_SEMA_SEMAAMDGPU_H
Forward declaration of all AST node types.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition Expr.h:2946
Decl - This represents one declaration (or definition), e.g.
Definition DeclBase.h:86
This represents one expression.
Definition Expr.h:112
Represents a function declaration or definition.
Definition Decl.h:2018
ParsedAttr - Represents a syntactic attribute.
Definition ParsedAttr.h:119
void handleAMDGPUMaxNumWorkGroupsAttr(Decl *D, const ParsedAttr &AL)
void addAMDGPUFlatWorkGroupSizeAttr(Decl *D, const AttributeCommonInfo &CI, Expr *Min, Expr *Max)
addAMDGPUFlatWorkGroupSizeAttr - Adds an amdgpu_flat_work_group_size attribute to a particular declar...
bool checkCoopAtomicFunctionCall(CallExpr *TheCall, bool IsStore)
bool HasPotentiallyUnguardedBuiltinUsage(FunctionDecl *FD) const
void handleAMDGPUFlatWorkGroupSizeAttr(Decl *D, const ParsedAttr &AL)
bool checkAVLoadStore(CallExpr *TheCall, bool IsStore)
bool checkAtomicMonitorLoad(CallExpr *TheCall)
bool checkAtomicOrderingCABIArg(Expr *E, bool MayLoad, bool MayStore)
Emits a diagnostic if the E is not an atomic ordering encoded in the C ABI format,...
void handleAMDGPUNumSGPRAttr(Decl *D, const ParsedAttr &AL)
AMDGPUMaxNumWorkGroupsAttr * CreateAMDGPUMaxNumWorkGroupsAttr(const AttributeCommonInfo &CI, Expr *XExpr, Expr *YExpr, Expr *ZExpr)
Create an AMDGPUMaxNumWorkGroupsAttr attribute.
Expr * ExpandAMDGPUPredicateBuiltIn(Expr *CE)
Expand a valid use of the feature identification builtins into its corresponding sequence of instruct...
AMDGPUWavesPerEUAttr * CreateAMDGPUWavesPerEUAttr(const AttributeCommonInfo &CI, Expr *Min, Expr *Max)
Create an AMDGPUWavesPerEUAttr attribute.
void DiagnoseUnguardedBuiltinUsage(FunctionDecl *FD)
void handleAMDGPUNumVGPRAttr(Decl *D, const ParsedAttr &AL)
AMDGPUFlatWorkGroupSizeAttr * CreateAMDGPUFlatWorkGroupSizeAttr(const AttributeCommonInfo &CI, Expr *Min, Expr *Max)
Create an AMDGPUWavesPerEUAttr attribute.
void AddPotentiallyUnguardedBuiltinUser(FunctionDecl *FD)
Diagnose unguarded usages of AMDGPU builtins and recommend guarding with __builtin_amdgcn_is_invocabl...
bool checkMovDPPFunctionCall(CallExpr *TheCall, unsigned NumArgs, unsigned NumDataArgs)
void handleAMDGPUWavesPerEUAttr(Decl *D, const ParsedAttr &AL)
bool IsPredicate(Expr *E) const
bool CheckAMDGCNBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall)
void addAMDGPUWavesPerEUAttr(Decl *D, const AttributeCommonInfo &CI, Expr *Min, Expr *Max)
addAMDGPUWavePersEUAttr - Adds an amdgpu_waves_per_eu attribute to a particular declaration.
void addAMDGPUMaxNumWorkGroupsAttr(Decl *D, const AttributeCommonInfo &CI, Expr *XExpr, Expr *YExpr, Expr *ZExpr)
addAMDGPUMaxNumWorkGroupsAttr - Adds an amdgpu_max_num_work_groups attribute to a particular declarat...
SemaBase(Sema &S)
Definition SemaBase.cpp:7
Sema - This implements semantic analysis and AST building for C.
Definition Sema.h:868
The JSON file list parser is used to communicate input to InstallAPI.