2007-01-19 07:51:42 +00:00
|
|
|
//===- ARMConstantPoolValue.h - ARM constantpool value ----------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 20:36:04 +00:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2007-01-19 07:51:42 +00: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-09 21:36:17 +00:00
|
|
|
#include "llvm/Support/ErrorHandling.h"
|
2010-06-15 14:50:42 +00:00
|
|
|
#include <cstddef>
|
2007-01-19 07:51:42 +00:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
2009-11-02 16:59:06 +00:00
|
|
|
class Constant;
|
|
|
|
class BlockAddress;
|
2008-07-11 20:38:31 +00:00
|
|
|
class GlobalValue;
|
2009-08-13 21:58:54 +00:00
|
|
|
class LLVMContext;
|
2008-07-11 20:38:31 +00:00
|
|
|
|
2009-09-01 01:57:56 +00:00
|
|
|
namespace ARMCP {
|
|
|
|
enum ARMCPKind {
|
|
|
|
CPValue,
|
2009-11-02 16:59:06 +00:00
|
|
|
CPExtSymbol,
|
|
|
|
CPBlockAddress,
|
2009-09-01 01:57:56 +00:00
|
|
|
CPLSDA
|
|
|
|
};
|
2010-11-09 21:36:17 +00:00
|
|
|
|
|
|
|
enum ARMCPModifier {
|
|
|
|
no_modifier,
|
|
|
|
TLSGD,
|
|
|
|
GOT,
|
|
|
|
GOTOFF,
|
|
|
|
GOTTPOFF,
|
|
|
|
TPOFF
|
|
|
|
};
|
2009-09-01 01:57:56 +00:00
|
|
|
}
|
|
|
|
|
2007-01-19 07:51:42 +00:00
|
|
|
/// ARMConstantPoolValue - ARM specific constantpool value. This is used to
|
2009-11-02 17:10:37 +00:00
|
|
|
/// represent PC-relative displacement between the address of the load
|
2009-11-02 16:59:06 +00:00
|
|
|
/// instruction and the constant being loaded, i.e. (&GV-(LPIC+8)).
|
2007-01-19 07:51:42 +00:00
|
|
|
class ARMConstantPoolValue : public MachineConstantPoolValue {
|
2010-04-15 01:51:59 +00:00
|
|
|
const Constant *CVal; // Constant being loaded.
|
2007-01-30 20:37:08 +00:00
|
|
|
const char *S; // ExtSymbol being loaded.
|
2007-01-19 07:51:42 +00:00
|
|
|
unsigned LabelId; // Label id of the load.
|
2009-11-02 16:59:06 +00:00
|
|
|
ARMCP::ARMCPKind Kind; // Kind of constant.
|
2009-11-02 17:10:37 +00:00
|
|
|
unsigned char PCAdjust; // Extra adjustment if constantpool is pc-relative.
|
2007-01-19 07:51:42 +00:00
|
|
|
// 8 for ARM, 4 for Thumb.
|
2010-11-09 21:36:17 +00:00
|
|
|
ARMCP::ARMCPModifier Modifier; // GV modifier i.e. (&GV(modifier)-(LPIC+8))
|
2007-04-27 13:54:47 +00:00
|
|
|
bool AddCurrentAddress;
|
2007-01-19 07:51:42 +00:00
|
|
|
|
|
|
|
public:
|
2010-04-15 01:51:59 +00:00
|
|
|
ARMConstantPoolValue(const Constant *cval, unsigned id,
|
2009-09-01 01:57:56 +00:00
|
|
|
ARMCP::ARMCPKind Kind = ARMCP::CPValue,
|
2010-11-09 21:36:17 +00:00
|
|
|
unsigned char PCAdj = 0,
|
|
|
|
ARMCP::ARMCPModifier Modifier = ARMCP::no_modifier,
|
2007-04-27 13:54:47 +00:00
|
|
|
bool AddCurrentAddress = false);
|
2009-08-13 21:58:54 +00:00
|
|
|
ARMConstantPoolValue(LLVMContext &C, const char *s, unsigned id,
|
2010-11-09 21:36:17 +00:00
|
|
|
unsigned char PCAdj = 0,
|
|
|
|
ARMCP::ARMCPModifier Modifier = ARMCP::no_modifier,
|
2007-04-27 13:54:47 +00:00
|
|
|
bool AddCurrentAddress = false);
|
2010-11-09 21:36:17 +00:00
|
|
|
ARMConstantPoolValue(const GlobalValue *GV, ARMCP::ARMCPModifier Modifier);
|
2009-08-11 00:09:57 +00:00
|
|
|
ARMConstantPoolValue();
|
2009-08-11 15:26:27 +00:00
|
|
|
~ARMConstantPoolValue();
|
2007-04-22 00:04:12 +00:00
|
|
|
|
2010-04-15 01:51:59 +00:00
|
|
|
const GlobalValue *getGV() const;
|
2007-01-30 20:37:08 +00:00
|
|
|
const char *getSymbol() const { return S; }
|
2010-04-15 01:51:59 +00:00
|
|
|
const BlockAddress *getBlockAddress() const;
|
2010-11-09 21:36:17 +00:00
|
|
|
ARMCP::ARMCPModifier getModifier() const { return Modifier; }
|
|
|
|
const char *getModifierText() const {
|
|
|
|
switch (Modifier) {
|
|
|
|
default: llvm_unreachable("Unknown modifier!");
|
|
|
|
// FIXME: Are these case sensitive? It'd be nice to lower-case all the
|
|
|
|
// strings if that's legal.
|
|
|
|
case ARMCP::no_modifier: return "none";
|
|
|
|
case ARMCP::TLSGD: return "tlsgd";
|
|
|
|
case ARMCP::GOT: return "GOT";
|
|
|
|
case ARMCP::GOTOFF: return "GOTOFF";
|
|
|
|
case ARMCP::GOTTPOFF: return "gottpoff";
|
|
|
|
case ARMCP::TPOFF: return "tpoff";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bool hasModifier() const { return Modifier != ARMCP::no_modifier; }
|
2007-04-27 13:54:47 +00:00
|
|
|
bool mustAddCurrentAddress() const { return AddCurrentAddress; }
|
2007-01-19 07:51:42 +00:00
|
|
|
unsigned getLabelId() const { return LabelId; }
|
|
|
|
unsigned char getPCAdjustment() const { return PCAdjust; }
|
2009-11-02 16:59:06 +00:00
|
|
|
bool isGlobalValue() const { return Kind == ARMCP::CPValue; }
|
|
|
|
bool isExtSymbol() const { return Kind == ARMCP::CPExtSymbol; }
|
|
|
|
bool isBlockAddress() { return Kind == ARMCP::CPBlockAddress; }
|
2009-09-01 01:57:56 +00:00
|
|
|
bool isLSDA() { return Kind == ARMCP::CPLSDA; }
|
2007-01-19 07:51:42 +00:00
|
|
|
|
2010-11-29 23:09:20 +00:00
|
|
|
virtual unsigned getRelocationInfo() const { return 2; }
|
2009-07-21 23:34:23 +00:00
|
|
|
|
2007-01-19 07:51:42 +00:00
|
|
|
virtual int getExistingMachineCPValue(MachineConstantPool *CP,
|
|
|
|
unsigned Alignment);
|
|
|
|
|
|
|
|
virtual void AddSelectionDAGCSEId(FoldingSetNodeID &ID);
|
|
|
|
|
2009-11-07 03:52:02 +00: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-29 23:55:17 +00:00
|
|
|
void print(raw_ostream *O) const { if (O) print(*O); }
|
|
|
|
void print(raw_ostream &O) const;
|
|
|
|
void dump() const;
|
2007-01-19 07:51:42 +00:00
|
|
|
};
|
2008-10-29 23:55:17 +00:00
|
|
|
|
|
|
|
inline raw_ostream &operator<<(raw_ostream &O, const ARMConstantPoolValue &V) {
|
|
|
|
V.print(O);
|
|
|
|
return O;
|
2007-01-19 07:51:42 +00:00
|
|
|
}
|
|
|
|
|
2008-10-29 23:55:17 +00:00
|
|
|
} // End llvm namespace
|
|
|
|
|
2007-01-19 07:51:42 +00:00
|
|
|
#endif
|