ARMConstantPoolValue.h revision e4e4ed3b56f63e9343e01bf0b2ecd7c1f45d296c
1//===- ARMConstantPoolValue.h - ARM constantpool value ----------*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9// 10// This file implements the ARM specific constantpool value class. 11// 12//===----------------------------------------------------------------------===// 13 14#ifndef LLVM_TARGET_ARM_CONSTANTPOOLVALUE_H 15#define LLVM_TARGET_ARM_CONSTANTPOOLVALUE_H 16 17#include "llvm/CodeGen/MachineConstantPool.h" 18 19namespace llvm { 20 21class GlobalValue; 22class LLVMContext; 23 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)). 27class 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; 35 36public: 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(); 46 47 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; } 55 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. 59 return 2; 60 } 61 62 63 virtual int getExistingMachineCPValue(MachineConstantPool *CP, 64 unsigned Alignment); 65 66 virtual void AddSelectionDAGCSEId(FoldingSetNodeID &ID); 67 68 void print(raw_ostream *O) const { if (O) print(*O); } 69 void print(raw_ostream &O) const; 70 void dump() const; 71}; 72 73 74inline raw_ostream &operator<<(raw_ostream &O, const ARMConstantPoolValue &V) { 75 V.print(O); 76 return O; 77} 78 79} // End llvm namespace 80 81#endif 82