1 //===-- lib/MC/MCFunction.cpp -----------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "llvm/MC/MCFunction.h"
11 #include "llvm/MC/MCAtom.h"
12 #include "llvm/MC/MCModule.h"
19 MCFunction::MCFunction(StringRef Name, MCModule *Parent)
20 : Name(Name), ParentModule(Parent)
23 MCFunction::~MCFunction() {
24 for (iterator I = begin(), E = end(); I != E; ++I)
28 MCBasicBlock &MCFunction::createBlock(const MCTextAtom &TA) {
29 Blocks.push_back(new MCBasicBlock(TA, this));
30 return *Blocks.back();
35 MCBasicBlock::MCBasicBlock(const MCTextAtom &Insts, MCFunction *Parent)
36 : Insts(&Insts), Parent(Parent)
39 void MCBasicBlock::addSuccessor(const MCBasicBlock *MCBB) {
40 if (!isSuccessor(MCBB))
41 Successors.push_back(MCBB);
44 bool MCBasicBlock::isSuccessor(const MCBasicBlock *MCBB) const {
45 return std::find(Successors.begin(), Successors.end(),
46 MCBB) != Successors.end();
49 void MCBasicBlock::addPredecessor(const MCBasicBlock *MCBB) {
50 if (!isPredecessor(MCBB))
51 Predecessors.push_back(MCBB);
54 bool MCBasicBlock::isPredecessor(const MCBasicBlock *MCBB) const {
55 return std::find(Predecessors.begin(), Predecessors.end(),
56 MCBB) != Predecessors.end();