mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 20:32:21 +00:00
8fc5576413
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80841 91177308-0d34-0410-b5e6-96231b3b80d8
69 lines
1.9 KiB
C++
69 lines
1.9 KiB
C++
//===-- 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.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file implements LLVMContext, as a wrapper around the opaque
|
|
// class LLVMContextImpl.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "llvm/LLVMContext.h"
|
|
#include "llvm/Constants.h"
|
|
#include "llvm/Instruction.h"
|
|
#include "llvm/Support/ManagedStatic.h"
|
|
#include "LLVMContextImpl.h"
|
|
#include <set>
|
|
|
|
using namespace llvm;
|
|
|
|
static ManagedStatic<LLVMContext> GlobalContext;
|
|
|
|
LLVMContext& llvm::getGlobalContext() {
|
|
return *GlobalContext;
|
|
}
|
|
|
|
LLVMContext::LLVMContext() : pImpl(new LLVMContextImpl(*this)) { }
|
|
LLVMContext::~LLVMContext() { delete pImpl; }
|
|
|
|
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];
|
|
}
|
|
|
|
bool LLVMContext::RemoveDeadMetadata() {
|
|
std::vector<const MDNode *> DeadMDNodes;
|
|
bool Changed = false;
|
|
while (1) {
|
|
|
|
for (SmallPtrSet<const MDNode *, 8>::iterator
|
|
I = pImpl->MDNodes.begin(),
|
|
E = pImpl->MDNodes.end(); I != E; ++I) {
|
|
const MDNode *N = cast<MDNode>(*I);
|
|
if (N->use_empty())
|
|
DeadMDNodes.push_back(N);
|
|
}
|
|
|
|
if (DeadMDNodes.empty())
|
|
return Changed;
|
|
|
|
while (!DeadMDNodes.empty()) {
|
|
const MDNode *N = DeadMDNodes.back(); DeadMDNodes.pop_back();
|
|
delete N;
|
|
}
|
|
}
|
|
return Changed;
|
|
}
|