llvm/lib/VMCore/iBranch.cpp
Chris Lattner 7e70829632 MEGAPATCH checkin.
For details, See: docs/2002-06-25-MegaPatchInfo.txt


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2779 91177308-0d34-0410-b5e6-96231b3b80d8
2002-06-25 16:13:24 +00:00

37 lines
1.3 KiB
C++

//===-- iBranch.cpp - Implement the Branch instruction -----------*- C++ -*--=//
//
// This file implements the 'br' instruction, which can represent either a
// conditional or unconditional branch.
//
//===----------------------------------------------------------------------===//
#include "llvm/iTerminators.h"
#include "llvm/BasicBlock.h"
#include "llvm/Type.h"
BranchInst::BranchInst(BasicBlock *True, BasicBlock *False, Value *Cond)
: TerminatorInst(Instruction::Br) {
assert(True != 0 && "True branch destination may not be null!!!");
Operands.reserve(False ? 3 : 1);
Operands.push_back(Use(True, this));
if (False) {
Operands.push_back(Use(False, this));
Operands.push_back(Use(Cond, this));
}
assert(!!False == !!Cond &&
"Either both cond and false or neither can be specified!");
assert((Cond == 0 || Cond->getType() == Type::BoolTy) &&
"May only branch on boolean predicates!!!!");
}
BranchInst::BranchInst(const BranchInst &BI) : TerminatorInst(Instruction::Br) {
Operands.reserve(BI.Operands.size());
Operands.push_back(Use(BI.Operands[0], this));
if (BI.Operands.size() != 1) {
assert(BI.Operands.size() == 3 && "BR can have 1 or 3 operands!");
Operands.push_back(Use(BI.Operands[1], this));
Operands.push_back(Use(BI.Operands[2], this));
}
}