summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDavid Woodhouse <dwmw2@infradead.org>2014-01-28 23:12:53 +0000
committerDavid Woodhouse <dwmw2@infradead.org>2014-01-28 23:12:53 +0000
commit41c8ba9d61acb86847ad6cf823656e212d8dbbf5 (patch)
treeefcb7a7b032fec0ed330e442838b7eebb73f338c /include
parentd5d381b76253fb6ccda6adc7b9d7239305b3d881 (diff)
downloadllvm-41c8ba9d61acb86847ad6cf823656e212d8dbbf5.tar.gz
llvm-41c8ba9d61acb86847ad6cf823656e212d8dbbf5.tar.bz2
llvm-41c8ba9d61acb86847ad6cf823656e212d8dbbf5.tar.xz
Keep the MCSubtargetInfo in the MCRelxableFragment class.
Needed to fix PR18303 to correctly re-encode the instruction if it is relaxed. We keep a copy of the MCSubtargetInfo to make sure that we are not effected by future changes to the subtarget info coming from the assembler (e.g. when parsing .code 16 directived). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200347 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/MC/MCAssembler.h15
1 files changed, 13 insertions, 2 deletions
diff --git a/include/llvm/MC/MCAssembler.h b/include/llvm/MC/MCAssembler.h
index 8735a55ce0..e1cf66d3f9 100644
--- a/include/llvm/MC/MCAssembler.h
+++ b/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;
}