1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 12:41:49 +01:00

Make SubRegIndex size mandatory, following r183020.

This also makes TableGen able to compute sizes/offsets of synthesized
indices representing tuples.

llvm-svn: 183061
This commit is contained in:
Ahmed Bougacha 2013-05-31 23:45:26 +00:00
parent fafe6e2851
commit 2263547c8f
14 changed files with 74 additions and 54 deletions

View File

@ -338,12 +338,15 @@ public:
/// otherwise.
unsigned getSubRegIndex(unsigned RegNo, unsigned SubRegNo) const;
/// \brief Get the bit range covered by a given sub-register index.
/// In some cases, for instance non-contiguous synthesized indices,
/// there is no meaningful bit range to get, so return true if \p Offset
/// and \p Size were set.
bool getSubRegIdxCoveredBits(unsigned Idx,
unsigned &Offset, unsigned &Size) const;
/// \brief Get the size of the bit range covered by a sub-register index.
/// If the index isn't continuous, return the sum of the sizes of its parts.
/// If the index is used to access subregisters of different sizes, return -1.
unsigned getSubRegIdxSize(unsigned Idx) const;
/// \brief Get the offset of the bit range covered by a sub-register index.
/// If an Offset doesn't make sense (the index isn't continuous, or is used to
/// access sub-registers at different offsets), return -1.
unsigned getSubRegIdxOffset(unsigned Idx) const;
/// \brief Return the human-readable symbolic target-specific name for the
/// specified physical register.

View File

