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())
46 if (
const auto *AA = FD->getAttr<AlignedAttr>()) {
50 Diag(FD->getLocation(), diag::warn_not_xl_compatible) << FD;
51 Diag(
Loc, diag::note_misaligned_member_used_here) << PD;
60 case PPC::BI__builtin_divde:
61 case PPC::BI__builtin_divdeu:
62 case PPC::BI__builtin_bpermd:
63 case PPC::BI__builtin_pdepd:
64 case PPC::BI__builtin_pextd:
65 case PPC::BI__builtin_ppc_cdtbcd:
66 case PPC::BI__builtin_ppc_cbcdtd:
67 case PPC::BI__builtin_ppc_addg6s:
68 case PPC::BI__builtin_ppc_ldarx:
69 case PPC::BI__builtin_ppc_stdcx:
70 case PPC::BI__builtin_ppc_tdw:
71 case PPC::BI__builtin_ppc_trapd:
72 case PPC::BI__builtin_ppc_cmpeqb:
73 case PPC::BI__builtin_ppc_setb:
74 case PPC::BI__builtin_ppc_mulhd:
75 case PPC::BI__builtin_ppc_mulhdu:
76 case PPC::BI__builtin_ppc_maddhd:
77 case PPC::BI__builtin_ppc_maddhdu:
78 case PPC::BI__builtin_ppc_maddld:
79 case PPC::BI__builtin_ppc_load8r:
80 case PPC::BI__builtin_ppc_store8r:
81 case PPC::BI__builtin_ppc_insert_exp:
82 case PPC::BI__builtin_ppc_extract_sig:
83 case PPC::BI__builtin_ppc_addex:
84 case PPC::BI__builtin_darn:
85 case PPC::BI__builtin_darn_raw:
86 case PPC::BI__builtin_ppc_compare_and_swaplp:
87 case PPC::BI__builtin_ppc_fetch_and_addlp:
88 case PPC::BI__builtin_ppc_fetch_and_andlp:
89 case PPC::BI__builtin_ppc_fetch_and_orlp:
90 case PPC::BI__builtin_ppc_fetch_and_swaplp:
104 return Diag(TheCall->
getBeginLoc(), diag::err_64_bit_builtin_32_bit_tgt)
110 case PPC::BI__builtin_altivec_crypto_vshasigmaw:
111 case PPC::BI__builtin_altivec_crypto_vshasigmad:
114 case PPC::BI__builtin_altivec_dss:
116 case PPC::BI__builtin_tbegin:
117 case PPC::BI__builtin_tend:
119 case PPC::BI__builtin_tsr:
121 case PPC::BI__builtin_tabortwc:
122 case PPC::BI__builtin_tabortdc:
124 case PPC::BI__builtin_tabortwci:
125 case PPC::BI__builtin_tabortdci:
131 case PPC::BI__builtin_unpack_longdouble:
135 case PPC::BI__builtin_pack_longdouble:
137 return Diag(TheCall->
getBeginLoc(), diag::err_ppc_builtin_requires_abi)
140 case PPC::BI__builtin_altivec_dst:
141 case PPC::BI__builtin_altivec_dstt:
142 case PPC::BI__builtin_altivec_dstst:
143 case PPC::BI__builtin_altivec_dststt:
145 case PPC::BI__builtin_vsx_xxpermdi:
146 case PPC::BI__builtin_vsx_xxsldwi:
148 case PPC::BI__builtin_unpack_vector_int128:
150 case PPC::BI__builtin_altivec_vgnb:
152 case PPC::BI__builtin_vsx_xxeval:
154 case PPC::BI__builtin_altivec_vsldbi:
156 case PPC::BI__builtin_altivec_vsrdbi:
158 case PPC::BI__builtin_vsx_xxpermx:
160 case PPC::BI__builtin_ppc_tw:
161 case PPC::BI__builtin_ppc_tdw:
163 case PPC::BI__builtin_ppc_cmprb:
167 case PPC::BI__builtin_ppc_rlwnm:
169 case PPC::BI__builtin_ppc_rlwimi:
172 case PPC::BI__builtin_ppc_rldimi:
175 case PPC::BI__builtin_ppc_addex: {
186 case PPC::BI__builtin_ppc_mtfsb0:
187 case PPC::BI__builtin_ppc_mtfsb1:
189 case PPC::BI__builtin_ppc_mtfsf:
191 case PPC::BI__builtin_ppc_mtfsfi:
194 case PPC::BI__builtin_ppc_alignx:
196 case PPC::BI__builtin_ppc_rdlam:
198 case PPC::BI__builtin_vsx_ldrmb:
199 case PPC::BI__builtin_vsx_strmb:
201 case PPC::BI__builtin_altivec_vcntmbb:
202 case PPC::BI__builtin_altivec_vcntmbh:
203 case PPC::BI__builtin_altivec_vcntmbw:
204 case PPC::BI__builtin_altivec_vcntmbd:
206 case PPC::BI__builtin_vsx_xxgenpcvbm:
207 case PPC::BI__builtin_vsx_xxgenpcvhm:
208 case PPC::BI__builtin_vsx_xxgenpcvwm:
209 case PPC::BI__builtin_vsx_xxgenpcvdm:
211 case PPC::BI__builtin_ppc_test_data_class: {
215 if (ArgType !=
QualType(Context.FloatTy) &&
216 ArgType !=
QualType(Context.DoubleTy) &&
217 ArgType !=
QualType(Context.Float128Ty))
219 diag::err_ppc_invalid_test_data_class_type);
222 case PPC::BI__builtin_ppc_maxfe:
223 case PPC::BI__builtin_ppc_minfe:
224 case PPC::BI__builtin_ppc_maxfl:
225 case PPC::BI__builtin_ppc_minfl:
226 case PPC::BI__builtin_ppc_maxfs:
227 case PPC::BI__builtin_ppc_minfs: {
228 if (Context.getTargetInfo().getTriple().isOSAIX() &&
229 (BuiltinID == PPC::BI__builtin_ppc_maxfe ||
230 BuiltinID == PPC::BI__builtin_ppc_minfe))
232 <<
"builtin" <<
true << 128 <<
QualType(Context.LongDoubleTy)
233 <<
false << Context.getTargetInfo().getTriple().str();
236 if (BuiltinID == PPC::BI__builtin_ppc_maxfl ||
237 BuiltinID == PPC::BI__builtin_ppc_minfl)
238 ArgType =
QualType(Context.DoubleTy);
239 else if (BuiltinID == PPC::BI__builtin_ppc_maxfs ||
240 BuiltinID == PPC::BI__builtin_ppc_minfs)
241 ArgType =
QualType(Context.FloatTy);
242 for (
unsigned I = 0,
E = TheCall->
getNumArgs(); I <
E; ++I)
245 diag::err_typecheck_convert_incompatible)
249#define CUSTOM_BUILTIN(Name, Intr, Types, Acc, Feature) \
250 case PPC::BI__builtin_##Name: \
251 return BuiltinPPCMMACall(TheCall, BuiltinID, Types);
252#include "clang/Basic/BuiltinsPPC.def"
254 llvm_unreachable(
"must return from switch");
264 QualType CoreType =
Type.getCanonicalType().getUnqualifiedType();
265#define PPC_VECTOR_TYPE(Name, Id, Size) || CoreType == Context.Id##Ty
267#include
"clang/Basic/PPCTypes.def"
283 bool RequireICE =
false;
291 unsigned size = strtoul(Str, &End, 10);
292 assert(End != Str &&
"Missing constant parameter constraint");
295 return Context.
IntTy;
299 unsigned size = strtoul(Str, &End, 10);
300 assert(End != Str &&
"Missing PowerPC MMA type size");
304#define PPC_VECTOR_TYPE(typeName, Id, size) \
306 Type = Context.Id##Ty; \
308#include "clang/Basic/PPCTypes.def"
310 llvm_unreachable(
"Invalid PowerPC MMA vector type");
312 bool CheckVectorArgs =
false;
313 while (!CheckVectorArgs) {
322 CheckVectorArgs =
true;
330 return Context.
DecodeTypeStr(--Str, Context, Error, RequireICE,
true);
335 const char *TypeStr) {
337 assert((TypeStr[0] !=
'\0') &&
338 "Invalid types in PPC MMA builtin declaration");
349 while (*TypeStr !=
'\0') {
373 diag::err_typecheck_convert_incompatible)
390 while (*TypeStr !=
'\0') {
401 unsigned ExpectedNumArgs = 3;
408 diag::err_vsx_builtin_nonconstant_argument)
420 return Diag(BuiltinLoc, diag::err_vec_builtin_non_vector)
427 if (!
getASTContext().hasSameUnqualifiedType(Arg1Ty, Arg2Ty)) {
428 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 LLVM_READONLY
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.
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point.
bool isIntegerConstantExpr(const ASTContext &Ctx, SourceLocation *Loc=nullptr) const
std::optional< llvm::APSInt > getIntegerConstantExpr(const ASTContext &Ctx, SourceLocation *Loc=nullptr) 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
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
RecordDecl * getDecl() 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
const T * castAs() const
Member-template castAs<specific type>.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
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)
@ Result
The result type of a method or function.
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