ARM "rrx" shift operands do not have an immediate. PR7790.
[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 #include <cstddef>
19
20 namespace llvm {
21
22 class Constant;
23 class BlockAddress;
24 class GlobalValue;
25 class LLVMContext;
26
27 namespace ARMCP {
28   enum ARMCPKind {
29     CPValue,
30     CPExtSymbol,
31     CPBlockAddress,
32     CPLSDA
33   };
34 }
35
36 /// ARMConstantPoolValue - ARM specific constantpool value. This is used to
37 /// represent PC-relative displacement between the address of the load
38 /// instruction and the constant being loaded, i.e. (&GV-(LPIC+8)).
39 class ARMConstantPoolValue : public MachineConstantPoolValue {
40   const Constant *CVal;    // Constant being loaded.
41   const char *S;           // ExtSymbol being loaded.
42   unsigned LabelId;        // Label id of the load.
43   ARMCP::ARMCPKind Kind;   // Kind of constant.
44   unsigned char PCAdjust;  // Extra adjustment if constantpool is pc-relative.
45                            // 8 for ARM, 4 for Thumb.
46   const char *Modifier;    // GV modifier i.e. (&GV(modifier)-(LPIC+8))
47   bool AddCurrentAddress;
48
49 public:
50   ARMConstantPoolValue(const Constant *cval, unsigned id,
51                        ARMCP::ARMCPKind Kind = ARMCP::CPValue,
52                        unsigned char PCAdj = 0, const char *Modifier = NULL,
53                        bool AddCurrentAddress = false);
54   ARMConstantPoolValue(LLVMContext &C, const char *s, unsigned id,
55                        unsigned char PCAdj = 0, const char *Modifier = NULL,
56                        bool AddCurrentAddress = false);
57   ARMConstantPoolValue(const GlobalValue *GV, const char *Modifier);
58   ARMConstantPoolValue();
59   ~ARMConstantPoolValue();
60
61   const GlobalValue *getGV() const;
62   const char *getSymbol() const { return S; }
63   const BlockAddress *getBlockAddress() const;
64   const char *getModifier() const { return Modifier; }
65   bool hasModifier() const { return Modifier != NULL; }
66   bool mustAddCurrentAddress() const { return AddCurrentAddress; }
67   unsigned getLabelId() const { return LabelId; }
68   unsigned char getPCAdjustment() const { return PCAdjust; }
69   bool isGlobalValue() const { return Kind == ARMCP::CPValue; }
70   bool isExtSymbol() const { return Kind == ARMCP::CPExtSymbol; }
71   bool isBlockAddress() { return Kind == ARMCP::CPBlockAddress; }
72   bool isLSDA() { return Kind == ARMCP::CPLSDA; }
73
74   virtual unsigned getRelocationInfo() const {
75     // FIXME: This is conservatively claiming that these entries require a
76     // relocation, we may be able to do better than this.
77     return 2;
78   }
79
80   virtual int getExistingMachineCPValue(MachineConstantPool *CP,
81                                         unsigned Alignment);
82
83   virtual void AddSelectionDAGCSEId(FoldingSetNodeID &ID);
84
85   /// hasSameValue - Return true if this ARM constpool value
86   /// can share the same constantpool entry as another ARM constpool value.
87   bool hasSameValue(ARMConstantPoolValue *ACPV);
88
89   void print(raw_ostream *O) const { if (O) print(*O); }
90   void print(raw_ostream &O) const;
91   void dump() const;
92 };
93
94 inline raw_ostream &operator<<(raw_ostream &O, const ARMConstantPoolValue &V) {
95   V.print(O);
96   return O;
97 }
98
99 } // End llvm namespace
100
101 #endif