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-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 Constant;
|
|
|
|
class BlockAddress;
|
2008-07-12 04:38:31 +08:00
|
|
|
class GlobalValue;
|
2009-08-14 05:58:54 +08:00
|
|
|
class LLVMContext;
|
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,
|
2009-09-01 09:57:56 +08:00
|
|
|
CPLSDA
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
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.
|
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.
|
2007-04-22 08:04:12 +08:00
|
|
|
const char *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
|
|
|
|
|
|
|
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,
|
2007-04-27 21:54:47 +08:00
|
|
|
unsigned char PCAdj = 0, const char *Modifier = NULL,
|
|
|
|
bool AddCurrentAddress = false);
|
2009-08-14 05:58:54 +08:00
|
|
|
ARMConstantPoolValue(LLVMContext &C, const char *s, unsigned id,
|
2007-04-27 21:54:47 +08:00
|
|
|
unsigned char PCAdj = 0, const char *Modifier = NULL,
|
|
|
|
bool AddCurrentAddress = false);
|
2010-04-15 09:51:59 +08:00
|
|
|
ARMConstantPoolValue(const GlobalValue *GV, const char *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;
|
2007-04-22 08:04:12 +08:00
|
|
|
const char *getModifier() const { return Modifier; }
|
|
|
|
bool hasModifier() const { return Modifier != NULL; }
|
2007-04-27 21:54:47 +08:00
|
|
|
bool mustAddCurrentAddress() const { return AddCurrentAddress; }
|
2007-01-19 15:51:42 +08:00
|
|
|
unsigned getLabelId() const { return LabelId; }
|
|
|
|
unsigned char getPCAdjustment() const { return PCAdjust; }
|
2009-11-03 00:59:06 +08:00
|
|
|
bool isGlobalValue() const { return Kind == ARMCP::CPValue; }
|
|
|
|
bool isExtSymbol() const { return Kind == ARMCP::CPExtSymbol; }
|
|
|
|
bool isBlockAddress() { return Kind == ARMCP::CPBlockAddress; }
|
2009-09-01 09:57:56 +08:00
|
|
|
bool isLSDA() { return Kind == ARMCP::CPLSDA; }
|
2007-01-19 15:51:42 +08:00
|
|
|
|
2009-07-22 07:36:01 +08:00
|
|
|
virtual unsigned getRelocationInfo() const {
|
2009-07-22 07:34:23 +08:00
|
|
|
// FIXME: This is conservatively claiming that these entries require a
|
|
|
|
// relocation, we may be able to do better than this.
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
2007-01-19 15:51:42 +08:00
|
|
|
virtual int getExistingMachineCPValue(MachineConstantPool *CP,
|
|
|
|
unsigned Alignment);
|
|
|
|
|
|
|
|
virtual void AddSelectionDAGCSEId(FoldingSetNodeID &ID);
|
|
|
|
|
2009-11-07 11:52:02 +08:00
|
|
|
/// hasSameValue - Return true if this ARM constpool value
|
|
|
|
/// can share the same constantpool entry as another ARM constpool value.
|
|
|
|
bool hasSameValue(ARMConstantPoolValue *ACPV);
|
|
|
|
|
2008-10-30 07:55:17 +08:00
|
|
|
void print(raw_ostream *O) const { if (O) print(*O); }
|
|
|
|
void print(raw_ostream &O) const;
|
|
|
|
void dump() const;
|
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
|
|
|
}
|
|
|
|
|
2008-10-30 07:55:17 +08:00
|
|
|
} // End llvm namespace
|
|
|
|
|
2007-01-19 15:51:42 +08:00
|
|
|
#endif
|