[llvm-mca] Move llvm-mca library to llvm/lib/MCA.

Summary: See PR38731.

Reviewers: andreadb

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

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@349332 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/CODE_OWNERS.TXT b/CODE_OWNERS.TXT
index 67b91f2..a6e10fc 100644
--- a/CODE_OWNERS.TXT
+++ b/CODE_OWNERS.TXT
@@ -71,7 +71,7 @@
 N: Andrea Di Biagio
 E: andrea.dibiagio@sony.com
 E: andrea.dibiagio@gmail.com
-D: llvm-mca
+D: MCA, llvm-mca
 
 N: Duncan P. N. Exon Smith
 E: dexonsmith@apple.com
diff --git a/tools/llvm-mca/include/Context.h b/include/llvm/MCA/Context.h
similarity index 89%
rename from tools/llvm-mca/include/Context.h
rename to include/llvm/MCA/Context.h
index ebd1528..6b2bee0 100644
--- a/tools/llvm-mca/include/Context.h
+++ b/include/llvm/MCA/Context.h
@@ -15,14 +15,15 @@
 ///
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_TOOLS_LLVM_MCA_CONTEXT_H
-#define LLVM_TOOLS_LLVM_MCA_CONTEXT_H
-#include "HardwareUnits/HardwareUnit.h"
-#include "InstrBuilder.h"
-#include "Pipeline.h"
-#include "SourceMgr.h"
+#ifndef LLVM_MCA_CONTEXT_H
+#define LLVM_MCA_CONTEXT_H
+
 #include "llvm/MC/MCRegisterInfo.h"
 #include "llvm/MC/MCSubtargetInfo.h"
+#include "llvm/MCA/HardwareUnits/HardwareUnit.h"
+#include "llvm/MCA/InstrBuilder.h"
+#include "llvm/MCA/Pipeline.h"
+#include "llvm/MCA/SourceMgr.h"
 #include <memory>
 
 namespace llvm {
@@ -65,4 +66,4 @@
 
 } // namespace mca
 } // namespace llvm
-#endif // LLVM_TOOLS_LLVM_MCA_CONTEXT_H
+#endif // LLVM_MCA_CONTEXT_H
diff --git a/tools/llvm-mca/include/HWEventListener.h b/include/llvm/MCA/HWEventListener.h
similarity index 96%
rename from tools/llvm-mca/include/HWEventListener.h
rename to include/llvm/MCA/HWEventListener.h
index 0216fae..3b32b2c 100644
--- a/tools/llvm-mca/include/HWEventListener.h
+++ b/include/llvm/MCA/HWEventListener.h
@@ -12,12 +12,12 @@
 ///
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_TOOLS_LLVM_MCA_HWEVENTLISTENER_H
-#define LLVM_TOOLS_LLVM_MCA_HWEVENTLISTENER_H
+#ifndef LLVM_MCA_HWEVENTLISTENER_H
+#define LLVM_MCA_HWEVENTLISTENER_H
 
-#include "Instruction.h"
-#include "Support.h"
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/MCA/Instruction.h"
+#include "llvm/MCA/Support.h"
 
 namespace llvm {
 namespace mca {
@@ -153,4 +153,4 @@
 } // namespace mca
 } // namespace llvm
 
-#endif
+#endif // LLVM_MCA_HWEVENTLISTENER_H
diff --git a/tools/llvm-mca/include/HardwareUnits/HardwareUnit.h b/include/llvm/MCA/HardwareUnits/HardwareUnit.h
similarity index 86%
rename from tools/llvm-mca/include/HardwareUnits/HardwareUnit.h
rename to include/llvm/MCA/HardwareUnits/HardwareUnit.h
index 5070418..104a200 100644
--- a/tools/llvm-mca/include/HardwareUnits/HardwareUnit.h
+++ b/include/llvm/MCA/HardwareUnits/HardwareUnit.h
@@ -13,8 +13,8 @@
 ///
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_TOOLS_LLVM_MCA_HARDWAREUNIT_H
-#define LLVM_TOOLS_LLVM_MCA_HARDWAREUNIT_H
+#ifndef LLVM_MCA_HARDWAREUNIT_H
+#define LLVM_MCA_HARDWAREUNIT_H
 
 namespace llvm {
 namespace mca {
@@ -30,4 +30,4 @@
 
 } // namespace mca
 } // namespace llvm
-#endif // LLVM_TOOLS_LLVM_MCA_HARDWAREUNIT_H
+#endif // LLVM_MCA_HARDWAREUNIT_H
diff --git a/tools/llvm-mca/include/HardwareUnits/LSUnit.h b/include/llvm/MCA/HardwareUnits/LSUnit.h
similarity index 98%
rename from tools/llvm-mca/include/HardwareUnits/LSUnit.h
rename to include/llvm/MCA/HardwareUnits/LSUnit.h
index 3f37651..e217fc5 100644
--- a/tools/llvm-mca/include/HardwareUnits/LSUnit.h
+++ b/include/llvm/MCA/HardwareUnits/LSUnit.h
@@ -13,12 +13,12 @@
 ///
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_TOOLS_LLVM_MCA_LSUNIT_H
-#define LLVM_TOOLS_LLVM_MCA_LSUNIT_H
+#ifndef LLVM_MCA_LSUNIT_H
+#define LLVM_MCA_LSUNIT_H
 
-#include "HardwareUnits/HardwareUnit.h"
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/MC/MCSchedule.h"
+#include "llvm/MCA/HardwareUnits/HardwareUnit.h"
 
 namespace llvm {
 namespace mca {
@@ -204,4 +204,4 @@
 } // namespace mca
 } // namespace llvm
 
