It turns out most of the thumb2 instructions are not allowed to touch SP. The semanti...
[llvm/avr.git] / lib / VMCore / LLVMContextImpl.h
blob966f54b3e222d23876a83b3ed1a1cdf02bbf8410
1 //===----------------- LLVMContextImpl.h - Implementation ------*- 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 declares LLVMContextImpl, the opaque implementation
11 // of LLVMContext.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_LLVMCONTEXT_IMPL_H
16 #define LLVM_LLVMCONTEXT_IMPL_H
18 #include "ConstantsContext.h"
19 #include "TypesContext.h"
20 #include "llvm/LLVMContext.h"
21 #include "llvm/Constants.h"
22 #include "llvm/DerivedTypes.h"
23 #include "llvm/System/RWMutex.h"
24 #include "llvm/ADT/APFloat.h"
25 #include "llvm/ADT/APInt.h"
26 #include "llvm/ADT/DenseMap.h"
27 #include "llvm/ADT/FoldingSet.h"
28 #include "llvm/ADT/StringMap.h"
29 #include <vector>
31 namespace llvm {
33 class ConstantInt;
34 class ConstantFP;
35 class MDString;
36 class MDNode;
37 struct LLVMContext;
38 class Type;
39 class Value;
41 struct DenseMapAPIntKeyInfo {
42 struct KeyTy {
43 APInt val;
44 const Type* type;
45 KeyTy(const APInt& V, const Type* Ty) : val(V), type(Ty) {}
46 KeyTy(const KeyTy& that) : val(that.val), type(that.type) {}
47 bool operator==(const KeyTy& that) const {
48 return type == that.type && this->val == that.val;
50 bool operator!=(const KeyTy& that) const {
51 return !this->operator==(that);
54 static inline KeyTy getEmptyKey() { return KeyTy(APInt(1,0), 0); }
55 static inline KeyTy getTombstoneKey() { return KeyTy(APInt(1,1), 0); }
56 static unsigned getHashValue(const KeyTy &Key) {
57 return DenseMapInfo<void*>::getHashValue(Key.type) ^
58 Key.val.getHashValue();
60 static bool isEqual(const KeyTy &LHS, const KeyTy &RHS) {
61 return LHS == RHS;
63 static bool isPod() { return false; }
66 struct DenseMapAPFloatKeyInfo {
67 struct KeyTy {
68 APFloat val;
69 KeyTy(const APFloat& V) : val(V){}
70 KeyTy(const KeyTy& that) : val(that.val) {}
71 bool operator==(const KeyTy& that) const {
72 return this->val.bitwiseIsEqual(that.val);
74 bool operator!=(const KeyTy& that) const {
75 return !this->operator==(that);
78 static inline KeyTy getEmptyKey() {
79 return KeyTy(APFloat(APFloat::Bogus,1));
81 static inline KeyTy getTombstoneKey() {
82 return KeyTy(APFloat(APFloat::Bogus,2));
84 static unsigned getHashValue(const KeyTy &Key) {
85 return Key.val.getHashValue();
87 static bool isEqual(const KeyTy &LHS, const KeyTy &RHS) {
88 return LHS == RHS;
90 static bool isPod() { return false; }
93 struct LLVMContextImpl {
94 sys::SmartRWMutex<true> ConstantsLock;
96 typedef DenseMap<DenseMapAPIntKeyInfo::KeyTy, ConstantInt*,
97 DenseMapAPIntKeyInfo> IntMapTy;
98 IntMapTy IntConstants;
100 typedef DenseMap<DenseMapAPFloatKeyInfo::KeyTy, ConstantFP*,
101 DenseMapAPFloatKeyInfo> FPMapTy;
102 FPMapTy FPConstants;
104 StringMap<MDString*> MDStringCache;
106 FoldingSet<MDNode> MDNodeSet;
108 ValueMap<char, Type, ConstantAggregateZero> AggZeroConstants;
110 typedef ValueMap<std::vector<Constant*>, ArrayType,
111 ConstantArray, true /*largekey*/> ArrayConstantsTy;
112 ArrayConstantsTy ArrayConstants;
114 typedef ValueMap<std::vector<Constant*>, StructType,
115 ConstantStruct, true /*largekey*/> StructConstantsTy;
116 StructConstantsTy StructConstants;
118 typedef ValueMap<std::vector<Constant*>, VectorType,
119 ConstantVector> VectorConstantsTy;
120 VectorConstantsTy VectorConstants;
122 ValueMap<char, PointerType, ConstantPointerNull> NullPtrConstants;
124 ValueMap<char, Type, UndefValue> UndefValueConstants;
126 ValueMap<ExprMapKeyType, Type, ConstantExpr> ExprConstants;
128 ConstantInt *TheTrueVal;
129 ConstantInt *TheFalseVal;
131 TypeMap<ArrayValType, ArrayType> ArrayTypes;
132 TypeMap<VectorValType, VectorType> VectorTypes;
133 TypeMap<PointerValType, PointerType> PointerTypes;
134 TypeMap<FunctionValType, FunctionType> FunctionTypes;
135 TypeMap<StructValType, StructType> StructTypes;
137 LLVMContextImpl() : TheTrueVal(0), TheFalseVal(0) { }
142 #endif