23#include "llvm/ADT/APSInt.h"
30 const auto *ICE = dyn_cast<ImplicitCastExpr>(Arg->
IgnoreParens());
34 const auto *DR = dyn_cast<DeclRefExpr>(ICE->getSubExpr());
38 const auto *PD = dyn_cast<ParmVarDecl>(DR->getDecl());
39 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:
103 return Diag(TheCall->
getBeginLoc(), diag::err_64_bit_builtin_32_bit_tgt)
109 case PPC::BI__builtin_altivec_crypto_vshasigmaw:
110 case PPC::BI__builtin_altivec_crypto_vshasigmad:
113 case PPC::BI__builtin_altivec_dss:
115 case PPC::BI__builtin_tbegin:
116 case PPC::BI__builtin_tend:
118 case PPC::BI__builtin_tsr:
120 case PPC::BI__builtin_tabortwc:
121 case PPC::BI__builtin_tabortdc:
123 case PPC::BI__builtin_tabortwci:
124 case PPC::BI__builtin_tabortdci:
130 case PPC::BI__builtin_unpack_longdouble:
134 case PPC::BI__builtin_pack_longdouble:
136 return Diag(TheCall->
getBeginLoc(), diag::err_ppc_builtin_requires_abi)
139 case PPC::BI__builtin_altivec_dst:
140 case PPC::BI__builtin_altivec_dstt:
141 case PPC::BI__builtin_altivec_dstst:
142 case PPC::BI__builtin_altivec_dststt:
144 case PPC::BI__builtin_vsx_xxpermdi:
145 case PPC::BI__builtin_vsx_xxsldwi:
147 case PPC::BI__builtin_unpack_vector_int128:
149 case PPC::BI__builtin_altivec_vgnb:
151 case PPC::BI__builtin_vsx_xxeval:
153 case PPC::BI__builtin_altivec_vsldbi:
155 case PPC::BI__builtin_altivec_vsrdbi:
157 case PPC::BI__builtin_vsx_xxpermx:
159 case PPC::BI__builtin_ppc_tw:
160 case PPC::BI__builtin_ppc_tdw:
162 case PPC::BI__builtin_ppc_cmprb:
166 case PPC::BI__builtin_ppc_rlwnm:
168 case PPC::BI__builtin_ppc_rlwimi:
171 case PPC::BI__builtin_ppc_rldimi:
174 case PPC::BI__builtin_ppc_addex: {
185 case PPC::BI__builtin_ppc_mtfsb0:
186 case PPC::BI__builtin_ppc_mtfsb1:
188 case PPC::BI__builtin_ppc_mtfsf:
190 case PPC::BI__builtin_ppc_mtfsfi:
193 case PPC::BI__builtin_ppc_alignx:
195 case PPC::BI__builtin_ppc_rdlam:
197 case PPC::BI__builtin_vsx_ldrmb:
198 case PPC::BI__builtin_vsx_strmb:
200 case PPC::BI__builtin_altivec_vcntmbb:
201 case PPC::BI__builtin_altivec_vcntmbh:
202 case PPC::BI__builtin_altivec_vcntmbw:
203 case PPC::BI__builtin_altivec_vcntmbd:
205 case PPC::BI__builtin_vsx_xxgenpcvbm:
206 case PPC::BI__builtin_vsx_xxgenpcvhm:
207 case PPC::BI__builtin_vsx_xxgenpcvwm:
208 case PPC::BI__builtin_vsx_xxgenpcvdm:
210 case PPC::BI__builtin_ppc_test_data_class: {
214 if (ArgType !=
QualType(Context.FloatTy) &&
215 ArgType !=
QualType(Context.DoubleTy) &&
216 ArgType !=
QualType(Context.Float128Ty))
218 diag::err_ppc_invalid_test_data_class_type);
221 case PPC::BI__builtin_ppc_maxfe:
222 case PPC::BI__builtin_ppc_minfe:
223 case PPC::BI__builtin_ppc_maxfl:
224 case PPC::BI__builtin_ppc_minfl:
225 case PPC::BI__builtin_ppc_maxfs:
226 case PPC::BI__builtin_ppc_minfs: {
227 if (Context.getTargetInfo().getTriple().isOSAIX() &&
228 (BuiltinID == PPC::BI__builtin_ppc_maxfe ||
229 BuiltinID == PPC::BI__builtin_ppc_minfe))
231 <<
"builtin" <<
true << 128 <<
QualType(Context.LongDoubleTy)
232 <<
false << Context.getTargetInfo().getTriple().str();
235 if (BuiltinID == PPC::BI__builtin_ppc_maxfl ||
236 BuiltinID == PPC::BI__builtin_ppc_minfl)
237 ArgType =
QualType(Context.DoubleTy);
238 else if (BuiltinID == PPC::BI__builtin_ppc_maxfs ||
239 BuiltinID == PPC::BI__builtin_ppc_minfs)
240 ArgType =
QualType(Context.FloatTy);
241 for (
unsigned I = 0,
E = TheCall->
getNumArgs(); I <
E; ++I)
244 diag::err_typecheck_convert_incompatible)
248#define CUSTOM_BUILTIN(Name, Intr, Types, Acc, Feature) \
249 case PPC::BI__builtin_##Name: \
250 return BuiltinPPCMMACall(TheCall, BuiltinID, Types);
251#include "clang/Basic/BuiltinsPPC.def"
253 llvm_unreachable(
"must return from switch");
263 QualType CoreType =
Type.getCanonicalType().getUnqualifiedType();
264#define PPC_VECTOR_TYPE(Name, Id, Size) || CoreType == Context.Id##Ty
266#include
"clang/Basic/PPCTypes.def"
282 bool RequireICE =
false;
290 unsigned size = strtoul(Str, &End, 10);
291 assert(End != Str &&
"Missing constant parameter constraint");
294 return Context.
IntTy;
298 unsigned size = strtoul(Str, &End, 10);
299 assert(End != Str &&
"Missing PowerPC MMA type size");
303#define PPC_VECTOR_TYPE(typeName, Id, size) \
305 Type = Context.Id##Ty; \
307#include "clang/Basic/PPCTypes.def"
309 llvm_unreachable(
"Invalid PowerPC MMA vector type");
311 bool CheckVectorArgs =
false;
312 while (!CheckVectorArgs) {
321 CheckVectorArgs =
true;
329 return Context.
DecodeTypeStr(--Str, Context, Error, RequireICE,
true);
334 const char *TypeStr) {
336 assert((TypeStr[0] !=
'\0') &&
337 "Invalid types in PPC MMA builtin declaration");
348 while (*TypeStr !=
'\0') {
372 diag::err_typecheck_convert_incompatible)
389 while (*TypeStr !=
'\0') {
400 unsigned ExpectedNumArgs = 3;
407 diag::err_vsx_builtin_nonconstant_argument)
419 return Diag(BuiltinLoc, diag::err_vec_builtin_non_vector)
426 if (!
getASTContext().hasSameUnqualifiedType(Arg1Ty, Arg2Ty)) {
427 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
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