-#endif
+#endif // LLVM_MCA_LSUNIT_H
diff --git a/tools/llvm-mca/include/HardwareUnits/RegisterFile.h b/include/llvm/MCA/HardwareUnits/RegisterFile.h
similarity index 97%
rename from tools/llvm-mca/include/HardwareUnits/RegisterFile.h
rename to include/llvm/MCA/HardwareUnits/RegisterFile.h
index d9949bf..c23ab03 100644
--- a/tools/llvm-mca/include/HardwareUnits/RegisterFile.h
+++ b/include/llvm/MCA/HardwareUnits/RegisterFile.h
@@ -14,14 +14,14 @@
 ///
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_TOOLS_LLVM_MCA_REGISTER_FILE_H
-#define LLVM_TOOLS_LLVM_MCA_REGISTER_FILE_H
+#ifndef LLVM_MCA_REGISTER_FILE_H
+#define LLVM_MCA_REGISTER_FILE_H
 
-#include "HardwareUnits/HardwareUnit.h"
 #include "llvm/ADT/APInt.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/MC/MCRegisterInfo.h"
 #include "llvm/MC/MCSchedule.h"
+#include "llvm/MCA/HardwareUnits/HardwareUnit.h"
 #include "llvm/Support/Error.h"
 
 namespace llvm {
@@ -236,4 +236,4 @@
 } // namespace mca
 } // namespace llvm
 
-#endif // LLVM_TOOLS_LLVM_MCA_REGISTER_FILE_H
+#endif // LLVM_MCA_REGISTER_FILE_H
diff --git a/tools/llvm-mca/include/HardwareUnits/ResourceManager.h b/include/llvm/MCA/HardwareUnits/ResourceManager.h
similarity index 98%
rename from tools/llvm-mca/include/HardwareUnits/ResourceManager.h
rename to include/llvm/MCA/HardwareUnits/ResourceManager.h
index aa1bdb0..5429f2b 100644
--- a/tools/llvm-mca/include/HardwareUnits/ResourceManager.h
+++ b/include/llvm/MCA/HardwareUnits/ResourceManager.h
@@ -13,15 +13,15 @@
 ///
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_TOOLS_LLVM_MCA_RESOURCE_MANAGER_H
-#define LLVM_TOOLS_LLVM_MCA_RESOURCE_MANAGER_H
+#ifndef LLVM_MCA_RESOURCE_MANAGER_H
+#define LLVM_MCA_RESOURCE_MANAGER_H
 
-#include "Instruction.h"
-#include "Support.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/MC/MCSchedule.h"
+#include "llvm/MCA/Instruction.h"
+#include "llvm/MCA/Support.h"
 
 namespace llvm {
 namespace mca {
@@ -357,4 +357,4 @@
 } // namespace mca
 } // namespace llvm
 
-#endif // LLVM_TOOLS_LLVM_MCA_RESOURCE_MANAGER_H
+#endif // LLVM_MCA_RESOURCE_MANAGER_H
diff --git a/tools/llvm-mca/include/HardwareUnits/RetireControlUnit.h b/include/llvm/MCA/HardwareUnits/RetireControlUnit.h
similarity index 93%
rename from tools/llvm-mca/include/HardwareUnits/RetireControlUnit.h
rename to include/llvm/MCA/HardwareUnits/RetireControlUnit.h
index 12e0a1f..71360e9 100644
--- a/tools/llvm-mca/include/HardwareUnits/RetireControlUnit.h
+++ b/include/llvm/MCA/HardwareUnits/RetireControlUnit.h
@@ -12,12 +12,12 @@
 ///
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_TOOLS_LLVM_MCA_RETIRE_CONTROL_UNIT_H
-#define LLVM_TOOLS_LLVM_MCA_RETIRE_CONTROL_UNIT_H
+#ifndef LLVM_MCA_RETIRE_CONTROL_UNIT_H
+#define LLVM_MCA_RETIRE_CONTROL_UNIT_H
 
-#include "HardwareUnits/HardwareUnit.h"
-#include "Instruction.h"
 #include "llvm/MC/MCSchedule.h"
+#include "llvm/MCA/HardwareUnits/HardwareUnit.h"
+#include "llvm/MCA/Instruction.h"
 #include <vector>
 
 namespace llvm {
@@ -101,4 +101,4 @@
 } // namespace mca
 } // namespace llvm
 
-#endif // LLVM_TOOLS_LLVM_MCA_RETIRE_CONTROL_UNIT_H
+#endif // LLVM_MCA_RETIRE_CONTROL_UNIT_H
diff --git a/tools/llvm-mca/include/HardwareUnits/Scheduler.h b/include/llvm/MCA/HardwareUnits/Scheduler.h
similarity index 96%
rename from tools/llvm-mca/include/HardwareUnits/Scheduler.h
rename to include/llvm/MCA/HardwareUnits/Scheduler.h
index a8d00d2..351ea48 100644
--- a/tools/llvm-mca/include/HardwareUnits/Scheduler.h
+++ b/include/llvm/MCA/HardwareUnits/Scheduler.h
@@ -12,15 +12,15 @@
 ///
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_TOOLS_LLVM_MCA_SCHEDULER_H
-#define LLVM_TOOLS_LLVM_MCA_SCHEDULER_H
+#ifndef LLVM_MCA_SCHEDULER_H
+#define LLVM_MCA_SCHEDULER_H
 
-#include "HardwareUnits/HardwareUnit.h"
-#include "HardwareUnits/LSUnit.h"
-#include "ResourceManager.h"
-#include "Support.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/MC/MCSchedule.h"
+#include "llvm/MCA/HardwareUnits/HardwareUnit.h"
+#include "llvm/MCA/HardwareUnits/LSUnit.h"
+#include "llvm/MCA/HardwareUnits/ResourceManager.h"
+#include "llvm/MCA/Support.h"
 
 namespace llvm {
 namespace mca {
@@ -211,4 +211,4 @@
 } // namespace mca
 } // namespace llvm
 
