Clean up LSDA name generation and use for SJLJ exception handling. This
[oota-llvm.git] / lib / Target / ARM / ARMConstantPoolValue.h
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
19 namespace llvm {
20
21 class GlobalValue;
22 class LLVMContext;
23
24 namespace ARMCP {
25   enum ARMCPKind {
26     CPValue,
27     CPLSDA
28   };
29 }
30
31 /// ARMConstantPoolValue - ARM specific constantpool value. This is used to
32 /// represent PC relative displacement between the address of the load
33 /// instruction and the global value being loaded, i.e. (&GV-(LPIC+8)).
34 class ARMConstantPoolValue : public MachineConstantPoolValue {
35   GlobalValue *GV;         // GlobalValue being loaded.
36   const char *S;           // ExtSymbol being loaded.
37   ARMCP::ARMCPKind Kind;   // Value or LSDA?
38   unsigned LabelId;        // Label id of the load.
39   unsigned char PCAdjust;  // Extra adjustment if constantpool is pc relative.
40                            // 8 for ARM, 4 for Thumb.
41   const char *Modifier;    // GV modifier i.e. (&GV(modifier)-(LPIC+8))
42   bool AddCurrentAddress;
43
44 public:
45   ARMConstantPoolValue(GlobalValue *gv, unsigned id,
46                        ARMCP::ARMCPKind Kind = ARMCP::CPValue,
47                        unsigned char PCAdj = 0, const char *Modifier = NULL,
48                        bool AddCurrentAddress = false);
49   ARMConstantPoolValue(LLVMContext &C, const char *s, unsigned id,
50                        unsigned char PCAdj = 0, const char *Modifier = NULL,
51                        bool AddCurrentAddress = false);
52   ARMConstantPoolValue(GlobalValue *GV, const char *Modifier);
53   ARMConstantPoolValue();
54   ~ARMConstantPoolValue();
55
56
57   GlobalValue *getGV() const { return GV; }
58   const char *getSymbol() const { return S; }
59   const char *getModifier() const { return Modifier; }
60   bool hasModifier() const { return Modifier != NULL; }
61   bool mustAddCurrentAddress() const { return AddCurrentAddress; }
62   unsigned getLabelId() const { return LabelId; }
63   unsigned char getPCAdjustment() const { return PCAdjust; }
64   bool isLSDA() { return Kind == ARMCP::CPLSDA; }
65
66   virtual unsigned getRelocationInfo() const {
67     // FIXME: This is conservatively claiming that these entries require a
68     // relocation, we may be able to do better than this.
69     return 2;
70   }
71
72
73   virtual int getExistingMachineCPValue(MachineConstantPool *CP,
74                                         unsigned Alignment);
75
76   virtual void AddSelectionDAGCSEId(FoldingSetNodeID &ID);
77
78   void print(raw_ostream *O) const { if (O) print(*O); }
79   void print(raw_ostream &O) const;
80   void dump() const;
81 };
82
83
84 inline raw_ostream &operator<<(raw_ostream &O, const ARMConstantPoolValue &V) {
85   V.print(O);
86   return O;
87 }
88
89 } // End llvm namespace
90
91 #endif