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/AST/Type.cpp
Show All 40 Lines | |||||
#include "llvm/ADT/APInt.h" | #include "llvm/ADT/APInt.h" | ||||
#include "llvm/ADT/APSInt.h" | #include "llvm/ADT/APSInt.h" | ||||
#include "llvm/ADT/ArrayRef.h" | #include "llvm/ADT/ArrayRef.h" | ||||
#include "llvm/ADT/FoldingSet.h" | #include "llvm/ADT/FoldingSet.h" | ||||
#include "llvm/ADT/SmallVector.h" | #include "llvm/ADT/SmallVector.h" | ||||
#include "llvm/Support/Casting.h" | #include "llvm/Support/Casting.h" | ||||
#include "llvm/Support/ErrorHandling.h" | #include "llvm/Support/ErrorHandling.h" | ||||
#include "llvm/Support/MathExtras.h" | #include "llvm/Support/MathExtras.h" | ||||
#include "llvm/TargetParser/RISCVTargetParser.h" | |||||
#include <algorithm> | #include <algorithm> | ||||
#include <cassert> | #include <cassert> | ||||
#include <cstdint> | #include <cstdint> | ||||
#include <cstring> | #include <cstring> | ||||
#include <optional> | #include <optional> | ||||
#include <type_traits> | #include <type_traits> | ||||
using namespace clang; | using namespace clang; | ||||
▲ Show 20 Lines • Show All 1,866 Lines • ▼ Show 20 Lines | bool Type::hasIntegerRepresentation() const { | ||||
if (const auto *VT = dyn_cast<VectorType>(CanonicalType)) | if (const auto *VT = dyn_cast<VectorType>(CanonicalType)) | ||||
return VT->getElementType()->isIntegerType(); | return VT->getElementType()->isIntegerType(); | ||||
if (CanonicalType->isVLSTBuiltinType()) { | if (CanonicalType->isVLSTBuiltinType()) { | ||||
const auto *VT = cast<BuiltinType>(CanonicalType); | const auto *VT = cast<BuiltinType>(CanonicalType); | ||||
return VT->getKind() == BuiltinType::SveBool || | return VT->getKind() == BuiltinType::SveBool || | ||||
(VT->getKind() >= BuiltinType::SveInt8 && | (VT->getKind() >= BuiltinType::SveInt8 && | ||||
VT->getKind() <= BuiltinType::SveUint64); | VT->getKind() <= BuiltinType::SveUint64); | ||||
} | } | ||||
if (CanonicalType->isRVVVLSBuiltinType()) { | |||||
const auto *VT = cast<BuiltinType>(CanonicalType); | |||||
return (VT->getKind() >= BuiltinType::RvvInt8mf8 && | |||||
VT->getKind() <= BuiltinType::RvvUint64m8); | |||||
} | |||||
return isIntegerType(); | return isIntegerType(); | ||||
} | } | ||||
/// Determine whether this type is an integral type. | /// Determine whether this type is an integral type. | ||||
/// | /// | ||||
/// This routine determines whether the given type is an integral type per | /// This routine determines whether the given type is an integral type per | ||||
/// C++ [basic.fundamental]p7. Although the C standard does not define the | /// C++ [basic.fundamental]p7. Although the C standard does not define the | ||||
▲ Show 20 Lines • Show All 481 Lines • ▼ Show 20 Lines | if (BTy->getKind() == BuiltinType::SveBool) | ||||
// Represent predicates as i8 rather than i1 to avoid any layout issues. | // Represent predicates as i8 rather than i1 to avoid any layout issues. | ||||
// The type is bitcasted to a scalable predicate type when casting between | // The type is bitcasted to a scalable predicate type when casting between | ||||
// scalable and fixed-length vectors. | // scalable and fixed-length vectors. | ||||
return Ctx.UnsignedCharTy; | return Ctx.UnsignedCharTy; | ||||
else | else | ||||
return Ctx.getBuiltinVectorTypeInfo(BTy).ElementType; | return Ctx.getBuiltinVectorTypeInfo(BTy).ElementType; | ||||
} | } | ||||
bool Type::isRVVVLSBuiltinType() const { | |||||
if (const BuiltinType *BT = getAs<BuiltinType>()) { | |||||
switch (BT->getKind()) { | |||||
// FIXME: Support more than LMUL 1. | |||||
#define RVV_VECTOR_TYPE(Name, Id, SingletonId, NumEls, ElBits, NF, IsSigned, IsFP) \ | |||||
case BuiltinType::Id: \ | |||||
return NF == 1 && (NumEls * ElBits) == llvm::RISCV::RVVBitsPerBlock; | |||||
#include "clang/Basic/RISCVVTypes.def" | |||||
default: | |||||
return false; | |||||
} | |||||
} | |||||
return false; | |||||
} | |||||
QualType Type::getRVVEltType(const ASTContext &Ctx) const { | |||||
assert(isRVVVLSBuiltinType() && "unsupported type!"); | |||||
const BuiltinType *BTy = getAs<BuiltinType>(); | |||||
return Ctx.getBuiltinVectorTypeInfo(BTy).ElementType; | |||||
} | |||||
bool QualType::isPODType(const ASTContext &Context) const { | bool QualType::isPODType(const ASTContext &Context) const { | ||||
// C++11 has a more relaxed definition of POD. | // C++11 has a more relaxed definition of POD. | ||||
if (Context.getLangOpts().CPlusPlus11) | if (Context.getLangOpts().CPlusPlus11) | ||||
return isCXX11PODType(Context); | return isCXX11PODType(Context); | ||||
return isCXX98PODType(Context); | return isCXX98PODType(Context); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 2,232 Lines • Show Last 20 Lines |