[lib/Fuzzer] fix docs
[oota-llvm.git] / lib / MC / MCSection.cpp
1 //===- lib/MC/MCSection.cpp - Machine Code Section Representation ---------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #include "llvm/MC/MCSection.h"
11 #include "llvm/MC/MCAssembler.h"
12 #include "llvm/MC/MCAsmInfo.h"
13 #include "llvm/MC/MCContext.h"
14 #include "llvm/MC/MCSymbol.h"
15 #include "llvm/Support/raw_ostream.h"
16 using namespace llvm;
17
18 //===----------------------------------------------------------------------===//
19 // MCSection
20 //===----------------------------------------------------------------------===//
21
22 MCSection::MCSection(SectionVariant V, SectionKind K, MCSymbol *Begin)
23     : Begin(Begin), HasInstructions(false), Data(*this), Variant(V), Kind(K) {}
24
25 MCSymbol *MCSection::getEndSymbol(MCContext &Ctx) {
26   if (!End)
27     End = Ctx.createTempSymbol("sec_end", true);
28   return End;
29 }
30
31 bool MCSection::hasEnded() const { return End && End->isInSection(); }
32
33 MCSection::~MCSection() {
34 }
35
36 void MCSection::setBundleLockState(BundleLockStateType NewState) {
37   if (NewState == NotBundleLocked) {
38     if (BundleLockNestingDepth == 0) {
39       report_fatal_error("Mismatched bundle_lock/unlock directives");
40     }
41     if (--BundleLockNestingDepth == 0) {
42       BundleLockState = NotBundleLocked;
43     }
44     return;
45   }
46
47   // If any of the directives is an align_to_end directive, the whole nested
48   // group is align_to_end. So don't downgrade from align_to_end to just locked.
49   if (BundleLockState != BundleLockedAlignToEnd) {
50     BundleLockState = NewState;
51   }
52   ++BundleLockNestingDepth;
53 }
54
55 MCSectionData::iterator MCSection::begin() { return Data.begin(); }
56
57 MCSectionData::iterator MCSection::end() { return Data.end(); }
58
59 MCSectionData::reverse_iterator MCSection::rbegin() { return Data.rbegin(); }
60
61 MCSectionData::FragmentListType &MCSection::getFragmentList() {
62   return Data.getFragmentList();
63 }
64
65 MCSectionData::iterator MCSectionData::begin() { return Fragments.begin(); }
66
67 MCSectionData::iterator MCSectionData::end() { return Fragments.end(); }
68
69 MCSectionData::reverse_iterator MCSectionData::rbegin() {
70   return Fragments.rbegin();
71 }
72
73 MCSectionData::reverse_iterator MCSectionData::rend() {
74   return Fragments.rend();
75 }
76
77 size_t MCSectionData::size() const { return Fragments.size(); }
78
79 bool MCSectionData::empty() const { return Fragments.empty(); }