mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-03-26 07:34:14 +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
@ -22,6 +22,18 @@
|
|||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
using namespace llvm;
|
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,
|
ARMConstantPoolValue::ARMConstantPoolValue(const Constant *cval, unsigned id,
|
||||||
ARMCP::ARMCPKind K,
|
ARMCP::ARMCPKind K,
|
||||||
unsigned char PCAdj,
|
unsigned char PCAdj,
|
||||||
@ -145,7 +157,6 @@ void ARMConstantPoolValue::dump() const {
|
|||||||
errs() << " " << *this;
|
errs() << " " << *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ARMConstantPoolValue::print(raw_ostream &O) const {
|
void ARMConstantPoolValue::print(raw_ostream &O) const {
|
||||||
if (CVal)
|
if (CVal)
|
||||||
O << CVal->getName();
|
O << CVal->getName();
|
||||||
@ -160,3 +171,44 @@ void ARMConstantPoolValue::print(raw_ostream &O) const {
|
|||||||
O << ")";
|
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))
|
ARMCP::ARMCPModifier Modifier; // GV modifier i.e. (&GV(modifier)-(LPIC+8))
|
||||||
bool AddCurrentAddress;
|
bool AddCurrentAddress;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
ARMConstantPoolValue(Type *Ty, unsigned id, ARMCP::ARMCPKind Kind,
|
||||||
|
unsigned char PCAdj, ARMCP::ARMCPModifier Modifier,
|
||||||
|
bool AddCurrentAddress);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ARMConstantPoolValue(const Constant *cval, unsigned id,
|
ARMConstantPoolValue(const Constant *cval, unsigned id,
|
||||||
ARMCP::ARMCPKind Kind = ARMCP::CPValue,
|
ARMCP::ARMCPKind Kind = ARMCP::CPValue,
|
||||||
@ -94,7 +99,7 @@ public:
|
|||||||
|
|
||||||
bool isGlobalValue() const { return Kind == ARMCP::CPValue; }
|
bool isGlobalValue() const { return Kind == ARMCP::CPValue; }
|
||||||
bool isExtSymbol() const { return Kind == ARMCP::CPExtSymbol; }
|
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 isLSDA() const { return Kind == ARMCP::CPLSDA; }
|
||||||
bool isMachineBasicBlock() { return Kind == ARMCP::CPMachineBasicBlock; }
|
bool isMachineBasicBlock() { return Kind == ARMCP::CPMachineBasicBlock; }
|
||||||
|
|
||||||
@ -105,13 +110,15 @@ public:
|
|||||||
|
|
||||||
virtual void addSelectionDAGCSEId(FoldingSetNodeID &ID);
|
virtual void addSelectionDAGCSEId(FoldingSetNodeID &ID);
|
||||||
|
|
||||||
/// hasSameValue - Return true if this ARM constpool value
|
/// hasSameValue - Return true if this ARM constpool value can share the same
|
||||||
/// can share the same constantpool entry as another ARM constpool value.
|
/// constantpool entry as another ARM constpool value.
|
||||||
bool hasSameValue(ARMConstantPoolValue *ACPV);
|
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 { if (O) print(*O); }
|
||||||
void print(raw_ostream &O) const;
|
|
||||||
void dump() const;
|
void dump() const;
|
||||||
|
|
||||||
|
static bool classof(const ARMConstantPoolValue *) { return true; }
|
||||||
};
|
};
|
||||||
|
|
||||||
inline raw_ostream &operator<<(raw_ostream &O, const ARMConstantPoolValue &V) {
|
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;
|
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
|
} // End llvm namespace
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user