blob: b7511aa8dd644a4756e43778d40c358c5830e643 [file] [log] [blame]
Evan Chenga8e29892007-01-19 07:51:42 +00001//===- ARMConstantPoolValue.h - ARM constantpool value ----------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file was developed by Evan Cheng and is distributed under the
6// University of Illinois Open Source 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
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))
Evan Chenga8e29892007-01-19 07:51:42 +000040
41public:
Evan Chengc60e76d2007-01-30 20:37:08 +000042 ARMConstantPoolValue(GlobalValue *gv, unsigned id,
43 ARMCP::ARMCPKind Kind = ARMCP::CPValue,
Lauro Ramos Venancio0ae4a332007-04-22 00:04:12 +000044 unsigned char PCAdj = 0, const char *Modifier = NULL);
Evan Chengc60e76d2007-01-30 20:37:08 +000045 ARMConstantPoolValue(const char *s, unsigned id,
46 ARMCP::ARMCPKind Kind = ARMCP::CPValue,
Lauro Ramos Venancio0ae4a332007-04-22 00:04:12 +000047 unsigned char PCAdj = 0, const char *Modifier = NULL);
48 ARMConstantPoolValue(GlobalValue *GV, ARMCP::ARMCPKind Kind,
49 const char *Modifier);
50
Evan Chenga8e29892007-01-19 07:51:42 +000051
52 GlobalValue *getGV() const { return GV; }
Evan Chengc60e76d2007-01-30 20:37:08 +000053 const char *getSymbol() const { return S; }
Lauro Ramos Venancio0ae4a332007-04-22 00:04:12 +000054 const char *getModifier() const { return Modifier; }
55 bool hasModifier() const { return Modifier != NULL; }
Evan Chenga8e29892007-01-19 07:51:42 +000056 unsigned getLabelId() const { return LabelId; }
Evan Chengc60e76d2007-01-30 20:37:08 +000057 bool isNonLazyPointer() const { return Kind == ARMCP::CPNonLazyPtr; }
58 bool isStub() const { return Kind == ARMCP::CPStub; }
Evan Chenga8e29892007-01-19 07:51:42 +000059 unsigned char getPCAdjustment() const { return PCAdjust; }
60
61 virtual int getExistingMachineCPValue(MachineConstantPool *CP,
62 unsigned Alignment);
63
64 virtual void AddSelectionDAGCSEId(FoldingSetNodeID &ID);
65
66 virtual void print(std::ostream &O) const;
67};
68
69}
70
71#endif