[PATCH] D71468: [llvm-exegesis] Set up AsmTargetStreamer in readSnippets
Guillaume Chatelet via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 16 02:48:24 PST 2019
gchatelet updated this revision to Diff 234006.
gchatelet added a comment.
- Address comments
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D71468/new/
https://reviews.llvm.org/D71468
Files:
llvm/tools/llvm-exegesis/lib/SnippetFile.cpp
llvm/unittests/tools/llvm-exegesis/X86/SnippetFileTest.cpp
Index: llvm/unittests/tools/llvm-exegesis/X86/SnippetFileTest.cpp
===================================================================
--- llvm/unittests/tools/llvm-exegesis/X86/SnippetFileTest.cpp
+++ llvm/unittests/tools/llvm-exegesis/X86/SnippetFileTest.cpp
@@ -115,6 +115,13 @@
consumeError(std::move(Error));
}
+TEST_F(X86SnippetFileTest, NoAsmStreamer) {
+ auto Snippets = TestCommon(R"(
+ .cv_fpo_proc foo 4
+ )");
+ EXPECT_FALSE((bool)Snippets.takeError());
+}
+
} // namespace
} // namespace exegesis
} // namespace llvm
Index: llvm/tools/llvm-exegesis/lib/SnippetFile.cpp
===================================================================
--- llvm/tools/llvm-exegesis/lib/SnippetFile.cpp
+++ llvm/tools/llvm-exegesis/lib/SnippetFile.cpp
@@ -9,6 +9,7 @@
#include "SnippetFile.h"
#include "Error.h"
#include "llvm/MC/MCContext.h"
+#include "llvm/MC/MCInstPrinter.h"
#include "llvm/MC/MCObjectFileInfo.h"
#include "llvm/MC/MCParser/MCAsmParser.h"
#include "llvm/MC/MCParser/MCTargetAsmParser.h"
@@ -135,6 +136,21 @@
ObjectFileInfo.InitMCObjectFileInfo(TM.getTargetTriple(), /*PIC*/ false,
Context);
BenchmarkCodeStreamer Streamer(&Context, TM.getMCRegisterInfo(), &Result);
+
+ std::string Error;
+ raw_string_ostream ErrorStream(Error);
+ formatted_raw_ostream InstPrinterOStream(ErrorStream);
+ const std::unique_ptr<MCInstPrinter> InstPrinter(
+ TM.getTarget().createMCInstPrinter(
+ TM.getTargetTriple(), TM.getMCAsmInfo()->getAssemblerDialect(),
+ *TM.getMCAsmInfo(), *TM.getMCInstrInfo(), *TM.getMCRegisterInfo()));
+ // The following call will take care of calling Streamer.setTargetStreamer.
+ TM.getTarget().createAsmTargetStreamer(Streamer, InstPrinterOStream,
+ InstPrinter.get(),
+ TM.Options.MCOptions.AsmVerbose);
+ if (!Streamer.getTargetStreamer())
+ return make_error<Failure>("cannot create target asm streamer");
+
const std::unique_ptr<MCAsmParser> AsmParser(
createMCAsmParser(SM, Context, Streamer, *TM.getMCAsmInfo()));
if (!AsmParser)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71468.234006.patch
Type: text/x-patch
Size: 2158 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191216/fd030295/attachment.bin>
More information about the llvm-commits
mailing list