1 //===- Types.cpp - Helper for the selection of C++ data types. ------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
11 // For LLVM_ATTRIBUTE_UNUSED
12 #include "llvm/Support/Compiler.h"
18 const char *llvm::getMinimalTypeForRange(uint64_t Range, unsigned MaxSize LLVM_ATTRIBUTE_UNUSED) {
19 // TODO: The original callers only used 32 and 64 so these are the only
20 // values permitted. Rather than widen the supported values we should
21 // allow 64 for the callers that currently use 32 and remove the
22 // argument altogether.
23 assert((MaxSize == 32 || MaxSize == 64) && "Unexpected size");
24 assert(MaxSize <= 64 && "Unexpected size");
25 assert(((MaxSize > 32) ? Range <= 0xFFFFFFFFFFFFFFFFULL
26 : Range <= 0xFFFFFFFFULL) &&
29 if (Range > 0xFFFFFFFFULL)
38 const char *llvm::getMinimalTypeForEnumBitfield(uint64_t Size) {
39 uint64_t MaxIndex = Size;
42 assert(MaxIndex <= 64 && "Too many bits");
43 return getMinimalTypeForRange(1ULL << MaxIndex);