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"
24 /// ARMConstantPoolValue - ARM specific constantpool value. This is used to
25 /// represent PC relative displacement between the address of the load
26 /// instruction and the global value being loaded, i.e. (&GV-(LPIC+8)).
27 class ARMConstantPoolValue : public MachineConstantPoolValue {
28 GlobalValue *GV; // GlobalValue being loaded.
29 const char *S; // ExtSymbol being loaded.
30 unsigned LabelId; // Label id of the load.
31 unsigned char PCAdjust; // Extra adjustment if constantpool is pc relative.
32 // 8 for ARM, 4 for Thumb.
33 const char *Modifier; // GV modifier i.e. (&GV(modifier)-(LPIC+8))
34 bool AddCurrentAddress;
37 ARMConstantPoolValue(GlobalValue *gv, unsigned id,
38 unsigned char PCAdj = 0, const char *Modifier = NULL,
39 bool AddCurrentAddress = false);
40 ARMConstantPoolValue(LLVMContext &C, const char *s, unsigned id,
41 unsigned char PCAdj = 0, const char *Modifier = NULL,
42 bool AddCurrentAddress = false);
43 ARMConstantPoolValue(GlobalValue *GV, const char *Modifier);
44 ARMConstantPoolValue();
45 ~ARMConstantPoolValue();
48 GlobalValue *getGV() const { return GV; }
49 const char *getSymbol() const { return S; }
50 const char *getModifier() const { return Modifier; }
51 bool hasModifier() const { return Modifier != NULL; }
52 bool mustAddCurrentAddress() const { return AddCurrentAddress; }
53 unsigned getLabelId() const { return LabelId; }
54 unsigned char getPCAdjustment() const { return PCAdjust; }
56 virtual unsigned getRelocationInfo() const {
57 // FIXME: This is conservatively claiming that these entries require a
58 // relocation, we may be able to do better than this.
63 virtual int getExistingMachineCPValue(MachineConstantPool *CP,
66 virtual void AddSelectionDAGCSEId(FoldingSetNodeID &ID);
68 void print(raw_ostream *O) const { if (O) print(*O); }
69 void print(raw_ostream &O) const;
74 inline raw_ostream &operator<<(raw_ostream &O, const ARMConstantPoolValue &V) {
79 } // End llvm namespace