| OLD | NEW |
| 1 //===- lib/MC/MCAsmStreamer.cpp - Text Assembly Output --------------------===// | 1 //===- lib/MC/MCAsmStreamer.cpp - Text Assembly Output --------------------===// |
| 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 #include "llvm/MC/MCStreamer.h" | 10 #include "llvm/MC/MCStreamer.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 std::unique_ptr<MCInstPrinter> InstPrinter; | 45 std::unique_ptr<MCInstPrinter> InstPrinter; |
| 46 std::unique_ptr<MCCodeEmitter> Emitter; | 46 std::unique_ptr<MCCodeEmitter> Emitter; |
| 47 std::unique_ptr<MCAsmBackend> AsmBackend; | 47 std::unique_ptr<MCAsmBackend> AsmBackend; |
| 48 | 48 |
| 49 SmallString<128> CommentToEmit; | 49 SmallString<128> CommentToEmit; |
| 50 raw_svector_ostream CommentStream; | 50 raw_svector_ostream CommentStream; |
| 51 | 51 |
| 52 unsigned IsVerboseAsm : 1; | 52 unsigned IsVerboseAsm : 1; |
| 53 unsigned ShowInst : 1; | 53 unsigned ShowInst : 1; |
| 54 unsigned UseDwarfDirectory : 1; | 54 unsigned UseDwarfDirectory : 1; |
| 55 // @LOCALMOD: we don't have an MCAssembler object here, so we can't ask it |
| 56 // if bundle alignment is enabled. Instead, just track the alignment here. |
| 57 unsigned BundleAlignmentEnabled : 1; |
| 55 | 58 |
| 56 void EmitRegisterName(int64_t Register); | 59 void EmitRegisterName(int64_t Register); |
| 57 void EmitCFIStartProcImpl(MCDwarfFrameInfo &Frame) override; | 60 void EmitCFIStartProcImpl(MCDwarfFrameInfo &Frame) override; |
| 58 void EmitCFIEndProcImpl(MCDwarfFrameInfo &Frame) override; | 61 void EmitCFIEndProcImpl(MCDwarfFrameInfo &Frame) override; |
| 59 | 62 |
| 60 public: | 63 public: |
| 61 MCAsmStreamer(MCContext &Context, formatted_raw_ostream &os, | 64 MCAsmStreamer(MCContext &Context, formatted_raw_ostream &os, |
| 62 bool isVerboseAsm, bool useDwarfDirectory, | 65 bool isVerboseAsm, bool useDwarfDirectory, |
| 63 MCInstPrinter *printer, MCCodeEmitter *emitter, | 66 MCInstPrinter *printer, MCCodeEmitter *emitter, |
| 64 MCAsmBackend *asmbackend, bool showInst) | 67 MCAsmBackend *asmbackend, bool showInst) |
| 65 : MCStreamer(Context), OS(os), MAI(Context.getAsmInfo()), | 68 : MCStreamer(Context), OS(os), MAI(Context.getAsmInfo()), |
| 66 InstPrinter(printer), Emitter(emitter), AsmBackend(asmbackend), | 69 InstPrinter(printer), Emitter(emitter), AsmBackend(asmbackend), |
| 67 CommentStream(CommentToEmit), IsVerboseAsm(isVerboseAsm), | 70 CommentStream(CommentToEmit), IsVerboseAsm(isVerboseAsm), |
| 68 ShowInst(showInst), UseDwarfDirectory(useDwarfDirectory) { | 71 ShowInst(showInst), UseDwarfDirectory(useDwarfDirectory), |
| 72 BundleAlignmentEnabled(0) { |
| 69 if (InstPrinter && IsVerboseAsm) | 73 if (InstPrinter && IsVerboseAsm) |
| 70 InstPrinter->setCommentStream(CommentStream); | 74 InstPrinter->setCommentStream(CommentStream); |
| 71 } | 75 } |
| 72 | 76 |
| 73 inline void EmitEOL() { | 77 inline void EmitEOL() { |
| 74 // If we don't have any comments, just emit a \n. | 78 // If we don't have any comments, just emit a \n. |
| 75 if (!IsVerboseAsm) { | 79 if (!IsVerboseAsm) { |
| 76 OS << '\n'; | 80 OS << '\n'; |
| 77 return; | 81 return; |
| 78 } | 82 } |
| (...skipping 1157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1236 const MCFixupKindInfo &Info = AsmBackend->getFixupKindInfo(F.getKind()); | 1240 const MCFixupKindInfo &Info = AsmBackend->getFixupKindInfo(F.getKind()); |
| 1237 OS << " fixup " << char('A' + i) << " - " << "offset: " << F.getOffset() | 1241 OS << " fixup " << char('A' + i) << " - " << "offset: " << F.getOffset() |
| 1238 << ", value: " << *F.getValue() << ", kind: " << Info.Name << "\n"; | 1242 << ", value: " << *F.getValue() << ", kind: " << Info.Name << "\n"; |
| 1239 } | 1243 } |
| 1240 } | 1244 } |
| 1241 | 1245 |
| 1242 void MCAsmStreamer::EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &S
TI) { | 1246 void MCAsmStreamer::EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &S
TI) { |
| 1243 assert(getCurrentSection().first && | 1247 assert(getCurrentSection().first && |
| 1244 "Cannot emit contents before setting section!"); | 1248 "Cannot emit contents before setting section!"); |
| 1245 | 1249 |
| 1250 // @LOCALMOD-START |
| 1251 if (BundleAlignmentEnabled && AsmBackend && |
| 1252 AsmBackend->CustomExpandInst(Inst, *this)) { |
| 1253 return; |
| 1254 } |
| 1255 // @LOCALMOD-END |
| 1246 // Show the encoding in a comment if we have a code emitter. | 1256 // Show the encoding in a comment if we have a code emitter. |
| 1247 if (Emitter) | 1257 if (Emitter) |
| 1248 AddEncodingComment(Inst, STI); | 1258 AddEncodingComment(Inst, STI); |
| 1249 | 1259 |
| 1250 // Show the MCInst if enabled. | 1260 // Show the MCInst if enabled. |
| 1251 if (ShowInst) { | 1261 if (ShowInst) { |
| 1252 Inst.dump_pretty(GetCommentOS(), MAI, InstPrinter.get(), "\n "); | 1262 Inst.dump_pretty(GetCommentOS(), MAI, InstPrinter.get(), "\n "); |
| 1253 GetCommentOS() << "\n"; | 1263 GetCommentOS() << "\n"; |
| 1254 } | 1264 } |
| 1255 | 1265 |
| 1256 // If we have an AsmPrinter, use that to print, otherwise print the MCInst. | 1266 // If we have an AsmPrinter, use that to print, otherwise print the MCInst. |
| 1257 if (InstPrinter) | 1267 if (InstPrinter) |
| 1258 InstPrinter->printInst(&Inst, OS, ""); | 1268 InstPrinter->printInst(&Inst, OS, ""); |
| 1259 else | 1269 else |
| 1260 Inst.print(OS, MAI); | 1270 Inst.print(OS, MAI); |
| 1261 EmitEOL(); | 1271 EmitEOL(); |
| 1262 } | 1272 } |
| 1263 | 1273 |
| 1264 void MCAsmStreamer::EmitBundleAlignMode(unsigned AlignPow2) { | 1274 void MCAsmStreamer::EmitBundleAlignMode(unsigned AlignPow2) { |
| 1265 OS << "\t.bundle_align_mode " << AlignPow2; | 1275 OS << "\t.bundle_align_mode " << AlignPow2; |
| 1276 BundleAlignmentEnabled = AlignPow2 > 0; // @LOCALMOD |
| 1266 EmitEOL(); | 1277 EmitEOL(); |
| 1267 } | 1278 } |
| 1268 | 1279 |
| 1269 void MCAsmStreamer::EmitBundleLock(bool AlignToEnd) { | 1280 void MCAsmStreamer::EmitBundleLock(bool AlignToEnd) { |
| 1270 OS << "\t.bundle_lock"; | 1281 OS << "\t.bundle_lock"; |
| 1271 if (AlignToEnd) | 1282 if (AlignToEnd) |
| 1272 OS << " align_to_end"; | 1283 OS << " align_to_end"; |
| 1273 EmitEOL(); | 1284 EmitEOL(); |
| 1274 } | 1285 } |
| 1275 | 1286 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1307 } | 1318 } |
| 1308 | 1319 |
| 1309 MCStreamer *llvm::createAsmStreamer(MCContext &Context, | 1320 MCStreamer *llvm::createAsmStreamer(MCContext &Context, |
| 1310 formatted_raw_ostream &OS, | 1321 formatted_raw_ostream &OS, |
| 1311 bool isVerboseAsm, bool useDwarfDirectory, | 1322 bool isVerboseAsm, bool useDwarfDirectory, |
| 1312 MCInstPrinter *IP, MCCodeEmitter *CE, | 1323 MCInstPrinter *IP, MCCodeEmitter *CE, |
| 1313 MCAsmBackend *MAB, bool ShowInst) { | 1324 MCAsmBackend *MAB, bool ShowInst) { |
| 1314 return new MCAsmStreamer(Context, OS, isVerboseAsm, useDwarfDirectory, IP, CE, | 1325 return new MCAsmStreamer(Context, OS, isVerboseAsm, useDwarfDirectory, IP, CE, |
| 1315 MAB, ShowInst); | 1326 MAB, ShowInst); |
| 1316 } | 1327 } |
| OLD | NEW |