llvm-mirror/tools
Matt Davis efffaf5cb4 [llvm-mca] Introduce a pipeline Stage class and FetchStage.
Summary:
    This is just an idea, really two ideas.  I expect some push-back,
    but I realize that posting a diff is the most comprehensive way to express
    these concepts.

    This patch introduces a Stage class which represents the
    various stages of an instruction pipeline.  As a start, I have created a simple
    FetchStage that is based on existing logic for how MCA produces
    instructions, but now encapsulated in a Stage.  The idea should become more concrete
    once we introduce additional stages.  The idea being, that when a stage completes,
    the next stage in the pipeline will be executed.  Stages are chained together
    as a singly linked list to closely model a real pipeline. For now there is only one stage,
    so the stage-to-stage flow of instructions isn't immediately obvious.

    Eventually, Stage will also handle event notifications, but that functionality
    is not complete, and not destined for this patch.  Ideally, an interested party 
    can register for notifications from a particular stage.  Callbacks will be issued to
    these listeners at various points in the execution of the stage.  
    For now, eventing functionality remains similar to what it has been in mca::Backend. 
    We will be building-up the Stage class as we move on, such as adding debug output.

    This patch also removes the unique_ptr<Instruction> return value from
    InstrBuilder::createInstruction.  An Instruction pointer is still produced,
    but now it's up to the caller to decide how that item should be managed post-allocation
    (e.g., smart pointer).  This allows the Fetch stage to create instructions and
    manage the lifetime of those instructions as it wishes, and not have to be bound to any
    specific managed pointer type.  Other callers of createInstruction might have different 
    requirements, and thus can manage the pointer to fit their needs.  Another idea would be to push the
   ownership to the RCU. 

    Currently, the FetchStage will wrap the Instruction
    pointer in a shared_ptr.  This allows us to remove the Instruction container in
    Backend, which was probably going to disappear, or move, at some point anyways.
    Note that I did run these changes through valgrind, to make sure we are not leaking
    memory.  While the shared_ptr comes with some additional overhead it relieves us
    from having to manage a list of generated instructions, and/or make lookup calls
    to remove the instructions. 

    I realize that both the Stage class and the Instruction pointer management
    (mentioned directly above) are separate but related ideas, and probably should
    land as separate patches; I am happy to do that if either idea is decent.
    The main reason these two ideas are together is that
    Stage::execute() can mutate an InstRef. For the fetch stage, the InstRef is populated
    as the primary action of that stage (execute()).  I didn't want to change the Stage interface
    to support the idea of generating an instruction.  Ideally, instructions are to
    be pushed through the pipeline.  I didn't want to draw too much of a
    specialization just for the fetch stage.  Excuse the word-salad.

Reviewers: andreadb, courbet, RKSimon

Reviewed By: andreadb

Subscribers: llvm-commits, mgorny, javed.absar, tschuett, gbedwell

Differential Revision: https://reviews.llvm.org/D46741