-#endif // LLVM_TOOLS_LLVM_MCA_SCHEDULER_H
+#endif // LLVM_MCA_SCHEDULER_H
diff --git a/tools/llvm-mca/include/InstrBuilder.h b/include/llvm/MCA/InstrBuilder.h
similarity index 93%
rename from tools/llvm-mca/include/InstrBuilder.h
rename to include/llvm/MCA/InstrBuilder.h
index 1c958c5..0fadbce 100644
--- a/tools/llvm-mca/include/InstrBuilder.h
+++ b/include/llvm/MCA/InstrBuilder.h
@@ -12,15 +12,15 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_TOOLS_LLVM_MCA_INSTRBUILDER_H
-#define LLVM_TOOLS_LLVM_MCA_INSTRBUILDER_H
+#ifndef LLVM_MCA_INSTRBUILDER_H
+#define LLVM_MCA_INSTRBUILDER_H
 
-#include "Instruction.h"
-#include "Support.h"
 #include "llvm/MC/MCInstrAnalysis.h"
 #include "llvm/MC/MCInstrInfo.h"
 #include "llvm/MC/MCRegisterInfo.h"
 #include "llvm/MC/MCSubtargetInfo.h"
+#include "llvm/MCA/Instruction.h"
+#include "llvm/MCA/Support.h"
 #include "llvm/Support/Error.h"
 
 namespace llvm {
@@ -74,4 +74,4 @@
 } // namespace mca
 } // namespace llvm
 
-#endif
+#endif // LLVM_MCA_INSTRBUILDER_H
diff --git a/tools/llvm-mca/include/Instruction.h b/include/llvm/MCA/Instruction.h
similarity index 99%
rename from tools/llvm-mca/include/Instruction.h
rename to include/llvm/MCA/Instruction.h
index dff9513..d3fa8cc 100644
--- a/tools/llvm-mca/include/Instruction.h
+++ b/include/llvm/MCA/Instruction.h
@@ -13,8 +13,8 @@
 ///
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_TOOLS_LLVM_MCA_INSTRUCTION_H
-#define LLVM_TOOLS_LLVM_MCA_INSTRUCTION_H
+#ifndef LLVM_MCA_INSTRUCTION_H
+#define LLVM_MCA_INSTRUCTION_H
 
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/STLExtras.h"
@@ -539,4 +539,4 @@
 } // namespace mca
 } // namespace llvm
 
-#endif
+#endif  // LLVM_MCA_INSTRUCTION_H
diff --git a/tools/llvm-mca/include/Pipeline.h b/include/llvm/MCA/Pipeline.h
similarity index 92%
rename from tools/llvm-mca/include/Pipeline.h
rename to include/llvm/MCA/Pipeline.h
index 0fd4026..acd2560 100644
--- a/tools/llvm-mca/include/Pipeline.h
+++ b/include/llvm/MCA/Pipeline.h
@@ -13,12 +13,12 @@
 ///
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_TOOLS_LLVM_MCA_PIPELINE_H
-#define LLVM_TOOLS_LLVM_MCA_PIPELINE_H
+#ifndef LLVM_MCA_PIPELINE_H
+#define LLVM_MCA_PIPELINE_H
 
-#include "HardwareUnits/Scheduler.h"
-#include "Stages/Stage.h"
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/MCA/HardwareUnits/Scheduler.h"
+#include "llvm/MCA/Stages/Stage.h"
 #include "llvm/Support/Error.h"
 
 namespace llvm {
@@ -76,4 +76,4 @@
 } // namespace mca
 } // namespace llvm
 
-#endif // LLVM_TOOLS_LLVM_MCA_PIPELINE_H
+#endif // LLVM_MCA_PIPELINE_H
diff --git a/tools/llvm-mca/include/SourceMgr.h b/include/llvm/MCA/SourceMgr.h
similarity index 94%
rename from tools/llvm-mca/include/SourceMgr.h
rename to include/llvm/MCA/SourceMgr.h
index e518010..5e0ca64 100644
--- a/tools/llvm-mca/include/SourceMgr.h
+++ b/include/llvm/MCA/SourceMgr.h
@@ -13,8 +13,8 @@
 ///
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_TOOLS_LLVM_MCA_SOURCEMGR_H
-#define LLVM_TOOLS_LLVM_MCA_SOURCEMGR_H
+#ifndef LLVM_MCA_SOURCEMGR_H
+#define LLVM_MCA_SOURCEMGR_H
 
 #include "llvm/ADT/ArrayRef.h"
 
@@ -54,4 +54,4 @@
 } // namespace mca
 } // namespace llvm
 
-#endif
+#endif // LLVM_MCA_SOURCEMGR_H
diff --git a/tools/llvm-mca/include/Stages/DispatchStage.h b/include/llvm/MCA/Stages/DispatchStage.h
similarity index 90%
rename from tools/llvm-mca/include/Stages/DispatchStage.h
rename to include/llvm/MCA/Stages/DispatchStage.h
index 29cace1..f015cd7 100644
--- a/tools/llvm-mca/include/Stages/DispatchStage.h
+++ b/include/llvm/MCA/Stages/DispatchStage.h
@@ -16,16 +16,16 @@
 ///
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_TOOLS_LLVM_MCA_DISPATCH_STAGE_H
-#define LLVM_TOOLS_LLVM_MCA_DISPATCH_STAGE_H
+#ifndef LLVM_MCA_DISPATCH_STAGE_H
+#define LLVM_MCA_DISPATCH_STAGE_H
 
-#include "HWEventListener.h"
-#include "HardwareUnits/RegisterFile.h"
-#include "HardwareUnits/RetireControlUnit.h"
-#include "Instruction.h"
-#include "Stages/Stage.h"
 #include "llvm/MC/MCRegisterInfo.h"
 #include "llvm/MC/MCSubtargetInfo.h"
+#include "llvm/MCA/HWEventListener.h"
+#include "llvm/MCA/HardwareUnits/RegisterFile.h"
+#include "llvm/MCA/HardwareUnits/RetireControlUnit.h"
+#include "llvm/MCA/Instruction.h"
+#include "llvm/MCA/Stages/Stage.h"
 
 namespace llvm {
 namespace mca {
@@ -90,4 +90,4 @@
 } // namespace mca
 } // namespace llvm
 
