From 62eaf7ef60f607112f54580df6d0e8ced4ef9e62 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 29 Oct 2002 21:47:50 +0000 Subject: [PATCH] Implement findOptimalStorageSize a bit more generally git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4416 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/TargetMachine.cpp | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/lib/Target/TargetMachine.cpp b/lib/Target/TargetMachine.cpp index 2d0d330d8db..f50580332a6 100644 --- a/lib/Target/TargetMachine.cpp +++ b/lib/Target/TargetMachine.cpp @@ -25,21 +25,13 @@ // space equal to optSizeForSubWordData, and all other primitive data // items use space according to the type. // -unsigned int -TargetMachine::findOptimalStorageSize(const Type* ty) const -{ - switch(ty->getPrimitiveID()) - { - case Type::BoolTyID: - case Type::UByteTyID: - case Type::SByteTyID: - case Type::UShortTyID: - case Type::ShortTyID: - return optSizeForSubWordData; - - default: - return DataLayout.getTypeSize(ty); - } +unsigned TargetMachine::findOptimalStorageSize(const Type *Ty) const { + // Round integral values smaller than SubWordDataSize up to SubWordDataSize + if (Ty->isIntegral() && + Ty->getPrimitiveSize() < DataLayout.getSubWordDataSize()) + return DataLayout.getSubWordDataSize(); + + return DataLayout.getTypeSize(Ty); } -- 2.34.1