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 
00024 namespace ARMCP {
00025   enum ARMCPKind {
00026     CPValue,
00027     CPNonLazyPtr,
00028     CPStub
00029   };
00030 }
00031 
00032 /// ARMConstantPoolValue - ARM specific constantpool value. This is used to
00033 /// represent PC relative displacement between the address of the load
00034 /// instruction and the global value being loaded, i.e. (&GV-(LPIC+8)).
00035 class ARMConstantPoolValue : public MachineConstantPoolValue {
00036   GlobalValue *GV;         // GlobalValue being loaded.
00037   const char *S;           // ExtSymbol being loaded.
00038   unsigned LabelId;        // Label id of the load.
00039   ARMCP::ARMCPKind Kind;   // non_lazy_ptr or stub?
00040   unsigned char PCAdjust;  // Extra adjustment if constantpool is pc relative.
00041                            // 8 for ARM, 4 for Thumb.
00042   const char *Modifier;    // GV modifier i.e. (&GV(modifier)-(LPIC+8))
00043   bool AddCurrentAddress;
00044 
00045 public:
00046   ARMConstantPoolValue(GlobalValue *gv, unsigned id,
00047                        ARMCP::ARMCPKind Kind = ARMCP::CPValue,
00048                        unsigned char PCAdj = 0, const char *Modifier = NULL,
00049                        bool AddCurrentAddress = false);
00050   ARMConstantPoolValue(const char *s, unsigned id,
00051                        ARMCP::ARMCPKind Kind = ARMCP::CPValue,
00052                        unsigned char PCAdj = 0, const char *Modifier = NULL,
00053                        bool AddCurrentAddress = false);
00054   ARMConstantPoolValue(GlobalValue *GV, ARMCP::ARMCPKind Kind,
00055                        const char *Modifier);
00056 
00057 
00058   GlobalValue *getGV() const { return GV; }
00059   const char *getSymbol() const { return S; }
00060   const char *getModifier() const { return Modifier; }
00061   bool hasModifier() const { return Modifier != NULL; }
00062   bool mustAddCurrentAddress() const { return AddCurrentAddress; }
00063   unsigned getLabelId() const { return LabelId; }
00064   bool isNonLazyPointer() const { return Kind == ARMCP::CPNonLazyPtr; }
00065   bool isStub() const { return Kind == ARMCP::CPStub; }
00066   unsigned char getPCAdjustment() const { return PCAdjust; }
00067 
00068   virtual int getExistingMachineCPValue(MachineConstantPool *CP,
00069                                         unsigned Alignment);
00070 
00071   virtual void AddSelectionDAGCSEId(FoldingSetNodeID &ID);
00072 
00073   void print(std::ostream *O) const { if (O) print(*O); }
00074   void print(std::ostream &O) const;
00075   void print(raw_ostream *O) const { if (O) print(*O); }
00076   void print(raw_ostream &O) const;
00077   void dump() const;
00078 };
00079 
00080   inline std::ostream &operator<<(std::ostream &O, const ARMConstantPoolValue &V) {
00081   V.print(O);
00082   return O;
00083 }
00084   
00085 inline raw_ostream &operator<<(raw_ostream &O, const ARMConstantPoolValue &V) {
00086   V.print(O);
00087   return O;
00088 }
00089 
00090 } // End llvm namespace
00091 
00092 #endif