2009-06-30 08:48:55 +08: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-07-01 01:06:46 +08:00
|
|
|
//
|
|
|
|
// This file implements LLVMContext, as a wrapper around the opaque
|
2009-08-12 01:45:13 +08:00
|
|
|
// class LLVMContextImpl.
|
2009-07-01 01:06:46 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
2009-06-30 08:48:55 +08:00
|
|
|
|
|
|
|
#include "llvm/LLVMContext.h"
|
2009-09-03 09:39:20 +08:00
|
|
|
#include "llvm/Metadata.h"
|
2009-06-30 08:48:55 +08:00
|
|
|
#include "llvm/Constants.h"
|
2009-07-13 12:09:18 +08:00
|
|
|
#include "llvm/Instruction.h"
|
2009-07-01 07:39:59 +08:00
|
|
|
#include "llvm/Support/ManagedStatic.h"
|
2009-06-30 08:48:55 +08:00
|
|
|
#include "LLVMContextImpl.h"
|
|
|
|
using namespace llvm;
|
|
|
|
|
2009-07-01 07:39:59 +08:00
|
|
|
static ManagedStatic<LLVMContext> GlobalContext;
|
|
|
|
|
2009-07-02 07:13:44 +08:00
|
|
|
LLVMContext& llvm::getGlobalContext() {
|
2009-07-02 05:22:36 +08:00
|
|
|
return *GlobalContext;
|
2009-07-01 07:39:59 +08:00
|
|
|
}
|
|
|
|
|
2009-08-14 07:27:32 +08:00
|
|
|
LLVMContext::LLVMContext() : pImpl(new LLVMContextImpl(*this)) { }
|
2009-06-30 08:48:55 +08:00
|
|
|
LLVMContext::~LLVMContext() { delete pImpl; }
|
2009-08-05 06:41:48 +08: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 14:31:57 +08:00
|
|
|
|