Add LLVMContext, which will eventually be used as a container for privatizing a lot...
[oota-llvm.git] / include / llvm / LLVMContext.h
1 //===-- llvm/LLVMContext.h - Class for managing "global" state --*- 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 #ifndef LLVM_LLVMCONTEXT_H
11 #define LLVM_LLVMCONTEXT_H
12
13 #include "llvm/Support/DataTypes.h"
14 #include <vector>
15 #include <string>
16
17 namespace llvm {
18
19 class LLVMContextImpl;
20 class Constant;
21 class ConstantInt;
22 class ConstantPointerNull;
23 class ConstantStruct;
24 class ConstantAggregateZero;
25 class ConstantArray;
26 class ConstantFP;
27 class ConstantVector;
28 class IntegerType;
29 class PointerType;
30 class StructType;
31 class ArrayType;
32 class VectorType;
33 class Type;
34 class APInt;
35 class APFloat;
36 class Value;
37
38 class LLVMContext {
39   LLVMContextImpl* pImpl;
40 public:
41   LLVMContext();
42   ~LLVMContext();
43   
44   // ConstantInt accessors
45   ConstantInt* getConstantIntTrue();
46   ConstantInt* getConstantIntFalse();
47   ConstantInt* getConstantInt(const IntegerType* Ty, uint64_t V,
48                               bool isSigned = false);
49   ConstantInt* getConstantIntSigned(const IntegerType* Ty, int64_t V);
50   ConstantInt* getConstantInt(const APInt& V);
51   Constant* getConstantInt(const Type* Ty, const APInt& V);
52   ConstantInt* getAllOnesConstantInt(const Type* Ty);
53   
54   // ConstantPointerNull accessors
55   ConstantPointerNull* getConstantPointerNull(const PointerType* T);
56   
57   // ConstantStruct accessors
58   Constant* getConstantStruct(const StructType* T,
59                               const std::vector<Constant*>& V);
60   Constant* getConstantStruct(const std::vector<Constant*>& V,
61                               bool Packed = false);
62   Constant* getConstantStruct(Constant* const *Vals, unsigned NumVals,
63                               bool Packed = false);
64                               
65   // ConstantAggregateZero accessors
66   ConstantAggregateZero* getConstantAggregateZero(const Type* Ty);
67   
68   // ConstantArray accessors
69   Constant* getConstantArray(const ArrayType* T,
70                              const std::vector<Constant*>& V);
71   Constant* getConstantArray(const ArrayType* T, Constant* const* Vals,
72                              unsigned NumVals);
73   Constant* getConstantArray(const std::string& Initializer,
74                              bool AddNull = false);
75                              
76   // ConstantExpr accessors
77   Constant* getConstantExpr(unsigned Opcode, Constant* C1, Constant* C2);
78   Constant* getConstantExprTrunc(Constant* C, const Type* Ty);
79   Constant* getConstantExprSExt(Constant* C, const Type* Ty);
80   Constant* getConstantExprZExt(Constant* C, const Type* Ty);
81   Constant* getConstantExprFPTrunc(Constant* C, const Type* Ty);
82   Constant* getConstantExprFPExtend(Constant* C, const Type* Ty);
83   Constant* getConstantExprUIToFP(Constant* C, const Type* Ty);
84   Constant* getConstantExprSIToFP(Constant* C, const Type* Ty);
85   Constant* getConstantExprFPToUI(Constant* C, const Type* Ty);
86   Constant* getConstantExprFPToSI(Constant* C, const Type* Ty);
87   Constant* getConstantExprPtrToInt(Constant* C, const Type* Ty);
88   Constant* getConstantExprIntToPtr(Constant* C, const Type* Ty);
89   Constant* getConstantExprBitCast(Constant* C, const Type* Ty);
90   Constant* getConstantExprCast(unsigned ops, Constant* C, const Type* Ty);
91   Constant* getConstantExprZExtOrBitCast(Constant* C, const Type* Ty);
92   Constant* getConstantExprSExtOrBitCast(Constant* C, const Type* Ty);
93   Constant* getConstantExprTruncOrBitCast(Constant* C, const Type* Ty);
94   Constant* getConstantExprPointerCast(Constant* C, const Type* Ty);
95   Constant* getConstantExprIntegerCast(Constant* C, const Type* Ty,
96                                        bool isSigned);
97   Constant* getConstantExprFPCast(Constant* C, const Type* Ty);
98   Constant* getConstantExprSelect(Constant* C, Constant* V1, Constant* V2);
99   Constant* getConstantExprAlignOf(const Type* Ty);
100   Constant* getConstantExprCompare(unsigned short pred,
101                                    Constant* C1, Constant* C2);
102   Constant* getConstantExprNeg(Constant* C);
103   Constant* getConstantExprFNeg(Constant* C);
104   Constant* getConstantExprNot(Constant* C);
105   Constant* getConstantExprAdd(Constant* C1, Constant* C2);
106   Constant* getConstantExprFAdd(Constant* C1, Constant* C2);
107   Constant* getConstantExprSub(Constant* C1, Constant* C2);
108   Constant* getConstantExprFSub(Constant* C1, Constant* C2);
109   Constant* getConstantExprMul(Constant* C1, Constant* C2);
110   Constant* getConstantExprFMul(Constant* C1, Constant* C2);
111   Constant* getConstantExprUDiv(Constant* C1, Constant* C2);
112   Constant* getConstantExprSDiv(Constant* C1, Constant* C2);
113   Constant* getConstantExprFDiv(Constant* C1, Constant* C2);
114   Constant* getConstantExprURem(Constant* C1, Constant* C2);
115   Constant* getConstantExprSRem(Constant* C1, Constant* C2);
116   Constant* getConstantExprFRem(Constant* C1, Constant* C2);
117   Constant* getConstantExprAnd(Constant* C1, Constant* C2);
118   Constant* getConstantExprOr(Constant* C1, Constant* C2);
119   Constant* getConstantExprXor(Constant* C1, Constant* C2);
120   Constant* getConstantExprICmp(unsigned short pred, Constant* LHS,
121                                 Constant* RHS);
122   Constant* getConstantExprFCmp(unsigned short pred, Constant* LHS,
123                                 Constant* RHS);
124   Constant* getConstantExprVICmp(unsigned short pred, Constant* LHS,
125                                  Constant* RHS);
126   Constant* getConstantExprVFCmp(unsigned short pred, Constant* LHS,
127                                  Constant* RHS);
128   Constant* getConstantExprShl(Constant* C1, Constant* C2);
129   Constant* getConstantExprLShr(Constant* C1, Constant* C2);
130   Constant* getConstantExprAShr(Constant* C1, Constant* C2);
131   Constant* getConstantExprGetElementPtr(Constant* C, Constant* const* IdxList, 
132                                          unsigned NumIdx);
133   Constant* getConstantExprGetElementPtr(Constant* C, Value* const* IdxList, 
134                                           unsigned NumIdx);
135   Constant* getConstantExprExtractElement(Constant* Vec, Constant* Idx);
136   Constant* getConstantExprInsertElement(Constant* Vec, Constant* Elt,
137                                          Constant* Idx);
138   Constant* getConstantExprShuffleVector(Constant* V1, Constant* V2,
139                                          Constant* Mask);
140   Constant* getConstantExprExtractValue(Constant* Agg, const unsigned* IdxList, 
141                                         unsigned NumIdx);
142   Constant* getConstantExprInsertValue(Constant* Agg, Constant* Val,
143                                        const unsigned* IdxList,
144                                        unsigned NumIdx);
145   Constant* getZeroValueForNegation(const Type* Ty);
146   
147   // ConstantFP accessors
148   ConstantFP* getConstantFP(const APFloat& V);
149   Constant* getConstantFP(const Type* Ty, double V);
150   ConstantFP* getConstantFPNegativeZero(const Type* Ty);
151   
152   // ConstantVector accessors
153   Constant* getConstantVector(const VectorType* T,
154                               const std::vector<Constant*>& V);
155   Constant* getConstantVector(const std::vector<Constant*>& V);
156   Constant* getConstantVector(Constant* const* Vals, unsigned NumVals);
157   ConstantVector* getConstantVectorAllOnes(const VectorType* Ty);
158 };
159
160 }
161
162 #endif