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"
36 /// ARMConstantPoolValue - ARM specific constantpool value. This is used to
37 /// represent PC-relative displacement between the address of the load
38 /// instruction and the constant being loaded, i.e. (&GV-(LPIC+8)).
39 class ARMConstantPoolValue : public MachineConstantPoolValue {
40 const Constant *CVal; // Constant being loaded.
41 const char *S; // ExtSymbol being loaded.
42 unsigned LabelId; // Label id of the load.
43 ARMCP::ARMCPKind Kind; // Kind of constant.
44 unsigned char PCAdjust; // Extra adjustment if constantpool is pc-relative.
45 // 8 for ARM, 4 for Thumb.
46 const char *Modifier; // GV modifier i.e. (&GV(modifier)-(LPIC+8))
47 bool AddCurrentAddress;
50 ARMConstantPoolValue(const Constant *cval, unsigned id,
51 ARMCP::ARMCPKind Kind = ARMCP::CPValue,
52 unsigned char PCAdj = 0, const char *Modifier = NULL,
53 bool AddCurrentAddress = false);
54 ARMConstantPoolValue(LLVMContext &C, const char *s, unsigned id,
55 unsigned char PCAdj = 0, const char *Modifier = NULL,
56 bool AddCurrentAddress = false);
57 ARMConstantPoolValue(const GlobalValue *GV, const char *Modifier);
58 ARMConstantPoolValue();
59 ~ARMConstantPoolValue();
61 const GlobalValue *getGV() const;
62 const char *getSymbol() const { return S; }
63 const BlockAddress *getBlockAddress() const;
64 const char *getModifier() const { return Modifier; }
65 bool hasModifier() const { return Modifier != NULL; }
66 bool mustAddCurrentAddress() const { return AddCurrentAddress; }
67 unsigned getLabelId() const { return LabelId; }
68 unsigned char getPCAdjustment() const { return PCAdjust; }
69 bool isGlobalValue() const { return Kind == ARMCP::CPValue; }
70 bool isExtSymbol() const { return Kind == ARMCP::CPExtSymbol; }
71 bool isBlockAddress() { return Kind == ARMCP::CPBlockAddress; }
72 bool isLSDA() { return Kind == ARMCP::CPLSDA; }
74 virtual unsigned getRelocationInfo() const {
75 // FIXME: This is conservatively claiming that these entries require a
76 // relocation, we may be able to do better than this.
80 virtual int getExistingMachineCPValue(MachineConstantPool *CP,
83 virtual void AddSelectionDAGCSEId(FoldingSetNodeID &ID);
85 /// hasSameValue - Return true if this ARM constpool value
86 /// can share the same constantpool entry as another ARM constpool value.
87 bool hasSameValue(ARMConstantPoolValue *ACPV);
89 void print(raw_ostream *O) const { if (O) print(*O); }
90 void print(raw_ostream &O) const;
94 inline raw_ostream &operator<<(raw_ostream &O, const ARMConstantPoolValue &V) {
99 } // End llvm namespace