Index: tools/llvm-mca/CMakeLists.txt =================================================================== --- tools/llvm-mca/CMakeLists.txt +++ tools/llvm-mca/CMakeLists.txt @@ -1,3 +1,5 @@ +include_directories(include) + set(LLVM_LINK_COMPONENTS AllTargetsAsmPrinters AllTargetsAsmParsers @@ -10,33 +12,19 @@ ) add_llvm_tool(llvm-mca - CodeRegion.cpp - Context.cpp - DispatchStage.cpp + llvm-mca.cpp DispatchStatistics.cpp - ExecuteStage.cpp - FetchStage.cpp - HWEventListener.cpp - HardwareUnit.cpp - InstrBuilder.cpp - Instruction.cpp InstructionInfoView.cpp - InstructionTables.cpp - LSUnit.cpp - llvm-mca.cpp - Pipeline.cpp PipelinePrinter.cpp - RegisterFile.cpp RegisterFileStatistics.cpp ResourcePressureView.cpp - RetireControlUnit.cpp RetireControlUnitStatistics.cpp - RetireStage.cpp - Scheduler.cpp SchedulerStatistics.cpp - Stage.cpp - Support.cpp SummaryView.cpp TimelineView.cpp View.cpp ) + +set(LLVM_MCA_SOURCE_DIR ${CURRENT_SOURCE_DIR}) +add_subdirectory(lib) +target_link_libraries(llvm-mca PRIVATE LLVMMCA) Index: tools/llvm-mca/InstructionInfoView.h =================================================================== --- tools/llvm-mca/InstructionInfoView.h +++ tools/llvm-mca/InstructionInfoView.h @@ -35,8 +35,8 @@ #ifndef LLVM_TOOLS_LLVM_MCA_INSTRUCTIONINFOVIEW_H #define LLVM_TOOLS_LLVM_MCA_INSTRUCTIONINFOVIEW_H -#include "SourceMgr.h" #include "View.h" +#include "include/SourceMgr.h" #include "llvm/MC/MCInstPrinter.h" #include "llvm/MC/MCInstrInfo.h" #include "llvm/MC/MCSubtargetInfo.h" Index: tools/llvm-mca/PipelinePrinter.h =================================================================== --- tools/llvm-mca/PipelinePrinter.h +++ tools/llvm-mca/PipelinePrinter.h @@ -17,8 +17,8 @@ #ifndef LLVM_TOOLS_LLVM_MCA_PIPELINEPRINTER_H #define LLVM_TOOLS_LLVM_MCA_PIPELINEPRINTER_H -#include "Pipeline.h" #include "View.h" +#include "include/Pipeline.h" #include "llvm/ADT/SmallVector.h" #include "llvm/Support/raw_ostream.h" Index: tools/llvm-mca/ResourcePressureView.h =================================================================== --- tools/llvm-mca/ResourcePressureView.h +++ tools/llvm-mca/ResourcePressureView.h @@ -58,8 +58,8 @@ #ifndef LLVM_TOOLS_LLVM_MCA_RESOURCEPRESSUREVIEW_H #define LLVM_TOOLS_LLVM_MCA_RESOURCEPRESSUREVIEW_H -#include "SourceMgr.h" #include "View.h" +#include "include/SourceMgr.h" #include "llvm/ADT/DenseMap.h" #include "llvm/MC/MCInstPrinter.h" #include "llvm/MC/MCSubtargetInfo.h" Index: tools/llvm-mca/SummaryView.h =================================================================== --- tools/llvm-mca/SummaryView.h +++ tools/llvm-mca/SummaryView.h @@ -29,8 +29,8 @@ #ifndef LLVM_TOOLS_LLVM_MCA_SUMMARYVIEW_H #define LLVM_TOOLS_LLVM_MCA_SUMMARYVIEW_H -#include "SourceMgr.h" #include "View.h" +#include "include/SourceMgr.h" #include "llvm/ADT/DenseMap.h" #include "llvm/MC/MCSchedule.h" #include "llvm/Support/raw_ostream.h" Index: tools/llvm-mca/SummaryView.cpp =================================================================== --- tools/llvm-mca/SummaryView.cpp +++ tools/llvm-mca/SummaryView.cpp @@ -14,7 +14,7 @@ //===----------------------------------------------------------------------===// #include "SummaryView.h" -#include "Support.h" +#include "include/Support.h" #include "llvm/ADT/SmallVector.h" #include "llvm/Support/Format.h" Index: tools/llvm-mca/TimelineView.h =================================================================== --- tools/llvm-mca/TimelineView.h +++ tools/llvm-mca/TimelineView.h @@ -100,8 +100,8 @@ #ifndef LLVM_TOOLS_LLVM_MCA_TIMELINEVIEW_H #define LLVM_TOOLS_LLVM_MCA_TIMELINEVIEW_H -#include "SourceMgr.h" #include "View.h" +#include "include/SourceMgr.h" #include "llvm/MC/MCInstPrinter.h" #include "llvm/MC/MCSubtargetInfo.h" #include "llvm/Support/FormattedStream.h" Index: tools/llvm-mca/View.h =================================================================== --- tools/llvm-mca/View.h +++ tools/llvm-mca/View.h @@ -16,7 +16,7 @@ #ifndef LLVM_TOOLS_LLVM_MCA_VIEW_H #define LLVM_TOOLS_LLVM_MCA_VIEW_H -#include "HWEventListener.h" +#include "include/HWEventListener.h" #include "llvm/Support/raw_ostream.h" namespace mca { Index: tools/llvm-mca/include/Context.h =================================================================== --- tools/llvm-mca/include/Context.h +++ tools/llvm-mca/include/Context.h @@ -17,7 +17,7 @@ #ifndef LLVM_TOOLS_LLVM_MCA_CONTEXT_H #define LLVM_TOOLS_LLVM_MCA_CONTEXT_H -#include "HardwareUnit.h" +#include "HardwareUnits/HardwareUnit.h" #include "InstrBuilder.h" #include "Pipeline.h" #include "SourceMgr.h" Index: tools/llvm-mca/include/HardwareUnits/RegisterFile.h =================================================================== --- tools/llvm-mca/include/HardwareUnits/RegisterFile.h +++ tools/llvm-mca/include/HardwareUnits/RegisterFile.h @@ -17,7 +17,7 @@ #ifndef LLVM_TOOLS_LLVM_MCA_REGISTER_FILE_H #define LLVM_TOOLS_LLVM_MCA_REGISTER_FILE_H -#include "HardwareUnit.h" +#include "HardwareUnits/HardwareUnit.h" #include "llvm/ADT/SmallVector.h" #include "llvm/MC/MCRegisterInfo.h" #include "llvm/MC/MCSchedule.h" Index: tools/llvm-mca/include/Pipeline.h =================================================================== --- tools/llvm-mca/include/Pipeline.h +++ tools/llvm-mca/include/Pipeline.h @@ -16,8 +16,8 @@ #ifndef LLVM_TOOLS_LLVM_MCA_PIPELINE_H #define LLVM_TOOLS_LLVM_MCA_PIPELINE_H -#include "Scheduler.h" -#include "Stage.h" +#include "HardwareUnits/Scheduler.h" +#include "Stages/Stage.h" #include "llvm/ADT/SmallVector.h" #include "llvm/Support/Error.h" Index: tools/llvm-mca/include/Stages/DispatchStage.h =================================================================== --- tools/llvm-mca/include/Stages/DispatchStage.h +++ tools/llvm-mca/include/Stages/DispatchStage.h @@ -20,10 +20,10 @@ #define LLVM_TOOLS_LLVM_MCA_DISPATCH_STAGE_H #include "HWEventListener.h" +#include "HardwareUnits/RegisterFile.h" +#include "HardwareUnits/RetireControlUnit.h" #include "Instruction.h" -#include "RegisterFile.h" -#include "RetireControlUnit.h" -#include "Stage.h" +#include "Stages/Stage.h" #include "llvm/MC/MCRegisterInfo.h" #include "llvm/MC/MCSubtargetInfo.h" Index: tools/llvm-mca/include/Stages/ExecuteStage.h =================================================================== --- tools/llvm-mca/include/Stages/ExecuteStage.h +++ tools/llvm-mca/include/Stages/ExecuteStage.h @@ -18,9 +18,9 @@ #ifndef LLVM_TOOLS_LLVM_MCA_EXECUTE_STAGE_H #define LLVM_TOOLS_LLVM_MCA_EXECUTE_STAGE_H +#include "HardwareUnits/Scheduler.h" #include "Instruction.h" -#include "Scheduler.h" -#include "Stage.h" +#include "Stages/Stage.h" #include "llvm/ADT/ArrayRef.h" namespace mca { Index: tools/llvm-mca/include/Stages/FetchStage.h =================================================================== --- tools/llvm-mca/include/Stages/FetchStage.h +++ tools/llvm-mca/include/Stages/FetchStage.h @@ -18,7 +18,7 @@ #include "InstrBuilder.h" #include "SourceMgr.h" -#include "Stage.h" +#include "Stages/Stage.h" #include namespace mca { Index: tools/llvm-mca/include/Stages/InstructionTables.h =================================================================== --- tools/llvm-mca/include/Stages/InstructionTables.h +++ tools/llvm-mca/include/Stages/InstructionTables.h @@ -17,10 +17,9 @@ #ifndef LLVM_TOOLS_LLVM_MCA_INSTRUCTIONTABLES_H #define LLVM_TOOLS_LLVM_MCA_INSTRUCTIONTABLES_H +#include "HardwareUnits/Scheduler.h" #include "InstrBuilder.h" -#include "Scheduler.h" -#include "Stage.h" -#include "View.h" +#include "Stages/Stage.h" #include "llvm/ADT/SmallVector.h" #include "llvm/MC/MCSchedule.h" Index: tools/llvm-mca/include/Stages/RetireStage.h =================================================================== --- tools/llvm-mca/include/Stages/RetireStage.h +++ tools/llvm-mca/include/Stages/RetireStage.h @@ -17,9 +17,9 @@ #ifndef LLVM_TOOLS_LLVM_MCA_RETIRE_STAGE_H #define LLVM_TOOLS_LLVM_MCA_RETIRE_STAGE_H -#include "RegisterFile.h" -#include "RetireControlUnit.h" -#include "Stage.h" +#include "HardwareUnits/RegisterFile.h" +#include "HardwareUnits/RetireControlUnit.h" +#include "Stages/Stage.h" namespace mca { Index: tools/llvm-mca/lib/CMakeLists.txt =================================================================== --- /dev/null +++ tools/llvm-mca/lib/CMakeLists.txt @@ -0,0 +1,26 @@ +include_directories(${LLVM_MCA_SOURCE_DIR}/include) + +add_library(LLVMMCA + STATIC + CodeRegion.cpp + Context.cpp + HWEventListener.cpp + HardwareUnits/HardwareUnit.cpp + HardwareUnits/LSUnit.cpp + HardwareUnits/RegisterFile.cpp + HardwareUnits/RetireControlUnit.cpp + HardwareUnits/Scheduler.cpp + InstrBuilder.cpp + Instruction.cpp + Pipeline.cpp + Stages/DispatchStage.cpp + Stages/ExecuteStage.cpp + Stages/FetchStage.cpp + Stages/InstructionTables.cpp + Stages/RetireStage.cpp + Stages/Stage.cpp + Support.cpp + ) + +llvm_update_compile_flags(LLVMMCA) +target_link_libraries(LLVMMCA ${libs}) Index: tools/llvm-mca/lib/Context.cpp =================================================================== --- tools/llvm-mca/lib/Context.cpp +++ tools/llvm-mca/lib/Context.cpp @@ -16,13 +16,13 @@ //===----------------------------------------------------------------------===// #include "Context.h" -#include "DispatchStage.h" -#include "ExecuteStage.h" -#include "FetchStage.h" -#include "RegisterFile.h" -#include "RetireControlUnit.h" -#include "RetireStage.h" -#include "Scheduler.h" +#include "HardwareUnits/RegisterFile.h" +#include "HardwareUnits/RetireControlUnit.h" +#include "HardwareUnits/Scheduler.h" +#include "Stages/DispatchStage.h" +#include "Stages/ExecuteStage.h" +#include "Stages/FetchStage.h" +#include "Stages/RetireStage.h" namespace mca { Index: tools/llvm-mca/lib/HardwareUnits/HardwareUnit.cpp =================================================================== --- tools/llvm-mca/lib/HardwareUnits/HardwareUnit.cpp +++ tools/llvm-mca/lib/HardwareUnits/HardwareUnit.cpp @@ -13,7 +13,7 @@ /// //===----------------------------------------------------------------------===// -#include "HardwareUnit.h" +#include "HardwareUnits/HardwareUnit.h" namespace mca { Index: tools/llvm-mca/lib/HardwareUnits/LSUnit.cpp =================================================================== --- tools/llvm-mca/lib/HardwareUnits/LSUnit.cpp +++ tools/llvm-mca/lib/HardwareUnits/LSUnit.cpp @@ -12,7 +12,7 @@ /// //===----------------------------------------------------------------------===// -#include "LSUnit.h" +#include "HardwareUnits/LSUnit.h" #include "Instruction.h" #include "llvm/Support/Debug.h" Index: tools/llvm-mca/lib/HardwareUnits/RegisterFile.cpp =================================================================== --- tools/llvm-mca/lib/HardwareUnits/RegisterFile.cpp +++ tools/llvm-mca/lib/HardwareUnits/RegisterFile.cpp @@ -14,7 +14,7 @@ /// //===----------------------------------------------------------------------===// -#include "RegisterFile.h" +#include "HardwareUnits/RegisterFile.h" #include "Instruction.h" #include "llvm/Support/Debug.h" Index: tools/llvm-mca/lib/HardwareUnits/RetireControlUnit.cpp =================================================================== --- tools/llvm-mca/lib/HardwareUnits/RetireControlUnit.cpp +++ tools/llvm-mca/lib/HardwareUnits/RetireControlUnit.cpp @@ -12,7 +12,7 @@ /// //===----------------------------------------------------------------------===// -#include "RetireControlUnit.h" +#include "HardwareUnits/RetireControlUnit.h" #include "llvm/Support/Debug.h" using namespace llvm; Index: tools/llvm-mca/lib/HardwareUnits/Scheduler.cpp =================================================================== --- tools/llvm-mca/lib/HardwareUnits/Scheduler.cpp +++ tools/llvm-mca/lib/HardwareUnits/Scheduler.cpp @@ -11,7 +11,7 @@ // //===----------------------------------------------------------------------===// -#include "Scheduler.h" +#include "HardwareUnits/Scheduler.h" #include "Support.h" #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" @@ -267,7 +267,7 @@ Event = StallKind::StoreQueueFull; if (Desc.MayLoad && LSU->isLQFull()) Event = StallKind::LoadQueueFull; - + switch (Resources->canBeDispatched(Desc.Buffers)) { case ResourceStateEvent::RS_BUFFER_UNAVAILABLE: Event = StallKind::SchedulerQueueFull; Index: tools/llvm-mca/lib/Stages/DispatchStage.cpp =================================================================== --- tools/llvm-mca/lib/Stages/DispatchStage.cpp +++ tools/llvm-mca/lib/Stages/DispatchStage.cpp @@ -16,9 +16,9 @@ /// //===----------------------------------------------------------------------===// -#include "DispatchStage.h" +#include "Stages/DispatchStage.h" #include "HWEventListener.h" -#include "Scheduler.h" +#include "HardwareUnits/Scheduler.h" #include "llvm/Support/Debug.h" using namespace llvm; Index: tools/llvm-mca/lib/Stages/ExecuteStage.cpp =================================================================== --- tools/llvm-mca/lib/Stages/ExecuteStage.cpp +++ tools/llvm-mca/lib/Stages/ExecuteStage.cpp @@ -15,7 +15,7 @@ /// //===----------------------------------------------------------------------===// -#include "ExecuteStage.h" +#include "Stages/ExecuteStage.h" #include "llvm/ADT/SmallVector.h" #include "llvm/Support/Debug.h" @@ -65,7 +65,7 @@ HWS.updateIssuedSet(InstructionIDs); for (InstRef &IR : InstructionIDs) { notifyInstructionExecuted(IR); - //FIXME: add a buffer of executed instructions. + // FIXME: add a buffer of executed instructions. if (Error S = moveToTheNextStage(IR)) return S; } @@ -91,7 +91,7 @@ notifyInstructionIssued(IR, Used); if (IR.getInstruction()->isExecuted()) { notifyInstructionExecuted(IR); - //FIXME: add a buffer of executed instructions. + // FIXME: add a buffer of executed instructions. if (Error S = moveToTheNextStage(IR)) return S; } @@ -186,7 +186,7 @@ notifyInstructionIssued(IR, Used); if (IR.getInstruction()->isExecuted()) { notifyInstructionExecuted(IR); - //FIXME: add a buffer of executed instructions. + // FIXME: add a buffer of executed instructions. return moveToTheNextStage(IR); } return ErrorSuccess(); Index: tools/llvm-mca/lib/Stages/FetchStage.cpp =================================================================== --- tools/llvm-mca/lib/Stages/FetchStage.cpp +++ tools/llvm-mca/lib/Stages/FetchStage.cpp @@ -13,7 +13,7 @@ /// //===----------------------------------------------------------------------===// -#include "FetchStage.h" +#include "Stages/FetchStage.h" namespace mca { Index: tools/llvm-mca/lib/Stages/InstructionTables.cpp =================================================================== --- tools/llvm-mca/lib/Stages/InstructionTables.cpp +++ tools/llvm-mca/lib/Stages/InstructionTables.cpp @@ -15,7 +15,7 @@ /// //===----------------------------------------------------------------------===// -#include "InstructionTables.h" +#include "Stages/InstructionTables.h" namespace mca { Index: tools/llvm-mca/lib/Stages/RetireStage.cpp =================================================================== --- tools/llvm-mca/lib/Stages/RetireStage.cpp +++ tools/llvm-mca/lib/Stages/RetireStage.cpp @@ -14,7 +14,7 @@ /// //===----------------------------------------------------------------------===// -#include "RetireStage.h" +#include "Stages/RetireStage.h" #include "HWEventListener.h" #include "llvm/Support/Debug.h" Index: tools/llvm-mca/lib/Stages/Stage.cpp =================================================================== --- tools/llvm-mca/lib/Stages/Stage.cpp +++ tools/llvm-mca/lib/Stages/Stage.cpp @@ -13,7 +13,7 @@ /// //===----------------------------------------------------------------------===// -#include "Stage.h" +#include "Stages/Stage.h" namespace mca { Index: tools/llvm-mca/llvm-mca.cpp =================================================================== --- tools/llvm-mca/llvm-mca.cpp +++ tools/llvm-mca/llvm-mca.cpp @@ -21,13 +21,8 @@ // //===----------------------------------------------------------------------===// -#include "CodeRegion.h" -#include "Context.h" #include "DispatchStatistics.h" -#include "FetchStage.h" #include "InstructionInfoView.h" -#include "InstructionTables.h" -#include "Pipeline.h" #include "PipelinePrinter.h" #include "RegisterFileStatistics.h" #include "ResourcePressureView.h" @@ -35,6 +30,11 @@ #include "SchedulerStatistics.h" #include "SummaryView.h" #include "TimelineView.h" +#include "include/CodeRegion.h" +#include "include/Context.h" +#include "include/Pipeline.h" +#include "include/Stages/FetchStage.h" +#include "include/Stages/InstructionTables.h" #include "llvm/MC/MCAsmInfo.h" #include "llvm/MC/MCContext.h" #include "llvm/MC/MCObjectFileInfo.h"