blob: 2665d3e167b6d065368ef8e109fc73cbe7e7d218 (
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
|
//===-- lib/MC/MCFunction.cpp -----------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "llvm/MC/MCFunction.h"
#include "llvm/MC/MCAtom.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
using namespace llvm;
// MCFunction
MCFunction::MCFunction(StringRef Name)
: Name(Name)
{}
MCFunction::~MCFunction() {
for (iterator I = begin(), E = end(); I != E; ++I)
delete *I;
}
MCBasicBlock &MCFunction::createBlock(const MCTextAtom &TA) {
Blocks.push_back(new MCBasicBlock(TA, this));
return *Blocks.back();
}
// MCBasicBlock
MCBasicBlock::MCBasicBlock(const MCTextAtom &Insts, MCFunction *Parent)
: Insts(&Insts), Parent(Parent)
{}
void MCBasicBlock::addSuccessor(const MCBasicBlock *MCBB) {
Successors.push_back(MCBB);
}
bool MCBasicBlock::isSuccessor(const MCBasicBlock *MCBB) const {
return std::find(Successors.begin(), Successors.end(),
MCBB) != Successors.end();
}
void MCBasicBlock::addPredecessor(const MCBasicBlock *MCBB) {
Predecessors.push_back(MCBB);
}
bool MCBasicBlock::isPredecessor(const MCBasicBlock *MCBB) const {
return std::find(Predecessors.begin(), Predecessors.end(),
MCBB) != Predecessors.end();
}
|