Skip to content

Commit

Permalink
[AIE] Model accumulators as integer types.
Browse files Browse the repository at this point in the history
  • Loading branch information
SagarMaheshwari99 committed Jan 18, 2025
1 parent 5cdf955 commit a8d7dde
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions clang/include/clang/AST/Type.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// Modifications (c) Copyright 2023-2024 Advanced Micro Devices, Inc. or its
// Modifications (c) Copyright 2023-2025 Advanced Micro Devices, Inc. or its
// affiliates
//
//===----------------------------------------------------------------------===//
Expand Down Expand Up @@ -2670,9 +2670,12 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
/// set of type specifiers.
bool isSpecifierType() const;

/// Returns true if this is a AIE ACC48.
/// Returns true if this is a AIE accumulator type.
bool isAIEAccumulatorType() const;

/// Returns true if this is a AIE integer accumulator type.
bool isAIEIntegerAccumulatorType() const;

/// Determine the linkage of this type.
Linkage getLinkage() const;

Expand Down Expand Up @@ -7745,8 +7748,9 @@ bool IsEnumDeclScoped(EnumDecl *);

inline bool Type::isIntegerType() const {
if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
return BT->getKind() >= BuiltinType::Bool &&
BT->getKind() <= BuiltinType::Int128;
return isAIEIntegerAccumulatorType() ||
(BT->getKind() >= BuiltinType::Bool &&
BT->getKind() <= BuiltinType::Int128);
if (const EnumType *ET = dyn_cast<EnumType>(CanonicalType)) {
// Incomplete enum types are not treated as integer types.
// FIXME: In C++, enum types are never integer types.
Expand Down Expand Up @@ -7803,12 +7807,10 @@ inline bool Type::isUnsignedFixedPointType() const {
}

inline bool Type::isScalarType() const {
if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) {
if (isAIEAccumulatorType())
return true;
return BT->getKind() > BuiltinType::Void &&
BT->getKind() <= BuiltinType::NullPtr;
}
if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
return isAIEAccumulatorType() || (BT->getKind() > BuiltinType::Void &&
BT->getKind() <= BuiltinType::NullPtr);

if (const EnumType *ET = dyn_cast<EnumType>(CanonicalType))
// Enums are scalar types, but only if they are defined. Incomplete enums
// are not treated as scalar types.
Expand All @@ -7823,8 +7825,9 @@ inline bool Type::isScalarType() const {

inline bool Type::isIntegralOrEnumerationType() const {
if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
return BT->getKind() >= BuiltinType::Bool &&
BT->getKind() <= BuiltinType::Int128;
return isAIEIntegerAccumulatorType() ||
(BT->getKind() >= BuiltinType::Bool &&
BT->getKind() <= BuiltinType::Int128);

// Check for a complete enum type; incomplete enum types are not properly an
// enumeration type in the sense required here.
Expand Down Expand Up @@ -7860,10 +7863,14 @@ inline bool Type::isTypedefNameType() const {
return false;
}

inline bool Type::isAIEAccumulatorType() const {
inline bool Type::isAIEIntegerAccumulatorType() const {
return (isSpecificBuiltinType(BuiltinType::ACC32) ||
isSpecificBuiltinType(BuiltinType::ACC48) ||
isSpecificBuiltinType(BuiltinType::ACC64) ||
isSpecificBuiltinType(BuiltinType::ACC64));
}

inline bool Type::isAIEAccumulatorType() const {
return (isAIEIntegerAccumulatorType() ||
isSpecificBuiltinType(BuiltinType::ACCFLOAT));
}

Expand Down

0 comments on commit a8d7dde

Please sign in to comment.