Chris Lattner | c10132a | 2009-07-31 17:02:00 +0000 | [diff] [blame] | 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" |
Rafael Espindola | 09266ba | 2015-05-25 22:57:48 +0000 | [diff] [blame^] | 11 | #include "llvm/MC/MCAssembler.h" |
Chris Lattner | 7b26fce | 2009-08-22 20:48:53 +0000 | [diff] [blame] | 12 | #include "llvm/MC/MCAsmInfo.h" |
Chandler Carruth | ed0881b | 2012-12-03 16:50:05 +0000 | [diff] [blame] | 13 | #include "llvm/MC/MCContext.h" |
Rafael Espindola | f2b408c | 2015-03-23 21:22:04 +0000 | [diff] [blame] | 14 | #include "llvm/MC/MCSymbol.h" |
Chris Lattner | 1cb9396 | 2009-08-08 22:41:53 +0000 | [diff] [blame] | 15 | #include "llvm/Support/raw_ostream.h" |
Chris Lattner | c10132a | 2009-07-31 17:02:00 +0000 | [diff] [blame] | 16 | using namespace llvm; |
| 17 | |
Chris Lattner | 1cb9396 | 2009-08-08 22:41:53 +0000 | [diff] [blame] | 18 | //===----------------------------------------------------------------------===// |
| 19 | // MCSection |
| 20 | //===----------------------------------------------------------------------===// |
| 21 | |
Rafael Espindola | 0709a7b | 2015-05-21 19:20:38 +0000 | [diff] [blame] | 22 | MCSymbol *MCSection::getEndSymbol(MCContext &Ctx) { |
Rafael Espindola | f2b408c | 2015-03-23 21:22:04 +0000 | [diff] [blame] | 23 | if (!End) |
| 24 | End = Ctx.createTempSymbol("sec_end", true); |
| 25 | return End; |
| 26 | } |
| 27 | |
| 28 | bool MCSection::hasEnded() const { return End && End->isInSection(); } |
| 29 | |
Chris Lattner | c10132a | 2009-07-31 17:02:00 +0000 | [diff] [blame] | 30 | MCSection::~MCSection() { |
| 31 | } |
| 32 | |
Rafael Espindola | b028cc8 | 2015-05-25 15:04:26 +0000 | [diff] [blame] | 33 | void MCSection::setBundleLockState(BundleLockStateType NewState) { |
| 34 | if (NewState == NotBundleLocked) { |
| 35 | if (BundleLockNestingDepth == 0) { |
| 36 | report_fatal_error("Mismatched bundle_lock/unlock directives"); |
| 37 | } |
| 38 | if (--BundleLockNestingDepth == 0) { |
| 39 | BundleLockState = NotBundleLocked; |
| 40 | } |
| 41 | return; |
| 42 | } |
| 43 | |
| 44 | // If any of the directives is an align_to_end directive, the whole nested |
| 45 | // group is align_to_end. So don't downgrade from align_to_end to just locked. |
| 46 | if (BundleLockState != BundleLockedAlignToEnd) { |
| 47 | BundleLockState = NewState; |
| 48 | } |
| 49 | ++BundleLockNestingDepth; |
| 50 | } |
Rafael Espindola | 09266ba | 2015-05-25 22:57:48 +0000 | [diff] [blame^] | 51 | |
| 52 | MCSectionData::iterator MCSectionData::begin() { return Fragments.begin(); } |
| 53 | |
| 54 | MCSectionData::iterator MCSectionData::end() { return Fragments.end(); } |
| 55 | |
| 56 | MCSectionData::reverse_iterator MCSectionData::rbegin() { |
| 57 | return Fragments.rbegin(); |
| 58 | } |
| 59 | |
| 60 | MCSectionData::reverse_iterator MCSectionData::rend() { |
| 61 | return Fragments.rend(); |
| 62 | } |
| 63 | |
| 64 | size_t MCSectionData::size() const { return Fragments.size(); } |
| 65 | |
| 66 | bool MCSectionData::empty() const { return Fragments.empty(); } |