blob: 657fb15171b63f7e625e6e3c0b78f3043fce2ff2 [file] [log] [blame]
Sanjiv Gupta0e687712008-05-13 09:02:57 +00001//===- PIC16ConstantPoolValue.h - PIC16 constantpool value ------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file implements the PIC16 specific constantpool value class.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_TARGET_PIC16_CONSTANTPOOLVALUE_H
15#define LLVM_TARGET_PIC16_CONSTANTPOOLVALUE_H
16
17#include "llvm/CodeGen/MachineConstantPool.h"
18
19namespace llvm {
20
Dan Gohmandc2fbdd2008-07-11 20:38:31 +000021class GlobalValue;
22
Sanjiv Gupta0e687712008-05-13 09:02:57 +000023namespace PIC16CP {
24 enum PIC16CPKind {
25 CPValue,
26 CPNonLazyPtr,
27 CPStub
28 };
29}
30
31/// PIC16ConstantPoolValue - PIC16 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 PIC16ConstantPoolValue : public MachineConstantPoolValue {
35 GlobalValue *GV; // GlobalValue being loaded.
36 const char *S; // ExtSymbol being loaded.
37 unsigned LabelId; // Label id of the load.
38 PIC16CP::PIC16CPKind Kind; // non_lazy_ptr or stub?
39 unsigned char PCAdjust; // Extra adjustment if constantpool is pc relative.
40 // 8 for PIC16
41 const char *Modifier; // GV modifier i.e. (&GV(modifier)-(LPIC+8))
42 bool AddCurrentAddress;
43
44public:
45 PIC16ConstantPoolValue(GlobalValue *gv, unsigned id,
Sanjiv Gupta2010b3e2008-05-14 11:31:39 +000046 PIC16CP::PIC16CPKind Kind = PIC16CP::CPValue,
47 unsigned char PCAdj = 0, const char *Modifier = NULL,
48 bool AddCurrentAddress = false);
Sanjiv Gupta0e687712008-05-13 09:02:57 +000049 PIC16ConstantPoolValue(const char *s, unsigned id,
Sanjiv Gupta2010b3e2008-05-14 11:31:39 +000050 PIC16CP::PIC16CPKind Kind = PIC16CP::CPValue,
51 unsigned char PCAdj = 0, const char *Modifier = NULL,
52 bool AddCurrentAddress = false);
Sanjiv Gupta0e687712008-05-13 09:02:57 +000053 PIC16ConstantPoolValue(GlobalValue *GV, PIC16CP::PIC16CPKind Kind,
Sanjiv Gupta2010b3e2008-05-14 11:31:39 +000054 const char *Modifier);
Sanjiv Gupta0e687712008-05-13 09:02:57 +000055
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 == PIC16CP::CPNonLazyPtr; }
64 bool isStub() const { return Kind == PIC16CP::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
Chris Lattner944fac72008-08-23 22:23:09 +000072 virtual void print(raw_ostream &O) const;
Sanjiv Gupta0e687712008-05-13 09:02:57 +000073};
74
75}
76
77#endif