forked from llvm-mirror/llvm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[tablegen] Merge duplicate definitions of getMinimalTypeForRange. NFC.
Summary: Depends on D25614 Reviewers: qcolombet Subscribers: qcolombet, beanz, mgorny, llvm-commits Differential Revision: https://reviews.llvm.org/D25617 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@287438 91177308-0d34-0410-b5e6-96231b3b80d8
- Loading branch information
1 parent
c466a4a
commit 90085b5
Showing
6 changed files
with
72 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
//===- Types.cpp - Helper for the selection of C++ data types. ------------===// | ||
// | ||
// The LLVM Compiler Infrastructure | ||
// | ||
// This file is distributed under the University of Illinois Open Source | ||
// License. See LICENSE.TXT for details. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "Types.h" | ||
|
||
// For LLVM_ATTRIBUTE_UNUSED | ||
#include "llvm/Support/Compiler.h" | ||
|
||
#include <cassert> | ||
|
||
using namespace llvm; | ||
|
||
const char *llvm::getMinimalTypeForRange(uint64_t Range, unsigned MaxSize LLVM_ATTRIBUTE_UNUSED) { | ||
// TODO: The original callers only used 32 and 64 so these are the only | ||
// values permitted. Rather than widen the supported values we should | ||
// allow 64 for the callers that currently use 32 and remove the | ||
// argument altogether. | ||
assert((MaxSize == 32 || MaxSize == 64) && "Unexpected size"); | ||
assert(MaxSize <= 64 && "Unexpected size"); | ||
assert(((MaxSize > 32) ? Range <= 0xFFFFFFFFFFFFFFFFULL | ||
: Range <= 0xFFFFFFFFULL) && | ||
"Enum too large"); | ||
|
||
if (Range > 0xFFFFFFFFULL) | ||
return "uint64_t"; | ||
if (Range > 0xFFFF) | ||
return "uint32_t"; | ||
if (Range > 0xFF) | ||
return "uint16_t"; | ||
return "uint8_t"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
//===- Types.h - Helper for the selection of C++ types. ---------*- C++ -*-===// | ||
// | ||
// The LLVM Compiler Infrastructure | ||
// | ||
// This file is distributed under the University of Illinois Open Source | ||
// License. See LICENSE.TXT for details. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef LLVM_UTILS_TABLEGEN_TYPES_H | ||
#define LLVM_UTILS_TABLEGEN_TYPES_H | ||
|
||
#include <cstdint> | ||
|
||
namespace llvm { | ||
/// Returns the smallest unsigned integer type that can hold the given range. | ||
/// MaxSize indicates the largest size of integer to consider (in bits) and only | ||
/// supports values of at least 32. | ||
const char *getMinimalTypeForRange(uint64_t Range, unsigned MaxSize = 64); | ||
} | ||
|
||
#endif |