1 //===-- llvm/LLVMContext.h - Class for managing "global" state --*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_LLVMCONTEXT_H
11 #define LLVM_LLVMCONTEXT_H
13 #include "llvm/Support/DataTypes.h"
19 class LLVMContextImpl;
22 class ConstantPointerNull;
24 class ConstantAggregateZero;
39 LLVMContextImpl* pImpl;
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);
54 // ConstantPointerNull accessors
55 ConstantPointerNull* getConstantPointerNull(const PointerType* T);
57 // ConstantStruct accessors
58 Constant* getConstantStruct(const StructType* T,
59 const std::vector<Constant*>& V);
60 Constant* getConstantStruct(const std::vector<Constant*>& V,
62 Constant* getConstantStruct(Constant* const *Vals, unsigned NumVals,
65 // ConstantAggregateZero accessors
66 ConstantAggregateZero* getConstantAggregateZero(const Type* Ty);
68 // ConstantArray accessors
69 Constant* getConstantArray(const ArrayType* T,
70 const std::vector<Constant*>& V);
71 Constant* getConstantArray(const ArrayType* T, Constant* const* Vals,
73 Constant* getConstantArray(const std::string& Initializer,
74 bool AddNull = false);
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,
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,
122 Constant* getConstantExprFCmp(unsigned short pred, Constant* LHS,
124 Constant* getConstantExprVICmp(unsigned short pred, Constant* LHS,
126 Constant* getConstantExprVFCmp(unsigned short pred, Constant* LHS,
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,
133 Constant* getConstantExprGetElementPtr(Constant* C, Value* const* IdxList,
135 Constant* getConstantExprExtractElement(Constant* Vec, Constant* Idx);
136 Constant* getConstantExprInsertElement(Constant* Vec, Constant* Elt,
138 Constant* getConstantExprShuffleVector(Constant* V1, Constant* V2,
140 Constant* getConstantExprExtractValue(Constant* Agg, const unsigned* IdxList,
142 Constant* getConstantExprInsertValue(Constant* Agg, Constant* Val,
143 const unsigned* IdxList,
145 Constant* getZeroValueForNegation(const Type* Ty);
147 // ConstantFP accessors
148 ConstantFP* getConstantFP(const APFloat& V);
149 Constant* getConstantFP(const Type* Ty, double V);
150 ConstantFP* getConstantFPNegativeZero(const Type* Ty);
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);