1 //===- ARMConstantPoolValue.h - ARM constantpool value ----------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file implements the ARM specific constantpool value class.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_TARGET_ARM_CONSTANTPOOLVALUE_H
15 #define LLVM_TARGET_ARM_CONSTANTPOOLVALUE_H
17 #include "llvm/CodeGen/MachineConstantPool.h"
33 /// ARMConstantPoolValue - ARM specific constantpool value. This is used to
34 /// represent PC relative displacement between the address of the load
35 /// instruction and the global value being loaded, i.e. (&GV-(LPIC+8)).
36 class ARMConstantPoolValue : public MachineConstantPoolValue {
37 GlobalValue *GV; // GlobalValue being loaded.
38 const char *S; // ExtSymbol being loaded.
39 unsigned LabelId; // Label id of the load.
40 ARMCP::ARMCPKind Kind; // non_lazy_ptr or stub?
41 unsigned char PCAdjust; // Extra adjustment if constantpool is pc relative.
42 // 8 for ARM, 4 for Thumb.
43 const char *Modifier; // GV modifier i.e. (&GV(modifier)-(LPIC+8))
44 bool AddCurrentAddress;
47 ARMConstantPoolValue(GlobalValue *gv, unsigned id,
48 ARMCP::ARMCPKind Kind = ARMCP::CPValue,
49 unsigned char PCAdj = 0, const char *Modifier = NULL,
50 bool AddCurrentAddress = false);
51 ARMConstantPoolValue(const char *s, unsigned id,
52 ARMCP::ARMCPKind Kind = ARMCP::CPValue,
53 unsigned char PCAdj = 0, const char *Modifier = NULL,
54 bool AddCurrentAddress = false);
55 ARMConstantPoolValue(GlobalValue *GV, ARMCP::ARMCPKind Kind,
56 const char *Modifier);
57 ARMConstantPoolValue();
58 ~ARMConstantPoolValue() {free((void*)S);}
61 GlobalValue *getGV() const { return GV; }
62 const char *getSymbol() const { return S; }
63 const char *getModifier() const { return Modifier; }
64 bool hasModifier() const { return Modifier != NULL; }
65 bool mustAddCurrentAddress() const { return AddCurrentAddress; }
66 unsigned getLabelId() const { return LabelId; }
67 bool isNonLazyPointer() const { return Kind == ARMCP::CPNonLazyPtr; }
68 bool isStub() const { return Kind == ARMCP::CPStub; }
69 unsigned char getPCAdjustment() const { return PCAdjust; }
71 virtual unsigned getRelocationInfo() const {
72 // FIXME: This is conservatively claiming that these entries require a
73 // relocation, we may be able to do better than this.
78 virtual int getExistingMachineCPValue(MachineConstantPool *CP,
81 virtual void AddSelectionDAGCSEId(FoldingSetNodeID &ID);
83 void print(std::ostream *O) const { if (O) print(*O); }
84 void print(std::ostream &O) const;
85 void print(raw_ostream *O) const { if (O) print(*O); }
86 void print(raw_ostream &O) const;
90 inline std::ostream &operator<<(std::ostream &O,
91 const ARMConstantPoolValue &V) {
96 inline raw_ostream &operator<<(raw_ostream &O, const ARMConstantPoolValue &V) {
101 } // End llvm namespace