Author: Timm Baeder Date: 2025-06-04T10:07:48+02:00 New Revision: b36e161a09bdebbabe159598778abb011303a9eb
URL: https://github.com/llvm/llvm-project/commit/b36e161a09bdebbabe159598778abb011303a9eb DIFF: https://github.com/llvm/llvm-project/commit/b36e161a09bdebbabe159598778abb011303a9eb.diff LOG: [clang][bytecode][NFC] Cache more integer type sizes (#142720) Added: Modified: clang/lib/AST/ByteCode/Context.cpp clang/lib/AST/ByteCode/Context.h Removed: ################################################################################ diff --git a/clang/lib/AST/ByteCode/Context.cpp b/clang/lib/AST/ByteCode/Context.cpp index 6b8f4e31e4ff9..d73705b6126fe 100644 --- a/clang/lib/AST/ByteCode/Context.cpp +++ b/clang/lib/AST/ByteCode/Context.cpp @@ -22,8 +22,10 @@ using namespace clang; using namespace clang::interp; Context::Context(ASTContext &Ctx) : Ctx(Ctx), P(new Program(*this)) { + this->ShortWidth = Ctx.getTargetInfo().getShortWidth(); this->IntWidth = Ctx.getTargetInfo().getIntWidth(); this->LongWidth = Ctx.getTargetInfo().getLongWidth(); + this->LongLongWidth = Ctx.getTargetInfo().getLongLongWidth(); assert(Ctx.getTargetInfo().getCharWidth() == 8 && "We're assuming 8 bit chars"); } @@ -265,6 +267,11 @@ std::optional<PrimType> Context::classify(QualType T) const { return PT_MemberPtr; // Just trying to avoid the ASTContext::getIntWidth call below. + if (Kind == BuiltinType::Short) + return integralTypeToPrimTypeS(this->ShortWidth); + if (Kind == BuiltinType::UShort) + return integralTypeToPrimTypeU(this->ShortWidth); + if (Kind == BuiltinType::Int) return integralTypeToPrimTypeS(this->IntWidth); if (Kind == BuiltinType::UInt) @@ -273,6 +280,11 @@ std::optional<PrimType> Context::classify(QualType T) const { return integralTypeToPrimTypeS(this->LongWidth); if (Kind == BuiltinType::ULong) return integralTypeToPrimTypeU(this->LongWidth); + if (Kind == BuiltinType::LongLong) + return integralTypeToPrimTypeS(this->LongLongWidth); + if (Kind == BuiltinType::ULongLong) + return integralTypeToPrimTypeU(this->LongLongWidth); + if (Kind == BuiltinType::SChar || Kind == BuiltinType::Char_S) return integralTypeToPrimTypeS(8); if (Kind == BuiltinType::UChar || Kind == BuiltinType::Char_U || diff --git a/clang/lib/AST/ByteCode/Context.h b/clang/lib/AST/ByteCode/Context.h index 9a604ce8ebbe9..5898ab5e54599 100644 --- a/clang/lib/AST/ByteCode/Context.h +++ b/clang/lib/AST/ByteCode/Context.h @@ -138,8 +138,10 @@ class Context final { /// ID identifying an evaluation. unsigned EvalID = 0; /// Cached widths (in bits) of common types, for a faster classify(). + unsigned ShortWidth; unsigned IntWidth; unsigned LongWidth; + unsigned LongLongWidth; }; } // namespace interp _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits