blob: 29b293f1aa29b190c5ee72f3b8fa0457208b0e23 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
//===-- 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));
}
|