blob: 8a0348b7970a5d10439cef045f9a0938a0f2e6b4 [file] [log] [blame]
Evan Cheng10043e22007-01-19 07:51:42 +00001//===- ARMConstantPoolValue.h - ARM constantpool value ----------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattnerf3ebc3f2007-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 Cheng10043e22007-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
Dan Gohman0597e5b2008-07-11 20:38:31 +000021class GlobalValue;
Owen Anderson55f1c092009-08-13 21:58:54 +000022class LLVMContext;
Dan Gohman0597e5b2008-07-11 20:38:31 +000023
Evan Cheng10043e22007-01-19 07:51:42 +000024/// ARMConstantPoolValue - ARM specific constantpool value. This is used to
25/// represent PC relative displacement between the address of the load
26/// instruction and the global value being loaded, i.e. (&GV-(LPIC+8)).
27class ARMConstantPoolValue : public MachineConstantPoolValue {
28 GlobalValue *GV; // GlobalValue being loaded.
Evan Cheng83f35172007-01-30 20:37:08 +000029 const char *S; // ExtSymbol being loaded.
Evan Cheng10043e22007-01-19 07:51:42 +000030 unsigned LabelId; // Label id of the load.
Evan Cheng10043e22007-01-19 07:51:42 +000031 unsigned char PCAdjust; // Extra adjustment if constantpool is pc relative.
32 // 8 for ARM, 4 for Thumb.
Lauro Ramos Venancioee2d1642007-04-22 00:04:12 +000033 const char *Modifier; // GV modifier i.e. (&GV(modifier)-(LPIC+8))
Lauro Ramos Venancioc39c12a2007-04-27 13:54:47 +000034 bool AddCurrentAddress;
Evan Cheng10043e22007-01-19 07:51:42 +000035
36public:
Evan Cheng83f35172007-01-30 20:37:08 +000037 ARMConstantPoolValue(GlobalValue *gv, unsigned id,
Lauro Ramos Venancioc39c12a2007-04-27 13:54:47 +000038 unsigned char PCAdj = 0, const char *Modifier = NULL,
39 bool AddCurrentAddress = false);
Owen Anderson55f1c092009-08-13 21:58:54 +000040 ARMConstantPoolValue(LLVMContext &C, const char *s, unsigned id,
Lauro Ramos Venancioc39c12a2007-04-27 13:54:47 +000041 unsigned char PCAdj = 0, const char *Modifier = NULL,
42 bool AddCurrentAddress = false);
Evan Cheng43b9ca62009-08-28 23:18:09 +000043 ARMConstantPoolValue(GlobalValue *GV, const char *Modifier);
Jim Grosbach693e36a2009-08-11 00:09:57 +000044 ARMConstantPoolValue();
Jim Grosbach74eb9e72009-08-11 15:26:27 +000045 ~ARMConstantPoolValue();
Lauro Ramos Venancioee2d1642007-04-22 00:04:12 +000046
Evan Cheng10043e22007-01-19 07:51:42 +000047
48 GlobalValue *getGV() const { return GV; }
Evan Cheng83f35172007-01-30 20:37:08 +000049 const char *getSymbol() const { return S; }
Lauro Ramos Venancioee2d1642007-04-22 00:04:12 +000050 const char *getModifier() const { return Modifier; }
51 bool hasModifier() const { return Modifier != NULL; }
Lauro Ramos Venancioc39c12a2007-04-27 13:54:47 +000052 bool mustAddCurrentAddress() const { return AddCurrentAddress; }
Evan Cheng10043e22007-01-19 07:51:42 +000053 unsigned getLabelId() const { return LabelId; }
Evan Cheng10043e22007-01-19 07:51:42 +000054 unsigned char getPCAdjustment() const { return PCAdjust; }
55
Chris Lattner9bd736e2009-07-21 23:36:01 +000056 virtual unsigned getRelocationInfo() const {
Chris Lattnercfb01e22009-07-21 23:34:23 +000057 // FIXME: This is conservatively claiming that these entries require a
58 // relocation, we may be able to do better than this.
59 return 2;
60 }
61
Jim Grosbachf24f9d92009-08-11 15:33:49 +000062
Evan Cheng10043e22007-01-19 07:51:42 +000063 virtual int getExistingMachineCPValue(MachineConstantPool *CP,
64 unsigned Alignment);
65
66 virtual void AddSelectionDAGCSEId(FoldingSetNodeID &ID);
67
Evan Chengde9dbc52008-10-29 23:55:17 +000068 void print(raw_ostream *O) const { if (O) print(*O); }
69 void print(raw_ostream &O) const;
70 void dump() const;
Evan Cheng10043e22007-01-19 07:51:42 +000071};
Evan Chengde9dbc52008-10-29 23:55:17 +000072
Jim Grosbachf24f9d92009-08-11 15:33:49 +000073
Evan Chengde9dbc52008-10-29 23:55:17 +000074inline raw_ostream &operator<<(raw_ostream &O, const ARMConstantPoolValue &V) {
75 V.print(O);
76 return O;
77}
78
79} // End llvm namespace
Evan Cheng10043e22007-01-19 07:51:42 +000080
81#endif