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"
32 /// ARMConstantPoolValue - ARM specific constantpool value. This is used to
33 /// represent PC relative displacement between the address of the load
34 /// instruction and the global value being loaded, i.e. (&GV-(LPIC+8)).
35 class ARMConstantPoolValue : public MachineConstantPoolValue {
36 GlobalValue *GV; // GlobalValue being loaded.
37 const char *S; // ExtSymbol being loaded.
38 unsigned LabelId; // Label id of the load.
39 ARMCP::ARMCPKind Kind; // non_lazy_ptr or stub?
40 unsigned char PCAdjust; // Extra adjustment if constantpool is pc relative.
41 // 8 for ARM, 4 for Thumb.
42 const char *Modifier; // GV modifier i.e. (&GV(modifier)-(LPIC+8))
43 bool AddCurrentAddress;
46 ARMConstantPoolValue(GlobalValue *gv, unsigned id,
47 ARMCP::ARMCPKind Kind = ARMCP::CPValue,
48 unsigned char PCAdj = 0, const char *Modifier = NULL,
49 bool AddCurrentAddress = false);
50 ARMConstantPoolValue(LLVMContext &C, const char *s, unsigned id,
51 ARMCP::ARMCPKind Kind = ARMCP::CPValue,
52 unsigned char PCAdj = 0, const char *Modifier = NULL,
53 bool AddCurrentAddress = false);
54 ARMConstantPoolValue(GlobalValue *GV, ARMCP::ARMCPKind Kind,
55 const char *Modifier);
56 ARMConstantPoolValue();
57 ~ARMConstantPoolValue();
60 GlobalValue *getGV() const { return GV; }
61 const char *getSymbol() const { return S; }
62 const char *getModifier() const { return Modifier; }
63 bool hasModifier() const { return Modifier != NULL; }
64 bool mustAddCurrentAddress() const { return AddCurrentAddress; }
65 unsigned getLabelId() const { return LabelId; }
66 bool isNonLazyPointer() const { return Kind == ARMCP::CPNonLazyPtr; }
67 bool isStub() const { return Kind == ARMCP::CPStub; }
68 unsigned char getPCAdjustment() const { return PCAdjust; }
70 virtual unsigned getRelocationInfo() const {
71 // FIXME: This is conservatively claiming that these entries require a
72 // relocation, we may be able to do better than this.
77 virtual int getExistingMachineCPValue(MachineConstantPool *CP,
80 virtual void AddSelectionDAGCSEId(FoldingSetNodeID &ID);
82 void print(raw_ostream *O) const { if (O) print(*O); }
83 void print(raw_ostream &O) const;
88 inline raw_ostream &operator<<(raw_ostream &O, const ARMConstantPoolValue &V) {
93 } // End llvm namespace