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"
18 #include "llvm/Support/ErrorHandling.h"
46 /// ARMConstantPoolValue - ARM specific constantpool value. This is used to
47 /// represent PC-relative displacement between the address of the load
48 /// instruction and the constant being loaded, i.e. (&GV-(LPIC+8)).
49 class ARMConstantPoolValue
: public MachineConstantPoolValue
{
50 const Constant
*CVal
; // Constant being loaded.
51 const char *S
; // ExtSymbol being loaded.
52 unsigned LabelId
; // Label id of the load.
53 ARMCP::ARMCPKind Kind
; // Kind of constant.
54 unsigned char PCAdjust
; // Extra adjustment if constantpool is pc-relative.
55 // 8 for ARM, 4 for Thumb.
56 ARMCP::ARMCPModifier Modifier
; // GV modifier i.e. (&GV(modifier)-(LPIC+8))
57 bool AddCurrentAddress
;
60 ARMConstantPoolValue(const Constant
*cval
, unsigned id
,
61 ARMCP::ARMCPKind Kind
= ARMCP::CPValue
,
62 unsigned char PCAdj
= 0,
63 ARMCP::ARMCPModifier Modifier
= ARMCP::no_modifier
,
64 bool AddCurrentAddress
= false);
65 ARMConstantPoolValue(LLVMContext
&C
, const char *s
, unsigned id
,
66 unsigned char PCAdj
= 0,
67 ARMCP::ARMCPModifier Modifier
= ARMCP::no_modifier
,
68 bool AddCurrentAddress
= false);
69 ARMConstantPoolValue(const GlobalValue
*GV
, ARMCP::ARMCPModifier Modifier
);
70 ARMConstantPoolValue();
71 ~ARMConstantPoolValue();
73 const GlobalValue
*getGV() const;
74 const char *getSymbol() const { return S
; }
75 const BlockAddress
*getBlockAddress() const;
76 ARMCP::ARMCPModifier
getModifier() const { return Modifier
; }
77 const char *getModifierText() const {
79 default: llvm_unreachable("Unknown modifier!");
80 // FIXME: Are these case sensitive? It'd be nice to lower-case all the
81 // strings if that's legal.
82 case ARMCP::no_modifier
: return "none";
83 case ARMCP::TLSGD
: return "tlsgd";
84 case ARMCP::GOT
: return "GOT";
85 case ARMCP::GOTOFF
: return "GOTOFF";
86 case ARMCP::GOTTPOFF
: return "gottpoff";
87 case ARMCP::TPOFF
: return "tpoff";
90 bool hasModifier() const { return Modifier
!= ARMCP::no_modifier
; }
91 bool mustAddCurrentAddress() const { return AddCurrentAddress
; }
92 unsigned getLabelId() const { return LabelId
; }
93 unsigned char getPCAdjustment() const { return PCAdjust
; }
94 bool isGlobalValue() const { return Kind
== ARMCP::CPValue
; }
95 bool isExtSymbol() const { return Kind
== ARMCP::CPExtSymbol
; }
96 bool isBlockAddress() { return Kind
== ARMCP::CPBlockAddress
; }
97 bool isLSDA() { return Kind
== ARMCP::CPLSDA
; }
99 virtual unsigned getRelocationInfo() const { return 2; }
101 virtual int getExistingMachineCPValue(MachineConstantPool
*CP
,
104 virtual void AddSelectionDAGCSEId(FoldingSetNodeID
&ID
);
106 /// hasSameValue - Return true if this ARM constpool value
107 /// can share the same constantpool entry as another ARM constpool value.
108 bool hasSameValue(ARMConstantPoolValue
*ACPV
);
110 void print(raw_ostream
*O
) const { if (O
) print(*O
); }
111 void print(raw_ostream
&O
) const;
115 inline raw_ostream
&operator<<(raw_ostream
&O
, const ARMConstantPoolValue
&V
) {
120 } // End llvm namespace