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