mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-23 14:25:07 +00:00
Make SubRegIndex size mandatory, following r183020.
This also makes TableGen able to compute sizes/offsets of synthesized indices representing tuples. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183061 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -338,12 +338,15 @@ public:
|
|||||||
/// otherwise.
|
/// otherwise.
|
||||||
unsigned getSubRegIndex(unsigned RegNo, unsigned SubRegNo) const;
|
unsigned getSubRegIndex(unsigned RegNo, unsigned SubRegNo) const;
|
||||||
|
|
||||||
/// \brief Get the bit range covered by a given sub-register index.
|
/// \brief Get the size of the bit range covered by a sub-register index.
|
||||||
/// In some cases, for instance non-contiguous synthesized indices,
|
/// If the index isn't continuous, return the sum of the sizes of its parts.
|
||||||
/// there is no meaningful bit range to get, so return true if \p Offset
|
/// If the index is used to access subregisters of different sizes, return -1.
|
||||||
/// and \p Size were set.
|
unsigned getSubRegIdxSize(unsigned Idx) const;
|
||||||
bool getSubRegIdxCoveredBits(unsigned Idx,
|
|
||||||
unsigned &Offset, unsigned &Size) 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
|
/// \brief Return the human-readable symbolic target-specific name for the
|
||||||
/// specified physical register.
|
/// specified physical register.
|
||||||
|
@@ -22,13 +22,16 @@ include "llvm/IR/Intrinsics.td"
|
|||||||
class RegisterClass; // Forward def
|
class RegisterClass; // Forward def
|
||||||
|
|
||||||
// SubRegIndex - Use instances of SubRegIndex to identify subregisters.
|
// 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 = "";
|
string Namespace = "";
|
||||||
|
|
||||||
// Size - Size (in bits) of the sub-registers represented by this index.
|
// Size - Size (in bits) of the sub-registers represented by this index.
|
||||||
int Size = size;
|
int Size = size;
|
||||||
|
|
||||||
// Offset - Offset of the first bit that is part of this sub-register index.
|
// 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;
|
int Offset = offset;
|
||||||
|
|
||||||
// ComposedOf - A list of two SubRegIndex instances, [A, B].
|
// 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.
|
// 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.
|
// 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>
|
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.
|
// See SubRegIndex.
|
||||||
let ComposedOf = [A, B];
|
let ComposedOf = [A, B];
|
||||||
}
|
}
|
||||||
|
@@ -46,17 +46,16 @@ unsigned MCRegisterInfo::getSubRegIndex(unsigned Reg, unsigned SubReg) const {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MCRegisterInfo::getSubRegIdxCoveredBits(unsigned Idx, unsigned &Offset,
|
unsigned MCRegisterInfo::getSubRegIdxSize(unsigned Idx) const {
|
||||||
unsigned &Size) const {
|
|
||||||
assert(Idx && Idx < getNumSubRegIndices() &&
|
assert(Idx && Idx < getNumSubRegIndices() &&
|
||||||
"This is not a subregister index");
|
"This is not a subregister index");
|
||||||
// Get a pointer to the corresponding SubRegIdxRanges struct.
|
return SubRegIdxRanges[Idx].Size;
|
||||||
const SubRegCoveredBits *Bits = &SubRegIdxRanges[Idx];
|
}
|
||||||
if (Bits->Offset == (uint16_t)-1 || Bits->Size == (uint16_t)-1)
|
|
||||||
return false;
|
unsigned MCRegisterInfo::getSubRegIdxOffset(unsigned Idx) const {
|
||||||
Offset = Bits->Offset;
|
assert(Idx && Idx < getNumSubRegIndices() &&
|
||||||
Size = Bits->Size;
|
"This is not a subregister index");
|
||||||
return true;
|
return SubRegIdxRanges[Idx].Offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MCRegisterInfo::getDwarfRegNum(unsigned RegNum, bool isEH) const {
|
int MCRegisterInfo::getDwarfRegNum(unsigned RegNum, bool isEH) const {
|
||||||
|
@@ -12,15 +12,15 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
let Namespace = "AArch64" in {
|
let Namespace = "AArch64" in {
|
||||||
def sub_128 : SubRegIndex;
|
def sub_128 : SubRegIndex<128>;
|
||||||
def sub_64 : SubRegIndex;
|
def sub_64 : SubRegIndex<64>;
|
||||||
def sub_32 : SubRegIndex;
|
def sub_32 : SubRegIndex<32>;
|
||||||
def sub_16 : SubRegIndex;
|
def sub_16 : SubRegIndex<16>;
|
||||||
def sub_8 : SubRegIndex;
|
def sub_8 : SubRegIndex<8>;
|
||||||
|
|
||||||
// The VPR registers are handled as sub-registers of FPR equivalents, but
|
// 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.
|
// 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.
|
// Registers are identified with 5-bit ID numbers.
|
||||||
|
@@ -57,8 +57,8 @@ let Namespace = "Hexagon" in {
|
|||||||
let Aliases = [R];
|
let Aliases = [R];
|
||||||
}
|
}
|
||||||
|
|
||||||
def subreg_loreg : SubRegIndex;
|
def subreg_loreg : SubRegIndex<32>;
|
||||||
def subreg_hireg : SubRegIndex;
|
def subreg_hireg : SubRegIndex<32, 32>;
|
||||||
|
|
||||||
// Integer registers.
|
// Integer registers.
|
||||||
def R0 : Ri< 0, "r0">, DwarfRegNum<[0]>;
|
def R0 : Ri< 0, "r0">, DwarfRegNum<[0]>;
|
||||||
|
@@ -43,7 +43,7 @@ def R13B : MSP430Reg<13, "r13">;
|
|||||||
def R14B : MSP430Reg<14, "r14">;
|
def R14B : MSP430Reg<14, "r14">;
|
||||||
def R15B : MSP430Reg<15, "r15">;
|
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 {
|
let SubRegIndices = [subreg_8bit] in {
|
||||||
def PCW : MSP430RegWithSubregs<0, "r0", [PCB]>;
|
def PCW : MSP430RegWithSubregs<0, "r0", [PCB]>;
|
||||||
|
@@ -11,16 +11,16 @@
|
|||||||
// Declarations that describe the MIPS register file
|
// Declarations that describe the MIPS register file
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
let Namespace = "Mips" in {
|
let Namespace = "Mips" in {
|
||||||
def sub_fpeven : SubRegIndex;
|
def sub_fpeven : SubRegIndex<32>;
|
||||||
def sub_fpodd : SubRegIndex;
|
def sub_fpodd : SubRegIndex<32, 32>;
|
||||||
def sub_32 : SubRegIndex;
|
def sub_32 : SubRegIndex<32>;
|
||||||
def sub_lo : SubRegIndex;
|
def sub_lo : SubRegIndex<32>;
|
||||||
def sub_hi : SubRegIndex;
|
def sub_hi : SubRegIndex<32, 32>;
|
||||||
def sub_dsp16_19 : SubRegIndex;
|
def sub_dsp16_19 : SubRegIndex<4, 16>;
|
||||||
def sub_dsp20 : SubRegIndex;
|
def sub_dsp20 : SubRegIndex<1, 20>;
|
||||||
def sub_dsp21 : SubRegIndex;
|
def sub_dsp21 : SubRegIndex<1, 21>;
|
||||||
def sub_dsp22 : SubRegIndex;
|
def sub_dsp22 : SubRegIndex<1, 22>;
|
||||||
def sub_dsp23 : SubRegIndex;
|
def sub_dsp23 : SubRegIndex<1, 23>;
|
||||||
}
|
}
|
||||||
|
|
||||||
class Unallocatable {
|
class Unallocatable {
|
||||||
|
@@ -11,11 +11,11 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
let Namespace = "PPC" in {
|
let Namespace = "PPC" in {
|
||||||
def sub_lt : SubRegIndex;
|
def sub_lt : SubRegIndex<1>;
|
||||||
def sub_gt : SubRegIndex;
|
def sub_gt : SubRegIndex<1, 1>;
|
||||||
def sub_eq : SubRegIndex;
|
def sub_eq : SubRegIndex<1, 2>;
|
||||||
def sub_un : SubRegIndex;
|
def sub_un : SubRegIndex<1, 3>;
|
||||||
def sub_32 : SubRegIndex;
|
def sub_32 : SubRegIndex<32>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -14,7 +14,8 @@
|
|||||||
let Namespace = "AMDGPU" in {
|
let Namespace = "AMDGPU" in {
|
||||||
|
|
||||||
foreach Index = 0-15 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">;
|
def INDIRECT_BASE_ADDR : Register <"INDIRECT_BASE_ADDR">;
|
||||||
|
@@ -21,8 +21,8 @@ class SparcCtrlReg<string n>: Register<n> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let Namespace = "SP" in {
|
let Namespace = "SP" in {
|
||||||
def sub_even : SubRegIndex;
|
def sub_even : SubRegIndex<32>;
|
||||||
def sub_odd : SubRegIndex;
|
def sub_odd : SubRegIndex<32, 32>;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Registers are identified with 5-bit ID numbers.
|
// Registers are identified with 5-bit ID numbers.
|
||||||
|
@@ -21,9 +21,10 @@ class SystemZRegWithSubregs<string n, list<Register> subregs>
|
|||||||
}
|
}
|
||||||
|
|
||||||
let Namespace = "SystemZ" in {
|
let Namespace = "SystemZ" in {
|
||||||
def subreg_32bit : SubRegIndex; // could also be known as "subreg_high32"
|
def subreg_32bit : SubRegIndex<32>; // could also be named "subreg_high32"
|
||||||
def subreg_high : SubRegIndex;
|
// Indices are used in a variety of ways, so don't set an Offset.
|
||||||
def subreg_low : SubRegIndex;
|
def subreg_high : SubRegIndex<64, -1>;
|
||||||
|
def subreg_low : SubRegIndex<64, -1>;
|
||||||
def subreg_low32 : ComposedSubRegIndex<subreg_low, subreg_32bit>;
|
def subreg_low32 : ComposedSubRegIndex<subreg_low, subreg_32bit>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1092,11 +1092,24 @@ getConcatSubRegIndex(const SmallVector<CodeGenSubRegIndex*, 8> &Parts) {
|
|||||||
|
|
||||||
// None exists, synthesize one.
|
// None exists, synthesize one.
|
||||||
std::string Name = Parts.front()->getName();
|
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) {
|
for (unsigned i = 1, e = Parts.size(); i != e; ++i) {
|
||||||
Name += '_';
|
Name += '_';
|
||||||
Name += Parts[i]->getName();
|
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() {
|
void CodeGenRegBank::computeComposites() {
|
||||||
|
@@ -37,10 +37,10 @@ namespace llvm {
|
|||||||
Record *const TheDef;
|
Record *const TheDef;
|
||||||
std::string Name;
|
std::string Name;
|
||||||
std::string Namespace;
|
std::string Namespace;
|
||||||
uint16_t Size;
|
|
||||||
uint16_t Offset;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
uint16_t Size;
|
||||||
|
uint16_t Offset;
|
||||||
const unsigned EnumValue;
|
const unsigned EnumValue;
|
||||||
unsigned LaneMask;
|
unsigned LaneMask;
|
||||||
|
|
||||||
@@ -54,8 +54,6 @@ namespace llvm {
|
|||||||
const std::string &getName() const { return Name; }
|
const std::string &getName() const { return Name; }
|
||||||
const std::string &getNamespace() const { return Namespace; }
|
const std::string &getNamespace() const { return Namespace; }
|
||||||
std::string getQualifiedName() const;
|
std::string getQualifiedName() const;
|
||||||
uint16_t getSize() const { return Size; }
|
|
||||||
uint16_t getOffset() const { return Offset; }
|
|
||||||
|
|
||||||
// Order CodeGenSubRegIndex pointers by EnumValue.
|
// Order CodeGenSubRegIndex pointers by EnumValue.
|
||||||
struct Less {
|
struct Less {
|
||||||
|
@@ -798,8 +798,8 @@ RegisterInfoEmitter::runMCDesc(raw_ostream &OS, CodeGenTarget &Target,
|
|||||||
for (ArrayRef<CodeGenSubRegIndex*>::const_iterator
|
for (ArrayRef<CodeGenSubRegIndex*>::const_iterator
|
||||||
SRI = SubRegIndices.begin(), SRE = SubRegIndices.end();
|
SRI = SubRegIndices.begin(), SRE = SubRegIndices.end();
|
||||||
SRI != SRE; ++SRI) {
|
SRI != SRE; ++SRI) {
|
||||||
OS << " { " << (*SRI)->getOffset() << ", "
|
OS << " { " << (*SRI)->Offset << ", "
|
||||||
<< (*SRI)->getSize()
|
<< (*SRI)->Size
|
||||||
<< " },\t// " << (*SRI)->getName() << "\n";
|
<< " },\t// " << (*SRI)->getName() << "\n";
|
||||||
}
|
}
|
||||||
OS << "};\n\n";
|
OS << "};\n\n";
|
||||||
|
Reference in New Issue
Block a user