24#include "llvm/ADT/APSInt.h"
31 const auto *ICE = dyn_cast<ImplicitCastExpr>(Arg->
IgnoreParens());
35 const auto *DR = dyn_cast<DeclRefExpr>(ICE->getSubExpr());
39 const auto *PD = dyn_cast<ParmVarDecl>(DR->getDecl());
40 if (!PD || !PD->getType()->isRecordType())
45 if (
const auto *AA = FD->getAttr<AlignedAttr>()) {
49 Diag(FD->getLocation(), diag::warn_not_xl_compatible) << FD;
50 Diag(
Loc, diag::note_misaligned_member_used_here) << PD;
59 case PPC::BI__builtin_divde:
60 case PPC::BI__builtin_divdeu:
61 case PPC::BI__builtin_bpermd:
62 case PPC::BI__builtin_pdepd:
63 case PPC::BI__builtin_pextd:
64 case PPC::BI__builtin_ppc_cdtbcd:
65 case PPC::BI__builtin_ppc_cbcdtd:
66 case PPC::BI__builtin_ppc_addg6s:
67 case PPC::BI__builtin_ppc_ldarx:
68 case PPC::BI__builtin_ppc_stdcx:
69 case PPC::BI__builtin_ppc_tdw:
70 case PPC::BI__builtin_ppc_trapd:
71 case PPC::BI__builtin_ppc_cmpeqb:
72 case PPC::BI__builtin_ppc_setb:
73 case PPC::BI__builtin_ppc_mulhd:
74 case PPC::BI__builtin_ppc_mulhdu:
75 case PPC::BI__builtin_ppc_maddhd:
76 case PPC::BI__builtin_ppc_maddhdu:
77 case PPC::BI__builtin_ppc_maddld:
78 case PPC::BI__builtin_ppc_load8r:
79 case PPC::BI__builtin_ppc_store8r:
80 case PPC::BI__builtin_ppc_insert_exp:
81 case PPC::BI__builtin_ppc_extract_sig:
82 case PPC::BI__builtin_ppc_addex:
83 case PPC::BI__builtin_darn:
84 case PPC::BI__builtin_darn_raw:
85 case PPC::BI__builtin_ppc_compare_and_swaplp:
86 case PPC::BI__builtin_ppc_fetch_and_addlp:
87 case PPC::BI__builtin_ppc_fetch_and_andlp:
88 case PPC::BI__builtin_ppc_fetch_and_orlp:
89 case PPC::BI__builtin_ppc_fetch_and_swaplp:
102 return Diag(TheCall->
getBeginLoc(), diag::err_64_bit_builtin_32_bit_tgt)
108 case PPC::BI__builtin_ppc_bcdsetsign:
109 case PPC::BI__builtin_ppc_national2packed:
110 case PPC::BI__builtin_ppc_packed2zoned:
111 case PPC::BI__builtin_ppc_zoned2packed:
113 case PPC::BI__builtin_altivec_crypto_vshasigmaw:
114 case PPC::BI__builtin_altivec_crypto_vshasigmad:
117 case PPC::BI__builtin_altivec_dss:
119 case PPC::BI__builtin_tbegin:
120 case PPC::BI__builtin_tend:
122 case PPC::BI__builtin_tsr:
124 case PPC::BI__builtin_tabortwc:
125 case PPC::BI__builtin_tabortdc:
127 case PPC::BI__builtin_tabortwci:
128 case PPC::BI__builtin_tabortdci:
134 case PPC::BI__builtin_unpack_longdouble:
138 case PPC::BI__builtin_pack_longdouble:
140 return Diag(TheCall->
getBeginLoc(), diag::err_ppc_builtin_requires_abi)
143 case PPC::BI__builtin_altivec_dst:
144 case PPC::BI__builtin_altivec_dstt:
145 case PPC::BI__builtin_altivec_dstst:
146 case PPC::BI__builtin_altivec_dststt:
148 case PPC::BI__builtin_vsx_xxpermdi:
149 case PPC::BI__builtin_vsx_xxsldwi:
151 case PPC::BI__builtin_unpack_vector_int128:
153 case PPC::BI__builtin_altivec_vgnb:
155 case PPC::BI__builtin_vsx_xxeval:
157 case PPC::BI__builtin_altivec_vsldbi:
159 case PPC::BI__builtin_altivec_vsrdbi:
161 case PPC::BI__builtin_vsx_xxpermx:
163 case PPC::BI__builtin_ppc_tw:
164 case PPC::BI__builtin_ppc_tdw:
166 case PPC::BI__builtin_ppc_cmprb:
170 case PPC::BI__builtin_ppc_rlwnm:
172 case PPC::BI__builtin_ppc_rlwimi:
175 case PPC::BI__builtin_ppc_rldimi:
178 case PPC::BI__builtin_ppc_addex: {
189 case PPC::BI__builtin_ppc_mtfsb0:
190 case PPC::BI__builtin_ppc_mtfsb1:
192 case PPC::BI__builtin_ppc_mtfsf:
194 case PPC::BI__builtin_ppc_mtfsfi:
197 case PPC::BI__builtin_ppc_alignx:
199 case PPC::BI__builtin_ppc_rdlam:
201 case PPC::BI__builtin_vsx_ldrmb:
202 case PPC::BI__builtin_vsx_strmb:
204 case PPC::BI__builtin_altivec_vcntmbb:
205 case PPC::BI__builtin_altivec_vcntmbh:
206 case PPC::BI__builtin_altivec_vcntmbw:
207 case PPC::BI__builtin_altivec_vcntmbd:
209 case PPC::BI__builtin_vsx_xxgenpcvbm:
210 case PPC::BI__builtin_vsx_xxgenpcvhm:
211 case PPC::BI__builtin_vsx_xxgenpcvwm:
212 case PPC::BI__builtin_vsx_xxgenpcvdm:
214 case PPC::BI__builtin_ppc_test_data_class: {
218 if (ArgType !=
QualType(Context.FloatTy) &&
219 ArgType !=
QualType(Context.DoubleTy) &&
220 ArgType !=
QualType(Context.Float128Ty))
222 diag::err_ppc_invalid_test_data_class_type);
225 case PPC::BI__builtin_ppc_maxfe:
226 case PPC::BI__builtin_ppc_minfe:
227 case PPC::BI__builtin_ppc_maxfl:
228 case PPC::BI__builtin_ppc_minfl:
229 case PPC::BI__builtin_ppc_maxfs:
230 case PPC::BI__builtin_ppc_minfs: {
231 if (Context.getTargetInfo().getTriple().isOSAIX() &&
232 (BuiltinID == PPC::BI__builtin_ppc_maxfe ||
233 BuiltinID == PPC::BI__builtin_ppc_minfe))
235 <<
"builtin" <<
true << 128 <<
QualType(Context.LongDoubleTy)
236 <<
false << Context.getTargetInfo().getTriple().str();
239 if (BuiltinID == PPC::BI__builtin_ppc_maxfl ||
240 BuiltinID == PPC::BI__builtin_ppc_minfl)
241 ArgType =
QualType(Context.DoubleTy);
242 else if (BuiltinID == PPC::BI__builtin_ppc_maxfs ||
243 BuiltinID == PPC::BI__builtin_ppc_minfs)
244 ArgType =
QualType(Context.FloatTy);
245 for (
unsigned I = 0,
E = TheCall->
getNumArgs(); I <
E; ++I)
248 diag::err_typecheck_convert_incompatible)
252#define CUSTOM_BUILTIN(Name, Intr, Types, Acc, Feature) \
253 case PPC::BI__builtin_##Name: \
254 return BuiltinPPCMMACall(TheCall, BuiltinID, Types);
255#include "clang/Basic/BuiltinsPPC.def"
257 llvm_unreachable(
"must return from switch");
267 QualType CoreType =
Type.getCanonicalType().getUnqualifiedType();
268#define PPC_VECTOR_TYPE(Name, Id, Size) || CoreType == Context.Id##Ty
270#include
"clang/Basic/PPCTypes.def"
286 bool RequireICE =
false;
294 unsigned size = strtoul(Str, &End, 10);
295 assert(End != Str &&
"Missing constant parameter constraint");
298 return Context.
IntTy;
302 unsigned size = strtoul(Str, &End, 10);
303 assert(End != Str &&
"Missing PowerPC MMA type size");
307#define PPC_VECTOR_TYPE(typeName, Id, size) \
309 Type = Context.Id##Ty; \
311#include "clang/Basic/PPCTypes.def"
313 llvm_unreachable(
"Invalid PowerPC MMA vector type");
315 bool CheckVectorArgs =
false;
316 while (!CheckVectorArgs) {
325 CheckVectorArgs =
true;
333 return Context.
DecodeTypeStr(--Str, Context, Error, RequireICE,
true);
338 const char *TypeStr) {
340 assert((TypeStr[0] !=
'\0') &&
341 "Invalid types in PPC MMA builtin declaration");
352 while (*TypeStr !=
'\0') {
376 diag::err_typecheck_convert_incompatible)
393 while (*TypeStr !=
'\0') {
404 unsigned ExpectedNumArgs = 3;
411 diag::err_vsx_builtin_nonconstant_argument)
423 return Diag(BuiltinLoc, diag::err_vec_builtin_non_vector)
430 if (!
getASTContext().hasSameUnqualifiedType(Arg1Ty, Arg2Ty)) {
431 return Diag(BuiltinLoc, diag::err_vec_builtin_incompatible_vector)
Defines the clang::ASTContext interface.
This file declares semantic analysis functions specific to PowerPC.
Defines the clang::SourceLocation class and associated facilities.
Enumerates target-specific builtins in their own namespaces within namespace clang.
C Language Family Type Representation.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
QualType getVectorType(QualType VectorType, unsigned NumElts, VectorKind VecKind) const
Return the unique reference to a vector type of the specified element type and size.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
CanQualType UnsignedCharTy
CharUnits toCharUnitsFromBits(int64_t BitSize) const
Convert a size in bits to a size in characters.
QualType DecodeTypeStr(const char *&Str, const ASTContext &Context, ASTContext::GetBuiltinTypeError &Error, bool &RequireICE, bool AllowTypeModifiers) const
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
SourceLocation getBeginLoc() const
FunctionDecl * getDirectCallee()
If the callee is a FunctionDecl, return it. Otherwise return null.
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
CharUnits - This is an opaque type for sizes expressed in character units.
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
This represents one expression.
bool isIntegerConstantExpr(const ASTContext &Ctx) const
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point.
std::optional< llvm::APSInt > getIntegerConstantExpr(const ASTContext &Ctx) const
isIntegerConstantExpr - Return the value if this expression is a valid integer constant expression.
Represents a member of a struct/union/class.
A (possibly-)qualified type.
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
bool isRestrictQualified() const
Determine whether this type is restrict-qualified.
QualType getCanonicalType() const
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
field_range fields() const
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
ASTContext & getASTContext() const
bool CheckPPCBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID, CallExpr *TheCall)
void checkAIXMemberAlignment(SourceLocation Loc, const Expr *Arg)
bool BuiltinPPCMMACall(CallExpr *TheCall, unsigned BuiltinID, const char *TypeDesc)
BuiltinPPCMMACall - Check the call to a PPC MMA builtin for validity.
bool BuiltinVSX(CallExpr *TheCall)
bool CheckPPCMMAType(QualType Type, SourceLocation TypeLoc)
Sema - This implements semantic analysis and AST building for C.
bool ValueIsRunOfOnes(CallExpr *TheCall, unsigned ArgNum)
Returns true if the argument consists of one contiguous run of 1s with any number of 0s on either sid...
bool BuiltinConstantArgPower2(CallExpr *TheCall, int ArgNum)
BuiltinConstantArgPower2 - Check if argument ArgNum of TheCall is a constant expression representing ...
bool checkArgCount(CallExpr *Call, unsigned DesiredArgCount)
Checks that a call expression's argument count is the desired number.
bool BuiltinConstantArgRange(CallExpr *TheCall, int ArgNum, int Low, int High, bool RangeIsError=true)
BuiltinConstantArgRange - Handle a check if argument ArgNum of CallExpr TheCall is a constant express...
Encodes a location in the source.
A trivial tuple used to represent a source range.
SourceLocation getEndLoc() const LLVM_READONLY
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
SourceLocation getBeginLoc() const LLVM_READONLY
Exposes information about the current target.
unsigned getTypeWidth(IntType T) const
Return the width (in bits) of the specified integer type enum.
IntType getIntPtrType() const
const llvm::fltSemantics & getLongDoubleFormat() const
Base wrapper for a particular "section" of type source info.
The base class of the type hierarchy.
bool isPointerType() const
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
RecordDecl * castAsRecordDecl() const
bool isVectorType() const
Defines the clang::TargetInfo interface.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
The JSON file list parser is used to communicate input to InstallAPI.
static bool isPPC_64Builtin(unsigned BuiltinID)
static QualType DecodePPCMMATypeFromStr(ASTContext &Context, const char *&Str, unsigned &Mask)
DecodePPCMMATypeFromStr - This decodes one PPC MMA type descriptor from Str, advancing the pointer ov...
@ AltiVecVector
is AltiVec vector