blob: b5f8325f045db9a79c5b35d1cb0da85e98311f6f [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001//===- ARMConstantPoolValue.h - ARM constantpool value ----------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner081ce942007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007//
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
Dan Gohman02983112008-07-11 20:38:31 +000021class GlobalValue;
22
Dan Gohmanf17a25c2007-07-18 16:29:46 +000023namespace ARMCP {
24 enum ARMCPKind {
25 CPValue,
26 CPNonLazyPtr,
27 CPStub
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)).
34class ARMConstantPoolValue : public MachineConstantPoolValue {
35 GlobalValue *GV; // GlobalValue being loaded.
36 const char *S; // ExtSymbol being loaded.
37 unsigned LabelId; // Label id of the load.
38 ARMCP::ARMCPKind Kind; // non_lazy_ptr or stub?
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
44public:
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(const char *s, unsigned id,
50 ARMCP::ARMCPKind Kind = ARMCP::CPValue,
51 unsigned char PCAdj = 0, const char *Modifier = NULL,
52 bool AddCurrentAddress = false);
53 ARMConstantPoolValue(GlobalValue *GV, ARMCP::ARMCPKind Kind,
54 const char *Modifier);
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 bool isNonLazyPointer() const { return Kind == ARMCP::CPNonLazyPtr; }
64 bool isStub() const { return Kind == ARMCP::CPStub; }
65 unsigned char getPCAdjustment() const { return PCAdjust; }
66
67 virtual int getExistingMachineCPValue(MachineConstantPool *CP,
68 unsigned Alignment);
69
70 virtual void AddSelectionDAGCSEId(FoldingSetNodeID &ID);
71
Evan Chengf3aaeed2008-10-29 23:55:17 +000072 void print(std::ostream *O) const { if (O) print(*O); }
73 void print(std::ostream &O) const;
74 void print(raw_ostream *O) const { if (O) print(*O); }
75 void print(raw_ostream &O) const;
76 void dump() const;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000077};
Evan Chengf3aaeed2008-10-29 23:55:17 +000078
79 inline std::ostream &operator<<(std::ostream &O, const ARMConstantPoolValue &V) {
80 V.print(O);
81 return O;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000082}
Evan Chengf3aaeed2008-10-29 23:55:17 +000083
84inline raw_ostream &operator<<(raw_ostream &O, const ARMConstantPoolValue &V) {
85 V.print(O);
86 return O;
87}
88
89} // End llvm namespace
Dan Gohmanf17a25c2007-07-18 16:29:46 +000090
91#endif