OSDN Git Service

[llvm-mca] Lower to mca::Instructon before the pipeline is run.
authorAndrea Di Biagio <Andrea_DiBiagio@sn.scee.net>
Mon, 29 Oct 2018 13:29:22 +0000 (13:29 +0000)
committerAndrea Di Biagio <Andrea_DiBiagio@sn.scee.net>
Mon, 29 Oct 2018 13:29:22 +0000 (13:29 +0000)
commitee5a5147a1466539ad34f04e8d0c77479b7e7d73
treec52a28f44b5b571234634d0a0028578ef23cfa10
parent11ead03db9dd6f8378275bbd014bbc171eef8544
[llvm-mca] Lower to mca::Instructon before the pipeline is run.

Before this change, the lowering of instructions from llvm::MCInst to
mca::Instruction was done as part of the first stage of the pipeline (i.e. the
FetchStage).  In particular, FetchStage was responsible for picking the next
instruction from the source sequence, and lower it to an mca::Instruction with
the help of an object of class InstrBuilder.

The dependency on InstrBuilder was problematic for a number of reasons. Class
InstrBuilder only knows how to lower from llvm::MCInst to mca::Instruction.
That means, it is hard to support a different scenario where instructions
in input are not instances of class llvm::MCInst. Even if we managed to
specialize InstrBuilder, and generalize most of its internal logic, the
dependency on InstrBuilder in FetchStage would have caused more troubles (other
than complicating the pipeline logic).

With this patch, the lowering step is done before the pipeline is run. The
pipeline is no longer responsible for lowering from MCInst to mca::Instruction.
As a consequence of this, the FetchStage no longer needs to interact with an
InstrBuilder. The mca::SourceMgr class now simply wraps a reference to a
sequence of mca::Instruction objects.
This simplifies the logic of FetchStage, and increases the usability of it.  As
a result, on a debug build, we see a 7-9% speedup; on a release build, the
speedup is around 3-4%.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@345500 91177308-0d34-0410-b5e6-96231b3b80d8
tools/llvm-mca/include/Instruction.h
tools/llvm-mca/include/SourceMgr.h
tools/llvm-mca/include/Stages/FetchStage.h
tools/llvm-mca/lib/Context.cpp
tools/llvm-mca/lib/Instruction.cpp
tools/llvm-mca/lib/Stages/FetchStage.cpp
tools/llvm-mca/llvm-mca.cpp