etc/services - sync with NetBSD-8
[minix.git] / minix / llvm / passes / magic / support / VariableRefs.cpp
blob92bec82da2beef1fc1a475bf2154459bff9c287f
1 #include <magic/support/VariableRefs.h>
3 using namespace llvm;
5 namespace llvm {
7 //===----------------------------------------------------------------------===//
8 // Constructors, destructor, and operators
9 //===----------------------------------------------------------------------===//
11 VariableRefs::VariableRefs() {
12 clear();
15 //===----------------------------------------------------------------------===//
16 // Getters
17 //===----------------------------------------------------------------------===//
19 bool VariableRefs::isUnnecessaryInstruction(Instruction* inst) const {
20 //have already instruction in the entry block, skip
21 if(instructionInEntryBlock) {
22 return true;
24 //have already instruction in the same block, skip
25 if(instruction && inst->getParent() == instruction->getParent()) {
26 return true;
29 return false;
32 Instruction* VariableRefs::getInstruction() const {
33 return instruction;
36 bool VariableRefs::isInstructionInEntryBlock() const {
37 return instructionInEntryBlock;
40 //===----------------------------------------------------------------------===//
41 // Other public methods
42 //===----------------------------------------------------------------------===//
44 void VariableRefs::addInstruction(Instruction* inst) {
45 //no instruction yet, update instruction
46 if(!instruction) {
47 instruction = inst;
48 return;
50 //have already instruction in another block, give up and resort to a single instruction in the entry block
51 setFunctionEntryInstruction(inst->getParent()->getParent());
54 void VariableRefs::clear() {
55 instruction = NULL;
56 instructionInEntryBlock = false;
59 //===----------------------------------------------------------------------===//
60 // Private methods
61 //===----------------------------------------------------------------------===//
63 void VariableRefs::setFunctionEntryInstruction(Function* function) {
64 this->instruction = function->front().getFirstNonPHI();
65 this->instructionInEntryBlock = true;