2007-01-19 15:51:42 +08:00
|
|
|
//===- ARMConstantPoolValue.h - ARM constantpool value ----------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-30 04:36:04 +08:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2007-01-19 15:51:42 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file implements the ARM specific constantpool value class.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_TARGET_ARM_CONSTANTPOOLVALUE_H
|
|
|
|
#define LLVM_TARGET_ARM_CONSTANTPOOLVALUE_H
|
|
|
|
|
|
|
|
#include "llvm/CodeGen/MachineConstantPool.h"
|
2010-11-10 05:36:17 +08:00
|
|
|
#include "llvm/Support/ErrorHandling.h"
|
2010-06-15 22:50:42 +08:00
|
|
|
#include <cstddef>
|
2007-01-19 15:51:42 +08:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
2009-11-03 00:59:06 +08:00
|
|
|
class BlockAddress;
|
2011-09-30 07:48:44 +08:00
|
|
|
class Constant;
|
2008-07-12 04:38:31 +08:00
|
|
|
class GlobalValue;
|
2009-08-14 05:58:54 +08:00
|
|
|
class LLVMContext;
|
2011-09-30 07:48:44 +08:00
|
|
|
class MachineBasicBlock;
|
2008-07-12 04:38:31 +08:00
|
|
|
|
2009-09-01 09:57:56 +08:00
|
|
|
namespace ARMCP {
|
|
|
|
enum ARMCPKind {
|
|
|
|
CPValue,
|
2009-11-03 00:59:06 +08:00
|
|
|
CPExtSymbol,
|
|
|
|
CPBlockAddress,
|
2011-09-30 07:48:44 +08:00
|
|
|
CPLSDA,
|
|
|
|
CPMachineBasicBlock
|
2009-09-01 09:57:56 +08:00
|
|
|
};
|
2010-11-10 05:36:17 +08:00
|
|
|
|
|
|
|
enum ARMCPModifier {
|
|
|
|
no_modifier,
|
|
|
|
TLSGD,
|
|
|
|
GOT,
|
|
|
|
GOTOFF,
|
|
|
|
GOTTPOFF,
|
|
|
|
TPOFF
|
|
|
|
};
|
2009-09-01 09:57:56 +08:00
|
|
|
}
|
|
|
|
|
2007-01-19 15:51:42 +08:00
|
|
|
/// ARMConstantPoolValue - ARM specific constantpool value. This is used to
|
2009-11-03 01:10:37 +08:00
|
|
|
/// represent PC-relative displacement between the address of the load
|
2009-11-03 00:59:06 +08:00
|
|
|
/// instruction and the constant being loaded, i.e. (&GV-(LPIC+8)).
|
2007-01-19 15:51:42 +08:00
|
|
|
class ARMConstantPoolValue : public MachineConstantPoolValue {
|
2010-04-15 09:51:59 +08:00
|
|
|
const Constant *CVal; // Constant being loaded.
|
2011-09-30 07:48:44 +08:00
|
|
|
const MachineBasicBlock *MBB; // MachineBasicBlock being loaded.
|
2007-01-31 04:37:08 +08:00
|
|
|
const char *S; // ExtSymbol being loaded.
|
2007-01-19 15:51:42 +08:00
|
|
|
unsigned LabelId; // Label id of the load.
|
2009-11-03 00:59:06 +08:00
|
|
|
ARMCP::ARMCPKind Kind; // Kind of constant.
|
2009-11-03 01:10:37 +08:00
|
|
|
unsigned char PCAdjust; // Extra adjustment if constantpool is pc-relative.
|
2007-01-19 15:51:42 +08:00
|
|
|
// 8 for ARM, 4 for Thumb.
|
2010-11-10 05:36:17 +08:00
|
|
|
ARMCP::ARMCPModifier Modifier; // GV modifier i.e. (&GV(modifier)-(LPIC+8))
|
2007-04-27 21:54:47 +08:00
|
|
|
bool AddCurrentAddress;
|
2007-01-19 15:51:42 +08:00
|
|
|
|
2011-10-01 14:40:33 +08:00
|
|
|
protected:
|
|
|
|
ARMConstantPoolValue(Type *Ty, unsigned id, ARMCP::ARMCPKind Kind,
|
|
|
|
unsigned char PCAdj, ARMCP::ARMCPModifier Modifier,
|
|
|
|
bool AddCurrentAddress);
|
|
|
|
|
2007-01-19 15:51:42 +08:00
|
|
|
public:
|
2010-04-15 09:51:59 +08:00
|
|
|
ARMConstantPoolValue(const Constant *cval, unsigned id,
|
2009-09-01 09:57:56 +08:00
|
|
|
ARMCP::ARMCPKind Kind = ARMCP::CPValue,
|
2010-11-10 05:36:17 +08:00
|
|
|
unsigned char PCAdj = 0,
|
|
|
|
ARMCP::ARMCPModifier Modifier = ARMCP::no_modifier,
|
2007-04-27 21:54:47 +08:00
|
|
|
bool AddCurrentAddress = false);
|
2011-09-30 07:48:44 +08:00
|
|
|
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);
|
2009-08-14 05:58:54 +08:00
|
|
|
ARMConstantPoolValue(LLVMContext &C, const char *s, unsigned id,
|
2010-11-10 05:36:17 +08:00
|
|
|
unsigned char PCAdj = 0,
|
|
|
|
ARMCP::ARMCPModifier Modifier = ARMCP::no_modifier,
|
2007-04-27 21:54:47 +08:00
|
|
|
bool AddCurrentAddress = false);
|
2010-11-10 05:36:17 +08:00
|
|
|
ARMConstantPoolValue(const GlobalValue *GV, ARMCP::ARMCPModifier Modifier);
|
2009-08-11 08:09:57 +08:00
|
|
|
ARMConstantPoolValue();
|
2009-08-11 23:26:27 +08:00
|
|
|
~ARMConstantPoolValue();
|
2007-04-22 08:04:12 +08:00
|
|
|
|
2010-04-15 09:51:59 +08:00
|
|
|
const GlobalValue *getGV() const;
|
2007-01-31 04:37:08 +08:00
|
|
|
const char *getSymbol() const { return S; }
|
2010-04-15 09:51:59 +08:00
|
|
|
const BlockAddress *getBlockAddress() const;
|
2011-09-30 07:48:44 +08:00
|
|
|
const MachineBasicBlock *getMBB() const;
|
2011-10-01 02:42:06 +08:00
|
|
|
|
2010-11-10 05:36:17 +08:00
|
|
|
ARMCP::ARMCPModifier getModifier() const { return Modifier; }
|
2011-10-01 02:42:06 +08:00
|
|
|
const char *getModifierText() const;
|
2010-11-10 05:36:17 +08:00
|
|
|
bool hasModifier() const { return Modifier != ARMCP::no_modifier; }
|
2011-10-01 02:42:06 +08:00
|
|
|
|
2007-04-27 21:54:47 +08:00
|
|
|
bool mustAddCurrentAddress() const { return AddCurrentAddress; }
|
2011-10-01 02:42:06 +08:00
|
|
|
|
2007-01-19 15:51:42 +08:00
|
|
|
unsigned getLabelId() const { return LabelId; }
|
|
|
|
unsigned char getPCAdjustment() const { return PCAdjust; }
|
2011-10-01 02:42:06 +08:00
|
|
|
|
2009-11-03 00:59:06 +08:00
|
|
|
bool isGlobalValue() const { return Kind == ARMCP::CPValue; }
|
|
|
|
bool isExtSymbol() const { return Kind == ARMCP::CPExtSymbol; }
|
2011-10-01 14:40:33 +08:00
|
|
|
bool isBlockAddress() const { return Kind == ARMCP::CPBlockAddress; }
|
2011-10-01 02:42:06 +08:00
|
|
|
bool isLSDA() const { return Kind == ARMCP::CPLSDA; }
|
2011-09-30 07:48:44 +08:00
|
|
|
bool isMachineBasicBlock() { return Kind == ARMCP::CPMachineBasicBlock; }
|
2007-01-19 15:51:42 +08:00
|
|
|
|
2010-11-30 07:09:20 +08:00
|
|
|
virtual unsigned getRelocationInfo() const { return 2; }
|
2009-07-22 07:34:23 +08:00
|
|
|
|
2007-01-19 15:51:42 +08:00
|
|
|
virtual int getExistingMachineCPValue(MachineConstantPool *CP,
|
|
|
|
unsigned Alignment);
|
|
|
|
|
2011-09-28 04:59:33 +08:00
|
|
|
virtual void addSelectionDAGCSEId(FoldingSetNodeID &ID);
|
2007-01-19 15:51:42 +08:00
|
|
|
|
2011-10-01 14:40:33 +08:00
|
|
|
/// hasSameValue - Return true if this ARM constpool value can share the same
|
|
|
|
/// constantpool entry as another ARM constpool value.
|
|
|
|
virtual bool hasSameValue(ARMConstantPoolValue *ACPV);
|
2009-11-07 11:52:02 +08:00
|
|
|
|
2011-10-01 14:40:33 +08:00
|
|
|
virtual void print(raw_ostream &O) const;
|
2008-10-30 07:55:17 +08:00
|
|
|
void print(raw_ostream *O) const { if (O) print(*O); }
|
|
|
|
void dump() const;
|
2011-10-01 14:40:33 +08:00
|
|
|
|
|
|
|
static bool classof(const ARMConstantPoolValue *) { return true; }
|
2007-01-19 15:51:42 +08:00
|
|
|
};
|
2008-10-30 07:55:17 +08:00
|
|
|
|
|
|
|
inline raw_ostream &operator<<(raw_ostream &O, const ARMConstantPoolValue &V) {
|
|
|
|
V.print(O);
|
|
|
|
return O;
|
2007-01-19 15:51:42 +08:00
|
|
|
}
|
|
|
|
|
2011-10-01 14:40:33 +08:00
|
|
|
/// 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);
|
2011-10-01 14:44:24 +08:00
|
|
|
static ARMConstantPoolConstant *Create(const Constant *C, unsigned ID,
|
|
|
|
ARMCP::ARMCPKind Kind,
|
|
|
|
unsigned char PCAdj);
|
2011-10-01 14:40:33 +08:00
|
|
|
|
|
|
|
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; }
|
|
|
|
};
|
|
|
|
|
2008-10-30 07:55:17 +08:00
|
|
|
} // End llvm namespace
|
|
|
|
|
2007-01-19 15:51:42 +08:00
|
|
|
#endif
|