[llvm] 00c6e98 - [VE] Target stub for NEC SX-Aurora
Simon Moll via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 9 02:18:27 PST 2020
Author: Kazushi (Jam) Marukawa
Date: 2020-01-09T11:17:35+01:00
New Revision: 00c6e98409f98c3093aab4b1bfbc25c5b54731d0
URL: https://github.com/llvm/llvm-project/commit/00c6e98409f98c3093aab4b1bfbc25c5b54731d0
DIFF: https://github.com/llvm/llvm-project/commit/00c6e98409f98c3093aab4b1bfbc25c5b54731d0.diff
LOG: [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
Added:
llvm/lib/Target/VE/CMakeLists.txt
llvm/lib/Target/VE/LLVMBuild.txt
llvm/lib/Target/VE/MCTargetDesc/CMakeLists.txt
llvm/lib/Target/VE/MCTargetDesc/LLVMBuild.txt
llvm/lib/Target/VE/MCTargetDesc/VEMCTargetDesc.cpp
llvm/lib/Target/VE/MCTargetDesc/VEMCTargetDesc.h
llvm/lib/Target/VE/TargetInfo/CMakeLists.txt
llvm/lib/Target/VE/TargetInfo/LLVMBuild.txt
llvm/lib/Target/VE/TargetInfo/VETargetInfo.cpp
llvm/lib/Target/VE/VE.h
llvm/lib/Target/VE/VETargetMachine.cpp
llvm/lib/Target/VE/VETargetMachine.h
llvm/test/CodeGen/VE/lit.local.cfg
llvm/test/CodeGen/VE/target_support.ll
Modified:
llvm/CODE_OWNERS.TXT
llvm/include/llvm/ADT/Triple.h
llvm/lib/Support/Triple.cpp
llvm/lib/Target/LLVMBuild.txt
llvm/unittests/ADT/TripleTest.cpp
Removed:
################################################################################
diff --git a/llvm/CODE_OWNERS.TXT b/llvm/CODE_OWNERS.TXT
index df8aa0b4ef9d..457dabe39f90 100644
--- a/llvm/CODE_OWNERS.TXT
+++ b/llvm/CODE_OWNERS.TXT
@@ -150,6 +150,10 @@ N: Dylan McKay
E: me at dylanmckay.io
D: AVR Backend
+N: Simon Moll
+E: simon.moll at emea.nec.com
+D: VE Backend
+
N: Tim Northover
E: t.p.northover at 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 88a86bfa5ff3..76a754d671fb 100644
--- a/llvm/include/llvm/ADT/Triple.h
+++ b/llvm/include/llvm/ADT/Triple.h
@@ -95,7 +95,8 @@ class Triple {
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 @@ class Triple {
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 f2debc443d24..2af9ec7b9bc8 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 d6a95a3c6713..7403f7713a9f 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 000000000000..a3eb8bae4ac4
--- /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 000000000000..b45efd45c8ac
--- /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 000000000000..fa2fefbe47f0
--- /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 000000000000..e585042e60bb
--- /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 000000000000..7067f34a016f
--- /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 000000000000..a7969042606c
--- /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 000000000000..0850b0f27bf2
--- /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 000000000000..c440132476a4
--- /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 000000000000..be68fe7d2429
--- /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 000000000000..51d3e701f8ec
--- /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 000000000000..10fe9ba0e7eb
--- /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 000000000000..ac6089036ff8
--- /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 000000000000..b6366779272d
--- /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 000000000000..336d9cd36720
--- /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 c7f40dd1ca14..ef7f82d268e2 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",
More information about the llvm-commits
mailing list