From c47632910e42ced8ffe62fd89a38d55cc8935d27 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Tue, 15 Jan 2019 19:58:36 +0000 Subject: [PATCH] [Nios2] Remove Nios2 backend As mentioned here http://lists.llvm.org/pipermail/llvm-dev/2019-January/129121.html This backend is incomplete and has not been maintained in several months. Differential Revision: https://reviews.llvm.org/D56690 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@351230 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Basic/BuiltinsNios2.def | 70 ------------ include/clang/Basic/TargetBuiltins.h | 10 -- include/clang/module.modulemap | 1 - lib/Basic/CMakeLists.txt | 1 - lib/Basic/Targets.cpp | 4 - lib/Basic/Targets/Nios2.cpp | 56 ---------- lib/Basic/Targets/Nios2.h | 151 -------------------------- lib/Driver/ToolChains/CommonArgs.cpp | 19 ---- test/Driver/nios2-cpu.c | 26 ----- test/Misc/target-invalid-cpu-note.c | 4 - 10 files changed, 342 deletions(-) delete mode 100644 include/clang/Basic/BuiltinsNios2.def delete mode 100644 lib/Basic/Targets/Nios2.cpp delete mode 100644 lib/Basic/Targets/Nios2.h delete mode 100644 test/Driver/nios2-cpu.c diff --git a/include/clang/Basic/BuiltinsNios2.def b/include/clang/Basic/BuiltinsNios2.def deleted file mode 100644 index d9697e795c..0000000000 --- a/include/clang/Basic/BuiltinsNios2.def +++ /dev/null @@ -1,70 +0,0 @@ -//===-- BuiltinsNios2.def - Nios2 Builtin function database --------*- C++ -*-==// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file defines the Nios2-specific builtin function database. Users of -// this file must define the BUILTIN macro to make use of this information. -// -//===----------------------------------------------------------------------===// - -// The format of this database matches clang/Basic/Builtins.def. - -#if defined(BUILTIN) && !defined(TARGET_BUILTIN) -# define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) BUILTIN(ID, TYPE, ATTRS) -#endif - -// Nios2 R1 builtins: - -//int __builtin_ldbio(volatile const void *); -BUILTIN(__builtin_ldbio, "ivDC*", "") -//int __builtin_ldbuio(volatile const void *); -BUILTIN(__builtin_ldbuio, "ivDC*", "") -//int __builtin_ldhio(volatile const void *); -BUILTIN(__builtin_ldhio, "ivDC*", "") -//int __builtin_ldhuio(volatile const void *); -BUILTIN(__builtin_ldhuio, "ivDC*", "") -//int __builtin_ldwio(volatile const void *); -BUILTIN(__builtin_ldwio, "ivDC*", "") -//int __builtin_ldwuio(int); -BUILTIN(__builtin_ldwuio, "ii", "") -// int __builtin_rdctl(int); -BUILTIN(__builtin_rdctl, "iIi", "") -// void __builtin_wrctl(int, int); -BUILTIN(__builtin_wrctl, "vIii", "") -// int __builtin_rdprs(int, int); -BUILTIN(__builtin_rdprs, "iii", "") -//void __builtin_stbio(volatile void *, int); -BUILTIN(__builtin_stbio, "vvD*i", "") -//void __builtin_sthio(volatile void *, int); -BUILTIN(__builtin_sthio, "vvD*i", "") -//void __builtin_stwio(volatile void *, int); -BUILTIN(__builtin_stwio, "vvD*i", "") -//void __builtin_sync(void); -BUILTIN(__builtin_sync, "v", "") -// void __builtin_flushd(volatile void *); -BUILTIN(__builtin_flushd, "vvD*", "") -// void __builtin_flushda(volatile void *); -BUILTIN(__builtin_flushda, "vvD*", "") - -// Nios2 R2 builtins: - -// int __builtin_wrpie(int); -TARGET_BUILTIN(__builtin_wrpie, "ii", "", "nios2r2mandatory") -// void __builtin_eni(int); -TARGET_BUILTIN(__builtin_eni, "vi", "", "nios2r2mandatory") -// int __builtin_ldex(volatile const void *); -TARGET_BUILTIN(__builtin_ldex, "ivDC*", "", "nios2r2mandatory") -// int __builtin_stex(volatile void *, int); -TARGET_BUILTIN(__builtin_stex, "ivD*i", "", "nios2r2mandatory") -// int __builtin_ldsex(volatile const void *); -TARGET_BUILTIN(__builtin_ldsex, "ivDC*", "", "nios2r2mpx") -// int __builtin_stsex(volatile void *, int); -TARGET_BUILTIN(__builtin_stsex, "ivDC*i", "", "nios2r2mpx") - -#undef BUILTIN -#undef TARGET_BUILTIN diff --git a/include/clang/Basic/TargetBuiltins.h b/include/clang/Basic/TargetBuiltins.h index 75a3811007..ab4b1c43f7 100644 --- a/include/clang/Basic/TargetBuiltins.h +++ b/include/clang/Basic/TargetBuiltins.h @@ -150,16 +150,6 @@ namespace clang { }; } - /// Nios2 builtins - namespace Nios2 { - enum { - LastTIBuiltin = clang::Builtin::FirstTSBuiltin - 1, -#define BUILTIN(ID, TYPE, ATTRS) BI##ID, -#include "clang/Basic/BuiltinsNios2.def" - LastTSBuiltin - }; - } - /// MIPS builtins namespace Mips { enum { diff --git a/include/clang/module.modulemap b/include/clang/module.modulemap index 8fde1f662f..1f32ffe0c1 100644 --- a/include/clang/module.modulemap +++ b/include/clang/module.modulemap @@ -39,7 +39,6 @@ module Clang_Basic { textual header "Basic/BuiltinsLe64.def" textual header "Basic/BuiltinsMips.def" textual header "Basic/BuiltinsNEON.def" - textual header "Basic/BuiltinsNios2.def" textual header "Basic/BuiltinsNVPTX.def" textual header "Basic/BuiltinsPPC.def" textual header "Basic/BuiltinsSystemZ.def" diff --git a/lib/Basic/CMakeLists.txt b/lib/Basic/CMakeLists.txt index 0015ede742..8b3aa0f1e9 100644 --- a/lib/Basic/CMakeLists.txt +++ b/lib/Basic/CMakeLists.txt @@ -82,7 +82,6 @@ add_clang_library(clangBasic Targets/MSP430.cpp Targets/Mips.cpp Targets/NVPTX.cpp - Targets/Nios2.cpp Targets/OSTargets.cpp Targets/PNaCl.cpp Targets/PPC.cpp diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp index fd201a9add..0c3dbd8075 100644 --- a/lib/Basic/Targets.cpp +++ b/lib/Basic/Targets.cpp @@ -26,7 +26,6 @@ #include "Targets/MSP430.h" #include "Targets/Mips.h" #include "Targets/NVPTX.h" -#include "Targets/Nios2.h" #include "Targets/OSTargets.h" #include "Targets/PNaCl.h" #include "Targets/PPC.h" @@ -247,9 +246,6 @@ TargetInfo *AllocateTarget(const llvm::Triple &Triple, case llvm::Triple::msp430: return new MSP430TargetInfo(Triple, Opts); - case llvm::Triple::nios2: - return new LinuxTargetInfo(Triple, Opts); - case llvm::Triple::mips: switch (os) { case llvm::Triple::Linux: diff --git a/lib/Basic/Targets/Nios2.cpp b/lib/Basic/Targets/Nios2.cpp deleted file mode 100644 index 48f662dd98..0000000000 --- a/lib/Basic/Targets/Nios2.cpp +++ /dev/null @@ -1,56 +0,0 @@ -//===--- Nios2.cpp - Implement Nios2 target feature support ---------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements Nios2 TargetInfo objects. -// -//===----------------------------------------------------------------------===// - -#include "Nios2.h" -#include "Targets.h" -#include "clang/Basic/MacroBuilder.h" -#include "clang/Basic/TargetBuiltins.h" -#include "llvm/ADT/StringSwitch.h" - -using namespace clang; -using namespace clang::targets; - -const Builtin::Info Nios2TargetInfo::BuiltinInfo[] = { -#define BUILTIN(ID, TYPE, ATTRS) \ - {#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr}, -#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \ - {#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, FEATURE}, -#include "clang/Basic/BuiltinsNios2.def" -}; - -bool Nios2TargetInfo::isFeatureSupportedByCPU(StringRef Feature, - StringRef CPU) const { - const bool isR2 = CPU == "nios2r2"; - return llvm::StringSwitch(Feature) - .Case("nios2r2mandatory", isR2) - .Case("nios2r2bmx", isR2) - .Case("nios2r2mpx", isR2) - .Case("nios2r2cdx", isR2) - .Default(false); -} - -void Nios2TargetInfo::getTargetDefines(const LangOptions &Opts, - MacroBuilder &Builder) const { - DefineStd(Builder, "nios2", Opts); - DefineStd(Builder, "NIOS2", Opts); - - Builder.defineMacro("__nios2"); - Builder.defineMacro("__NIOS2"); - Builder.defineMacro("__nios2__"); - Builder.defineMacro("__NIOS2__"); -} - -ArrayRef Nios2TargetInfo::getTargetBuiltins() const { - return llvm::makeArrayRef(BuiltinInfo, clang::Nios2::LastTSBuiltin - - Builtin::FirstTSBuiltin); -} diff --git a/lib/Basic/Targets/Nios2.h b/lib/Basic/Targets/Nios2.h deleted file mode 100644 index ffeb414d47..0000000000 --- a/lib/Basic/Targets/Nios2.h +++ /dev/null @@ -1,151 +0,0 @@ -//===--- Nios2.h - Declare Nios2 target feature support ---------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file declares Nios2 TargetInfo objects. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_CLANG_LIB_BASIC_TARGETS_NIOS2_H -#define LLVM_CLANG_LIB_BASIC_TARGETS_NIOS2_H - -#include "clang/Basic/TargetInfo.h" -#include "clang/Basic/TargetOptions.h" -#include "llvm/ADT/Triple.h" -#include "llvm/Support/Compiler.h" - -namespace clang { -namespace targets { - -class LLVM_LIBRARY_VISIBILITY Nios2TargetInfo : public TargetInfo { - void setDataLayout() { - if (BigEndian) - resetDataLayout("E-p:32:32:32-i8:8:32-i16:16:32-n32"); - else - resetDataLayout("e-p:32:32:32-i8:8:32-i16:16:32-n32"); - } - - static const Builtin::Info BuiltinInfo[]; - std::string CPU; - std::string ABI; - -public: - Nios2TargetInfo(const llvm::Triple &triple, const TargetOptions &opts) - : TargetInfo(triple), CPU(opts.CPU), ABI(opts.ABI) { - SizeType = UnsignedInt; - PtrDiffType = SignedInt; - MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 32; - setDataLayout(); - } - - StringRef getABI() const override { return ABI; } - bool setABI(const std::string &Name) override { - if (Name == "o32" || Name == "eabi") { - ABI = Name; - return true; - } - return false; - } - - bool isValidCPUName(StringRef Name) const override { - return Name == "nios2r1" || Name == "nios2r2"; - } - - void fillValidCPUList(SmallVectorImpl &Values) const override { - Values.append({"nios2r1", "nios2r2"}); - } - - bool setCPU(const std::string &Name) override { - if (isValidCPUName(Name)) { - CPU = Name; - return true; - } - return false; - } - - void getTargetDefines(const LangOptions &Opts, - MacroBuilder &Builder) const override; - - ArrayRef getTargetBuiltins() const override; - - bool isFeatureSupportedByCPU(StringRef Feature, StringRef CPU) const; - - bool - initFeatureMap(llvm::StringMap &Features, DiagnosticsEngine &Diags, - StringRef CPU, - const std::vector &FeatureVec) const override { - static const char *allFeatures[] = {"nios2r2mandatory", "nios2r2bmx", - "nios2r2mpx", "nios2r2cdx" - }; - for (const char *feature : allFeatures) { - Features[feature] = isFeatureSupportedByCPU(feature, CPU); - } - return true; - } - - bool hasFeature(StringRef Feature) const override { - return isFeatureSupportedByCPU(Feature, CPU); - } - - BuiltinVaListKind getBuiltinVaListKind() const override { - return TargetInfo::VoidPtrBuiltinVaList; - } - - ArrayRef getGCCRegNames() const override { - static const char *const GCCRegNames[] = { - // CPU register names - // Must match second column of GCCRegAliases - "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", - "r11", "r12", "r13", "r14", "r15", "r16", "r17", "r18", "r19", "r20", - "r21", "r22", "r23", "r24", "r25", "r26", "r27", "r28", "r29", "r30", - "r31", - // Floating point register names - "ctl0", "ctl1", "ctl2", "ctl3", "ctl4", "ctl5", "ctl6", "ctl7", "ctl8", - "ctl9", "ctl10", "ctl11", "ctl12", "ctl13", "ctl14", "ctl15" - }; - return llvm::makeArrayRef(GCCRegNames); - } - - bool validateAsmConstraint(const char *&Name, - TargetInfo::ConstraintInfo &Info) const override { - switch (*Name) { - default: - return false; - - case 'r': // CPU registers. - case 'd': // Equivalent to "r" unless generating MIPS16 code. - case 'y': // Equivalent to "r", backwards compatibility only. - case 'f': // floating-point registers. - case 'c': // $25 for indirect jumps - case 'l': // lo register - case 'x': // hilo register pair - Info.setAllowsRegister(); - return true; - } - } - - const char *getClobbers() const override { return ""; } - - ArrayRef getGCCRegAliases() const override { - static const TargetInfo::GCCRegAlias aliases[] = { - {{"zero"}, "r0"}, {{"at"}, "r1"}, {{"et"}, "r24"}, - {{"bt"}, "r25"}, {{"gp"}, "r26"}, {{"sp"}, "r27"}, - {{"fp"}, "r28"}, {{"ea"}, "r29"}, {{"ba"}, "r30"}, - {{"ra"}, "r31"}, {{"status"}, "ctl0"}, {{"estatus"}, "ctl1"}, - {{"bstatus"}, "ctl2"}, {{"ienable"}, "ctl3"}, {{"ipending"}, "ctl4"}, - {{"cpuid"}, "ctl5"}, {{"exception"}, "ctl7"}, {{"pteaddr"}, "ctl8"}, - {{"tlbacc"}, "ctl9"}, {{"tlbmisc"}, "ctl10"}, {{"badaddr"}, "ctl12"}, - {{"config"}, "ctl13"}, {{"mpubase"}, "ctl14"}, {{"mpuacc"}, "ctl15"}, - }; - return llvm::makeArrayRef(aliases); - } -}; - -} // namespace targets -} // namespace clang -#endif // LLVM_CLANG_LIB_BASIC_TARGETS_NIOS2_H diff --git a/lib/Driver/ToolChains/CommonArgs.cpp b/lib/Driver/ToolChains/CommonArgs.cpp index cada16174f..d7e316befa 100644 --- a/lib/Driver/ToolChains/CommonArgs.cpp +++ b/lib/Driver/ToolChains/CommonArgs.cpp @@ -220,21 +220,6 @@ static std::string getR600TargetGPU(const ArgList &Args) { return ""; } -static std::string getNios2TargetCPU(const ArgList &Args) { - Arg *A = Args.getLastArg(options::OPT_mcpu_EQ); - if (!A) - A = Args.getLastArg(options::OPT_march_EQ); - - if (!A) - return ""; - - const char *name = A->getValue(); - return llvm::StringSwitch(name) - .Case("r1", "nios2r1") - .Case("r2", "nios2r2") - .Default(name); -} - static std::string getLanaiTargetCPU(const ArgList &Args) { if (Arg *A = Args.getLastArg(options::OPT_mcpu_EQ)) { return A->getValue(); @@ -287,10 +272,6 @@ std::string tools::getCPUName(const ArgList &Args, const llvm::Triple &T, return A->getValue(); return ""; - case llvm::Triple::nios2: { - return getNios2TargetCPU(Args); - } - case llvm::Triple::mips: case llvm::Triple::mipsel: case llvm::Triple::mips64: diff --git a/test/Driver/nios2-cpu.c b/test/Driver/nios2-cpu.c deleted file mode 100644 index 3a8bad4f36..0000000000 --- a/test/Driver/nios2-cpu.c +++ /dev/null @@ -1,26 +0,0 @@ -// RUN: %clang -target nios2--- %s -### -o %t.o 2>&1 \ -// RUN: | FileCheck %s - -// RUN: %clang -target nios2--- -mcpu=r1 %s -### -o %t.o 2>&1 \ -// RUN: | FileCheck -check-prefix=CHECK-R1 %s -// RUN: %clang -target nios2--- -mcpu=nios2r1 %s -### -o %t.o 2>&1 \ -// RUN: | FileCheck -check-prefix=CHECK-R1 %s -// RUN: %clang -target nios2--- -march=r1 %s -### -o %t.o 2>&1 \ -// RUN: | FileCheck -check-prefix=CHECK-R1 %s -// RUN: %clang -target nios2--- -march=nios2r1 %s -### -o %t.o 2>&1 \ -// RUN: | FileCheck -check-prefix=CHECK-R1 %s - -// RUN: %clang -target nios2--- -mcpu=r2 %s -### -o %t.o 2>&1 \ -// RUN: | FileCheck -check-prefix=CHECK-R2 %s -// RUN: %clang -target nios2--- -mcpu=nios2r2 %s -### -o %t.o 2>&1 \ -// RUN: | FileCheck -check-prefix=CHECK-R2 %s -// RUN: %clang -target nios2--- -march=r2 %s -### -o %t.o 2>&1 \ -// RUN: | FileCheck -check-prefix=CHECK-R2 %s -// RUN: %clang -target nios2--- -march=nios2r2 %s -### -o %t.o 2>&1 \ -// RUN: | FileCheck -check-prefix=CHECK-R2 %s - -// CHECK: "-triple" "nios2-unknown-unknown-unknown" -// CHECK-R1: "-triple" "nios2-unknown-unknown-unknown" -// CHECK-R1: "-target-cpu" "nios2r1" -// CHECK-R2: "-triple" "nios2-unknown-unknown-unknown" -// CHECK-R2: "-target-cpu" "nios2r2" diff --git a/test/Misc/target-invalid-cpu-note.c b/test/Misc/target-invalid-cpu-note.c index 170efb5497..babfaa9ffc 100644 --- a/test/Misc/target-invalid-cpu-note.c +++ b/test/Misc/target-invalid-cpu-note.c @@ -84,10 +84,6 @@ // PPC-SAME: pwr7, power8, pwr8, power9, pwr9, powerpc, ppc, powerpc64, ppc64, // PPC-SAME: powerpc64le, ppc64le -// RUN: not %clang_cc1 -triple nios2--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix NIOS -// NIOS: error: unknown target CPU 'not-a-cpu' -// NIOS: note: valid target CPU values are: nios2r1, nios2r2 - // RUN: not %clang_cc1 -triple mips--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix MIPS // MIPS: error: unknown target CPU 'not-a-cpu' // MIPS: note: valid target CPU values are: mips1, mips2, mips3, mips4, mips5, -- 2.40.0