2009-06-30 00:48:55 +00:00
|
|
|
//===-- LLVMContext.cpp - Implement LLVMContext -----------------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
2009-06-30 17:06:46 +00:00
|
|
|
//
|
|
|
|
// This file implements LLVMContext, as a wrapper around the opaque
|
2009-08-11 17:45:13 +00:00
|
|
|
// class LLVMContextImpl.
|
2009-06-30 17:06:46 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
2009-06-30 00:48:55 +00:00
|
|
|
|
|
|
|
#include "llvm/LLVMContext.h"
|
2009-09-03 01:39:20 +00:00
|
|
|
#include "llvm/Metadata.h"
|
2009-06-30 00:48:55 +00:00
|
|
|
#include "llvm/Constants.h"
|
2009-07-13 04:09:18 +00:00
|
|
|
#include "llvm/Instruction.h"
|
2009-06-30 23:39:59 +00:00
|
|
|
#include "llvm/Support/ManagedStatic.h"
|
2009-09-03 17:03:47 +00:00
|
|
|
#include "llvm/Support/ValueHandle.h"
|
2009-06-30 00:48:55 +00:00
|
|
|
#include "LLVMContextImpl.h"
|
2009-08-11 06:31:57 +00:00
|
|
|
#include <set>
|
2009-06-30 00:48:55 +00:00
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
2009-06-30 23:39:59 +00:00
|
|
|
static ManagedStatic<LLVMContext> GlobalContext;
|
|
|
|
|
2009-07-01 23:13:44 +00:00
|
|
|
LLVMContext& llvm::getGlobalContext() {
|
2009-07-01 21:22:36 +00:00
|
|
|
return *GlobalContext;
|
2009-06-30 23:39:59 +00:00
|
|
|
}
|
|
|
|
|
2009-08-13 23:27:32 +00:00
|
|
|
LLVMContext::LLVMContext() : pImpl(new LLVMContextImpl(*this)) { }
|
2009-06-30 00:48:55 +00:00
|
|
|
LLVMContext::~LLVMContext() { delete pImpl; }
|
2009-08-04 22:41:48 +00:00
|
|
|
|
|
|
|
GetElementPtrConstantExpr::GetElementPtrConstantExpr
|
|
|
|
(Constant *C,
|
|
|
|
const std::vector<Constant*> &IdxList,
|
|
|
|
const Type *DestTy)
|
|
|
|
: ConstantExpr(DestTy, Instruction::GetElementPtr,
|
|
|
|
OperandTraits<GetElementPtrConstantExpr>::op_end(this)
|
|
|
|
- (IdxList.size()+1),
|
|
|
|
IdxList.size()+1) {
|
|
|
|
OperandList[0] = C;
|
|
|
|
for (unsigned i = 0, E = IdxList.size(); i != E; ++i)
|
|
|
|
OperandList[i+1] = IdxList[i];
|
|
|
|
}
|
2009-08-11 06:31:57 +00:00
|
|
|
|
2009-09-28 21:41:20 +00:00
|
|
|
MetadataContext &LLVMContext::getMetadata() {
|
2009-09-16 18:09:00 +00:00
|
|
|
return pImpl->TheMetadata;
|
|
|
|
}
|