Add a isBundleLocked helper to MCELFStreamer.
authorRafael Espindola <rafael.espindola@gmail.com>
Mon, 25 May 2015 14:57:35 +0000 (14:57 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Mon, 25 May 2015 14:57:35 +0000 (14:57 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238142 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/MC/MCELFStreamer.h
lib/MC/MCELFStreamer.cpp

index da6c54fcc9a012618b3efdfd032880b65f87e9ee..97058f5e9981bdc68e8ff16c4a7dac7484153ee3 100644 (file)
@@ -89,6 +89,7 @@ public:
   void EmitBundleUnlock() override;
 
 private:
+  bool isBundleLocked() const;
   void EmitInstToFragment(const MCInst &Inst, const MCSubtargetInfo &) override;
   void EmitInstToData(const MCInst &Inst, const MCSubtargetInfo &) override;
 
index e666b554236c7a3d435e16adc191e41a52329e69..6a47cc9c1ccca7b5b2a6dae7ff7f2e9606dccf8a 100644 (file)
 
 using namespace llvm;
 
+bool MCELFStreamer::isBundleLocked() const {
+  return getCurrentSectionData()->isBundleLocked();
+}
+
 MCELFStreamer::~MCELFStreamer() {
 }
 
@@ -143,7 +147,7 @@ static void setSectionAlignmentForBundling(
 void MCELFStreamer::ChangeSection(MCSection *Section,
                                   const MCExpr *Subsection) {
   MCSectionData *CurSection = getCurrentSectionData();
-  if (CurSection && CurSection->isBundleLocked())
+  if (CurSection && isBundleLocked())
     report_fatal_error("Unterminated .bundle_lock when changing a section");
 
   MCAssembler &Asm = getAssembler();
@@ -344,7 +348,7 @@ void MCELFStreamer::EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
 
 void MCELFStreamer::EmitValueImpl(const MCExpr *Value, unsigned Size,
                                   const SMLoc &Loc) {
-  if (getCurrentSectionData()->isBundleLocked())
+  if (isBundleLocked())
     report_fatal_error("Emitting values inside a locked bundle is forbidden");
   fixSymbolsInTLSFixups(Value);
   MCObjectStreamer::EmitValueImpl(Value, Size, Loc);
@@ -354,7 +358,7 @@ void MCELFStreamer::EmitValueToAlignment(unsigned ByteAlignment,
                                          int64_t Value,
                                          unsigned ValueSize,
                                          unsigned MaxBytesToEmit) {
-  if (getCurrentSectionData()->isBundleLocked())
+  if (isBundleLocked())
     report_fatal_error("Emitting values inside a locked bundle is forbidden");
   MCObjectStreamer::EmitValueToAlignment(ByteAlignment, Value,
                                          ValueSize, MaxBytesToEmit);
@@ -503,20 +507,20 @@ void MCELFStreamer::EmitInstToData(const MCInst &Inst,
 
   if (Assembler.isBundlingEnabled()) {
     MCSectionData *SD = getCurrentSectionData();
-    if (Assembler.getRelaxAll() && SD->isBundleLocked())
+    if (Assembler.getRelaxAll() && isBundleLocked())
       // If the -mc-relax-all flag is used and we are bundle-locked, we re-use
       // the current bundle group.
       DF = BundleGroups.back();
-    else if (Assembler.getRelaxAll() && !SD->isBundleLocked())
+    else if (Assembler.getRelaxAll() && !isBundleLocked())
       // When not in a bundle-locked group and the -mc-relax-all flag is used,
       // we create a new temporary fragment which will be later merged into
       // the current fragment.
       DF = new MCDataFragment();
-    else if (SD->isBundleLocked() && !SD->isBundleGroupBeforeFirstInst())
+    else if (isBundleLocked() && !SD->isBundleGroupBeforeFirstInst())
       // If we are bundle-locked, we re-use the current fragment.
       // The bundle-locking directive ensures this is a new data fragment.
       DF = cast<MCDataFragment>(getCurrentFragment());
-    else if (!SD->isBundleLocked() && Fixups.size() == 0) {
+    else if (!isBundleLocked() && Fixups.size() == 0) {
       // Optimize memory usage by emitting the instruction to a
       // MCCompactEncodedInstFragment when not in a bundle-locked group and
       // there are no fixups registered.
@@ -552,8 +556,7 @@ void MCELFStreamer::EmitInstToData(const MCInst &Inst,
   DF->getContents().append(Code.begin(), Code.end());
 
   if (Assembler.isBundlingEnabled() && Assembler.getRelaxAll()) {
-    MCSectionData *SD = getCurrentSectionData();
-    if (!SD->isBundleLocked()) {
+    if (!isBundleLocked()) {
       mergeFragment(getOrCreateDataFragment(), DF);
       delete DF;
     }
@@ -578,10 +581,10 @@ void MCELFStreamer::EmitBundleLock(bool AlignToEnd) {
   if (!getAssembler().isBundlingEnabled())
     report_fatal_error(".bundle_lock forbidden when bundling is disabled");
 
-  if (!SD->isBundleLocked())
+  if (!isBundleLocked())
     SD->setBundleGroupBeforeFirstInst(true);
 
-  if (getAssembler().getRelaxAll() && !SD->isBundleLocked()) {
+  if (getAssembler().getRelaxAll() && !isBundleLocked()) {
     // TODO: drop the lock state and set directly in the fragment
     MCDataFragment *DF = new MCDataFragment();
     BundleGroups.push_back(DF);
@@ -597,7 +600,7 @@ void MCELFStreamer::EmitBundleUnlock() {
   // Sanity checks
   if (!getAssembler().isBundlingEnabled())
     report_fatal_error(".bundle_unlock forbidden when bundling is disabled");
-  else if (!SD->isBundleLocked())
+  else if (!isBundleLocked())
     report_fatal_error(".bundle_unlock without matching lock");
   else if (SD->isBundleGroupBeforeFirstInst())
     report_fatal_error("Empty bundle-locked group is forbidden");
@@ -612,8 +615,8 @@ void MCELFStreamer::EmitBundleUnlock() {
     // FIXME: Use BundleGroups to track the lock state instead.
     SD->setBundleLockState(MCSectionData::NotBundleLocked);
 
-    // FIXME: Use more separate fragments for nested groups. 
-    if (!SD->isBundleLocked()) {
+    // FIXME: Use more separate fragments for nested groups.
+    if (!isBundleLocked()) {
       mergeFragment(getOrCreateDataFragment(), DF);
       BundleGroups.pop_back();
       delete DF;