blob: a614bec60fec83e4778592814a3eb5ea38b41af7 [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.
39
40public:
Evan Chengc60e76d2007-01-30 20:37:08 +000041 ARMConstantPoolValue(GlobalValue *gv, unsigned id,
42 ARMCP::ARMCPKind Kind = ARMCP::CPValue,
43 unsigned char PCAdj = 0);
44 ARMConstantPoolValue(const char *s, unsigned id,
45 ARMCP::ARMCPKind Kind = ARMCP::CPValue,
Evan Chenga8e29892007-01-19 07:51:42 +000046 unsigned char PCAdj = 0);
47
48 GlobalValue *getGV() const { return GV; }
Evan Chengc60e76d2007-01-30 20:37:08 +000049 const char *getSymbol() const { return S; }
Evan Chenga8e29892007-01-19 07:51:42 +000050 unsigned getLabelId() const { return LabelId; }
Evan Chengc60e76d2007-01-30 20:37:08 +000051 bool isNonLazyPointer() const { return Kind == ARMCP::CPNonLazyPtr; }
52 bool isStub() const { return Kind == ARMCP::CPStub; }
Evan Chenga8e29892007-01-19 07:51:42 +000053 unsigned char getPCAdjustment() const { return PCAdjust; }
54
55 virtual int getExistingMachineCPValue(MachineConstantPool *CP,
56 unsigned Alignment);
57
58 virtual void AddSelectionDAGCSEId(FoldingSetNodeID &ID);
59
60 virtual void print(std::ostream &O) const;
61};
62
63}
64
65#endif