LLVM API Documentation

ARMConstantPoolValue.h

Go to the documentation of this file.
00001 //===- ARMConstantPoolValue.h - ARM constantpool value ----------*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file implements the ARM specific constantpool value class.
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 #ifndef LLVM_TARGET_ARM_CONSTANTPOOLVALUE_H
00015 #define LLVM_TARGET_ARM_CONSTANTPOOLVALUE_H
00016 
00017 #include "llvm/CodeGen/MachineConstantPool.h"
00018 #include <iosfwd>
00019 
00020 namespace llvm {
00021 
00022 class GlobalValue;
00023 class LLVMContext;
00024 
00025 /// ARMConstantPoolValue - ARM specific constantpool value. This is used to
00026 /// represent PC relative displacement between the address of the load
00027 /// instruction and the global value being loaded, i.e. (&GV-(LPIC+8)).
00028 class ARMConstantPoolValue : public MachineConstantPoolValue {
00029   GlobalValue *GV;         // GlobalValue being loaded.
00030   const char *S;           // ExtSymbol being loaded.
00031   unsigned LabelId;        // Label id of the load.
00032   unsigned char PCAdjust;  // Extra adjustment if constantpool is pc relative.
00033                            // 8 for ARM, 4 for Thumb.
00034   const char *Modifier;    // GV modifier i.e. (&GV(modifier)-(LPIC+8))
00035   bool AddCurrentAddress;
00036 
00037 public:
00038   ARMConstantPoolValue(GlobalValue *gv, unsigned id,
00039                        unsigned char PCAdj = 0, const char *Modifier = NULL,
00040                        bool AddCurrentAddress = false);
00041   ARMConstantPoolValue(LLVMContext &C, const char *s, unsigned id,
00042                        unsigned char PCAdj = 0, const char *Modifier = NULL,
00043                        bool AddCurrentAddress = false);
00044   ARMConstantPoolValue(GlobalValue *GV, const char *Modifier);
00045   ARMConstantPoolValue();
00046   ~ARMConstantPoolValue();
00047 
00048 
00049   GlobalValue *getGV() const { return GV; }
00050   const char *getSymbol() const { return S; }
00051   const char *getModifier() const { return Modifier; }
00052   bool hasModifier() const { return Modifier != NULL; }
00053   bool mustAddCurrentAddress() const { return AddCurrentAddress; }
00054   unsigned getLabelId() const { return LabelId; }
00055   unsigned char getPCAdjustment() const { return PCAdjust; }
00056 
00057   virtual unsigned getRelocationInfo() const {
00058     // FIXME: This is conservatively claiming that these entries require a
00059     // relocation, we may be able to do better than this.
00060     return 2;
00061   }
00062 
00063 
00064   virtual int getExistingMachineCPValue(MachineConstantPool *CP,
00065                                         unsigned Alignment);
00066 
00067   virtual void AddSelectionDAGCSEId(FoldingSetNodeID &ID);
00068 
00069   void print(std::ostream *O) const { if (O) print(*O); }
00070   void print(std::ostream &O) const;
00071   void print(raw_ostream *O) const { if (O) print(*O); }
00072   void print(raw_ostream &O) const;
00073   void dump() const;
00074 };
00075 
00076 inline std::ostream &operator<<(std::ostream &O,
00077                                 const ARMConstantPoolValue &V) {
00078   V.print(O);
00079   return O;
00080 }
00081 
00082 inline raw_ostream &operator<<(raw_ostream &O, const ARMConstantPoolValue &V) {
00083   V.print(O);
00084   return O;
00085 }
00086 
00087 } // End llvm namespace
00088 
00089 #endif