-#endif // LLVM_TOOLS_LLVM_MCA_DISPATCH_STAGE_H
+#endif // LLVM_MCA_DISPATCH_STAGE_H
diff --git a/tools/llvm-mca/include/Stages/EntryStage.h b/include/llvm/MCA/Stages/EntryStage.h
similarity index 88%
rename from tools/llvm-mca/include/Stages/EntryStage.h
rename to include/llvm/MCA/Stages/EntryStage.h
index 21b8331..cd9a65b 100644
--- a/tools/llvm-mca/include/Stages/EntryStage.h
+++ b/include/llvm/MCA/Stages/EntryStage.h
@@ -14,12 +14,12 @@
 ///
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_TOOLS_LLVM_MCA_ENTRY_STAGE_H
-#define LLVM_TOOLS_LLVM_MCA_ENTRY_STAGE_H
+#ifndef LLVM_MCA_ENTRY_STAGE_H
+#define LLVM_MCA_ENTRY_STAGE_H
 
-#include "SourceMgr.h"
-#include "Stages/Stage.h"
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/MCA/SourceMgr.h"
+#include "llvm/MCA/Stages/Stage.h"
 
 namespace llvm {
 namespace mca {
@@ -49,4 +49,4 @@
 } // namespace mca
 } // namespace llvm
 
-#endif // LLVM_TOOLS_LLVM_MCA_FETCH_STAGE_H
+#endif // LLVM_MCA_FETCH_STAGE_H
diff --git a/tools/llvm-mca/include/Stages/ExecuteStage.h b/include/llvm/MCA/Stages/ExecuteStage.h
similarity index 92%
rename from tools/llvm-mca/include/Stages/ExecuteStage.h
rename to include/llvm/MCA/Stages/ExecuteStage.h
index 91b2405..4f40c5c 100644
--- a/tools/llvm-mca/include/Stages/ExecuteStage.h
+++ b/include/llvm/MCA/Stages/ExecuteStage.h
@@ -15,13 +15,13 @@
 ///
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_TOOLS_LLVM_MCA_EXECUTE_STAGE_H
-#define LLVM_TOOLS_LLVM_MCA_EXECUTE_STAGE_H
+#ifndef LLVM_MCA_EXECUTE_STAGE_H
+#define LLVM_MCA_EXECUTE_STAGE_H
 
-#include "HardwareUnits/Scheduler.h"
-#include "Instruction.h"
-#include "Stages/Stage.h"
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/MCA/HardwareUnits/Scheduler.h"
+#include "llvm/MCA/Instruction.h"
+#include "llvm/MCA/Stages/Stage.h"
 
 namespace llvm {
 namespace mca {
@@ -77,4 +77,4 @@
 } // namespace mca
 } // namespace llvm
 
-#endif // LLVM_TOOLS_LLVM_MCA_EXECUTE_STAGE_H
+#endif // LLVM_MCA_EXECUTE_STAGE_H
diff --git a/tools/llvm-mca/include/Stages/InstructionTables.h b/include/llvm/MCA/Stages/InstructionTables.h
similarity index 83%
rename from tools/llvm-mca/include/Stages/InstructionTables.h
rename to include/llvm/MCA/Stages/InstructionTables.h
index e618d06..50f84fc 100644
--- a/tools/llvm-mca/include/Stages/InstructionTables.h
+++ b/include/llvm/MCA/Stages/InstructionTables.h
@@ -14,14 +14,14 @@
 ///
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_TOOLS_LLVM_MCA_INSTRUCTIONTABLES_H
-#define LLVM_TOOLS_LLVM_MCA_INSTRUCTIONTABLES_H
+#ifndef LLVM_MCA_INSTRUCTIONTABLES_H
+#define LLVM_MCA_INSTRUCTIONTABLES_H
 
-#include "HardwareUnits/Scheduler.h"
-#include "Stages/Stage.h"
-#include "Support.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/MC/MCSchedule.h"
+#include "llvm/MCA/HardwareUnits/Scheduler.h"
+#include "llvm/MCA/Stages/Stage.h"
+#include "llvm/MCA/Support.h"
 
 namespace llvm {
 namespace mca {
@@ -42,4 +42,4 @@
 } // namespace mca
 } // namespace llvm
 
-#endif
+#endif // LLVM_MCA_INSTRUCTIONTABLES_H
diff --git a/tools/llvm-mca/include/Stages/RetireStage.h b/include/llvm/MCA/Stages/RetireStage.h
similarity index 83%
rename from tools/llvm-mca/include/Stages/RetireStage.h
rename to include/llvm/MCA/Stages/RetireStage.h
index 28eda40..2051ce5 100644
--- a/tools/llvm-mca/include/Stages/RetireStage.h
+++ b/include/llvm/MCA/Stages/RetireStage.h
@@ -14,12 +14,12 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_TOOLS_LLVM_MCA_RETIRE_STAGE_H
-#define LLVM_TOOLS_LLVM_MCA_RETIRE_STAGE_H
+#ifndef LLVM_MCA_RETIRE_STAGE_H
+#define LLVM_MCA_RETIRE_STAGE_H
 
-#include "HardwareUnits/RegisterFile.h"
-#include "HardwareUnits/RetireControlUnit.h"
-#include "Stages/Stage.h"
+#include "llvm/MCA/HardwareUnits/RegisterFile.h"
+#include "llvm/MCA/HardwareUnits/RetireControlUnit.h"
+#include "llvm/MCA/Stages/Stage.h"
 
 namespace llvm {
 namespace mca {
@@ -45,4 +45,4 @@
 } // namespace mca
 } // namespace llvm
 
