mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-07-20 10:30:03 +00:00
b0b0aa3849
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11 91177308-0d34-0410-b5e6-96231b3b80d8
74 lines
2.3 KiB
C++
74 lines
2.3 KiB
C++
//===-- InstrTypes.cpp - Implement Instruction subclasses --------*- C++ -*--=//
|
|
//
|
|
// This file implements
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "llvm/iOther.h"
|
|
#include "llvm/BasicBlock.h"
|
|
#include "llvm/Method.h"
|
|
#include "llvm/SymbolTable.h"
|
|
#include "llvm/Type.h"
|
|
#include <algorithm>
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// TerminatorInst Class
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
TerminatorInst::TerminatorInst(unsigned iType)
|
|
: Instruction(Type::VoidTy, iType, "") {
|
|
}
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// MethodArgument Class
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Specialize setName to take care of symbol table majik
|
|
void MethodArgument::setName(const string &name) {
|
|
Method *P;
|
|
if ((P = getParent()) && hasName()) P->getSymbolTable()->remove(this);
|
|
Value::setName(name);
|
|
if (P && hasName()) P->getSymbolTable()->insert(this);
|
|
}
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// PHINode Class
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
PHINode::PHINode(const Type *Ty, const string &name)
|
|
: Instruction(Ty, Instruction::PHINode, name) {
|
|
}
|
|
|
|
PHINode::PHINode(const PHINode &PN)
|
|
: Instruction(PN.getType(), Instruction::PHINode) {
|
|
|
|
for (unsigned i = 0; i < PN.IncomingValues.size(); i++)
|
|
IncomingValues.push_back(Use(PN.IncomingValues[i], this));
|
|
}
|
|
|
|
void PHINode::dropAllReferences() {
|
|
IncomingValues.clear();
|
|
}
|
|
|
|
bool PHINode::setOperand(unsigned i, Value *Val) {
|
|
assert(Val && "PHI node must only reference nonnull definitions!");
|
|
if (i >= IncomingValues.size()) return false;
|
|
|
|
IncomingValues[i] = Val;
|
|
return true;
|
|
}
|
|
|
|
void PHINode::addIncoming(Value *D) {
|
|
IncomingValues.push_back(Use(D, this));
|
|
}
|
|
|
|
// removeIncomingValue - Remove an incoming value. This is useful if a
|
|
// predecessor basic block is deleted.
|
|
Value *PHINode::removeIncomingValue(unsigned idx) {
|
|
Value *Removed = IncomingValues[idx];
|
|
IncomingValues.erase(IncomingValues.begin()+idx);
|
|
return Removed;
|
|
}
|