mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-03-17 21:32:04 +00:00
Refactoring: Separate out the ARM constant pool Constant from the ARM constant
pool value. It's not used right now, but will be soon. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140933 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
1cea66c3ba
commit
f2b76aae2b
lib/Target/ARM
@ -22,6 +22,18 @@
|
||||
#include <cstdlib>
|
||||
using namespace llvm;
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// ARMConstantPoolValue
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
ARMConstantPoolValue::ARMConstantPoolValue(Type *Ty, unsigned id,
|
||||
ARMCP::ARMCPKind kind,
|
||||
unsigned char PCAdj,
|
||||
ARMCP::ARMCPModifier modifier,
|
||||
bool addCurrentAddress)
|
||||
: MachineConstantPoolValue(Ty), LabelId(id), Kind(kind), PCAdjust(PCAdj),
|
||||
Modifier(modifier), AddCurrentAddress(addCurrentAddress) {}
|
||||
|
||||
ARMConstantPoolValue::ARMConstantPoolValue(const Constant *cval, unsigned id,
|
||||
ARMCP::ARMCPKind K,
|
||||
unsigned char PCAdj,
|
||||
@ -145,7 +157,6 @@ void ARMConstantPoolValue::dump() const {
|
||||
errs() << " " << *this;
|
||||
}
|
||||
|
||||
|
||||
void ARMConstantPoolValue::print(raw_ostream &O) const {
|
||||
if (CVal)
|
||||
O << CVal->getName();
|
||||
@ -160,3 +171,44 @@ void ARMConstantPoolValue::print(raw_ostream &O) const {
|
||||
O << ")";
|
||||
}
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// ARMConstantPoolConstant
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
ARMConstantPoolConstant::ARMConstantPoolConstant(const Constant *C,
|
||||
unsigned ID,
|
||||
ARMCP::ARMCPKind Kind,
|
||||
unsigned char PCAdj,
|
||||
ARMCP::ARMCPModifier Modifier,
|
||||
bool AddCurrentAddress)
|
||||
: ARMConstantPoolValue((Type*)C->getType(), ID, Kind, PCAdj, Modifier,
|
||||
AddCurrentAddress),
|
||||
CVal(C) {}
|
||||
|
||||
ARMConstantPoolConstant *
|
||||
ARMConstantPoolConstant::Create(const Constant *C, unsigned ID) {
|
||||
return new ARMConstantPoolConstant(C, ID, ARMCP::CPValue, 0,
|
||||
ARMCP::no_modifier, false);
|
||||
}
|
||||
|
||||
const GlobalValue *ARMConstantPoolConstant::getGV() const {
|
||||
return dyn_cast<GlobalValue>(CVal);
|
||||
}
|
||||
|
||||
bool ARMConstantPoolConstant::hasSameValue(ARMConstantPoolValue *ACPV) {
|
||||
const ARMConstantPoolConstant *ACPC = dyn_cast<ARMConstantPoolConstant>(ACPV);
|
||||
|
||||
return (ACPC ? ACPC->CVal == CVal : true) &&
|
||||
ARMConstantPoolValue::hasSameValue(ACPV);
|
||||
}
|
||||
|
||||
void ARMConstantPoolConstant::addSelectionDAGCSEId(FoldingSetNodeID &ID) {
|
||||
ID.AddPointer(CVal);
|
||||
ARMConstantPoolValue::addSelectionDAGCSEId(ID);
|
||||
}
|
||||
|
||||
void ARMConstantPoolConstant::print(raw_ostream &O) const {
|
||||
O << CVal->getName();
|
||||
ARMConstantPoolValue::print(O);
|
||||
}
|
||||
|
@ -59,6 +59,11 @@ class ARMConstantPoolValue : public MachineConstantPoolValue {
|
||||
ARMCP::ARMCPModifier Modifier; // GV modifier i.e. (&GV(modifier)-(LPIC+8))
|
||||
bool AddCurrentAddress;
|
||||
|
||||
protected:
|
||||
ARMConstantPoolValue(Type *Ty, unsigned id, ARMCP::ARMCPKind Kind,
|
||||
unsigned char PCAdj, ARMCP::ARMCPModifier Modifier,
|
||||
bool AddCurrentAddress);
|
||||
|
||||
public:
|
||||
ARMConstantPoolValue(const Constant *cval, unsigned id,
|
||||
ARMCP::ARMCPKind Kind = ARMCP::CPValue,
|
||||
@ -94,7 +99,7 @@ public:
|
||||
|
||||
bool isGlobalValue() const { return Kind == ARMCP::CPValue; }
|
||||
bool isExtSymbol() const { return Kind == ARMCP::CPExtSymbol; }
|
||||
bool isBlockAddress() { return Kind == ARMCP::CPBlockAddress; }
|
||||
bool isBlockAddress() const { return Kind == ARMCP::CPBlockAddress; }
|
||||
bool isLSDA() const { return Kind == ARMCP::CPLSDA; }
|
||||
bool isMachineBasicBlock() { return Kind == ARMCP::CPMachineBasicBlock; }
|
||||
|
||||
@ -105,13 +110,15 @@ public:
|
||||
|
||||
virtual void addSelectionDAGCSEId(FoldingSetNodeID &ID);
|
||||
|
||||
/// hasSameValue - Return true if this ARM constpool value
|
||||
/// can share the same constantpool entry as another ARM constpool value.
|
||||
bool hasSameValue(ARMConstantPoolValue *ACPV);
|
||||
/// hasSameValue - Return true if this ARM constpool value can share the same
|
||||
/// constantpool entry as another ARM constpool value.
|
||||
virtual bool hasSameValue(ARMConstantPoolValue *ACPV);
|
||||
|
||||
virtual void print(raw_ostream &O) const;
|
||||
void print(raw_ostream *O) const { if (O) print(*O); }
|
||||
void print(raw_ostream &O) const;
|
||||
void dump() const;
|
||||
|
||||
static bool classof(const ARMConstantPoolValue *) { return true; }
|
||||
};
|
||||
|
||||
inline raw_ostream &operator<<(raw_ostream &O, const ARMConstantPoolValue &V) {
|
||||
@ -119,6 +126,35 @@ inline raw_ostream &operator<<(raw_ostream &O, const ARMConstantPoolValue &V) {
|
||||
return O;
|
||||
}
|
||||
|
||||
/// ARMConstantPoolConstant - ARM-specific constant pool values for Constants,
|
||||
/// Functions, and BlockAddresses.
|
||||
class ARMConstantPoolConstant : public ARMConstantPoolValue {
|
||||
const Constant *CVal; // Constant being loaded.
|
||||
|
||||
ARMConstantPoolConstant(const Constant *C,
|
||||
unsigned ID,
|
||||
ARMCP::ARMCPKind Kind,
|
||||
unsigned char PCAdj,
|
||||
ARMCP::ARMCPModifier Modifier,
|
||||
bool AddCurrentAddress);
|
||||
public:
|
||||
static ARMConstantPoolConstant *Create(const Constant *C, unsigned ID);
|
||||
|
||||
const GlobalValue *getGV() const;
|
||||
|
||||
/// hasSameValue - Return true if this ARM constpool value can share the same
|
||||
/// constantpool entry as another ARM constpool value.
|
||||
virtual bool hasSameValue(ARMConstantPoolValue *ACPV);
|
||||
|
||||
virtual void addSelectionDAGCSEId(FoldingSetNodeID &ID);
|
||||
|
||||
virtual void print(raw_ostream &O) const;
|
||||
static bool classof(const ARMConstantPoolValue *APV) {
|
||||
return APV->isGlobalValue() || APV->isBlockAddress() || APV->isLSDA();
|
||||
}
|
||||
static bool classof(const ARMConstantPoolConstant *) { return true; }
|
||||
};
|
||||
|
||||
} // End llvm namespace
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user