-#endif // LLVM_TOOLS_LLVM_MCA_RETIRE_STAGE_H
+#endif // LLVM_MCA_RETIRE_STAGE_H
diff --git a/tools/llvm-mca/include/Stages/Stage.h b/include/llvm/MCA/Stages/Stage.h
similarity index 94%
rename from tools/llvm-mca/include/Stages/Stage.h
rename to include/llvm/MCA/Stages/Stage.h
index 5665fc4..fc7ab56 100644
--- a/tools/llvm-mca/include/Stages/Stage.h
+++ b/include/llvm/MCA/Stages/Stage.h
@@ -13,10 +13,10 @@
 ///
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_TOOLS_LLVM_MCA_STAGE_H
-#define LLVM_TOOLS_LLVM_MCA_STAGE_H
+#ifndef LLVM_MCA_STAGE_H
+#define LLVM_MCA_STAGE_H
 
-#include "HWEventListener.h"
+#include "llvm/MCA/HWEventListener.h"
 #include "llvm/Support/Error.h"
 #include <set>
 
@@ -85,4 +85,4 @@
 
 } // namespace mca
 } // namespace llvm
-#endif // LLVM_TOOLS_LLVM_MCA_STAGE_H
+#endif // LLVM_MCA_STAGE_H
diff --git a/tools/llvm-mca/include/Support.h b/include/llvm/MCA/Support.h
similarity index 97%
rename from tools/llvm-mca/include/Support.h
rename to include/llvm/MCA/Support.h
index e7a4e33..5c5a354 100644
--- a/tools/llvm-mca/include/Support.h
+++ b/include/llvm/MCA/Support.h
@@ -12,8 +12,8 @@
 ///
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_TOOLS_LLVM_MCA_SUPPORT_H
-#define LLVM_TOOLS_LLVM_MCA_SUPPORT_H
+#ifndef LLVM_MCA_SUPPORT_H
+#define LLVM_MCA_SUPPORT_H
 
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/SmallVector.h"
@@ -116,4 +116,4 @@
 } // namespace mca
 } // namespace llvm
 
-#endif
+#endif // LLVM_MCA_SUPPORT_H
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index d45dc7c..f25c7a0 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -12,6 +12,7 @@
 add_subdirectory(Analysis)
 add_subdirectory(LTO)
 add_subdirectory(MC)
+add_subdirectory(MCA)
 add_subdirectory(Object)
 add_subdirectory(ObjectYAML)
 add_subdirectory(Option)
diff --git a/lib/LLVMBuild.txt b/lib/LLVMBuild.txt
index 2f6628e..d87bf79 100644
--- a/lib/LLVMBuild.txt
+++ b/lib/LLVMBuild.txt
@@ -31,6 +31,7 @@
  IRReader
  LTO
  MC
+ MCA
  Object
  BinaryFormat
  ObjectYAML
