blob: db4c057a0a9a52c6ad0b5fc3fa6f4a3aabb5e937 [file] [log] [blame]
Evan Chenga8e29892007-01-19 07:51:42 +00001//===- ARMConstantPoolValue.h - ARM constantpool value ----------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Evan Chenga8e29892007-01-19 07:51:42 +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
Evan Chengc60e76d2007-01-30 20:37:08 +000021namespace ARMCP {
22 enum ARMCPKind {
23 CPValue,
24 CPNonLazyPtr,
25 CPStub
26 };
27}
28
Evan Chenga8e29892007-01-19 07:51:42 +000029/// ARMConstantPoolValue - ARM specific constantpool value. This is used to
30/// represent PC relative displacement between the address of the load
31/// instruction and the global value being loaded, i.e. (&GV-(LPIC+8)).
32class ARMConstantPoolValue : public MachineConstantPoolValue {
33 GlobalValue *GV; // GlobalValue being loaded.
Evan Chengc60e76d2007-01-30 20:37:08 +000034 const char *S; // ExtSymbol being loaded.
Evan Chenga8e29892007-01-19 07:51:42 +000035 unsigned LabelId; // Label id of the load.
Evan Chengc60e76d2007-01-30 20:37:08 +000036 ARMCP::ARMCPKind Kind; // non_lazy_ptr or stub?
Evan Chenga8e29892007-01-19 07:51:42 +000037 unsigned char PCAdjust; // Extra adjustment if constantpool is pc relative.
38 // 8 for ARM, 4 for Thumb.
Lauro Ramos Venancio0ae4a332007-04-22 00:04:12 +000039 const char *Modifier; // GV modifier i.e. (&GV(modifier)-(LPIC+8))
Lauro Ramos Venancio64f4fa52007-04-27 13:54:47 +000040 bool AddCurrentAddress;
Evan Chenga8e29892007-01-19 07:51:42 +000041
42public:
Evan Chengc60e76d2007-01-30 20:37:08 +000043 ARMConstantPoolValue(GlobalValue *gv, unsigned id,
44 ARMCP::ARMCPKind Kind = ARMCP::CPValue,
Lauro Ramos Venancio64f4fa52007-04-27 13:54:47 +000045 unsigned char PCAdj = 0, const char *Modifier = NULL,
46 bool AddCurrentAddress = false);
Evan Chengc60e76d2007-01-30 20:37:08 +000047 ARMConstantPoolValue(const char *s, unsigned id,
48 ARMCP::ARMCPKind Kind = ARMCP::CPValue,
Lauro Ramos Venancio64f4fa52007-04-27 13:54:47 +000049 unsigned char PCAdj = 0, const char *Modifier = NULL,
50 bool AddCurrentAddress = false);
Lauro Ramos Venancio0ae4a332007-04-22 00:04:12 +000051 ARMConstantPoolValue(GlobalValue *GV, ARMCP::ARMCPKind Kind,
52 const char *Modifier);
53
Evan Chenga8e29892007-01-19 07:51:42 +000054
55 GlobalValue *getGV() const { return GV; }
Evan Chengc60e76d2007-01-30 20:37:08 +000056 const char *getSymbol() const { return S; }
Lauro Ramos Venancio0ae4a332007-04-22 00:04:12 +000057 const char *getModifier() const { return Modifier; }
58 bool hasModifier() const { return Modifier != NULL; }
Lauro Ramos Venancio64f4fa52007-04-27 13:54:47 +000059 bool mustAddCurrentAddress() const { return AddCurrentAddress; }
Evan Chenga8e29892007-01-19 07:51:42 +000060 unsigned getLabelId() const { return LabelId; }
Evan Chengc60e76d2007-01-30 20:37:08 +000061 bool isNonLazyPointer() const { return Kind == ARMCP::CPNonLazyPtr; }
62 bool isStub() const { return Kind == ARMCP::CPStub; }
Evan Chenga8e29892007-01-19 07:51:42 +000063 unsigned char getPCAdjustment() const { return PCAdjust; }
64
65 virtual int getExistingMachineCPValue(MachineConstantPool *CP,
66 unsigned Alignment);
67
68 virtual void AddSelectionDAGCSEId(FoldingSetNodeID &ID);
69
70 virtual void print(std::ostream &O) const;
71};
72
73}
74
75#endif