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