diff --git a/tools/llvm-mca/lib/CMakeLists.txt b/lib/MCA/CMakeLists.txt
similarity index 62%
rename from tools/llvm-mca/lib/CMakeLists.txt
rename to lib/MCA/CMakeLists.txt
index 21b6e34..bfd0782 100644
--- a/tools/llvm-mca/lib/CMakeLists.txt
+++ b/lib/MCA/CMakeLists.txt
@@ -1,7 +1,4 @@
-include_directories(${LLVM_MCA_SOURCE_DIR}/include)
-
-add_library(LLVMMCA
-  STATIC
+add_llvm_library(LLVMMCA
   Context.cpp
   HWEventListener.cpp
   HardwareUnits/HardwareUnit.cpp
@@ -20,13 +17,7 @@
   Stages/RetireStage.cpp
   Stages/Stage.cpp
   Support.cpp
-  )
 
-llvm_update_compile_flags(LLVMMCA)
-llvm_map_components_to_libnames(libs
-  MC
-  Support
+  ADDITIONAL_HEADER_DIRS
+  ${LLVM_MAIN_INCLUDE_DIR}/llvm/MCA
   )
-
-target_link_libraries(LLVMMCA ${libs})
-set_target_properties(LLVMMCA PROPERTIES FOLDER "Libraries")
diff --git a/tools/llvm-mca/lib/Context.cpp b/lib/MCA/Context.cpp
similarity index 86%
rename from tools/llvm-mca/lib/Context.cpp
rename to lib/MCA/Context.cpp
index 17b992a..c1b197d 100644
--- a/tools/llvm-mca/lib/Context.cpp
+++ b/lib/MCA/Context.cpp
@@ -15,14 +15,14 @@
 ///
 //===----------------------------------------------------------------------===//
 
-#include "Context.h"
-#include "HardwareUnits/RegisterFile.h"
-#include "HardwareUnits/RetireControlUnit.h"
-#include "HardwareUnits/Scheduler.h"
-#include "Stages/DispatchStage.h"
-#include "Stages/EntryStage.h"
-#include "Stages/ExecuteStage.h"
-#include "Stages/RetireStage.h"
+#include "llvm/MCA/Context.h"
+#include "llvm/MCA/HardwareUnits/RegisterFile.h"
+#include "llvm/MCA/HardwareUnits/RetireControlUnit.h"
+#include "llvm/MCA/HardwareUnits/Scheduler.h"
+#include "llvm/MCA/Stages/DispatchStage.h"
+#include "llvm/MCA/Stages/EntryStage.h"
+#include "llvm/MCA/Stages/ExecuteStage.h"
+#include "llvm/MCA/Stages/RetireStage.h"
 
 namespace llvm {
 namespace mca {
diff --git a/tools/llvm-mca/lib/HWEventListener.cpp b/lib/MCA/HWEventListener.cpp
similarity index 93%
rename from tools/llvm-mca/lib/HWEventListener.cpp
rename to lib/MCA/HWEventListener.cpp
index 3930e25..4a0e5b1 100644
--- a/tools/llvm-mca/lib/HWEventListener.cpp
+++ b/lib/MCA/HWEventListener.cpp
@@ -12,7 +12,7 @@
 ///
 //===----------------------------------------------------------------------===//
 
-#include "HWEventListener.h"
+#include "llvm/MCA/HWEventListener.h"
 
 namespace llvm {
 namespace mca {
diff --git a/tools/llvm-mca/lib/HardwareUnits/HardwareUnit.cpp b/lib/MCA/HardwareUnits/HardwareUnit.cpp
similarity index 93%
rename from tools/llvm-mca/lib/HardwareUnits/HardwareUnit.cpp
rename to lib/MCA/HardwareUnits/HardwareUnit.cpp
index 4e46ffa..edd32b9 100644
--- a/tools/llvm-mca/lib/HardwareUnits/HardwareUnit.cpp
+++ b/lib/MCA/HardwareUnits/HardwareUnit.cpp
@@ -13,7 +13,7 @@
 ///
 //===----------------------------------------------------------------------===//
 
-#include "HardwareUnits/HardwareUnit.h"
+#include "llvm/MCA/HardwareUnits/HardwareUnit.h"
 
 namespace llvm {
 namespace mca {
diff --git a/tools/llvm-mca/lib/HardwareUnits/LSUnit.cpp b/lib/MCA/HardwareUnits/LSUnit.cpp
similarity index 98%
rename from tools/llvm-mca/lib/HardwareUnits/LSUnit.cpp
rename to lib/MCA/HardwareUnits/LSUnit.cpp
index ed82691..8895eb3 100644
--- a/tools/llvm-mca/lib/HardwareUnits/LSUnit.cpp
+++ b/lib/MCA/HardwareUnits/LSUnit.cpp
@@ -12,8 +12,8 @@
 ///
 //===----------------------------------------------------------------------===//
 
-#include "HardwareUnits/LSUnit.h"
-#include "Instruction.h"
+#include "llvm/MCA/HardwareUnits/LSUnit.h"
+#include "llvm/MCA/Instruction.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/raw_ostream.h"
 
diff --git a/tools/llvm-mca/lib/HardwareUnits/RegisterFile.cpp b/lib/MCA/HardwareUnits/RegisterFile.cpp
similarity index 99%
rename from tools/llvm-mca/lib/HardwareUnits/RegisterFile.cpp
rename to lib/MCA/HardwareUnits/RegisterFile.cpp
index f96e4ca..22977e5 100644
--- a/tools/llvm-mca/lib/HardwareUnits/RegisterFile.cpp
+++ b/lib/MCA/HardwareUnits/RegisterFile.cpp
@@ -14,8 +14,8 @@
 ///
 //===----------------------------------------------------------------------===//
 
-#include "HardwareUnits/RegisterFile.h"
-#include "Instruction.h"
+#include "llvm/MCA/HardwareUnits/RegisterFile.h"
+#include "llvm/MCA/Instruction.h"
 #include "llvm/Support/Debug.h"
 
 #define DEBUG_TYPE "llvm-mca"
diff --git a/tools/llvm-mca/lib/HardwareUnits/ResourceManager.cpp b/lib/MCA/HardwareUnits/ResourceManager.cpp
similarity index 98%
rename from tools/llvm-mca/lib/HardwareUnits/ResourceManager.cpp
rename to lib/MCA/HardwareUnits/ResourceManager.cpp
index f12238a..b62fccd 100644
--- a/tools/llvm-mca/lib/HardwareUnits/ResourceManager.cpp
+++ b/lib/MCA/HardwareUnits/ResourceManager.cpp
@@ -13,8 +13,8 @@
 ///
 //===----------------------------------------------------------------------===//
 
-#include "HardwareUnits/ResourceManager.h"
-#include "Support.h"
+#include "llvm/MCA/HardwareUnits/ResourceManager.h"
+#include "llvm/MCA/Support.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/raw_ostream.h"
 
@@ -54,7 +54,7 @@
     RemovedFromNextInSequence |= Mask;
     return;
   }
- 
+
   NextInSequenceMask &= (~Mask);
   if (NextInSequenceMask)
     return;
diff --git a/tools/llvm-mca/lib/HardwareUnits/RetireControlUnit.cpp b/lib/MCA/HardwareUnits/RetireControlUnit.cpp
similarity index 97%
rename from tools/llvm-mca/lib/HardwareUnits/RetireControlUnit.cpp
rename to lib/MCA/HardwareUnits/RetireControlUnit.cpp
index bd7b411..de9f245 100644
--- a/tools/llvm-mca/lib/HardwareUnits/RetireControlUnit.cpp
+++ b/lib/MCA/HardwareUnits/RetireControlUnit.cpp
@@ -12,7 +12,7 @@
 ///
 //===----------------------------------------------------------------------===//
 
-#include "HardwareUnits/RetireControlUnit.h"
+#include "llvm/MCA/HardwareUnits/RetireControlUnit.h"
 #include "llvm/Support/Debug.h"
 
 #define DEBUG_TYPE "llvm-mca"
diff --git a/tools/llvm-mca/lib/HardwareUnits/Scheduler.cpp b/lib/MCA/HardwareUnits/Scheduler.cpp
similarity index 99%
rename from tools/llvm-mca/lib/HardwareUnits/Scheduler.cpp
rename to lib/MCA/HardwareUnits/Scheduler.cpp
index f0ac59e..3924ac5 100644
--- a/tools/llvm-mca/lib/HardwareUnits/Scheduler.cpp
+++ b/lib/MCA/HardwareUnits/Scheduler.cpp
@@ -11,7 +11,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "HardwareUnits/Scheduler.h"
+#include "llvm/MCA/HardwareUnits/Scheduler.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/raw_ostream.h"
 
diff --git a/tools/llvm-mca/lib/InstrBuilder.cpp b/lib/MCA/InstrBuilder.cpp
similarity index 99%
rename from tools/llvm-mca/lib/InstrBuilder.cpp
rename to lib/MCA/InstrBuilder.cpp
index f396082..5e228a2 100644
--- a/tools/llvm-mca/lib/InstrBuilder.cpp
+++ b/lib/MCA/InstrBuilder.cpp
@@ -12,7 +12,7 @@
 ///
 //===----------------------------------------------------------------------===//
 
-#include "InstrBuilder.h"
+#include "llvm/MCA/InstrBuilder.h"
 #include "llvm/ADT/APInt.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/MC/MCInst.h"
diff --git a/tools/llvm-mca/lib/Instruction.cpp b/lib/MCA/Instruction.cpp
similarity index 98%
rename from tools/llvm-mca/lib/Instruction.cpp
rename to lib/MCA/Instruction.cpp
index 47ba2f8..057e95c 100644
--- a/tools/llvm-mca/lib/Instruction.cpp
+++ b/lib/MCA/Instruction.cpp
@@ -12,7 +12,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "Instruction.h"
+#include "llvm/MCA/Instruction.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/raw_ostream.h"
 
diff --git a/tools/llvm-mca/lib/LLVMBuild.txt b/lib/MCA/LLVMBuild.txt
similarity index 100%
rename from tools/llvm-mca/lib/LLVMBuild.txt
rename to lib/MCA/LLVMBuild.txt
diff --git a/tools/llvm-mca/lib/Pipeline.cpp b/lib/MCA/Pipeline.cpp
similarity index 96%
rename from tools/llvm-mca/lib/Pipeline.cpp
rename to lib/MCA/Pipeline.cpp
index 0357124..fd97ea6 100644
--- a/tools/llvm-mca/lib/Pipeline.cpp
+++ b/lib/MCA/Pipeline.cpp
@@ -13,8 +13,8 @@
 ///
 //===----------------------------------------------------------------------===//
 
-#include "Pipeline.h"
-#include "HWEventListener.h"
+#include "llvm/MCA/Pipeline.h"
+#include "llvm/MCA/HWEventListener.h"
 #include "llvm/Support/Debug.h"
 
 namespace llvm {
diff --git a/tools/llvm-mca/lib/Stages/DispatchStage.cpp b/lib/MCA/Stages/DispatchStage.cpp
similarity index 97%
rename from tools/llvm-mca/lib/Stages/DispatchStage.cpp
rename to lib/MCA/Stages/DispatchStage.cpp
index 838dbad..52e04fa 100644
--- a/tools/llvm-mca/lib/Stages/DispatchStage.cpp
+++ b/lib/MCA/Stages/DispatchStage.cpp
@@ -16,9 +16,9 @@
 ///
 //===----------------------------------------------------------------------===//
 
-#include "Stages/DispatchStage.h"
-#include "HWEventListener.h"
-#include "HardwareUnits/Scheduler.h"
+#include "llvm/MCA/Stages/DispatchStage.h"
+#include "llvm/MCA/HWEventListener.h"
+#include "llvm/MCA/HardwareUnits/Scheduler.h"
 #include "llvm/Support/Debug.h"
 
 #define DEBUG_TYPE "llvm-mca"
diff --git a/tools/llvm-mca/lib/Stages/EntryStage.cpp b/lib/MCA/Stages/EntryStage.cpp
similarity index 96%
rename from tools/llvm-mca/lib/Stages/EntryStage.cpp
rename to lib/MCA/Stages/EntryStage.cpp
index f552132..3325bb3 100644
--- a/tools/llvm-mca/lib/Stages/EntryStage.cpp
+++ b/lib/MCA/Stages/EntryStage.cpp
@@ -13,8 +13,8 @@
 ///
 //===----------------------------------------------------------------------===//
 
-#include "Stages/EntryStage.h"
-#include "Instruction.h"
+#include "llvm/MCA/Stages/EntryStage.h"
+#include "llvm/MCA/Instruction.h"
 
 namespace llvm {
 namespace mca {
diff --git a/tools/llvm-mca/lib/Stages/ExecuteStage.cpp b/lib/MCA/Stages/ExecuteStage.cpp
similarity index 98%
rename from tools/llvm-mca/lib/Stages/ExecuteStage.cpp
rename to lib/MCA/Stages/ExecuteStage.cpp
index 298f08a..17f7ff7 100644
--- a/tools/llvm-mca/lib/Stages/ExecuteStage.cpp
+++ b/lib/MCA/Stages/ExecuteStage.cpp
@@ -15,7 +15,7 @@
 ///
 //===----------------------------------------------------------------------===//
 
-#include "Stages/ExecuteStage.h"
+#include "llvm/MCA/Stages/ExecuteStage.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/Debug.h"
 
diff --git a/tools/llvm-mca/lib/Stages/InstructionTables.cpp b/lib/MCA/Stages/InstructionTables.cpp
similarity index 97%
rename from tools/llvm-mca/lib/Stages/InstructionTables.cpp
rename to lib/MCA/Stages/InstructionTables.cpp
index 33c30e7..f918c18 100644
--- a/tools/llvm-mca/lib/Stages/InstructionTables.cpp
+++ b/lib/MCA/Stages/InstructionTables.cpp
@@ -15,7 +15,7 @@
 ///
 //===----------------------------------------------------------------------===//
 
-#include "Stages/InstructionTables.h"
+#include "llvm/MCA/Stages/InstructionTables.h"
 
 namespace llvm {
 namespace mca {
diff --git a/tools/llvm-mca/lib/Stages/RetireStage.cpp b/lib/MCA/Stages/RetireStage.cpp
similarity index 95%
rename from tools/llvm-mca/lib/Stages/RetireStage.cpp
rename to lib/MCA/Stages/RetireStage.cpp
index 47eed5f..d6bcc51 100644
--- a/tools/llvm-mca/lib/Stages/RetireStage.cpp
+++ b/lib/MCA/Stages/RetireStage.cpp
@@ -14,8 +14,8 @@
 ///
 //===----------------------------------------------------------------------===//
 
-#include "Stages/RetireStage.h"
-#include "HWEventListener.h"
+#include "llvm/MCA/Stages/RetireStage.h"
+#include "llvm/MCA/HWEventListener.h"
 #include "llvm/Support/Debug.h"
 
 #define DEBUG_TYPE "llvm-mca"
diff --git a/tools/llvm-mca/lib/Stages/Stage.cpp b/lib/MCA/Stages/Stage.cpp
similarity index 95%
rename from tools/llvm-mca/lib/Stages/Stage.cpp
rename to lib/MCA/Stages/Stage.cpp
index c3cfe47..3819164 100644
--- a/tools/llvm-mca/lib/Stages/Stage.cpp
+++ b/lib/MCA/Stages/Stage.cpp
@@ -13,7 +13,7 @@
 ///
 //===----------------------------------------------------------------------===//
 
-#include "Stages/Stage.h"
+#include "llvm/MCA/Stages/Stage.h"
 
 namespace llvm {
 namespace mca {
diff --git a/tools/llvm-mca/lib/Support.cpp b/lib/MCA/Support.cpp
similarity index 98%
rename from tools/llvm-mca/lib/Support.cpp
rename to lib/MCA/Support.cpp
index a6ff26d..3271bc6 100644
--- a/tools/llvm-mca/lib/Support.cpp
+++ b/lib/MCA/Support.cpp
@@ -13,7 +13,7 @@
 ///
 //===----------------------------------------------------------------------===//
 
-#include "Support.h"
+#include "llvm/MCA/Support.h"
 #include "llvm/MC/MCSchedule.h"
 
 namespace llvm {
diff --git a/tools/llvm-mca/CMakeLists.txt b/tools/llvm-mca/CMakeLists.txt
index 4339d48..1fceb08 100644
--- a/tools/llvm-mca/CMakeLists.txt
+++ b/tools/llvm-mca/CMakeLists.txt
@@ -6,6 +6,7 @@
   AllTargetsDescs
   AllTargetsDisassemblers
   AllTargetsInfos
+  MCA
   MC
   MCParser
   Support
@@ -28,5 +29,3 @@
   )
 
 set(LLVM_MCA_SOURCE_DIR ${CURRENT_SOURCE_DIR})
-add_subdirectory(lib)
-target_link_libraries(llvm-mca PRIVATE LLVMMCA)
diff --git a/tools/llvm-mca/LLVMBuild.txt b/tools/llvm-mca/LLVMBuild.txt
index 0afcd31..a704612 100644
--- a/tools/llvm-mca/LLVMBuild.txt
+++ b/tools/llvm-mca/LLVMBuild.txt
@@ -19,4 +19,4 @@
 type = Tool
 name = llvm-mca
 parent = Tools
-required_libraries = MC MCParser Support all-targets
+required_libraries = MC MCA MCParser Support all-targets
diff --git a/tools/llvm-mca/PipelinePrinter.h b/tools/llvm-mca/PipelinePrinter.h
index 7e42638..456026e 100644
--- a/tools/llvm-mca/PipelinePrinter.h
+++ b/tools/llvm-mca/PipelinePrinter.h
@@ -17,9 +17,9 @@
 #ifndef LLVM_TOOLS_LLVM_MCA_PIPELINEPRINTER_H
 #define LLVM_TOOLS_LLVM_MCA_PIPELINEPRINTER_H
 
-#include "Pipeline.h"
 #include "Views/View.h"
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/MCA/Pipeline.h"
 #include "llvm/Support/raw_ostream.h"
 
 #define DEBUG_TYPE "llvm-mca"
diff --git a/tools/llvm-mca/Views/SummaryView.cpp b/tools/llvm-mca/Views/SummaryView.cpp
index fdf2760..3a7eb82 100644
--- a/tools/llvm-mca/Views/SummaryView.cpp
+++ b/tools/llvm-mca/Views/SummaryView.cpp
@@ -14,8 +14,8 @@
 //===----------------------------------------------------------------------===//
 
 #include "Views/SummaryView.h"
-#include "Support.h"
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/MCA/Support.h"
 #include "llvm/Support/Format.h"
 
 namespace llvm {
diff --git a/tools/llvm-mca/Views/View.h b/tools/llvm-mca/Views/View.h
index c332bb5..4b82b0d 100644
--- a/tools/llvm-mca/Views/View.h
+++ b/tools/llvm-mca/Views/View.h
@@ -16,7 +16,7 @@
 #ifndef LLVM_TOOLS_LLVM_MCA_VIEW_H
 #define LLVM_TOOLS_LLVM_MCA_VIEW_H
 
-#include "HWEventListener.h"
+#include "llvm/MCA/HWEventListener.h"
 #include "llvm/Support/raw_ostream.h"
 
 namespace llvm {
diff --git a/tools/llvm-mca/llvm-mca.cpp b/tools/llvm-mca/llvm-mca.cpp
index a5edbce..310b0bf 100644
--- a/tools/llvm-mca/llvm-mca.cpp
+++ b/tools/llvm-mca/llvm-mca.cpp
@@ -24,8 +24,6 @@
 #include "CodeRegion.h"
 #include "CodeRegionGenerator.h"
 #include "PipelinePrinter.h"
-#include "Stages/EntryStage.h"
-#include "Stages/InstructionTables.h"
 #include "Views/DispatchStatistics.h"
 #include "Views/InstructionInfoView.h"
 #include "Views/RegisterFileStatistics.h"
@@ -34,13 +32,15 @@
 #include "Views/SchedulerStatistics.h"
 #include "Views/SummaryView.h"
 #include "Views/TimelineView.h"
-#include "include/Context.h"
-#include "include/Pipeline.h"
-#include "include/Support.h"
 #include "llvm/MC/MCAsmInfo.h"
 #include "llvm/MC/MCContext.h"
 #include "llvm/MC/MCObjectFileInfo.h"
 #include "llvm/MC/MCRegisterInfo.h"
+#include "llvm/MCA/Context.h"
+#include "llvm/MCA/Pipeline.h"
+#include "llvm/MCA/Stages/EntryStage.h"
+#include "llvm/MCA/Stages/InstructionTables.h"
+#include "llvm/MCA/Support.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/ErrorOr.h"