Change allowsUnalignedMemoryAccesses to take type argument since some targets
[llvm/avr.git] / lib / VMCore / LLVMContext.cpp
blob95ceeaee813f5aa2878aaf99862f89f6ed972d74
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.
13 //===----------------------------------------------------------------------===//
15 #include "llvm/LLVMContext.h"
16 #include "llvm/Constants.h"
17 #include "llvm/Instruction.h"
18 #include "llvm/Support/ManagedStatic.h"
19 #include "LLVMContextImpl.h"
20 #include <set>
22 using namespace llvm;
24 static ManagedStatic<LLVMContext> GlobalContext;
26 LLVMContext& llvm::getGlobalContext() {
27 return *GlobalContext;
30 LLVMContext::LLVMContext() : pImpl(new LLVMContextImpl(*this)) { }
31 LLVMContext::~LLVMContext() { delete pImpl; }
33 GetElementPtrConstantExpr::GetElementPtrConstantExpr
34 (Constant *C,
35 const std::vector<Constant*> &IdxList,
36 const Type *DestTy)
37 : ConstantExpr(DestTy, Instruction::GetElementPtr,
38 OperandTraits<GetElementPtrConstantExpr>::op_end(this)
39 - (IdxList.size()+1),
40 IdxList.size()+1) {
41 OperandList[0] = C;
42 for (unsigned i = 0, E = IdxList.size(); i != E; ++i)
43 OperandList[i+1] = IdxList[i];
46 bool LLVMContext::RemoveDeadMetadata() {
47 std::vector<const MDNode *> DeadMDNodes;
48 bool Changed = false;
49 while (1) {
51 for (LLVMContextImpl::MDNodeMapTy::MapTy::iterator
52 I = pImpl->MDNodes.map_begin(),
53 E = pImpl->MDNodes.map_end(); I != E; ++I) {
54 const MDNode *N = cast<MDNode>(I->second);
55 if (N->use_empty())
56 DeadMDNodes.push_back(N);
59 if (DeadMDNodes.empty())
60 return Changed;
62 while (!DeadMDNodes.empty()) {
63 const MDNode *N = DeadMDNodes.back(); DeadMDNodes.pop_back();
64 delete N;
67 return Changed;