mirror of
https://github.com/RPCS3/llvm.git
synced 2025-01-25 12:04:36 +00:00
[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
This commit is contained in:
parent
c466a4a7fd
commit
90085b5841
@ -98,6 +98,7 @@
|
|||||||
|
|
||||||
#include "CodeGenTarget.h"
|
#include "CodeGenTarget.h"
|
||||||
#include "SubtargetFeatureInfo.h"
|
#include "SubtargetFeatureInfo.h"
|
||||||
|
#include "Types.h"
|
||||||
#include "llvm/ADT/CachedHashString.h"
|
#include "llvm/ADT/CachedHashString.h"
|
||||||
#include "llvm/ADT/PointerUnion.h"
|
#include "llvm/ADT/PointerUnion.h"
|
||||||
#include "llvm/ADT/STLExtras.h"
|
#include "llvm/ADT/STLExtras.h"
|
||||||
@ -2363,17 +2364,6 @@ static void emitMatchRegisterAltName(CodeGenTarget &Target, Record *AsmParser,
|
|||||||
OS << "}\n\n";
|
OS << "}\n\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *getMinimalTypeForRange(uint64_t Range) {
|
|
||||||
assert(Range <= 0xFFFFFFFFFFFFFFFFULL && "Enum too large");
|
|
||||||
if (Range > 0xFFFFFFFFULL)
|
|
||||||
return "uint64_t";
|
|
||||||
if (Range > 0xFFFF)
|
|
||||||
return "uint32_t";
|
|
||||||
if (Range > 0xFF)
|
|
||||||
return "uint16_t";
|
|
||||||
return "uint8_t";
|
|
||||||
}
|
|
||||||
|
|
||||||
static const char *getMinimalRequiredFeaturesType(const AsmMatcherInfo &Info) {
|
static const char *getMinimalRequiredFeaturesType(const AsmMatcherInfo &Info) {
|
||||||
uint64_t MaxIndex = Info.SubtargetFeatures.size();
|
uint64_t MaxIndex = Info.SubtargetFeatures.size();
|
||||||
if (MaxIndex > 0)
|
if (MaxIndex > 0)
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#include "AsmWriterInst.h"
|
#include "AsmWriterInst.h"
|
||||||
#include "CodeGenTarget.h"
|
#include "CodeGenTarget.h"
|
||||||
#include "SequenceToOffsetTable.h"
|
#include "SequenceToOffsetTable.h"
|
||||||
|
#include "Types.h"
|
||||||
#include "llvm/ADT/SmallString.h"
|
#include "llvm/ADT/SmallString.h"
|
||||||
#include "llvm/ADT/StringExtras.h"
|
#include "llvm/ADT/StringExtras.h"
|
||||||
#include "llvm/ADT/Twine.h"
|
#include "llvm/ADT/Twine.h"
|
||||||
@ -477,15 +478,6 @@ void AsmWriterEmitter::EmitPrintInstruction(raw_ostream &O) {
|
|||||||
O << "}\n";
|
O << "}\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *getMinimalTypeForRange(uint64_t Range) {
|
|
||||||
assert(Range < 0xFFFFFFFFULL && "Enum too large");
|
|
||||||
if (Range > 0xFFFF)
|
|
||||||
return "uint32_t";
|
|
||||||
if (Range > 0xFF)
|
|
||||||
return "uint16_t";
|
|
||||||
return "uint8_t";
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
emitRegisterNameString(raw_ostream &O, StringRef AltName,
|
emitRegisterNameString(raw_ostream &O, StringRef AltName,
|
||||||
const std::deque<CodeGenRegister> &Registers) {
|
const std::deque<CodeGenRegister> &Registers) {
|
||||||
@ -530,7 +522,7 @@ emitRegisterNameString(raw_ostream &O, StringRef AltName,
|
|||||||
StringTable.emit(O, printChar);
|
StringTable.emit(O, printChar);
|
||||||
O << " };\n\n";
|
O << " };\n\n";
|
||||||
|
|
||||||
O << " static const " << getMinimalTypeForRange(StringTable.size()-1)
|
O << " static const " << getMinimalTypeForRange(StringTable.size() - 1, 32)
|
||||||
<< " RegAsmOffset" << AltName << "[] = {";
|
<< " RegAsmOffset" << AltName << "[] = {";
|
||||||
for (unsigned i = 0, e = Registers.size(); i != e; ++i) {
|
for (unsigned i = 0, e = Registers.size(); i != e; ++i) {
|
||||||
if ((i % 14) == 0)
|
if ((i % 14) == 0)
|
||||||
|
@ -31,6 +31,7 @@ add_tablegen(llvm-tblgen LLVM
|
|||||||
SubtargetEmitter.cpp
|
SubtargetEmitter.cpp
|
||||||
SubtargetFeatureInfo.cpp
|
SubtargetFeatureInfo.cpp
|
||||||
TableGen.cpp
|
TableGen.cpp
|
||||||
|
Types.cpp
|
||||||
X86DisassemblerTables.cpp
|
X86DisassemblerTables.cpp
|
||||||
X86ModRMFilters.cpp
|
X86ModRMFilters.cpp
|
||||||
X86RecognizableInstr.cpp
|
X86RecognizableInstr.cpp
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
#include "CodeGenRegisters.h"
|
#include "CodeGenRegisters.h"
|
||||||
#include "CodeGenTarget.h"
|
#include "CodeGenTarget.h"
|
||||||
|
#include "Types.h"
|
||||||
#include "SequenceToOffsetTable.h"
|
#include "SequenceToOffsetTable.h"
|
||||||
#include "llvm/ADT/ArrayRef.h"
|
#include "llvm/ADT/ArrayRef.h"
|
||||||
#include "llvm/ADT/BitVector.h"
|
#include "llvm/ADT/BitVector.h"
|
||||||
@ -177,15 +178,6 @@ static void printInt(raw_ostream &OS, int Val) {
|
|||||||
OS << Val;
|
OS << Val;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *getMinimalTypeForRange(uint64_t Range) {
|
|
||||||
assert(Range < 0xFFFFFFFFULL && "Enum too large");
|
|
||||||
if (Range > 0xFFFF)
|
|
||||||
return "uint32_t";
|
|
||||||
if (Range > 0xFF)
|
|
||||||
return "uint16_t";
|
|
||||||
return "uint8_t";
|
|
||||||
}
|
|
||||||
|
|
||||||
void RegisterInfoEmitter::
|
void RegisterInfoEmitter::
|
||||||
EmitRegUnitPressure(raw_ostream &OS, const CodeGenRegBank &RegBank,
|
EmitRegUnitPressure(raw_ostream &OS, const CodeGenRegBank &RegBank,
|
||||||
const std::string &ClassName) {
|
const std::string &ClassName) {
|
||||||
@ -264,8 +256,9 @@ EmitRegUnitPressure(raw_ostream &OS, const CodeGenRegBank &RegBank,
|
|||||||
OS << "// Get the register unit pressure limit for this dimension.\n"
|
OS << "// Get the register unit pressure limit for this dimension.\n"
|
||||||
<< "// This limit must be adjusted dynamically for reserved registers.\n"
|
<< "// This limit must be adjusted dynamically for reserved registers.\n"
|
||||||
<< "unsigned " << ClassName << "::\n"
|
<< "unsigned " << ClassName << "::\n"
|
||||||
<< "getRegPressureSetLimit(const MachineFunction &MF, unsigned Idx) const {\n"
|
<< "getRegPressureSetLimit(const MachineFunction &MF, unsigned Idx) const "
|
||||||
<< " static const " << getMinimalTypeForRange(MaxRegUnitWeight)
|
"{\n"
|
||||||
|
<< " static const " << getMinimalTypeForRange(MaxRegUnitWeight, 32)
|
||||||
<< " PressureLimitTable[] = {\n";
|
<< " PressureLimitTable[] = {\n";
|
||||||
for (unsigned i = 0; i < NumSets; ++i ) {
|
for (unsigned i = 0; i < NumSets; ++i ) {
|
||||||
const RegUnitSet &RegUnits = RegBank.getRegSetAt(i);
|
const RegUnitSet &RegUnits = RegBank.getRegSetAt(i);
|
||||||
@ -306,7 +299,7 @@ EmitRegUnitPressure(raw_ostream &OS, const CodeGenRegBank &RegBank,
|
|||||||
<< "/// Returns a -1 terminated array of pressure set IDs\n"
|
<< "/// Returns a -1 terminated array of pressure set IDs\n"
|
||||||
<< "const int* " << ClassName << "::\n"
|
<< "const int* " << ClassName << "::\n"
|
||||||
<< "getRegClassPressureSets(const TargetRegisterClass *RC) const {\n";
|
<< "getRegClassPressureSets(const TargetRegisterClass *RC) const {\n";
|
||||||
OS << " static const " << getMinimalTypeForRange(PSetsSeqs.size()-1)
|
OS << " static const " << getMinimalTypeForRange(PSetsSeqs.size() - 1, 32)
|
||||||
<< " RCSetStartTable[] = {\n ";
|
<< " RCSetStartTable[] = {\n ";
|
||||||
for (unsigned i = 0, e = NumRCs; i != e; ++i) {
|
for (unsigned i = 0, e = NumRCs; i != e; ++i) {
|
||||||
OS << PSetsSeqs.get(PSets[i]) << ",";
|
OS << PSetsSeqs.get(PSets[i]) << ",";
|
||||||
@ -322,7 +315,7 @@ EmitRegUnitPressure(raw_ostream &OS, const CodeGenRegBank &RegBank,
|
|||||||
<< "getRegUnitPressureSets(unsigned RegUnit) const {\n"
|
<< "getRegUnitPressureSets(unsigned RegUnit) const {\n"
|
||||||
<< " assert(RegUnit < " << RegBank.getNumNativeRegUnits()
|
<< " assert(RegUnit < " << RegBank.getNumNativeRegUnits()
|
||||||
<< " && \"invalid register unit\");\n";
|
<< " && \"invalid register unit\");\n";
|
||||||
OS << " static const " << getMinimalTypeForRange(PSetsSeqs.size()-1)
|
OS << " static const " << getMinimalTypeForRange(PSetsSeqs.size() - 1, 32)
|
||||||
<< " RUSetStartTable[] = {\n ";
|
<< " RUSetStartTable[] = {\n ";
|
||||||
for (unsigned UnitIdx = 0, UnitEnd = RegBank.getNumNativeRegUnits();
|
for (unsigned UnitIdx = 0, UnitEnd = RegBank.getNumNativeRegUnits();
|
||||||
UnitIdx < UnitEnd; ++UnitIdx) {
|
UnitIdx < UnitEnd; ++UnitIdx) {
|
||||||
@ -683,15 +676,15 @@ RegisterInfoEmitter::emitComposeSubRegIndices(raw_ostream &OS,
|
|||||||
|
|
||||||
// Output the row map if there is multiple rows.
|
// Output the row map if there is multiple rows.
|
||||||
if (Rows.size() > 1) {
|
if (Rows.size() > 1) {
|
||||||
OS << " static const " << getMinimalTypeForRange(Rows.size()) << " RowMap["
|
OS << " static const " << getMinimalTypeForRange(Rows.size(), 32)
|
||||||
<< SubRegIndicesSize << "] = {\n ";
|
<< " RowMap[" << SubRegIndicesSize << "] = {\n ";
|
||||||
for (unsigned i = 0, e = SubRegIndicesSize; i != e; ++i)
|
for (unsigned i = 0, e = SubRegIndicesSize; i != e; ++i)
|
||||||
OS << RowMap[i] << ", ";
|
OS << RowMap[i] << ", ";
|
||||||
OS << "\n };\n";
|
OS << "\n };\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Output the rows.
|
// Output the rows.
|
||||||
OS << " static const " << getMinimalTypeForRange(SubRegIndicesSize + 1)
|
OS << " static const " << getMinimalTypeForRange(SubRegIndicesSize + 1, 32)
|
||||||
<< " Rows[" << Rows.size() << "][" << SubRegIndicesSize << "] = {\n";
|
<< " Rows[" << Rows.size() << "][" << SubRegIndicesSize << "] = {\n";
|
||||||
for (unsigned r = 0, re = Rows.size(); r != re; ++r) {
|
for (unsigned r = 0, re = Rows.size(); r != re; ++r) {
|
||||||
OS << " { ";
|
OS << " { ";
|
||||||
|
37
utils/TableGen/Types.cpp
Normal file
37
utils/TableGen/Types.cpp
Normal file
@ -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";
|
||||||
|
}
|
22
utils/TableGen/Types.h
Normal file
22
utils/TableGen/Types.h
Normal file
@ -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
|
Loading…
x
Reference in New Issue
Block a user