Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(847)

Side by Side Diff: lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp

Issue 27690005: [MIPS] Modify LongBranch expansion to work with sandboxing (Closed) Base URL: http://git.chromium.org/native_client/pnacl-llvm.git@master
Patch Set: Changes per code review. Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | lib/Target/Mips/MipsInstrInfo.td » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===-- MipsASMBackend.cpp - Mips Asm Backend ----------------------------===// 1 //===-- MipsASMBackend.cpp - Mips Asm Backend ----------------------------===//
2 // 2 //
3 // The LLVM Compiler Infrastructure 3 // The LLVM Compiler Infrastructure
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 // 9 //
10 // This file implements the MipsAsmBackend and MipsELFObjectWriter classes. 10 // This file implements the MipsAsmBackend and MipsELFObjectWriter classes.
11 // 11 //
12 //===----------------------------------------------------------------------===// 12 //===----------------------------------------------------------------------===//
13 // 13 //
14 14
15 #include "MipsFixupKinds.h" 15 #include "MipsFixupKinds.h"
16 #include "MCTargetDesc/MipsMCTargetDesc.h" 16 #include "MCTargetDesc/MipsMCTargetDesc.h"
17 #include "MCTargetDesc/MipsMCNaCl.h" // @LOCALMOD 17 // @LOCALMOD-START
18 #include "MCTargetDesc/MipsMCNaCl.h"
19 #include "llvm/MC/MCAsmLayout.h"
20 #include "llvm/MC/MCExpr.h"
21 #include "llvm/MC/MCValue.h"
22 // @LOCALMOD-END
18 #include "llvm/MC/MCAsmBackend.h" 23 #include "llvm/MC/MCAsmBackend.h"
19 #include "llvm/MC/MCAssembler.h" 24 #include "llvm/MC/MCAssembler.h"
20 #include "llvm/MC/MCDirectives.h" 25 #include "llvm/MC/MCDirectives.h"
21 #include "llvm/MC/MCELFObjectWriter.h" 26 #include "llvm/MC/MCELFObjectWriter.h"
22 #include "llvm/MC/MCFixupKindInfo.h" 27 #include "llvm/MC/MCFixupKindInfo.h"
23 #include "llvm/MC/MCObjectWriter.h" 28 #include "llvm/MC/MCObjectWriter.h"
24 #include "llvm/MC/MCSubtargetInfo.h" 29 #include "llvm/MC/MCSubtargetInfo.h"
25 #include "llvm/Support/ErrorHandling.h" 30 #include "llvm/Support/ErrorHandling.h"
26 #include "llvm/Support/raw_ostream.h" 31 #include "llvm/Support/raw_ostream.h"
27 32
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 public: 96 public:
92 MipsAsmBackend(const Target &T, Triple::OSType _OSType, 97 MipsAsmBackend(const Target &T, Triple::OSType _OSType,
93 bool _isLittle, bool _is64Bit) 98 bool _isLittle, bool _is64Bit)
94 :MCAsmBackend(), OSType(_OSType), IsLittle(_isLittle), Is64Bit(_is64Bit) {} 99 :MCAsmBackend(), OSType(_OSType), IsLittle(_isLittle), Is64Bit(_is64Bit) {}
95 100
96 MCObjectWriter *createObjectWriter(raw_ostream &OS) const { 101 MCObjectWriter *createObjectWriter(raw_ostream &OS) const {
97 return createMipsELFObjectWriter(OS, 102 return createMipsELFObjectWriter(OS,
98 MCELFObjectTargetWriter::getOSABI(OSType), IsLittle, Is64Bit); 103 MCELFObjectTargetWriter::getOSABI(OSType), IsLittle, Is64Bit);
99 } 104 }
100 105
106 // @LOCALMOD-START
107 /// processFixupValue - Target hook to process the literal value of a fixup
108 /// if necessary.
109 void processFixupValue(const MCAssembler &Asm, const MCAsmLayout &Layout,
Mark Seaborn 2013/11/28 03:37:02 Can you send this part to upstream LLVM? You can
110 const MCFixup &Fixup, const MCFragment *DF,
111 MCValue &Target, uint64_t &Value,
112 bool &IsResolved) {
113 if ((unsigned)Fixup.getKind() == Mips::fixup_Mips_HI16
114 || (unsigned)Fixup.getKind() == Mips::fixup_Mips_LO16) {
115
116 // Check for expressions %hi(tmp) and %lo(tmp), where tmp = sym1-sym2.
Mark Seaborn 2013/11/28 03:37:02 This part isn't MIPS specific, so I wonder if you
117 if (Target.getSymA() != NULL && Target.getSymA()->getSymbol().isVariable()
118 && Target.getSymB() == NULL && Target.getConstant() == 0) {
119 const MCExpr *SymValue = Target.getSymA()->getSymbol()
120 .getVariableValue();
121 const MCBinaryExpr *BE = dyn_cast<MCBinaryExpr>(SymValue);
122 if (BE && BE->getOpcode() == MCBinaryExpr::Sub) {
123 const MCSymbolRefExpr *LHS = dyn_cast<MCSymbolRefExpr>(BE->getLHS());
124 const MCSymbolRefExpr *RHS = dyn_cast<MCSymbolRefExpr>(BE->getRHS());
125 if (LHS != NULL && LHS->getSymbol().isDefined()
126 && RHS != NULL && RHS->getSymbol().isDefined()) {
127 // Don't emit relocation for expressions %hi(tmp) and %lo(tmp),
128 // where tmp = sym1-sym2.
129 IsResolved = true;
130
131 // Calculate symbol value.
132 uint64_t Value1 =
133 Layout.getSymbolOffset(&Asm.getSymbolData(LHS->getSymbol()));
134 uint64_t Value2 =
135 Layout.getSymbolOffset(&Asm.getSymbolData(RHS->getSymbol()));
136 Value = Value1 - Value2;
137 }
138 }
139 }
140 }
141 }
142 // @LOCALMOD-END
143
101 /// ApplyFixup - Apply the \p Value for given \p Fixup into the provided 144 /// ApplyFixup - Apply the \p Value for given \p Fixup into the provided
102 /// data fragment, at the offset specified by the fixup and following the 145 /// data fragment, at the offset specified by the fixup and following the
103 /// fixup kind as appropriate. 146 /// fixup kind as appropriate.
104 void applyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize, 147 void applyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize,
105 uint64_t Value) const { 148 uint64_t Value) const {
106 MCFixupKind Kind = Fixup.getKind(); 149 MCFixupKind Kind = Fixup.getKind();
107 Value = adjustFixupValue((unsigned)Kind, Value); 150 Value = adjustFixupValue((unsigned)Kind, Value);
108 151
109 if (!Value) 152 if (!Value)
110 return; // Doesn't change encoding. 153 return; // Doesn't change encoding.
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 // @LOCALMOD-END 333 // @LOCALMOD-END
291 return new MipsAsmBackend(T, Triple(TT).getOS(), 334 return new MipsAsmBackend(T, Triple(TT).getOS(),
292 /*IsLittle*/true, /*Is64Bit*/true); 335 /*IsLittle*/true, /*Is64Bit*/true);
293 } 336 }
294 337
295 MCAsmBackend *llvm::createMipsAsmBackendEB64(const Target &T, StringRef TT, 338 MCAsmBackend *llvm::createMipsAsmBackendEB64(const Target &T, StringRef TT,
296 StringRef CPU) { 339 StringRef CPU) {
297 return new MipsAsmBackend(T, Triple(TT).getOS(), 340 return new MipsAsmBackend(T, Triple(TT).getOS(),
298 /*IsLittle*/false, /*Is64Bit*/true); 341 /*IsLittle*/false, /*Is64Bit*/true);
299 } 342 }
OLDNEW
« no previous file with comments | « no previous file | lib/Target/Mips/MipsInstrInfo.td » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698