Cast MO.getImm() to unsigned before comparing with an unsigned limit.
[llvm/avr.git] / lib / Target / ARM / ARMConstantPoolValue.h
blob00c48086aef669ea2c578d68959156cdea066d20
1 //===- ARMConstantPoolValue.h - ARM 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 ARM specific constantpool value class.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_TARGET_ARM_CONSTANTPOOLVALUE_H
15 #define LLVM_TARGET_ARM_CONSTANTPOOLVALUE_H
17 #include "llvm/CodeGen/MachineConstantPool.h"
19 namespace llvm {
21 class GlobalValue;
22 class LLVMContext;
24 namespace ARMCP {
25 enum ARMCPKind {
26 CPValue,
27 CPLSDA
31 /// ARMConstantPoolValue - ARM 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)).
34 class ARMConstantPoolValue : public MachineConstantPoolValue {
35 GlobalValue *GV; // GlobalValue being loaded.
36 const char *S; // ExtSymbol being loaded.
37 unsigned LabelId; // Label id of the load.
38 ARMCP::ARMCPKind Kind; // Value or LSDA?
39 unsigned char PCAdjust; // Extra adjustment if constantpool is pc relative.
40 // 8 for ARM, 4 for Thumb.
41 const char *Modifier; // GV modifier i.e. (&GV(modifier)-(LPIC+8))
42 bool AddCurrentAddress;
44 public:
45 ARMConstantPoolValue(GlobalValue *gv, unsigned id,
46 ARMCP::ARMCPKind Kind = ARMCP::CPValue,
47 unsigned char PCAdj = 0, const char *Modifier = NULL,
48 bool AddCurrentAddress = false);
49 ARMConstantPoolValue(LLVMContext &C, const char *s, unsigned id,
50 unsigned char PCAdj = 0, const char *Modifier = NULL,
51 bool AddCurrentAddress = false);
52 ARMConstantPoolValue(GlobalValue *GV, const char *Modifier);
53 ARMConstantPoolValue();
54 ~ARMConstantPoolValue();
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 unsigned char getPCAdjustment() const { return PCAdjust; }
64 bool isLSDA() { return Kind == ARMCP::CPLSDA; }
66 virtual unsigned getRelocationInfo() const {
67 // FIXME: This is conservatively claiming that these entries require a
68 // relocation, we may be able to do better than this.
69 return 2;
73 virtual int getExistingMachineCPValue(MachineConstantPool *CP,
74 unsigned Alignment);
76 virtual void AddSelectionDAGCSEId(FoldingSetNodeID &ID);
78 void print(raw_ostream *O) const { if (O) print(*O); }
79 void print(raw_ostream &O) const;
80 void dump() const;
84 inline raw_ostream &operator<<(raw_ostream &O, const ARMConstantPoolValue &V) {
85 V.print(O);
86 return O;
89 } // End llvm namespace
91 #endif