18#include "llvm/Support/AtomicOrdering.h"
28 unsigned OrderIndex, ScopeIndex;
30 case AMDGPU::BI__builtin_amdgcn_global_load_lds: {
31 constexpr const int SizeIdx = 2;
37 switch (Size.getSExtValue()) {
44 diag::err_amdgcn_global_load_lds_size_invalid_value)
47 diag::note_amdgcn_global_load_lds_size_valid_value)
52 case AMDGPU::BI__builtin_amdgcn_get_fpenv:
53 case AMDGPU::BI__builtin_amdgcn_set_fpenv:
55 case AMDGPU::BI__builtin_amdgcn_atomic_inc32:
56 case AMDGPU::BI__builtin_amdgcn_atomic_inc64:
57 case AMDGPU::BI__builtin_amdgcn_atomic_dec32:
58 case AMDGPU::BI__builtin_amdgcn_atomic_dec64:
62 case AMDGPU::BI__builtin_amdgcn_fence:
71 auto ArgExpr = Arg.
get();
75 return Diag(ArgExpr->getExprLoc(), diag::err_typecheck_expect_int)
76 << ArgExpr->getType();
77 auto Ord = ArgResult.
Val.
getInt().getZExtValue();
81 if (!llvm::isValidAtomicOrderingCABI(Ord))
82 return Diag(ArgExpr->getBeginLoc(),
83 diag::warn_atomic_op_has_invalid_memory_order)
84 << 0 << ArgExpr->getSourceRange();
85 switch (
static_cast<llvm::AtomicOrderingCABI
>(Ord)) {
86 case llvm::AtomicOrderingCABI::relaxed:
87 case llvm::AtomicOrderingCABI::consume:
88 if (BuiltinID == AMDGPU::BI__builtin_amdgcn_fence)
89 return Diag(ArgExpr->getBeginLoc(),
90 diag::warn_atomic_op_has_invalid_memory_order)
91 << 0 << ArgExpr->getSourceRange();
93 case llvm::AtomicOrderingCABI::acquire:
94 case llvm::AtomicOrderingCABI::release:
95 case llvm::AtomicOrderingCABI::acq_rel:
96 case llvm::AtomicOrderingCABI::seq_cst:
100 Arg = TheCall->
getArg(ScopeIndex);
104 if (!ArgExpr->EvaluateAsConstantExpr(ArgResult1,
getASTContext()))
105 return Diag(ArgExpr->getExprLoc(), diag::err_expr_not_string_literal)
106 << ArgExpr->getType();
113 const AMDGPUFlatWorkGroupSizeAttr &
Attr) {
127 if (
Min == 0 &&
Max != 0) {
141AMDGPUFlatWorkGroupSizeAttr *
145 AMDGPUFlatWorkGroupSizeAttr TmpAttr(Context, CI, MinExpr, MaxExpr);
149 return ::new (Context)
150 AMDGPUFlatWorkGroupSizeAttr(Context, CI, MinExpr, MaxExpr);
170 const AMDGPUWavesPerEUAttr &
Attr) {
188 if (
Min == 0 &&
Max != 0) {
202AMDGPUWavesPerEUAttr *
206 AMDGPUWavesPerEUAttr TmpAttr(Context, CI, MinExpr, MaxExpr);
211 return ::new (Context) AMDGPUWavesPerEUAttr(Context, CI, MinExpr, MaxExpr);
231 uint32_t NumSGPR = 0;
241 uint32_t NumVGPR = 0;
253 const AMDGPUMaxNumWorkGroupsAttr &
Attr) {
266 Expr *Exprs[3] = {XExpr, YExpr, ZExpr};
267 for (
int i = 0; i < 3; i++) {
286 AMDGPUMaxNumWorkGroupsAttr TmpAttr(Context, CI, XExpr, YExpr, ZExpr);
292 return ::new (Context)
293 AMDGPUMaxNumWorkGroupsAttr(Context, CI, XExpr, YExpr, ZExpr);
This file declares semantic analysis functions specific to AMDGPU.
Enumerates target-specific builtins in their own namespaces within namespace clang.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Attr - This represents one attribute.
SourceLocation getLocation() const
SourceLocation getLoc() const
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
Decl - This represents one declaration (or definition), e.g.
This represents one expression.
bool isValueDependent() const
Determines whether the value of this expression depends on.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
ParsedAttr - Represents a syntactic attribute.
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this attribute.
Expr * getArgAsExpr(unsigned Arg) const
bool checkAtLeastNumArgs(class Sema &S, unsigned Num) const
Check if the attribute has at least as many args as Num.
bool checkAtMostNumArgs(class Sema &S, unsigned Num) const
Check if the attribute has at most as many args as Num.
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...
void handleAMDGPUFlatWorkGroupSizeAttr(Decl *D, const ParsedAttr &AL)
void handleAMDGPUNumSGPRAttr(Decl *D, const ParsedAttr &AL)
AMDGPUMaxNumWorkGroupsAttr * CreateAMDGPUMaxNumWorkGroupsAttr(const AttributeCommonInfo &CI, Expr *XExpr, Expr *YExpr, Expr *ZExpr)
Create an AMDGPUMaxNumWorkGroupsAttr attribute.
AMDGPUWavesPerEUAttr * CreateAMDGPUWavesPerEUAttr(const AttributeCommonInfo &CI, Expr *Min, Expr *Max)
Create an AMDGPUWavesPerEUAttr attribute.
void handleAMDGPUNumVGPRAttr(Decl *D, const ParsedAttr &AL)
AMDGPUFlatWorkGroupSizeAttr * CreateAMDGPUFlatWorkGroupSizeAttr(const AttributeCommonInfo &CI, Expr *Min, Expr *Max)
Create an AMDGPUWavesPerEUAttr attribute.
void handleAMDGPUWavesPerEUAttr(Decl *D, const ParsedAttr &AL)
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...
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
ASTContext & getASTContext() const
Sema - This implements semantic analysis and AST building for C.
ExprResult VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result, VerifyICEDiagnoser &Diagnoser, AllowFoldKind CanFold=NoFold)
VerifyIntegerConstantExpression - Verifies that an expression is an ICE, and reports the appropriate ...
bool DiagnoseUnexpandedParameterPack(SourceLocation Loc, TypeSourceInfo *T, UnexpandedParameterPackContext UPPC)
If the given type contains an unexpanded parameter pack, diagnose the error.
bool checkUInt32Argument(const AttrInfo &AI, const Expr *Expr, uint32_t &Val, unsigned Idx=UINT_MAX, bool StrictlyUnsigned=false)
If Expr is a valid integer constant, get the value of the integer expression and return success or fa...
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
The JSON file list parser is used to communicate input to InstallAPI.
static bool checkAMDGPUMaxNumWorkGroupsArguments(Sema &S, Expr *XExpr, Expr *YExpr, Expr *ZExpr, const AMDGPUMaxNumWorkGroupsAttr &Attr)
static bool checkAMDGPUFlatWorkGroupSizeArguments(Sema &S, Expr *MinExpr, Expr *MaxExpr, const AMDGPUFlatWorkGroupSizeAttr &Attr)
static bool checkAMDGPUWavesPerEUArguments(Sema &S, Expr *MinExpr, Expr *MaxExpr, const AMDGPUWavesPerEUAttr &Attr)
EvalResult is a struct with detailed info about an evaluated expression.
APValue Val
Val - This is the value the expression can be folded to.