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 // This file declares LLVMContext, a container of "global" state in LLVM, such
11 // as the global type and constant uniquing tables.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_LLVMCONTEXT_H
16 #define LLVM_LLVMCONTEXT_H
18 #include "llvm/Support/DataTypes.h"
28 class ConstantAggregateZero;
32 class ConstantPointerNull;
37 class LLVMContextImpl;
50 /// This is an important class for using LLVM in a threaded context. It
51 /// (opaquely) owns and manages the core "global" data of LLVM's core
52 /// infrastructure, including the type and constant uniquing tables.
53 /// LLVMContext itself provides no locking guarantees, so you should be careful
54 /// to have one context per thread.
56 LLVMContextImpl* pImpl;
58 friend class ConstantInt;
59 friend class ConstantFP;
60 friend class ConstantStruct;
61 friend class ConstantArray;
62 friend class ConstantVector;
68 Constant* getNullValue(const Type* Ty);
70 /// @returns the value for an integer constant of the given type that has all
71 /// its bits set to true.
72 /// @brief Get the all ones value
73 Constant* getAllOnesValue(const Type* Ty);
75 // UndefValue accessors
76 UndefValue* getUndef(const Type* Ty);
78 // ConstantInt accessors
79 ConstantInt* getTrue();
80 ConstantInt* getFalse();
82 // ConstantPointerNull accessors
83 ConstantPointerNull* getConstantPointerNull(const PointerType* T);
85 // ConstantAggregateZero accessors
86 ConstantAggregateZero* getConstantAggregateZero(const Type* Ty);
89 MDNode* getMDNode(Value* const* Vals, unsigned NumVals);
92 MDString* getMDString(const StringRef &Str);
95 // Methods for erasing constants
96 void erase(MDString *M);
97 void erase(MDNode *M);
98 void erase(ConstantAggregateZero *Z);
101 /// FOR BACKWARDS COMPATIBILITY - Returns a global context.
102 extern LLVMContext& getGlobalContext();