summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKazushi (Jam) Marukawa <marukawa@nec.com>2020-01-09 09:59:37 +0100
committerSimon Moll <simon.moll@emea.nec.com>2020-01-09 11:17:35 +0100
commit00c6e98409f98c3093aab4b1bfbc25c5b54731d0 (patch)
tree9372154b42fa8f311ab43f519ab6ffbbe2fad532
parentf0abe820eebf47a3e9b9d0daf9f995d65db186bc (diff)
downloadbcm5719-llvm-00c6e98409f98c3093aab4b1bfbc25c5b54731d0.tar.gz
bcm5719-llvm-00c6e98409f98c3093aab4b1bfbc25c5b54731d0.zip
[VE] Target stub for NEC SX-Aurora
Summary: This patch registers the 've' target: the NEC SX-Aurora TSUBASA Vector Engine. Reviewed By: arsenm Differential Revision: https://reviews.llvm.org/D69103
-rw-r--r--llvm/CODE_OWNERS.TXT4
-rw-r--r--llvm/include/llvm/ADT/Triple.h8
-rw-r--r--llvm/lib/Support/Triple.cpp11
-rw-r--r--llvm/lib/Target/LLVMBuild.txt1
-rw-r--r--llvm/lib/Target/VE/CMakeLists.txt8
-rw-r--r--llvm/lib/Target/VE/LLVMBuild.txt33
-rw-r--r--llvm/lib/Target/VE/MCTargetDesc/CMakeLists.txt3
-rw-r--r--llvm/lib/Target/VE/MCTargetDesc/LLVMBuild.txt22
-rw-r--r--llvm/lib/Target/VE/MCTargetDesc/VEMCTargetDesc.cpp19
-rw-r--r--llvm/lib/Target/VE/MCTargetDesc/VEMCTargetDesc.h27
-rw-r--r--llvm/lib/Target/VE/TargetInfo/CMakeLists.txt3
-rw-r--r--llvm/lib/Target/VE/TargetInfo/LLVMBuild.txt22
-rw-r--r--llvm/lib/Target/VE/TargetInfo/VETargetInfo.cpp23
-rw-r--r--llvm/lib/Target/VE/VE.h19
-rw-r--r--llvm/lib/Target/VE/VETargetMachine.cpp62
-rw-r--r--llvm/lib/Target/VE/VETargetMachine.h31
-rw-r--r--llvm/test/CodeGen/VE/lit.local.cfg2
-rw-r--r--llvm/test/CodeGen/VE/target_support.ll2
-rw-r--r--llvm/unittests/ADT/TripleTest.cpp8
19 files changed, 307 insertions, 1 deletions
diff --git a/llvm/CODE_OWNERS.TXT b/llvm/CODE_OWNERS.TXT
index df8aa0b4ef9..457dabe39f9 100644
--- a/llvm/CODE_OWNERS.TXT
+++ b/llvm/CODE_OWNERS.TXT
@@ -150,6 +150,10 @@ N: Dylan McKay
E: me@dylanmckay.io
D: AVR Backend
+N: Simon Moll
+E: simon.moll@emea.nec.com
+D: VE Backend
+
N: Tim Northover
E: t.p.northover@gmail.com
D: AArch64 backend, misc ARM backend
diff --git a/llvm/include/llvm/ADT/Triple.h b/llvm/include/llvm/ADT/Triple.h
index 88a86bfa5ff..76a754d671f 100644
--- a/llvm/include/llvm/ADT/Triple.h
+++ b/llvm/include/llvm/ADT/Triple.h
@@ -95,7 +95,8 @@ public:
wasm64, // WebAssembly with 64-bit pointers
renderscript32, // 32-bit RenderScript
renderscript64, // 64-bit RenderScript
- LastArchType = renderscript64
+ ve, // NEC SX-Aurora Vector Engine
+ LastArchType = ve
};
enum SubArchType {
NoSubArch,
@@ -735,6 +736,11 @@ public:
return getArch() == Triple::x86 || getArch() == Triple::x86_64;
}
+ /// Tests whether the target is VE
+ bool isVE() const {
+ return getArch() == Triple::ve;
+ }
+
/// Tests whether the target supports comdat
bool supportsCOMDAT() const {
return !isOSBinFormatMachO();
diff --git a/llvm/lib/Support/Triple.cpp b/llvm/lib/Support/Triple.cpp
index f2debc443d2..2af9ec7b9bc 100644
--- a/llvm/lib/Support/Triple.cpp
+++ b/llvm/lib/Support/Triple.cpp
@@ -70,6 +70,7 @@ StringRef Triple::getArchTypeName(ArchType Kind) {
case wasm64: return "wasm64";
case renderscript32: return "renderscript32";
case renderscript64: return "renderscript64";
+ case ve: return "ve";
}
llvm_unreachable("Invalid ArchType!");
@@ -144,6 +145,8 @@ StringRef Triple::getArchTypePrefix(ArchType Kind) {
case riscv32:
case riscv64: return "riscv";
+
+ case ve: return "ve";
}
}
@@ -313,6 +316,7 @@ Triple::ArchType Triple::getArchTypeForLLVMName(StringRef Name) {
.Case("wasm64", wasm64)
.Case("renderscript32", renderscript32)
.Case("renderscript64", renderscript64)
+ .Case("ve", ve)
.Default(UnknownArch);
}
@@ -441,6 +445,7 @@ static Triple::ArchType parseArch(StringRef ArchName) {
.Case("wasm64", Triple::wasm64)
.Case("renderscript32", Triple::renderscript32)
.Case("renderscript64", Triple::renderscript64)
+ .Case("ve", Triple::ve)
.Default(Triple::UnknownArch);
// Some architectures require special parsing logic just to compute the
@@ -700,6 +705,7 @@ static Triple::ObjectFormatType getDefaultFormat(const Triple &T) {
case Triple::tcele:
case Triple::thumbeb:
case Triple::xcore:
+ case Triple::ve:
return Triple::ELF;
case Triple::ppc:
@@ -1283,6 +1289,7 @@ static unsigned getArchPointerBitWidth(llvm::Triple::ArchType Arch) {
case llvm::Triple::spir64:
case llvm::Triple::wasm64:
case llvm::Triple::renderscript64:
+ case llvm::Triple::ve:
return 64;
}
llvm_unreachable("Invalid architecture value");
@@ -1311,6 +1318,7 @@ Triple Triple::get32BitArchVariant() const {
case Triple::msp430:
case Triple::systemz:
case Triple::ppc64le:
+ case Triple::ve:
T.setArch(UnknownArch);
break;
@@ -1403,6 +1411,7 @@ Triple Triple::get64BitArchVariant() const {
case Triple::x86_64:
case Triple::wasm64:
case Triple::renderscript64:
+ case Triple::ve:
// Already 64-bit.
break;
@@ -1461,6 +1470,7 @@ Triple Triple::getBigEndianArchVariant() const {
case Triple::xcore:
case Triple::renderscript32:
case Triple::renderscript64:
+ case Triple::ve:
// ARM is intentionally unsupported here, changing the architecture would
// drop any arch suffixes.
@@ -1552,6 +1562,7 @@ bool Triple::isLittleEndian() const {
case Triple::tcele:
case Triple::renderscript32:
case Triple::renderscript64:
+ case Triple::ve:
return true;
default:
return false;
diff --git a/llvm/lib/Target/LLVMBuild.txt b/llvm/lib/Target/LLVMBuild.txt
index d6a95a3c671..7403f7713a9 100644
--- a/llvm/lib/Target/LLVMBuild.txt
+++ b/llvm/lib/Target/LLVMBuild.txt
@@ -36,6 +36,7 @@ subdirectories =
WebAssembly
X86
XCore
+ VE
; This is a special group whose required libraries are extended (by llvm-build)
; with the best execution engine (the native JIT, if available, or the
diff --git a/llvm/lib/Target/VE/CMakeLists.txt b/llvm/lib/Target/VE/CMakeLists.txt
new file mode 100644
index 00000000000..a3eb8bae4ac
--- /dev/null
+++ b/llvm/lib/Target/VE/CMakeLists.txt
@@ -0,0 +1,8 @@
+set(LLVM_TARGET_DEFINITIONS VE.td)
+
+add_llvm_target(VECodeGen
+ VETargetMachine.cpp
+ )
+
+add_subdirectory(TargetInfo)
+add_subdirectory(MCTargetDesc)
diff --git a/llvm/lib/Target/VE/LLVMBuild.txt b/llvm/lib/Target/VE/LLVMBuild.txt
new file mode 100644
index 00000000000..b45efd45c8a
--- /dev/null
+++ b/llvm/lib/Target/VE/LLVMBuild.txt
@@ -0,0 +1,33 @@
+;===- ./lib/Target/VE/LLVMBuild.txt ----------------------------*- Conf -*--===;
+;
+; Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+; See https://llvm.org/LICENSE.txt for license information.
+; SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+;
+;===------------------------------------------------------------------------===;
+;
+; 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
+;
+;===------------------------------------------------------------------------===;
+
+[common]
+subdirectories = MCTargetDesc TargetInfo
+
+[component_0]
+type = TargetGroup
+name = VE
+parent = Target
+has_asmparser = 0
+has_asmprinter = 0
+
+[component_1]
+type = Library
+name = VECodeGen
+parent = VE
+required_libraries = Analysis AsmPrinter CodeGen Core MC SelectionDAG
+ VEDesc VEInfo Support Target
+add_to_library_groups = VE
diff --git a/llvm/lib/Target/VE/MCTargetDesc/CMakeLists.txt b/llvm/lib/Target/VE/MCTargetDesc/CMakeLists.txt
new file mode 100644
index 00000000000..fa2fefbe47f
--- /dev/null
+++ b/llvm/lib/Target/VE/MCTargetDesc/CMakeLists.txt
@@ -0,0 +1,3 @@
+add_llvm_library(LLVMVEDesc
+ VEMCTargetDesc.cpp
+ )
diff --git a/llvm/lib/Target/VE/MCTargetDesc/LLVMBuild.txt b/llvm/lib/Target/VE/MCTargetDesc/LLVMBuild.txt
new file mode 100644
index 00000000000..e585042e60b
--- /dev/null
+++ b/llvm/lib/Target/VE/MCTargetDesc/LLVMBuild.txt
@@ -0,0 +1,22 @@
+;===- ./lib/Target/VE/MCTargetDesc/LLVMBuild.txt ---------------*- Conf -*--===;
+;
+; Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+; See https://llvm.org/LICENSE.txt for license information.
+; SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+;
+;===------------------------------------------------------------------------===;
+;
+; 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 = VEDesc
+parent = VE
+required_libraries = MC VEInfo Support
+add_to_library_groups = VE
diff --git a/llvm/lib/Target/VE/MCTargetDesc/VEMCTargetDesc.cpp b/llvm/lib/Target/VE/MCTargetDesc/VEMCTargetDesc.cpp
new file mode 100644
index 00000000000..7067f34a016
--- /dev/null
+++ b/llvm/lib/Target/VE/MCTargetDesc/VEMCTargetDesc.cpp
@@ -0,0 +1,19 @@
+//===-- VEMCTargetDesc.cpp - VE Target Descriptions -----------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file provides VE specific target descriptions.
+//
+//===----------------------------------------------------------------------===//
+
+#include "VEMCTargetDesc.h"
+
+using namespace llvm;
+
+extern "C" void LLVMInitializeVETargetMC() {
+ // TODO
+}
diff --git a/llvm/lib/Target/VE/MCTargetDesc/VEMCTargetDesc.h b/llvm/lib/Target/VE/MCTargetDesc/VEMCTargetDesc.h
new file mode 100644
index 00000000000..a7969042606
--- /dev/null
+++ b/llvm/lib/Target/VE/MCTargetDesc/VEMCTargetDesc.h
@@ -0,0 +1,27 @@
+//===-- VEMCTargetDesc.h - VE Target Descriptions ---------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file provides VE specific target descriptions.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIB_TARGET_VE_MCTARGETDESC_VEMCTARGETDESC_H
+#define LLVM_LIB_TARGET_VE_MCTARGETDESC_VEMCTARGETDESC_H
+
+#include "llvm/Support/DataTypes.h"
+
+#include <memory>
+
+namespace llvm {
+
+class Target;
+Target &getTheVETarget();
+
+} // end llvm namespace
+
+#endif
diff --git a/llvm/lib/Target/VE/TargetInfo/CMakeLists.txt b/llvm/lib/Target/VE/TargetInfo/CMakeLists.txt
new file mode 100644
index 00000000000..0850b0f27bf
--- /dev/null
+++ b/llvm/lib/Target/VE/TargetInfo/CMakeLists.txt
@@ -0,0 +1,3 @@
+add_llvm_component_library(LLVMVEInfo
+ VETargetInfo.cpp
+ )
diff --git a/llvm/lib/Target/VE/TargetInfo/LLVMBuild.txt b/llvm/lib/Target/VE/TargetInfo/LLVMBuild.txt
new file mode 100644
index 00000000000..c440132476a
--- /dev/null
+++ b/llvm/lib/Target/VE/TargetInfo/LLVMBuild.txt
@@ -0,0 +1,22 @@
+;===- ./lib/Target/VE/TargetInfo/LLVMBuild.txt -----------------*- Conf -*--===;
+;
+; Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+; See https://llvm.org/LICENSE.txt for license information.
+; SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+;
+;===------------------------------------------------------------------------===;
+;
+; 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 = VEInfo
+parent = VE
+required_libraries = Support
+add_to_library_groups = VE
diff --git a/llvm/lib/Target/VE/TargetInfo/VETargetInfo.cpp b/llvm/lib/Target/VE/TargetInfo/VETargetInfo.cpp
new file mode 100644
index 00000000000..be68fe7d242
--- /dev/null
+++ b/llvm/lib/Target/VE/TargetInfo/VETargetInfo.cpp
@@ -0,0 +1,23 @@
+//===-- VETargetInfo.cpp - VE Target Implementation -----------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "VE.h"
+#include "llvm/IR/Module.h"
+#include "llvm/Support/TargetRegistry.h"
+
+using namespace llvm;
+
+Target &llvm::getTheVETarget() {
+ static Target TheVETarget;
+ return TheVETarget;
+}
+
+extern "C" void LLVMInitializeVETargetInfo() {
+ RegisterTarget<Triple::ve, /*HasJIT=*/false> X(getTheVETarget(), "ve",
+ "VE", "VE");
+}
diff --git a/llvm/lib/Target/VE/VE.h b/llvm/lib/Target/VE/VE.h
new file mode 100644
index 00000000000..51d3e701f8e
--- /dev/null
+++ b/llvm/lib/Target/VE/VE.h
@@ -0,0 +1,19 @@
+//===-- VE.h - Top-level interface for VE representation --------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file contains the entry points for global functions defined in the LLVM
+// VE back-end.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIB_TARGET_VE_VE_H
+#define LLVM_LIB_TARGET_VE_VE_H
+
+#include "MCTargetDesc/VEMCTargetDesc.h"
+
+#endif
diff --git a/llvm/lib/Target/VE/VETargetMachine.cpp b/llvm/lib/Target/VE/VETargetMachine.cpp
new file mode 100644
index 00000000000..10fe9ba0e7e
--- /dev/null
+++ b/llvm/lib/Target/VE/VETargetMachine.cpp
@@ -0,0 +1,62 @@
+//===-- VETargetMachine.cpp - Define TargetMachine for VE -----------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+//
+//===----------------------------------------------------------------------===//
+
+#include "VETargetMachine.h"
+#include "VE.h"
+#include "llvm/Support/TargetRegistry.h"
+
+using namespace llvm;
+
+#define DEBUG_TYPE "ve"
+
+extern "C" void LLVMInitializeVETarget() {
+ // Register the target.
+ RegisterTargetMachine<VETargetMachine> X(getTheVETarget());
+}
+
+static std::string computeDataLayout(const Triple &T) {
+ // Aurora VE is little endian
+ std::string Ret = "e";
+
+ // Use ELF mangling
+ Ret += "-m:e";
+
+ // Alignments for 64 bit integers.
+ Ret += "-i64:64";
+
+ // VE supports 32 bit and 64 bits integer on registers
+ Ret += "-n32:64";
+
+ // Stack alignment is 64 bits
+ Ret += "-S64";
+
+ return Ret;
+}
+
+static Reloc::Model getEffectiveRelocModel(Optional<Reloc::Model> RM) {
+ if (!RM.hasValue())
+ return Reloc::Static;
+ return *RM;
+}
+
+/// Create an Aurora VE architecture model
+VETargetMachine::VETargetMachine(
+ const Target &T, const Triple &TT, StringRef CPU, StringRef FS,
+ const TargetOptions &Options, Optional<Reloc::Model> RM,
+ Optional<CodeModel::Model> CM, CodeGenOpt::Level OL, bool JIT)
+ : LLVMTargetMachine(
+ T, computeDataLayout(TT), TT, CPU, FS, Options,
+ getEffectiveRelocModel(RM),
+ getEffectiveCodeModel(CM, CodeModel::Small),
+ OL)
+{}
+
+VETargetMachine::~VETargetMachine() {}
diff --git a/llvm/lib/Target/VE/VETargetMachine.h b/llvm/lib/Target/VE/VETargetMachine.h
new file mode 100644
index 00000000000..ac6089036ff
--- /dev/null
+++ b/llvm/lib/Target/VE/VETargetMachine.h
@@ -0,0 +1,31 @@
+//===-- VETargetMachine.h - Define TargetMachine for VE ---------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file declares the VE specific subclass of TargetMachine.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIB_TARGET_VE_VETARGETMACHINE_H
+#define LLVM_LIB_TARGET_VE_VETARGETMACHINE_H
+
+#include "llvm/Target/TargetMachine.h"
+
+namespace llvm {
+
+class VETargetMachine : public LLVMTargetMachine {
+public:
+ VETargetMachine(const Target &T, const Triple &TT, StringRef CPU,
+ StringRef FS, const TargetOptions &Options,
+ Optional<Reloc::Model> RM, Optional<CodeModel::Model> CM,
+ CodeGenOpt::Level OL, bool JIT);
+ ~VETargetMachine() override;
+};
+
+} // namespace llvm
+
+#endif
diff --git a/llvm/test/CodeGen/VE/lit.local.cfg b/llvm/test/CodeGen/VE/lit.local.cfg
new file mode 100644
index 00000000000..b6366779272
--- /dev/null
+++ b/llvm/test/CodeGen/VE/lit.local.cfg
@@ -0,0 +1,2 @@
+if not 'VE' in config.root.targets:
+ config.unsupported = True
diff --git a/llvm/test/CodeGen/VE/target_support.ll b/llvm/test/CodeGen/VE/target_support.ll
new file mode 100644
index 00000000000..336d9cd3672
--- /dev/null
+++ b/llvm/test/CodeGen/VE/target_support.ll
@@ -0,0 +1,2 @@
+; RUN: llc --version | FileCheck %s
+; CHECK: ve - VE
diff --git a/llvm/unittests/ADT/TripleTest.cpp b/llvm/unittests/ADT/TripleTest.cpp
index c7f40dd1ca1..ef7f82d268e 100644
--- a/llvm/unittests/ADT/TripleTest.cpp
+++ b/llvm/unittests/ADT/TripleTest.cpp
@@ -319,6 +319,12 @@ TEST(TripleTest, ParsedIDs) {
EXPECT_EQ(Triple::AMDPAL, T.getOS());
EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
+ T = Triple("ve-unknown-linux");
+ EXPECT_EQ(Triple::ve, T.getArch());
+ EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
+ EXPECT_EQ(Triple::Linux, T.getOS());
+ EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
+
T = Triple("riscv32-unknown-unknown");
EXPECT_EQ(Triple::riscv32, T.getArch());
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
@@ -722,6 +728,8 @@ TEST(TripleTest, Normalization) {
Triple::normalize("i686-linux")); // i686-pc-linux-gnu
EXPECT_EQ("arm-none-unknown-eabi",
Triple::normalize("arm-none-eabi")); // arm-none-eabi
+ EXPECT_EQ("ve-unknown-linux",
+ Triple::normalize("ve-linux")); // ve-linux
EXPECT_EQ("wasm32-unknown-wasi",
Triple::normalize("wasm32-wasi")); // wasm32-unknown-wasi
EXPECT_EQ("wasm64-unknown-wasi",
OpenPOWER on IntegriCloud