[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
This commit is contained in:
Kazushi (Jam) Marukawa 2020-01-09 09:59:37 +01:00 committed by Simon Moll
parent f0abe820ee
commit 00c6e98409
19 changed files with 307 additions and 1 deletions

View File

@ -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

View File

@ -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();

View File

@ -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;

View File

@ -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

View File

@ -0,0 +1,8 @@
set(LLVM_TARGET_DEFINITIONS VE.td)
add_llvm_target(VECodeGen
VETargetMachine.cpp
)
add_subdirectory(TargetInfo)
add_subdirectory(MCTargetDesc)

View File

@ -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

View File

@ -0,0 +1,3 @@
add_llvm_library(LLVMVEDesc
VEMCTargetDesc.cpp
)

View File

@ -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

View File

@ -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
}

View File

@ -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

View File

@ -0,0 +1,3 @@
add_llvm_component_library(LLVMVEInfo
VETargetInfo.cpp
)

View File

@ -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

View File

@ -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");
}

19
llvm/lib/Target/VE/VE.h Normal file
View File

@ -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

View File

@ -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() {}

View File

@ -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

View File

@ -0,0 +1,2 @@
if not 'VE' in config.root.targets:
config.unsupported = True

View File

@ -0,0 +1,2 @@
; RUN: llc --version | FileCheck %s
; CHECK: ve - VE

View File

@ -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",