Sanjiv Gupta | 0e68771 | 2008-05-13 09:02:57 +0000 | [diff] [blame^] | 1 | //===- 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 | |
| 19 | namespace llvm { |
| 20 | |
| 21 | namespace PIC16CP { |
| 22 | enum PIC16CPKind { |
| 23 | CPValue, |
| 24 | CPNonLazyPtr, |
| 25 | CPStub |
| 26 | }; |
| 27 | } |
| 28 | |
| 29 | /// PIC16ConstantPoolValue - PIC16 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)). |
| 32 | class PIC16ConstantPoolValue : public MachineConstantPoolValue { |
| 33 | GlobalValue *GV; // GlobalValue being loaded. |
| 34 | const char *S; // ExtSymbol being loaded. |
| 35 | unsigned LabelId; // Label id of the load. |
| 36 | PIC16CP::PIC16CPKind Kind; // non_lazy_ptr or stub? |
| 37 | unsigned char PCAdjust; // Extra adjustment if constantpool is pc relative. |
| 38 | // 8 for PIC16 |
| 39 | const char *Modifier; // GV modifier i.e. (&GV(modifier)-(LPIC+8)) |
| 40 | bool AddCurrentAddress; |
| 41 | |
| 42 | public: |
| 43 | PIC16ConstantPoolValue(GlobalValue *gv, unsigned id, |
| 44 | PIC16CP::PIC16CPKind Kind = PIC16CP::CPValue, |
| 45 | unsigned char PCAdj = 0, const char *Modifier = NULL, |
| 46 | bool AddCurrentAddress = false); |
| 47 | PIC16ConstantPoolValue(const char *s, unsigned id, |
| 48 | PIC16CP::PIC16CPKind Kind = PIC16CP::CPValue, |
| 49 | unsigned char PCAdj = 0, const char *Modifier = NULL, |
| 50 | bool AddCurrentAddress = false); |
| 51 | PIC16ConstantPoolValue(GlobalValue *GV, PIC16CP::PIC16CPKind Kind, |
| 52 | const char *Modifier); |
| 53 | |
| 54 | |
| 55 | GlobalValue *getGV() const { return GV; } |
| 56 | const char *getSymbol() const { return S; } |
| 57 | const char *getModifier() const { return Modifier; } |
| 58 | bool hasModifier() const { return Modifier != NULL; } |
| 59 | bool mustAddCurrentAddress() const { return AddCurrentAddress; } |
| 60 | unsigned getLabelId() const { return LabelId; } |
| 61 | bool isNonLazyPointer() const { return Kind == PIC16CP::CPNonLazyPtr; } |
| 62 | bool isStub() const { return Kind == PIC16CP::CPStub; } |
| 63 | 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 |