@ -22,13 +22,16 @@ include "llvm/IR/Intrinsics.td"
class RegisterClass; // Forward def
// SubRegIndex - Use instances of SubRegIndex to identify subregisters.
class SubRegIndex<int size = -1, int offset = 0> {
class SubRegIndex<int size, int offset = 0> {
string Namespace = "";
// Size - Size (in bits) of the sub-registers represented by this index.
int Size = size;
// Offset - Offset of the first bit that is part of this sub-register index.
// Set it to -1 if the same index is used to represent sub-registers that can
// be at different offsets (for example when using an index to access an
// element in a register tuple).
int Offset = offset;
// ComposedOf - A list of two SubRegIndex instances, [A, B].
@ -58,7 +61,9 @@ class SubRegIndex<int size = -1, int offset = 0> {
// ComposedSubRegIndex - A sub-register that is the result of composing A and B.
// Offset is set to the sum of A and B's Offsets. Size is set to B's Size.
class ComposedSubRegIndex<SubRegIndex A, SubRegIndex B>
: SubRegIndex<B.Size, -1> {
: SubRegIndex<B.Size, !if(!eq(A.Offset, -1), -1,
!if(!eq(B.Offset, -1), -1,
!add(A.Offset, B.Offset)))> {
// See SubRegIndex.
let ComposedOf = [A, B];
}

View File

@ -46,17 +46,16 @@ unsigned MCRegisterInfo::getSubRegIndex(unsigned Reg, unsigned SubReg) const {
return 0;
}
bool MCRegisterInfo::getSubRegIdxCoveredBits(unsigned Idx, unsigned &Offset,
unsigned &Size) const {
unsigned MCRegisterInfo::getSubRegIdxSize(unsigned Idx) const {
assert(Idx && Idx < getNumSubRegIndices() &&
"This is not a subregister index");
// Get a pointer to the corresponding SubRegIdxRanges struct.
const SubRegCoveredBits *Bits = &SubRegIdxRanges[Idx];
if (Bits->Offset == (uint16_t)-1 || Bits->Size == (uint16_t)-1)
return false;
Offset = Bits->Offset;
Size = Bits->Size;
return true;
return SubRegIdxRanges[Idx].Size;
}
unsigned MCRegisterInfo::getSubRegIdxOffset(unsigned Idx) const {
assert(Idx && Idx < getNumSubRegIndices() &&
"This is not a subregister index");
return SubRegIdxRanges[Idx].Offset;
}
int MCRegisterInfo::getDwarfRegNum(unsigned RegNum, bool isEH) const {

View File

@ -12,15 +12,15 @@
//===----------------------------------------------------------------------===//
let Namespace = "AArch64" in {
def sub_128 : SubRegIndex;
def sub_64 : SubRegIndex;
def sub_32 : SubRegIndex;
def sub_16 : SubRegIndex;
def sub_8 : SubRegIndex;
def sub_128 : SubRegIndex<128>;
def sub_64 : SubRegIndex<64>;
def sub_32 : SubRegIndex<32>;
def sub_16 : SubRegIndex<16>;
def sub_8 : SubRegIndex<8>;
// The VPR registers are handled as sub-registers of FPR equivalents, but
// they're really the same thing. We give this concept a special index.
def sub_alias : SubRegIndex;
def sub_alias : SubRegIndex<128>;
}
// Registers are identified with 5-bit ID numbers.

View File

@ -57,8 +57,8 @@ let Namespace = "Hexagon" in {
let Aliases = [R];
}
def subreg_loreg : SubRegIndex;
def subreg_hireg : SubRegIndex;
def subreg_loreg : SubRegIndex<32>;
def subreg_hireg : SubRegIndex<32, 32>;
// Integer registers.
def R0 : Ri< 0, "r0">, DwarfRegNum<[0]>;

View File

@ -43,7 +43,7 @@ def R13B : MSP430Reg<13, "r13">;
def R14B : MSP430Reg<14, "r14">;
def R15B : MSP430Reg<15, "r15">;
def subreg_8bit : SubRegIndex { let Namespace = "MSP430"; }
def subreg_8bit : SubRegIndex<8> { let Namespace = "MSP430"; }
let SubRegIndices = [subreg_8bit] in {
def PCW : MSP430RegWithSubregs<0, "r0", [PCB]>;

View File

@ -11,16 +11,16 @@
// Declarations that describe the MIPS register file
//===----------------------------------------------------------------------===//
let Namespace = "Mips" in {
def sub_fpeven : SubRegIndex;
def sub_fpodd : SubRegIndex;
def sub_32 : SubRegIndex;
def sub_lo : SubRegIndex;
def sub_hi : SubRegIndex;
def sub_dsp16_19 : SubRegIndex;
def sub_dsp20 : SubRegIndex;
def sub_dsp21 : SubRegIndex;
def sub_dsp22 : SubRegIndex;
def sub_dsp23 : SubRegIndex;
def sub_fpeven : SubRegIndex<32>;
def sub_fpodd : SubRegIndex<32, 32>;
def sub_32 : SubRegIndex<32>;
def sub_lo : SubRegIndex<32>;
def sub_hi : SubRegIndex<32, 32>;
def sub_dsp16_19 : SubRegIndex<4, 16>;
def sub_dsp20 : SubRegIndex<1, 20>;
def sub_dsp21 : SubRegIndex<1, 21>;
def sub_dsp22 : SubRegIndex<1, 22>;
def sub_dsp23 : SubRegIndex<1, 23>;
}
class Unallocatable {

View File

@ -11,11 +11,11 @@
//===----------------------------------------------------------------------===//
let Namespace = "PPC" in {
def sub_lt : SubRegIndex;
def sub_gt : SubRegIndex;
def sub_eq : SubRegIndex;
def sub_un : SubRegIndex;
def sub_32 : SubRegIndex;
def sub_lt : SubRegIndex<1>;
def sub_gt : SubRegIndex<1, 1>;
def sub_eq : SubRegIndex<1, 2>;
def sub_un : SubRegIndex<1, 3>;
def sub_32 : SubRegIndex<32>;
}

View File

@ -14,7 +14,8 @@
let Namespace = "AMDGPU" in {
foreach Index = 0-15 in {
def sub#Index : SubRegIndex;
// Indices are used in a variety of ways here, so don't set a size/offset.
def sub#Index : SubRegIndex<-1, -1>;
}
def INDIRECT_BASE_ADDR : Register <"INDIRECT_BASE_ADDR">;

View File

@ -21,8 +21,8 @@ class SparcCtrlReg<string n>: Register<n> {
}
let Namespace = "SP" in {
def sub_even : SubRegIndex;
def sub_odd : SubRegIndex;
def sub_even : SubRegIndex<32>;
def sub_odd : SubRegIndex<32, 32>;
}
// Registers are identified with 5-bit ID numbers.

View File

@ -21,9 +21,10 @@ class SystemZRegWithSubregs<string n, list<Register> subregs>
}
let Namespace = "SystemZ" in {
def subreg_32bit : SubRegIndex; // could also be known as "subreg_high32"
def subreg_high : SubRegIndex;
def subreg_low : SubRegIndex;
def subreg_32bit : SubRegIndex<32>; // could also be named "subreg_high32"
// Indices are used in a variety of ways, so don't set an Offset.
def subreg_high : SubRegIndex<64, -1>;
def subreg_low : SubRegIndex<64, -1>;
def subreg_low32 : ComposedSubRegIndex<subreg_low, subreg_32bit>;
}

View File

@ -1092,11 +1092,24 @@ getConcatSubRegIndex(const SmallVector<CodeGenSubRegIndex*, 8> &Parts) {
// None exists, synthesize one.
std::string Name = Parts.front()->getName();
// Determine whether all parts are contiguous.
bool isContinuous = true;
unsigned Size = Parts.front()->Size;
unsigned LastOffset = Parts.front()->Offset;
unsigned LastSize = Parts.front()->Size;
for (unsigned i = 1, e = Parts.size(); i != e; ++i) {
Name += '_';
Name += Parts[i]->getName();
Size += Parts[i]->Size;
if (Parts[i]->Offset != (LastOffset + LastSize))
isContinuous = false;
LastOffset = Parts[i]->Offset;
LastSize = Parts[i]->Size;
}
return Idx = createSubRegIndex(Name, Parts.front()->getNamespace());
Idx = createSubRegIndex(Name, Parts.front()->getNamespace());
Idx->Size = Size;
Idx->Offset = isContinuous ? Parts.front()->Offset : -1;
return Idx;
}
void CodeGenRegBank::computeComposites() {

View File

@ -37,10 +37,10 @@ namespace llvm {
Record *const TheDef;
std::string Name;
std::string Namespace;
uint16_t Size;
uint16_t Offset;
public:
uint16_t Size;
uint16_t Offset;
const unsigned EnumValue;
unsigned LaneMask;
@ -54,8 +54,6 @@ namespace llvm {
const std::string &getName() const { return Name; }
const std::string &getNamespace() const { return Namespace; }
std::string getQualifiedName() const;
uint16_t getSize() const { return Size; }
uint16_t getOffset() const { return Offset; }
// Order CodeGenSubRegIndex pointers by EnumValue.
struct Less {

View File

@ -798,8 +798,8 @@ RegisterInfoEmitter::runMCDesc(raw_ostream &OS, CodeGenTarget &Target,
for (ArrayRef<CodeGenSubRegIndex*>::const_iterator
SRI = SubRegIndices.begin(), SRE = SubRegIndices.end();
SRI != SRE; ++SRI) {
OS << " { " << (*SRI)->getOffset() << ", "
<< (*SRI)->getSize()
OS << " { " << (*SRI)->Offset << ", "
<< (*SRI)->Size
<< " },\t// " << (*SRI)->getName() << "\n";
}
OS << "};\n\n";