summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/include/llvm/MC/MCAssembler.h15
-rw-r--r--llvm/lib/MC/MCObjectStreamer.cpp2
-rw-r--r--llvm/lib/MC/MCPureStreamer.cpp2
3 files changed, 15 insertions, 4 deletions
diff --git a/llvm/include/llvm/MC/MCAssembler.h b/llvm/include/llvm/MC/MCAssembler.h
index 8735a55ce04..e1cf66d3f9e 100644
--- a/llvm/include/llvm/MC/MCAssembler.h
+++ b/llvm/include/llvm/MC/MCAssembler.h
@@ -17,6 +17,7 @@
#include "llvm/ADT/ilist_node.h"
#include "llvm/MC/MCFixup.h"
#include "llvm/MC/MCInst.h"
+#include "llvm/MC/MCSubtargetInfo.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/DataTypes.h"
#include <algorithm>
@@ -33,6 +34,7 @@ class MCFragment;
class MCObjectWriter;
class MCSection;
class MCSectionData;
+class MCSubtargetInfo;
class MCSymbol;
class MCSymbolData;
class MCValue;
@@ -288,6 +290,11 @@ class MCRelaxableFragment : public MCEncodedFragmentWithFixups {
/// Inst - The instruction this is a fragment for.
MCInst Inst;
+ /// STI - The MCSubtargetInfo in effect when the instruction was encoded.
+ /// Keep a copy instead of a reference to make sure that updates to STI
+ /// in the assembler are not seen here.
+ const MCSubtargetInfo STI;
+
/// Contents - Binary data for the currently encoded instruction.
SmallVector<char, 8> Contents;
@@ -295,8 +302,10 @@ class MCRelaxableFragment : public MCEncodedFragmentWithFixups {
SmallVector<MCFixup, 1> Fixups;
public:
- MCRelaxableFragment(const MCInst &_Inst, MCSectionData *SD = 0)
- : MCEncodedFragmentWithFixups(FT_Relaxable, SD), Inst(_Inst) {
+ MCRelaxableFragment(const MCInst &_Inst,
+ const MCSubtargetInfo &_STI,
+ MCSectionData *SD = 0)
+ : MCEncodedFragmentWithFixups(FT_Relaxable, SD), Inst(_Inst), STI(_STI) {
}
virtual SmallVectorImpl<char> &getContents() { return Contents; }
@@ -305,6 +314,8 @@ public:
const MCInst &getInst() const { return Inst; }
void setInst(const MCInst& Value) { Inst = Value; }
+ const MCSubtargetInfo &getSubtargetInfo() { return STI; }
+
SmallVectorImpl<MCFixup> &getFixups() {
return Fixups;
}
diff --git a/llvm/lib/MC/MCObjectStreamer.cpp b/llvm/lib/MC/MCObjectStreamer.cpp
index d46f9d6f903..689c4230aac 100644
--- a/llvm/lib/MC/MCObjectStreamer.cpp
+++ b/llvm/lib/MC/MCObjectStreamer.cpp
@@ -230,7 +230,7 @@ void MCObjectStreamer::EmitInstToFragment(const MCInst &Inst,
const MCSubtargetInfo &STI) {
// Always create a new, separate fragment here, because its size can change
// during relaxation.
- MCRelaxableFragment *IF = new MCRelaxableFragment(Inst);
+ MCRelaxableFragment *IF = new MCRelaxableFragment(Inst, STI);
insert(IF);
SmallString<128> Code;
diff --git a/llvm/lib/MC/MCPureStreamer.cpp b/llvm/lib/MC/MCPureStreamer.cpp
index 6d93596676b..26d0765e15d 100644
--- a/llvm/lib/MC/MCPureStreamer.cpp
+++ b/llvm/lib/MC/MCPureStreamer.cpp
@@ -181,7 +181,7 @@ bool MCPureStreamer::EmitValueToOffset(const MCExpr *Offset,
void MCPureStreamer::EmitInstToFragment(const MCInst &Inst,
const MCSubtargetInfo &STI) {
- MCRelaxableFragment *IF = new MCRelaxableFragment(Inst);
+ MCRelaxableFragment *IF = new MCRelaxableFragment(Inst, STI);
insert(IF);
// Add the fixups and data.
OpenPOWER on IntegriCloud