Please use GitHub pull requests for new patches. Avoid migrating existing patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
clang/lib/Sema/SemaType.cpp
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
Show All 34 Lines | |||||
#include "clang/Sema/SemaInternal.h" | #include "clang/Sema/SemaInternal.h" | ||||
#include "clang/Sema/Template.h" | #include "clang/Sema/Template.h" | ||||
#include "clang/Sema/TemplateInstCallback.h" | #include "clang/Sema/TemplateInstCallback.h" | ||||
#include "llvm/ADT/ArrayRef.h" | #include "llvm/ADT/ArrayRef.h" | ||||
#include "llvm/ADT/SmallPtrSet.h" | #include "llvm/ADT/SmallPtrSet.h" | ||||
#include "llvm/ADT/SmallString.h" | #include "llvm/ADT/SmallString.h" | ||||
#include "llvm/IR/DerivedTypes.h" | #include "llvm/IR/DerivedTypes.h" | ||||
#include "llvm/Support/ErrorHandling.h" | #include "llvm/Support/ErrorHandling.h" | ||||
#include "llvm/TargetParser/RISCVTargetParser.h" | |||||
#include <bitset> | #include <bitset> | ||||
#include <optional> | #include <optional> | ||||
using namespace clang; | using namespace clang; | ||||
enum TypeDiagSelector { | enum TypeDiagSelector { | ||||
TDS_Function, | TDS_Function, | ||||
TDS_Pointer, | TDS_Pointer, | ||||
▲ Show 20 Lines • Show All 8,229 Lines • ▼ Show 20 Lines | static void HandleArmMveStrictPolymorphismAttr(TypeProcessingState &State, | ||||
} | } | ||||
CurType = | CurType = | ||||
State.getAttributedType(createSimpleAttr<ArmMveStrictPolymorphismAttr>( | State.getAttributedType(createSimpleAttr<ArmMveStrictPolymorphismAttr>( | ||||
State.getSema().Context, Attr), | State.getSema().Context, Attr), | ||||
CurType, CurType); | CurType, CurType); | ||||
} | } | ||||
/// HandleRISCVRVVVectorBitsTypeAttr - The "riscv_rvv_vector_bits" attribute is | |||||
/// used to create fixed-length versions of sizeless RVV types such as | |||||
/// vint8m1_t_t. | |||||
static void HandleRISCVRVVVectorBitsTypeAttr(QualType &CurType, | |||||
ParsedAttr &Attr, Sema &S) { | |||||
// Target must have vector extension. | |||||
craig.topper: I need to fix this comment. | |||||
if (!S.Context.getTargetInfo().hasFeature("zve32x")) { | |||||
S.Diag(Attr.getLoc(), diag::err_attribute_unsupported) | |||||
<< Attr << "'zve32x'"; | |||||
Attr.setInvalid(); | |||||
return; | |||||
} | |||||
auto VScale = S.Context.getTargetInfo().getVScaleRange(S.getLangOpts()); | |||||
if (!VScale || !VScale->first || VScale->first != VScale->second) { | |||||
S.Diag(Attr.getLoc(), diag::err_attribute_riscv_rvv_bits_unsupported) | |||||
<< Attr; | |||||
Attr.setInvalid(); | |||||
return; | |||||
} | |||||
// Check the attribute arguments. | |||||
if (Attr.getNumArgs() != 1) { | |||||
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) | |||||
<< Attr << 1; | |||||
Attr.setInvalid(); | |||||
return; | |||||
} | |||||
// The vector size must be an integer constant expression. | |||||
llvm::APSInt RVVVectorSizeInBits(32); | |||||
if (!verifyValidIntegerConstantExpr(S, Attr, RVVVectorSizeInBits)) | |||||
return; | |||||
unsigned VecSize = static_cast<unsigned>(RVVVectorSizeInBits.getZExtValue()); | |||||
// The attribute vector size must match -mrvv-vector-bits. | |||||
Not Done ReplyInline ActionsShould this be done as part of this patch (are we accepting code we shouldn't be accepting)? aaron.ballman: Should this be done as part of this patch (are we accepting code we shouldn't be accepting)? | |||||
No. I need to phrase this FIXME better. I'm only accepting types that have LMUL=1. (length multiplier). This is enforced in Type::isRVVVLSBuiltinType() where there's another FIXME about LMUL=1. craig.topper: No. I need to phrase this FIXME better. I'm only accepting types that have LMUL=1. (length… | |||||
// FIXME: Add support for types with LMUL!=1. Need to make sure size passed | |||||
// to attribute is equal to LMUL*VScaleMin*RVVBitsPerBlock. | |||||
if (VecSize != VScale->first * llvm::RISCV::RVVBitsPerBlock) { | |||||
S.Diag(Attr.getLoc(), diag::err_attribute_bad_rvv_vector_size) | |||||
<< VecSize << VScale->first * llvm::RISCV::RVVBitsPerBlock; | |||||
Attr.setInvalid(); | |||||
return; | |||||
} | |||||
// Attribute can only be attached to a single RVV vector type. | |||||
if (!CurType->isRVVVLSBuiltinType()) { | |||||
S.Diag(Attr.getLoc(), diag::err_attribute_invalid_rvv_type) | |||||
<< Attr << CurType; | |||||
Attr.setInvalid(); | |||||
return; | |||||
} | |||||
QualType EltType = CurType->getRVVEltType(S.Context); | |||||
unsigned TypeSize = S.Context.getTypeSize(EltType); | |||||
VectorType::VectorKind VecKind = VectorType::RVVFixedLengthDataVector; | |||||
VecSize /= TypeSize; | |||||
CurType = S.Context.getVectorType(EltType, VecSize, VecKind); | |||||
} | |||||
/// Handle OpenCL Access Qualifier Attribute. | /// Handle OpenCL Access Qualifier Attribute. | ||||
static void HandleOpenCLAccessAttr(QualType &CurType, const ParsedAttr &Attr, | static void HandleOpenCLAccessAttr(QualType &CurType, const ParsedAttr &Attr, | ||||
Sema &S) { | Sema &S) { | ||||
// OpenCL v2.0 s6.6 - Access qualifier can be used only for image and pipe type. | // OpenCL v2.0 s6.6 - Access qualifier can be used only for image and pipe type. | ||||
if (!(CurType->isImageType() || CurType->isPipeType())) { | if (!(CurType->isImageType() || CurType->isPipeType())) { | ||||
S.Diag(Attr.getLoc(), diag::err_opencl_invalid_access_qualifier); | S.Diag(Attr.getLoc(), diag::err_opencl_invalid_access_qualifier); | ||||
Attr.setInvalid(); | Attr.setInvalid(); | ||||
return; | return; | ||||
▲ Show 20 Lines • Show All 230 Lines • ▼ Show 20 Lines | case ParsedAttr::AT_ArmSveVectorBits: | ||||
HandleArmSveVectorBitsTypeAttr(type, attr, state.getSema()); | HandleArmSveVectorBitsTypeAttr(type, attr, state.getSema()); | ||||
attr.setUsedAsTypeAttr(); | attr.setUsedAsTypeAttr(); | ||||
break; | break; | ||||
case ParsedAttr::AT_ArmMveStrictPolymorphism: { | case ParsedAttr::AT_ArmMveStrictPolymorphism: { | ||||
HandleArmMveStrictPolymorphismAttr(state, type, attr); | HandleArmMveStrictPolymorphismAttr(state, type, attr); | ||||
attr.setUsedAsTypeAttr(); | attr.setUsedAsTypeAttr(); | ||||
break; | break; | ||||
} | } | ||||
case ParsedAttr::AT_RISCVRVVVectorBits: | |||||
HandleRISCVRVVVectorBitsTypeAttr(type, attr, state.getSema()); | |||||
attr.setUsedAsTypeAttr(); | |||||
break; | |||||
case ParsedAttr::AT_OpenCLAccess: | case ParsedAttr::AT_OpenCLAccess: | ||||
HandleOpenCLAccessAttr(type, attr, state.getSema()); | HandleOpenCLAccessAttr(type, attr, state.getSema()); | ||||
attr.setUsedAsTypeAttr(); | attr.setUsedAsTypeAttr(); | ||||
break; | break; | ||||
case ParsedAttr::AT_LifetimeBound: | case ParsedAttr::AT_LifetimeBound: | ||||
if (TAL == TAL_DeclChunk) | if (TAL == TAL_DeclChunk) | ||||
HandleLifetimeBoundAttr(state, type, attr); | HandleLifetimeBoundAttr(state, type, attr); | ||||
break; | break; | ||||
▲ Show 20 Lines • Show All 1,137 Lines • Show Last 20 Lines |
I need to fix this comment.