Fix XCoreTargetLowering::isLegalAddressingMode() to handle VoidTy.
[oota-llvm.git] / lib / VMCore / LLVMContext.cpp
1 //===-- LLVMContext.cpp - Implement LLVMContext -----------------------===//
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 //  This file implements LLVMContext, as a wrapper around the opaque
11 //  class LLVMContextImpl.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #include "llvm/LLVMContext.h"
16 #include "llvm/Metadata.h"
17 #include "llvm/Constants.h"
18 #include "llvm/Instruction.h"
19 #include "llvm/Support/ManagedStatic.h"
20 #include "LLVMContextImpl.h"
21 using namespace llvm;
22
23 static ManagedStatic<LLVMContext> GlobalContext;
24
25 LLVMContext& llvm::getGlobalContext() {
26   return *GlobalContext;
27 }
28
29 LLVMContext::LLVMContext() : pImpl(new LLVMContextImpl(*this)) { }
30 LLVMContext::~LLVMContext() { delete pImpl; }
31
32 GetElementPtrConstantExpr::GetElementPtrConstantExpr
33   (Constant *C,
34    const std::vector<Constant*> &IdxList,
35    const Type *DestTy)
36     : ConstantExpr(DestTy, Instruction::GetElementPtr,
37                    OperandTraits<GetElementPtrConstantExpr>::op_end(this)
38                    - (IdxList.size()+1),
39                    IdxList.size()+1) {
40   OperandList[0] = C;
41   for (unsigned i = 0, E = IdxList.size(); i != E; ++i)
42     OperandList[i+1] = IdxList[i];
43 }
44