mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-07-22 09:29:31 +00:00
Support creating a constant pool value for a machine basic block.
This is used when we want to take the address of a machine basic block, but it's not associated with a BB in LLVM IR. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140823 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
48105286cb
commit
4dd9b091cc
@ -17,6 +17,7 @@
|
|||||||
#include "llvm/Constants.h"
|
#include "llvm/Constants.h"
|
||||||
#include "llvm/GlobalValue.h"
|
#include "llvm/GlobalValue.h"
|
||||||
#include "llvm/Type.h"
|
#include "llvm/Type.h"
|
||||||
|
#include "llvm/CodeGen/MachineBasicBlock.h"
|
||||||
#include "llvm/Support/raw_ostream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
@ -30,6 +31,17 @@ ARMConstantPoolValue::ARMConstantPoolValue(const Constant *cval, unsigned id,
|
|||||||
CVal(cval), S(NULL), LabelId(id), Kind(K), PCAdjust(PCAdj),
|
CVal(cval), S(NULL), LabelId(id), Kind(K), PCAdjust(PCAdj),
|
||||||
Modifier(Modif), AddCurrentAddress(AddCA) {}
|
Modifier(Modif), AddCurrentAddress(AddCA) {}
|
||||||
|
|
||||||
|
ARMConstantPoolValue::ARMConstantPoolValue(LLVMContext &C,
|
||||||
|
const MachineBasicBlock *mbb,
|
||||||
|
unsigned id,
|
||||||
|
ARMCP::ARMCPKind K,
|
||||||
|
unsigned char PCAdj,
|
||||||
|
ARMCP::ARMCPModifier Modif,
|
||||||
|
bool AddCA)
|
||||||
|
: MachineConstantPoolValue((Type*)Type::getInt8PtrTy(C)),
|
||||||
|
CVal(NULL), MBB(mbb), S(NULL), LabelId(id), Kind(K), PCAdjust(PCAdj),
|
||||||
|
Modifier(Modif), AddCurrentAddress(AddCA) {}
|
||||||
|
|
||||||
ARMConstantPoolValue::ARMConstantPoolValue(LLVMContext &C,
|
ARMConstantPoolValue::ARMConstantPoolValue(LLVMContext &C,
|
||||||
const char *s, unsigned id,
|
const char *s, unsigned id,
|
||||||
unsigned char PCAdj,
|
unsigned char PCAdj,
|
||||||
@ -53,6 +65,10 @@ const BlockAddress *ARMConstantPoolValue::getBlockAddress() const {
|
|||||||
return dyn_cast_or_null<BlockAddress>(CVal);
|
return dyn_cast_or_null<BlockAddress>(CVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const MachineBasicBlock *ARMConstantPoolValue::getMBB() const {
|
||||||
|
return MBB;
|
||||||
|
}
|
||||||
|
|
||||||
static bool CPV_streq(const char *S1, const char *S2) {
|
static bool CPV_streq(const char *S1, const char *S2) {
|
||||||
if (S1 == S2)
|
if (S1 == S2)
|
||||||
return true;
|
return true;
|
||||||
@ -119,6 +135,8 @@ void ARMConstantPoolValue::dump() const {
|
|||||||
void ARMConstantPoolValue::print(raw_ostream &O) const {
|
void ARMConstantPoolValue::print(raw_ostream &O) const {
|
||||||
if (CVal)
|
if (CVal)
|
||||||
O << CVal->getName();
|
O << CVal->getName();
|
||||||
|
else if (MBB)
|
||||||
|
O << "";
|
||||||
else
|
else
|
||||||
O << S;
|
O << S;
|
||||||
if (Modifier) O << "(" << getModifierText() << ")";
|
if (Modifier) O << "(" << getModifierText() << ")";
|
||||||
|
@ -20,17 +20,19 @@
|
|||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
|
||||||
class Constant;
|
|
||||||
class BlockAddress;
|
class BlockAddress;
|
||||||
|
class Constant;
|
||||||
class GlobalValue;
|
class GlobalValue;
|
||||||
class LLVMContext;
|
class LLVMContext;
|
||||||
|
class MachineBasicBlock;
|
||||||
|
|
||||||
namespace ARMCP {
|
namespace ARMCP {
|
||||||
enum ARMCPKind {
|
enum ARMCPKind {
|
||||||
CPValue,
|
CPValue,
|
||||||
CPExtSymbol,
|
CPExtSymbol,
|
||||||
CPBlockAddress,
|
CPBlockAddress,
|
||||||
CPLSDA
|
CPLSDA,
|
||||||
|
CPMachineBasicBlock
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ARMCPModifier {
|
enum ARMCPModifier {
|
||||||
@ -48,6 +50,7 @@ namespace ARMCP {
|
|||||||
/// instruction and the constant being loaded, i.e. (&GV-(LPIC+8)).
|
/// instruction and the constant being loaded, i.e. (&GV-(LPIC+8)).
|
||||||
class ARMConstantPoolValue : public MachineConstantPoolValue {
|
class ARMConstantPoolValue : public MachineConstantPoolValue {
|
||||||
const Constant *CVal; // Constant being loaded.
|
const Constant *CVal; // Constant being loaded.
|
||||||
|
const MachineBasicBlock *MBB; // MachineBasicBlock being loaded.
|
||||||
const char *S; // ExtSymbol being loaded.
|
const char *S; // ExtSymbol being loaded.
|
||||||
unsigned LabelId; // Label id of the load.
|
unsigned LabelId; // Label id of the load.
|
||||||
ARMCP::ARMCPKind Kind; // Kind of constant.
|
ARMCP::ARMCPKind Kind; // Kind of constant.
|
||||||
@ -62,6 +65,11 @@ public:
|
|||||||
unsigned char PCAdj = 0,
|
unsigned char PCAdj = 0,
|
||||||
ARMCP::ARMCPModifier Modifier = ARMCP::no_modifier,
|
ARMCP::ARMCPModifier Modifier = ARMCP::no_modifier,
|
||||||
bool AddCurrentAddress = false);
|
bool AddCurrentAddress = false);
|
||||||
|
ARMConstantPoolValue(LLVMContext &C, const MachineBasicBlock *mbb,unsigned id,
|
||||||
|
ARMCP::ARMCPKind Kind = ARMCP::CPValue,
|
||||||
|
unsigned char PCAdj = 0,
|
||||||
|
ARMCP::ARMCPModifier Modifier = ARMCP::no_modifier,
|
||||||
|
bool AddCurrentAddress = false);
|
||||||
ARMConstantPoolValue(LLVMContext &C, const char *s, unsigned id,
|
ARMConstantPoolValue(LLVMContext &C, const char *s, unsigned id,
|
||||||
unsigned char PCAdj = 0,
|
unsigned char PCAdj = 0,
|
||||||
ARMCP::ARMCPModifier Modifier = ARMCP::no_modifier,
|
ARMCP::ARMCPModifier Modifier = ARMCP::no_modifier,
|
||||||
@ -73,6 +81,7 @@ public:
|
|||||||
const GlobalValue *getGV() const;
|
const GlobalValue *getGV() const;
|
||||||
const char *getSymbol() const { return S; }
|
const char *getSymbol() const { return S; }
|
||||||
const BlockAddress *getBlockAddress() const;
|
const BlockAddress *getBlockAddress() const;
|
||||||
|
const MachineBasicBlock *getMBB() const;
|
||||||
ARMCP::ARMCPModifier getModifier() const { return Modifier; }
|
ARMCP::ARMCPModifier getModifier() const { return Modifier; }
|
||||||
const char *getModifierText() const {
|
const char *getModifierText() const {
|
||||||
switch (Modifier) {
|
switch (Modifier) {
|
||||||
@ -95,6 +104,7 @@ public:
|
|||||||
bool isExtSymbol() const { return Kind == ARMCP::CPExtSymbol; }
|
bool isExtSymbol() const { return Kind == ARMCP::CPExtSymbol; }
|
||||||
bool isBlockAddress() { return Kind == ARMCP::CPBlockAddress; }
|
bool isBlockAddress() { return Kind == ARMCP::CPBlockAddress; }
|
||||||
bool isLSDA() { return Kind == ARMCP::CPLSDA; }
|
bool isLSDA() { return Kind == ARMCP::CPLSDA; }
|
||||||
|
bool isMachineBasicBlock() { return Kind == ARMCP::CPMachineBasicBlock; }
|
||||||
|
|
||||||
virtual unsigned getRelocationInfo() const { return 2; }
|
virtual unsigned getRelocationInfo() const { return 2; }
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user