summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorJohn Brawn <john.brawn@arm.com>2018-07-03 10:10:29 +0000
committerJohn Brawn <john.brawn@arm.com>2018-07-03 10:10:29 +0000
commitc4ed60042fa942d1e2c42cd5e0edaff29815f6b7 (patch)
tree9bcd8dc30b7103dceb1905a2bf771151569b926b /llvm
parent7fc854320861b4ff2e7bed6387d75b4f030c03c5 (diff)
downloadbcm5719-llvm-c4ed60042fa942d1e2c42cd5e0edaff29815f6b7.tar.gz
bcm5719-llvm-c4ed60042fa942d1e2c42cd5e0edaff29815f6b7.zip
[llvm-exegesis] Add an AArch64 target
The target does just enough to be able to run llvm-exegesis in latency mode for at least some opcodes. Differential Revision: https://reviews.llvm.org/D48780 llvm-svn: 336187
Diffstat (limited to 'llvm')
-rw-r--r--llvm/tools/llvm-exegesis/lib/AArch64/CMakeLists.txt18
-rw-r--r--llvm/tools/llvm-exegesis/lib/AArch64/LLVMBuild.txt22
-rw-r--r--llvm/tools/llvm-exegesis/lib/AArch64/Target.cpp54
-rw-r--r--llvm/tools/llvm-exegesis/lib/CMakeLists.txt4
-rw-r--r--llvm/unittests/tools/llvm-exegesis/AArch64/CMakeLists.txt21
-rw-r--r--llvm/unittests/tools/llvm-exegesis/AArch64/TargetTest.cpp38
-rw-r--r--llvm/unittests/tools/llvm-exegesis/CMakeLists.txt3
7 files changed, 160 insertions, 0 deletions
diff --git a/llvm/tools/llvm-exegesis/lib/AArch64/CMakeLists.txt b/llvm/tools/llvm-exegesis/lib/AArch64/CMakeLists.txt
new file mode 100644
index 00000000000..a251b8ff683
--- /dev/null
+++ b/llvm/tools/llvm-exegesis/lib/AArch64/CMakeLists.txt
@@ -0,0 +1,18 @@
+include_directories(
+ ${LLVM_MAIN_SRC_DIR}/lib/Target/AArch64
+ ${LLVM_BINARY_DIR}/lib/Target/AArch64
+ )
+
+add_library(LLVMExegesisAArch64
+ STATIC
+ Target.cpp
+ )
+
+llvm_update_compile_flags(LLVMExegesisAArch64)
+llvm_map_components_to_libnames(libs
+ AArch64
+ Exegesis
+ )
+
+target_link_libraries(LLVMExegesisAArch64 ${libs})
+set_target_properties(LLVMExegesisAArch64 PROPERTIES FOLDER "Libraries")
diff --git a/llvm/tools/llvm-exegesis/lib/AArch64/LLVMBuild.txt b/llvm/tools/llvm-exegesis/lib/AArch64/LLVMBuild.txt
new file mode 100644
index 00000000000..886fcb22749
--- /dev/null
+++ b/llvm/tools/llvm-exegesis/lib/AArch64/LLVMBuild.txt
@@ -0,0 +1,22 @@
+;===- ./tools/llvm-exegesis/lib/AArch64/LLVMBuild.txt ----------*- Conf -*--===;
+;
+; The LLVM Compiler Infrastructure
+;
+; This file is distributed under the University of Illinois Open Source
+; License. See LICENSE.TXT for details.
+;
+;===------------------------------------------------------------------------===;
+;
+; This is an LLVMBuild description file for the components in this subdirectory.
+;
+; For more information on the LLVMBuild system, please see:
+;
+; http://llvm.org/docs/LLVMBuild.html
+;
+;===------------------------------------------------------------------------===;
+
+[component_0]
+type = Library
+name = ExegesisAArch64
+parent = Libraries
+required_libraries = AArch64
diff --git a/llvm/tools/llvm-exegesis/lib/AArch64/Target.cpp b/llvm/tools/llvm-exegesis/lib/AArch64/Target.cpp
new file mode 100644
index 00000000000..88df44bd94c
--- /dev/null
+++ b/llvm/tools/llvm-exegesis/lib/AArch64/Target.cpp
@@ -0,0 +1,54 @@
+//===-- Target.cpp ----------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+#include "../Target.h"
+#include "../Latency.h"
+#include "AArch64.h"
+
+namespace exegesis {
+
+namespace {
+
+class AArch64LatencyBenchmarkRunner : public LatencyBenchmarkRunner {
+public:
+ AArch64LatencyBenchmarkRunner(const LLVMState &State)
+ : LatencyBenchmarkRunner(State) {}
+
+private:
+ const char *getCounterName() const override {
+ // All AArch64 subtargets have CPU_CYCLES as the cycle counter name
+ return "CPU_CYCLES";
+ }
+};
+
+class ExegesisAArch64Target : public ExegesisTarget {
+ bool matchesArch(llvm::Triple::ArchType Arch) const override {
+ return Arch == llvm::Triple::aarch64 || Arch == llvm::Triple::aarch64_be;
+ }
+ void addTargetSpecificPasses(llvm::PassManagerBase &PM) const override {
+ // Function return is a pseudo-instruction that needs to be expanded
+ PM.add(llvm::createAArch64ExpandPseudoPass());
+ }
+ std::unique_ptr<BenchmarkRunner>
+ createLatencyBenchmarkRunner(const LLVMState &State) const override {
+ return llvm::make_unique<AArch64LatencyBenchmarkRunner>(State);
+ }
+};
+
+} // namespace
+
+static ExegesisTarget *getTheExegesisAArch64Target() {
+ static ExegesisAArch64Target Target;
+ return &Target;
+}
+
+void InitializeAArch64ExegesisTarget() {
+ ExegesisTarget::registerTarget(getTheExegesisAArch64Target());
+}
+
+} // namespace exegesis
diff --git a/llvm/tools/llvm-exegesis/lib/CMakeLists.txt b/llvm/tools/llvm-exegesis/lib/CMakeLists.txt
index 3c69dea7e24..175c2adf9de 100644
--- a/llvm/tools/llvm-exegesis/lib/CMakeLists.txt
+++ b/llvm/tools/llvm-exegesis/lib/CMakeLists.txt
@@ -2,6 +2,10 @@ if (LLVM_TARGETS_TO_BUILD MATCHES "X86")
add_subdirectory(X86)
set(LLVM_EXEGESIS_TARGETS "${LLVM_EXEGESIS_TARGETS} X86" PARENT_SCOPE)
endif()
+if (LLVM_TARGETS_TO_BUILD MATCHES "AArch64")
+ add_subdirectory(AArch64)
+ set(LLVM_EXEGESIS_TARGETS "${LLVM_EXEGESIS_TARGETS} AArch64" PARENT_SCOPE)
+endif()
add_library(LLVMExegesis
STATIC
diff --git a/llvm/unittests/tools/llvm-exegesis/AArch64/CMakeLists.txt b/llvm/unittests/tools/llvm-exegesis/AArch64/CMakeLists.txt
new file mode 100644
index 00000000000..392efce26c0
--- /dev/null
+++ b/llvm/unittests/tools/llvm-exegesis/AArch64/CMakeLists.txt
@@ -0,0 +1,21 @@
+include_directories(
+ ${LLVM_MAIN_SRC_DIR}/lib/Target/AArch64
+ ${LLVM_BINARY_DIR}/lib/Target/AArch64
+ ${LLVM_MAIN_SRC_DIR}/tools/llvm-exegesis/lib
+ )
+
+set(LLVM_LINK_COMPONENTS
+ MC
+ MCParser
+ Object
+ Support
+ Symbolize
+ AArch64
+ )
+
+add_llvm_unittest(LLVMExegesisAArch64Tests
+ TargetTest.cpp
+ )
+target_link_libraries(LLVMExegesisAArch64Tests PRIVATE
+ LLVMExegesis
+ LLVMExegesisAArch64)
diff --git a/llvm/unittests/tools/llvm-exegesis/AArch64/TargetTest.cpp b/llvm/unittests/tools/llvm-exegesis/AArch64/TargetTest.cpp
new file mode 100644
index 00000000000..7d1f2e4804e
--- /dev/null
+++ b/llvm/unittests/tools/llvm-exegesis/AArch64/TargetTest.cpp
@@ -0,0 +1,38 @@
+#include "Target.h"
+
+#include <cassert>
+#include <memory>
+
+#include "MCTargetDesc/AArch64MCTargetDesc.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+namespace exegesis {
+
+void InitializeAArch64ExegesisTarget();
+
+namespace {
+
+using testing::Gt;
+using testing::NotNull;
+using testing::SizeIs;
+
+class AArch64TargetTest : public ::testing::Test {
+protected:
+ AArch64TargetTest()
+ : Target_(ExegesisTarget::lookup(llvm::Triple("aarch64-unknown-linux"))) {
+ EXPECT_THAT(Target_, NotNull());
+ }
+ static void SetUpTestCase() { InitializeAArch64ExegesisTarget(); }
+
+ const ExegesisTarget *const Target_;
+};
+
+TEST_F(AArch64TargetTest, SetRegToConstant) {
+ // The AArch64 target currently doesn't know how to set register values
+ const auto Insts = Target_->setRegToConstant(llvm::AArch64::X0);
+ EXPECT_THAT(Insts, SizeIs(0));
+}
+
+} // namespace
+} // namespace exegesis
diff --git a/llvm/unittests/tools/llvm-exegesis/CMakeLists.txt b/llvm/unittests/tools/llvm-exegesis/CMakeLists.txt
index 867df415b93..9afa17a8e80 100644
--- a/llvm/unittests/tools/llvm-exegesis/CMakeLists.txt
+++ b/llvm/unittests/tools/llvm-exegesis/CMakeLists.txt
@@ -23,3 +23,6 @@ endif()
if(LLVM_TARGETS_TO_BUILD MATCHES "ARM")
add_subdirectory(ARM)
endif()
+if(LLVM_TARGETS_TO_BUILD MATCHES "AArch64")
+ add_subdirectory(AArch64)
+endif()
OpenPOWER on IntegriCloud