llvm-svn: 332390
2018-05-15 20:21:04 +00:00
..
bugpoint Rename DEBUG macro to LLVM_DEBUG. 2018-05-14 12:53:11 +00:00
bugpoint-passes
dsymutil [DWARF] Rework debug line parsing to use llvm::Error and callbacks 2018-05-10 10:51:33 +00:00
gold [LTO] Add stats-file option to LTO/Config.h. 2018-04-20 10:18:36 +00:00
llc llc: don't call llvm_shutdown twice 2018-05-12 19:38:44 +00:00
lli Rename DEBUG macro to LLVM_DEBUG. 2018-05-14 12:53:11 +00:00
llvm-ar [llvm-ar] Make PositionalArgs static. 2018-05-14 05:56:48 +00:00
llvm-as Define InitLLVM to do common initialization all at once. 2018-04-13 18:26:06 +00:00
llvm-as-fuzzer make add_llvm_fuzzer calls slightly more consisten with other cmake 2018-05-11 17:58:52 +00:00
llvm-bcanalyzer [bcanalyzer] Recognize more stream types 2018-04-21 23:52:04 +00:00
llvm-c-test [LLVM-C] Add Bindings For Module Flags 2018-05-14 08:09:00 +00:00
llvm-cat
llvm-cfi-verify Make llvm-cfi-verify CMakeLists.txt formatting more consistent with the rest of LLVM. 2018-05-09 01:07:02 +00:00
llvm-config Remove \brief commands from doxygen comments. 2018-05-01 15:54:18 +00:00
llvm-cov Remove \brief commands from doxygen comments. 2018-05-01 15:54:18 +00:00
llvm-cvtres [llvm-cvtres] Allow parameters preceded by '-' in addition to '/' 2018-05-02 21:15:13 +00:00
llvm-cxxdump Define InitLLVM to do common initialization all at once. 2018-04-13 18:26:06 +00:00
llvm-cxxfilt Define InitLLVM to do common initialization all at once. 2018-04-13 18:26:06 +00:00
llvm-demangle-fuzzer make add_llvm_fuzzer calls slightly more consisten with other cmake 2018-05-11 17:58:52 +00:00
llvm-diff Let llvm-diff correctly deal with Undef/ConstantAggregateZero/ConstantVector/IndirectBr 2018-04-12 21:28:04 +00:00
llvm-dis [tools] Use WithColor for printing errors. 2018-04-21 21:11:59 +00:00
llvm-dwarfdump Rename DEBUG macro to LLVM_DEBUG. 2018-05-14 12:53:11 +00:00
llvm-dwp [llvm-dwp] Define InitLLVM. 2018-05-06 23:08:29 +00:00
llvm-exegesis [llvm-exegesis] Split AsmTemplate.Name into components. 2018-05-15 13:07:05 +00:00
llvm-extract Define InitLLVM to do common initialization all at once. 2018-04-13 18:26:06 +00:00
llvm-go
llvm-isel-fuzzer make add_llvm_fuzzer calls slightly more consisten with other cmake 2018-05-11 17:58:52 +00:00
llvm-jitlistener Define InitLLVM to do common initialization all at once. 2018-04-13 18:26:06 +00:00
llvm-link [llvm-link] Use WithColor for printing errors 2018-04-18 14:41:47 +00:00
llvm-lto Remove \brief commands from doxygen comments. 2018-05-01 15:54:18 +00:00
llvm-lto2 [LTO] Allow pass remarks with hotness to be set when emitting to stderr 2018-05-04 23:59:34 +00:00
llvm-mc [MC] Change AsmParser to leverage Assembler during evaluation 2018-04-30 19:22:40 +00:00
llvm-mc-assemble-fuzzer make add_llvm_fuzzer calls slightly more consisten with other cmake 2018-05-11 17:58:52 +00:00
llvm-mc-disassemble-fuzzer make add_llvm_fuzzer calls slightly more consisten with other cmake 2018-05-11 17:58:52 +00:00
llvm-mca [llvm-mca] Introduce a pipeline Stage class and FetchStage. 2018-05-15 20:21:04 +00:00
llvm-modextract
llvm-mt Define InitLLVM to do common initialization all at once. 2018-04-13 18:26:06 +00:00
llvm-nm Fix debug build by adding missing dependencies on libBinaryFormat 2018-05-15 00:46:43 +00:00
llvm-objcopy [llvm-objcopy] Add --keep-symbol (-K) option 2018-05-15 14:09:37 +00:00
llvm-objdump Fix debug build by adding missing dependencies on libBinaryFormat 2018-05-15 00:46:43 +00:00
llvm-opt-fuzzer make add_llvm_fuzzer calls slightly more consisten with other cmake 2018-05-11 17:58:52 +00:00
llvm-opt-report Remove \brief commands from doxygen comments. 2018-05-01 15:54:18 +00:00
llvm-pdbutil llvm-pdbutil: Fix an off-by-one error. 2018-04-17 21:44:17 +00:00
llvm-profdata [llvm-profdata] Use WithColor for printing errors 2018-04-18 14:42:33 +00:00
llvm-rc [llvm-rc] Add support for the optional CLASS statement for dialogs 2018-05-15 19:21:28 +00:00
llvm-readobj [WebAssembly] llvm-readobj: display symbols names in relocations 2018-05-01 16:35:16 +00:00
llvm-rtdyld Define InitLLVM to do common initialization all at once. 2018-04-13 18:26:06 +00:00
llvm-shlib Rename llvm library from libLLVM-X.Y to libLLVM-X 2018-03-29 09:44:09 +00:00
llvm-size Define InitLLVM to do common initialization all at once. 2018-04-13 18:26:06 +00:00
llvm-special-case-list-fuzzer make add_llvm_fuzzer calls slightly more consisten with other cmake 2018-05-11 17:58:52 +00:00
llvm-split
llvm-stress
llvm-strings Define InitLLVM to do common initialization all at once. 2018-04-13 18:26:06 +00:00
llvm-symbolizer Define InitLLVM to do common initialization all at once. 2018-04-13 18:26:06 +00:00
llvm-xray Inline contents of LLVM_XRAY_TOOLS variable into its only use. 2018-05-09 00:42:17 +00:00
lto s/LLVM_ON_WIN32/_WIN32/, llvm 2018-04-29 00:45:03 +00:00
msbuild
obj2yaml Fix debug build by adding missing dependencies on libBinaryFormat 2018-05-15 00:46:43 +00:00
opt [Debugify] Add -debugify-each for testing each pass in a pipeline 2018-05-15 00:29:27 +00:00
opt-viewer [opt-viewer] Kill parser processes before moving onto rendering 2018-02-26 21:15:51 +00:00
sancov Rename sancov.cc to sancov.cpp 2018-04-25 18:06:23 +00:00
sanstats
verify-uselistorder Rename DEBUG macro to LLVM_DEBUG. 2018-05-14 12:53:11 +00:00
xcode-toolchain
yaml2obj Remove \brief commands from doxygen comments. 2018-05-01 15:54:18 +00:00
CMakeLists.txt
LLVMBuild.txt Re-land r329156 "Add llvm-exegesis tool." 2018-04-04 11:37:06 +00:00