summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@intel.com>2019-01-15 19:59:19 +0000
committerCraig Topper <craig.topper@intel.com>2019-01-15 19:59:19 +0000
commitd6e22d762b24bde4ace93838d038f983cc247de5 (patch)
tree11317089ef4b9a166b90390fa534c49e833358c4
parentf9045b575ac2146e67c320488e4e28cd0efab08c (diff)
[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/D56691
-rw-r--r--llvm/include/llvm/ADT/Triple.h1
-rw-r--r--llvm/lib/Support/Triple.cpp11
-rw-r--r--llvm/lib/Target/LLVMBuild.txt1
-rw-r--r--llvm/lib/Target/Nios2/CMakeLists.txt30
-rw-r--r--llvm/lib/Target/Nios2/InstPrinter/CMakeLists.txt1
-rw-r--r--llvm/lib/Target/Nios2/InstPrinter/LLVMBuild.txt23
-rw-r--r--llvm/lib/Target/Nios2/InstPrinter/Nios2InstPrinter.cpp66
-rw-r--r--llvm/lib/Target/Nios2/InstPrinter/Nios2InstPrinter.h49
-rw-r--r--llvm/lib/Target/Nios2/LLVMBuild.txt66
-rw-r--r--llvm/lib/Target/Nios2/MCTargetDesc/CMakeLists.txt9
-rw-r--r--llvm/lib/Target/Nios2/MCTargetDesc/LLVMBuild.txt26
-rw-r--r--llvm/lib/Target/Nios2/MCTargetDesc/Nios2AsmBackend.cpp130
-rw-r--r--llvm/lib/Target/Nios2/MCTargetDesc/Nios2AsmBackend.h81
-rw-r--r--llvm/lib/Target/Nios2/MCTargetDesc/Nios2BaseInfo.h38
-rw-r--r--llvm/lib/Target/Nios2/MCTargetDesc/Nios2ELFObjectWriter.cpp43
-rw-r--r--llvm/lib/Target/Nios2/MCTargetDesc/Nios2FixupKinds.h41
-rw-r--r--llvm/lib/Target/Nios2/MCTargetDesc/Nios2MCAsmInfo.cpp44
-rw-r--r--llvm/lib/Target/Nios2/MCTargetDesc/Nios2MCAsmInfo.h31
-rw-r--r--llvm/lib/Target/Nios2/MCTargetDesc/Nios2MCExpr.cpp76
-rw-r--r--llvm/lib/Target/Nios2/MCTargetDesc/Nios2MCExpr.h60
-rw-r--r--llvm/lib/Target/Nios2/MCTargetDesc/Nios2MCTargetDesc.cpp102
-rw-r--r--llvm/lib/Target/Nios2/MCTargetDesc/Nios2MCTargetDesc.h52
-rw-r--r--llvm/lib/Target/Nios2/MCTargetDesc/Nios2TargetStreamer.cpp22
-rw-r--r--llvm/lib/Target/Nios2/Nios2.h35
-rw-r--r--llvm/lib/Target/Nios2/Nios2.td59
-rw-r--r--llvm/lib/Target/Nios2/Nios2AsmPrinter.cpp153
-rw-r--r--llvm/lib/Target/Nios2/Nios2CallingConv.td34
-rw-r--r--llvm/lib/Target/Nios2/Nios2FrameLowering.cpp27
-rw-r--r--llvm/lib/Target/Nios2/Nios2FrameLowering.h39
-rw-r--r--llvm/lib/Target/Nios2/Nios2ISelDAGToDAG.cpp76
-rw-r--r--llvm/lib/Target/Nios2/Nios2ISelLowering.cpp188
-rw-r--r--llvm/lib/Target/Nios2/Nios2ISelLowering.h63
-rw-r--r--llvm/lib/Target/Nios2/Nios2InstrFormats.td235
-rw-r--r--llvm/lib/Target/Nios2/Nios2InstrInfo.cpp54
-rw-r--r--llvm/lib/Target/Nios2/Nios2InstrInfo.h49
-rw-r--r--llvm/lib/Target/Nios2/Nios2InstrInfo.td109
-rw-r--r--llvm/lib/Target/Nios2/Nios2MCInstLower.cpp117
-rw-r--r--llvm/lib/Target/Nios2/Nios2MachineFunction.cpp14
-rw-r--r--llvm/lib/Target/Nios2/Nios2MachineFunction.h62
-rw-r--r--llvm/lib/Target/Nios2/Nios2RegisterInfo.cpp55
-rw-r--r--llvm/lib/Target/Nios2/Nios2RegisterInfo.h52
-rw-r--r--llvm/lib/Target/Nios2/Nios2RegisterInfo.td60
-rw-r--r--llvm/lib/Target/Nios2/Nios2Schedule.td39
-rw-r--r--llvm/lib/Target/Nios2/Nios2Subtarget.cpp56
-rw-r--r--llvm/lib/Target/Nios2/Nios2Subtarget.h97
-rw-r--r--llvm/lib/Target/Nios2/Nios2TargetMachine.cpp111
-rw-r--r--llvm/lib/Target/Nios2/Nios2TargetMachine.h45
-rw-r--r--llvm/lib/Target/Nios2/Nios2TargetObjectFile.cpp18
-rw-r--r--llvm/lib/Target/Nios2/Nios2TargetObjectFile.h26
-rw-r--r--llvm/lib/Target/Nios2/Nios2TargetStreamer.h30
-rw-r--r--llvm/lib/Target/Nios2/TargetInfo/CMakeLists.txt1
-rw-r--r--llvm/lib/Target/Nios2/TargetInfo/LLVMBuild.txt23
-rw-r--r--llvm/lib/Target/Nios2/TargetInfo/Nios2TargetInfo.cpp24
-rw-r--r--llvm/test/CodeGen/Nios2/add-sub.ll19
-rw-r--r--llvm/test/CodeGen/Nios2/lit.local.cfg3
-rw-r--r--llvm/test/CodeGen/Nios2/mul-div.ll27
-rw-r--r--llvm/test/CodeGen/Nios2/proc_support.ll10
-rw-r--r--llvm/test/CodeGen/Nios2/ret_generated.ll9
-rw-r--r--llvm/test/CodeGen/Nios2/shift-rotate.ll26
-rw-r--r--llvm/test/CodeGen/Nios2/target_support.ll11
-rw-r--r--llvm/utils/gn/secondary/clang/lib/Basic/BUILD.gn1
61 files changed, 0 insertions, 3060 deletions
diff --git a/llvm/include/llvm/ADT/Triple.h b/llvm/include/llvm/ADT/Triple.h
index ec2410d0d49..b070ae3c97b 100644
--- a/llvm/include/llvm/ADT/Triple.h
+++ b/llvm/include/llvm/ADT/Triple.h
@@ -60,7 +60,6 @@ public:
mips64, // MIPS64: mips64, mips64r6, mipsn32, mipsn32r6
mips64el, // MIPS64EL: mips64el, mips64r6el, mipsn32el, mipsn32r6el
msp430, // MSP430: msp430
- nios2, // NIOSII: nios2
ppc, // PPC: powerpc
ppc64, // PPC64: powerpc64, ppu
ppc64le, // PPC64LE: powerpc64le
diff --git a/llvm/lib/Support/Triple.cpp b/llvm/lib/Support/Triple.cpp
index 46522c0f6d5..4ca48dfaeee 100644
--- a/llvm/lib/Support/Triple.cpp
+++ b/llvm/lib/Support/Triple.cpp
@@ -35,7 +35,6 @@ StringRef Triple::getArchTypeName(ArchType Kind) {
case mips64: return "mips64";
case mips64el: return "mips64el";
case msp430: return "msp430";
- case nios2: return "nios2";
case ppc64: return "powerpc64";
case ppc64le: return "powerpc64le";
case ppc: return "powerpc";
@@ -102,8 +101,6 @@ StringRef Triple::getArchTypePrefix(ArchType Kind) {
case mips64:
case mips64el: return "mips";
- case nios2: return "nios2";
-
case hexagon: return "hexagon";
case amdgcn: return "amdgcn";
@@ -274,7 +271,6 @@ Triple::ArchType Triple::getArchTypeForLLVMName(StringRef Name) {
.Case("mips64", mips64)
.Case("mips64el", mips64el)
.Case("msp430", msp430)
- .Case("nios2", nios2)
.Case("ppc64", ppc64)
.Case("ppc32", ppc)
.Case("ppc", ppc)
@@ -409,7 +405,6 @@ static Triple::ArchType parseArch(StringRef ArchName) {
"mips64r6", "mipsn32r6", Triple::mips64)
.Cases("mips64el", "mipsn32el", "mipsisa64r6el", "mips64r6el",
"mipsn32r6el", Triple::mips64el)
- .Case("nios2", Triple::nios2)
.Case("r600", Triple::r600)
.Case("amdgcn", Triple::amdgcn)
.Case("riscv32", Triple::riscv32)
@@ -667,7 +662,6 @@ static Triple::ObjectFormatType getDefaultFormat(const Triple &T) {
case Triple::mips64el:
case Triple::mipsel:
case Triple::msp430:
- case Triple::nios2:
case Triple::nvptx:
case Triple::nvptx64:
case Triple::ppc64le:
@@ -1225,7 +1219,6 @@ static unsigned getArchPointerBitWidth(llvm::Triple::ArchType Arch) {
case llvm::Triple::le32:
case llvm::Triple::mips:
case llvm::Triple::mipsel:
- case llvm::Triple::nios2:
case llvm::Triple::nvptx:
case llvm::Triple::ppc:
case llvm::Triple::r600:
@@ -1310,7 +1303,6 @@ Triple Triple::get32BitArchVariant() const {
case Triple::le32:
case Triple::mips:
case Triple::mipsel:
- case Triple::nios2:
case Triple::nvptx:
case Triple::ppc:
case Triple::r600:
@@ -1359,7 +1351,6 @@ Triple Triple::get64BitArchVariant() const {
case Triple::kalimba:
case Triple::lanai:
case Triple::msp430:
- case Triple::nios2:
case Triple::r600:
case Triple::tce:
case Triple::tcele:
@@ -1431,7 +1422,6 @@ Triple Triple::getBigEndianArchVariant() const {
case Triple::le32:
case Triple::le64:
case Triple::msp430:
- case Triple::nios2:
case Triple::nvptx64:
case Triple::nvptx:
case Triple::r600:
@@ -1518,7 +1508,6 @@ bool Triple::isLittleEndian() const {
case Triple::mips64el:
case Triple::mipsel:
case Triple::msp430:
- case Triple::nios2:
case Triple::nvptx64:
case Triple::nvptx:
case Triple::ppc64le:
diff --git a/llvm/lib/Target/LLVMBuild.txt b/llvm/lib/Target/LLVMBuild.txt
index 0d899a9c782..0ed7e9f854d 100644
--- a/llvm/lib/Target/LLVMBuild.txt
+++ b/llvm/lib/Target/LLVMBuild.txt
@@ -30,7 +30,6 @@ subdirectories =
MSP430
NVPTX
Mips
- Nios2
PowerPC
RISCV
Sparc
diff --git a/llvm/lib/Target/Nios2/CMakeLists.txt b/llvm/lib/Target/Nios2/CMakeLists.txt
deleted file mode 100644
index 6393cc5fcb9..00000000000
--- a/llvm/lib/Target/Nios2/CMakeLists.txt
+++ /dev/null
@@ -1,30 +0,0 @@
-set(LLVM_TARGET_DEFINITIONS Nios2.td)
-
-tablegen(LLVM Nios2GenAsmWriter.inc -gen-asm-writer)
-tablegen(LLVM Nios2GenCallingConv.inc -gen-callingconv)
-tablegen(LLVM Nios2GenDAGISel.inc -gen-dag-isel)
-tablegen(LLVM Nios2GenInstrInfo.inc -gen-instr-info)
-tablegen(LLVM Nios2GenRegisterInfo.inc -gen-register-info)
-tablegen(LLVM Nios2GenSubtargetInfo.inc -gen-subtarget)
-
-add_public_tablegen_target(Nios2CommonTableGen)
-
-#Nios2CodeGen should match with LLVMBuild.txt Nios2CodeGen
-add_llvm_target(Nios2CodeGen
- Nios2AsmPrinter.cpp
- Nios2FrameLowering.cpp
- Nios2InstrInfo.cpp
- Nios2ISelDAGToDAG.cpp
- Nios2ISelLowering.cpp
- Nios2MachineFunction.cpp
- Nios2MCInstLower.cpp
- Nios2RegisterInfo.cpp
- Nios2Subtarget.cpp
- Nios2TargetMachine.cpp
- Nios2TargetObjectFile.cpp
- )
-
-#Should match with "subdirectories = InstPrinter MCTargetDesc TargetInfo" in LLVMBuild.txt
-add_subdirectory(InstPrinter)
-add_subdirectory(MCTargetDesc)
-add_subdirectory(TargetInfo)
diff --git a/llvm/lib/Target/Nios2/InstPrinter/CMakeLists.txt b/llvm/lib/Target/Nios2/InstPrinter/CMakeLists.txt
deleted file mode 100644
index dc50be75575..00000000000
--- a/llvm/lib/Target/Nios2/InstPrinter/CMakeLists.txt
+++ /dev/null
@@ -1 +0,0 @@
-add_llvm_library(LLVMNios2AsmPrinter Nios2InstPrinter.cpp)
diff --git a/llvm/lib/Target/Nios2/InstPrinter/LLVMBuild.txt b/llvm/lib/Target/Nios2/InstPrinter/LLVMBuild.txt
deleted file mode 100644
index bc7882dd357..00000000000
--- a/llvm/lib/Target/Nios2/InstPrinter/LLVMBuild.txt
+++ /dev/null
@@ -1,23 +0,0 @@
-;===- ./lib/Target/Nios2/InstPrinter/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 = Nios2AsmPrinter
-parent = Nios2
-required_libraries = MC Support
-add_to_library_groups = Nios2
diff --git a/llvm/lib/Target/Nios2/InstPrinter/Nios2InstPrinter.cpp b/llvm/lib/Target/Nios2/InstPrinter/Nios2InstPrinter.cpp
deleted file mode 100644
index de0a5f9e84e..00000000000
--- a/llvm/lib/Target/Nios2/InstPrinter/Nios2InstPrinter.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-//===-- Nios2InstPrinter.cpp - Convert Nios2 MCInst to assembly syntax-----===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This class prints an Nios2 MCInst to a .s file.
-//
-//===----------------------------------------------------------------------===//
-
-#include "Nios2InstPrinter.h"
-
-#include "Nios2InstrInfo.h"
-#include "llvm/MC/MCExpr.h"
-#include "llvm/MC/MCInst.h"
-#include "llvm/MC/MCInstrInfo.h"
-#include "llvm/Support/raw_ostream.h"
-using namespace llvm;
-
-#define DEBUG_TYPE "asm-printer"
-
-#define PRINT_ALIAS_INSTR
-#include "Nios2GenAsmWriter.inc"
-
-void Nios2InstPrinter::printRegName(raw_ostream &OS, unsigned RegNo) const {
- OS << getRegisterName(RegNo);
-}
-
-void Nios2InstPrinter::printInst(const MCInst *MI, raw_ostream &O,
- StringRef Annot, const MCSubtargetInfo &STI) {
- // Try to print any aliases first.
- if (!printAliasInstr(MI, STI, O))
- printInstruction(MI, STI, O);
- printAnnotation(O, Annot);
-}
-
-void Nios2InstPrinter::printOperand(const MCInst *MI, int OpNo,
- const MCSubtargetInfo &STI,
- raw_ostream &O) {
- const MCOperand &Op = MI->getOperand(OpNo);
- if (Op.isReg()) {
- printRegName(O, Op.getReg());
- return;
- }
-
- if (Op.isImm()) {
- O << Op.getImm();
- return;
- }
-
- assert(Op.isExpr() && "unknown operand kind in printOperand");
- Op.getExpr()->print(O, &MAI, true);
-}
-
-void Nios2InstPrinter::printMemOperand(const MCInst *MI, int opNum,
- const MCSubtargetInfo &STI,
- raw_ostream &O, const char *Modifier) {
- // Load/Store memory operands -- imm($reg)
- printOperand(MI, opNum + 1, STI, O);
- O << "(";
- printOperand(MI, opNum, STI, O);
- O << ")";
-}
diff --git a/llvm/lib/Target/Nios2/InstPrinter/Nios2InstPrinter.h b/llvm/lib/Target/Nios2/InstPrinter/Nios2InstPrinter.h
deleted file mode 100644
index 43a12951bae..00000000000
--- a/llvm/lib/Target/Nios2/InstPrinter/Nios2InstPrinter.h
+++ /dev/null
@@ -1,49 +0,0 @@
-//= Nios2InstPrinter.h - Convert Nios2 MCInst to assembly syntax -*- C++ -*-==//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This class prints a Nios2 MCInst to a .s file.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_LIB_TARGET_NIOS2_INSTPRINTER_NIOS2INSTPRINTER_H
-#define LLVM_LIB_TARGET_NIOS2_INSTPRINTER_NIOS2INSTPRINTER_H
-
-#include "llvm/MC/MCInstPrinter.h"
-
-namespace llvm {
-
-class Nios2InstPrinter : public MCInstPrinter {
-public:
- Nios2InstPrinter(const MCAsmInfo &MAI, const MCInstrInfo &MII,
- const MCRegisterInfo &MRI)
- : MCInstPrinter(MAI, MII, MRI) {}
-
- void printRegName(raw_ostream &OS, unsigned RegNo) const override;
- void printInst(const MCInst *MI, raw_ostream &O, StringRef Annot,
- const MCSubtargetInfo &STI) override;
-
- // Autogenerated by tblgen.
- void printInstruction(const MCInst *MI, const MCSubtargetInfo &STI,
- raw_ostream &O);
- static const char *getRegisterName(unsigned RegNo);
-
- bool printAliasInstr(const MCInst *MI, const MCSubtargetInfo &STI,
- raw_ostream &O);
-
- void printCustomAliasOperand(const MCInst *MI, unsigned OpIdx,
- unsigned PrintMethodIdx,
- const MCSubtargetInfo &STI, raw_ostream &O);
- void printOperand(const MCInst *MI, int opNum, const MCSubtargetInfo &STI,
- raw_ostream &OS);
- void printMemOperand(const MCInst *MI, int opNum, const MCSubtargetInfo &STI,
- raw_ostream &OS, const char *Modifier = nullptr);
-};
-} // end namespace llvm
-
-#endif
diff --git a/llvm/lib/Target/Nios2/LLVMBuild.txt b/llvm/lib/Target/Nios2/LLVMBuild.txt
deleted file mode 100644
index 46dd93308c0..00000000000
--- a/llvm/lib/Target/Nios2/LLVMBuild.txt
+++ /dev/null
@@ -1,66 +0,0 @@
-;===- ./lib/Target/Nios2/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
-;
-;===------------------------------------------------------------------------===;
-
-#Following comments extracted from http: // llvm.org/docs/LLVMBuild.html
-
-[common]
-subdirectories =
- InstPrinter
- MCTargetDesc
- TargetInfo
-
-[component_0]
-#TargetGroup components are an extension of LibraryGroups, specifically for
-#defining LLVM targets(which are handled specially in a few places).
-type = TargetGroup
-#The name of the component should always be the name of the target.(should
-#match "def Nios2 : Target" in Nios2.td)
-name = Nios2
-#Nios2 component is located in directory Target /
-parent = Target
-#Whether this target defines an assembly parser, assembly printer, disassembler
-#, and supports JIT compilation.They are optional.
-has_asmprinter = 1
-
-[component_1]
-#component_1 is a Library type and name is Nios2CodeGen.After build it will
-#in lib / libLLVMNios2CodeGen.a of your build command directory.
-type = Library
-name = Nios2CodeGen
-#Nios2CodeGen component(Library) is located in directory Nios2 /
-parent = Nios2
-#If given, a list of the names of Library or LibraryGroup components which
-#must also be linked in whenever this library is used.That is, the link time
-#dependencies for this component.When tools are built, the build system will
-#include the transitive closure of all required_libraries for the components
-#the tool needs.
-required_libraries = AsmPrinter
- CodeGen
- Core
- GlobalISel
- MC
- Nios2AsmPrinter
- Nios2Desc
- Nios2Info
- SelectionDAG
- Support
- Target
-#end of required_libraries
-
-#All LLVMBuild.txt in Target / Nios2 and subdirectory use 'add_to_library_groups
-#= Nios2'
-add_to_library_groups = Nios2
diff --git a/llvm/lib/Target/Nios2/MCTargetDesc/CMakeLists.txt b/llvm/lib/Target/Nios2/MCTargetDesc/CMakeLists.txt
deleted file mode 100644
index 138832d33ab..00000000000
--- a/llvm/lib/Target/Nios2/MCTargetDesc/CMakeLists.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-#MCTargetDesc / CMakeLists.txt
-add_llvm_library(LLVMNios2Desc
- Nios2AsmBackend.cpp
- Nios2ELFObjectWriter.cpp
- Nios2MCAsmInfo.cpp
- Nios2MCExpr.cpp
- Nios2MCTargetDesc.cpp
- Nios2TargetStreamer.cpp)
-
diff --git a/llvm/lib/Target/Nios2/MCTargetDesc/LLVMBuild.txt b/llvm/lib/Target/Nios2/MCTargetDesc/LLVMBuild.txt
deleted file mode 100644
index 3794c83e504..00000000000
--- a/llvm/lib/Target/Nios2/MCTargetDesc/LLVMBuild.txt
+++ /dev/null
@@ -1,26 +0,0 @@
-;===- ./lib/Target/Nios2/MCTargetDesc/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 = Nios2Desc
-parent = Nios2
-required_libraries = MC
- Nios2AsmPrinter
- Nios2Info
- Support
-add_to_library_groups = Nios2
diff --git a/llvm/lib/Target/Nios2/MCTargetDesc/Nios2AsmBackend.cpp b/llvm/lib/Target/Nios2/MCTargetDesc/Nios2AsmBackend.cpp
deleted file mode 100644
index 8ac08c6837d..00000000000
--- a/llvm/lib/Target/Nios2/MCTargetDesc/Nios2AsmBackend.cpp
+++ /dev/null
@@ -1,130 +0,0 @@
-//===-- Nios2AsmBackend.cpp - Nios2 Asm Backend --------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file implements the Nios2AsmBackend class.
-//
-//===----------------------------------------------------------------------===//
-//
-
-#include "MCTargetDesc/Nios2AsmBackend.h"
-#include "MCTargetDesc/Nios2FixupKinds.h"
-#include "MCTargetDesc/Nios2MCTargetDesc.h"
-#include "llvm/MC/MCAssembler.h"
-#include "llvm/MC/MCELFObjectWriter.h"
-#include "llvm/MC/MCFixupKindInfo.h"
-#include "llvm/MC/MCObjectWriter.h"
-#include "llvm/MC/MCSubtargetInfo.h"
-
-using namespace llvm;
-
-// Prepare value for the target space for it
-static unsigned adjustFixupValue(const MCFixup &Fixup, uint64_t Value) {
-
- unsigned Kind = Fixup.getKind();
-
- // Add/subtract and shift
- switch (Kind) {
- default:
- return 0;
- case Nios2::fixup_Nios2_LO16:
- break;
- case Nios2::fixup_Nios2_HI16:
- // Get the higher 16-bits. Also add 1 if bit 15 is 1.
- Value = ((Value + 0x8000) >> 16) & 0xffff;
- break;
- }
-
- return Value;
-}
-
-// Calculate index for Nios2 specific little endian byte order
-static unsigned calculateLEIndex(unsigned i) {
- assert(i <= 3 && "Index out of range!");
-
- return (1 - i / 2) * 2 + i % 2;
-}
-
-/// ApplyFixup - Apply the \p Value for given \p Fixup into the provided
-/// data fragment, at the offset specified by the fixup and following the
-/// fixup kind as appropriate.
-void Nios2AsmBackend::applyFixup(const MCAssembler &Asm, const MCFixup &Fixup,
- const MCValue &Target,
- MutableArrayRef<char> Data, uint64_t Value,
- bool IsResolved) const {
- MCFixupKind Kind = Fixup.getKind();
- Value = adjustFixupValue(Fixup, Value);
-
- if (!Value)
- return; // Doesn't change encoding.
-
- // Where do we start in the object
- unsigned Offset = Fixup.getOffset();
- // Number of bytes we need to fixup
- unsigned NumBytes = (getFixupKindInfo(Kind).TargetSize + 7) / 8;
- // Grab current value, if any, from bits.
- uint64_t CurVal = 0;
-
- for (unsigned i = 0; i != NumBytes; ++i) {
- unsigned Idx = calculateLEIndex(i);
- CurVal |= (uint64_t)((uint8_t)Data[Offset + Idx]) << (i * 8);
- }
-
- uint64_t Mask = ((uint64_t)(-1) >> (64 - getFixupKindInfo(Kind).TargetSize));
- CurVal |= Value & Mask;
-
- // Write out the fixed up bytes back to the code/data bits.
- for (unsigned i = 0; i != NumBytes; ++i) {
- unsigned Idx = calculateLEIndex(i);
- Data[Offset + Idx] = (uint8_t)((CurVal >> (i * 8)) & 0xff);
- }
-}
-
-Optional<MCFixupKind> Nios2AsmBackend::getFixupKind(StringRef Name) const {
- return StringSwitch<Optional<MCFixupKind>>(Name)
- .Case("R_NIOS2_NONE", (MCFixupKind)Nios2::fixup_Nios2_32)
- .Case("R_NIOS2_32", FK_Data_4)
- .Default(MCAsmBackend::getFixupKind(Name));
-}
-
-//@getFixupKindInfo {
-const MCFixupKindInfo &
-Nios2AsmBackend::getFixupKindInfo(MCFixupKind Kind) const {
- const static MCFixupKindInfo Infos[Nios2::NumTargetFixupKinds] = {
- // This table *must* be in same the order of fixup_* kinds in
- // Nios2FixupKinds.h.
- //
- // name offset bits flags
- {"fixup_Nios2_32", 0, 32, 0},
- {"fixup_Nios2_HI16", 0, 16, 0},
- {"fixup_Nios2_LO16", 0, 16, 0}};
-
- if (Kind < FirstTargetFixupKind)
- return MCAsmBackend::getFixupKindInfo(Kind);
-
- assert(unsigned(Kind - FirstTargetFixupKind) < getNumFixupKinds() &&
- "Invalid kind!");
- return Infos[Kind - FirstTargetFixupKind];
-}
-
-std::unique_ptr<MCObjectTargetWriter>
-Nios2AsmBackend::createObjectTargetWriter() const {
- return createNios2ELFObjectWriter(MCELFObjectTargetWriter::getOSABI(OSType));
-}
-
-bool Nios2AsmBackend::writeNopData(raw_ostream &OS, uint64_t Count) const {
- return true;
-}
-
-// MCAsmBackend
-MCAsmBackend *llvm::createNios2AsmBackend(const Target &T,
- const MCSubtargetInfo &STI,
- const MCRegisterInfo &MRI,
- const MCTargetOptions &Options) {
- return new Nios2AsmBackend(T, STI.getTargetTriple().getOS());
-}
diff --git a/llvm/lib/Target/Nios2/MCTargetDesc/Nios2AsmBackend.h b/llvm/lib/Target/Nios2/MCTargetDesc/Nios2AsmBackend.h
deleted file mode 100644
index 1f114bd869b..00000000000
--- a/llvm/lib/Target/Nios2/MCTargetDesc/Nios2AsmBackend.h
+++ /dev/null
@@ -1,81 +0,0 @@
-//===-- Nios2AsmBackend.h - Nios2 Asm Backend ----------------------------===//
-//
-// 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 Nios2AsmBackend class.
-//
-//===----------------------------------------------------------------------===//
-//
-
-#ifndef LLVM_LIB_TARGET_NIOS2_MCTARGETDESC_NIOS2ASMBACKEND_H
-#define LLVM_LIB_TARGET_NIOS2_MCTARGETDESC_NIOS2ASMBACKEND_H
-
-#include "MCTargetDesc/Nios2FixupKinds.h"
-#include "llvm/ADT/Triple.h"
-#include "llvm/MC/MCAsmBackend.h"
-
-namespace llvm {
-
-class MCAssembler;
-struct MCFixupKindInfo;
-class Target;
-class MCObjectWriter;
-
-class Nios2AsmBackend : public MCAsmBackend {
- Triple::OSType OSType;
-
-public:
- Nios2AsmBackend(const Target &T, Triple::OSType OSType)
- : MCAsmBackend(support::little), OSType(OSType) {}
-
- std::unique_ptr<MCObjectTargetWriter>
- createObjectTargetWriter() const override;
-
- bool writeNopData(raw_ostream &OS, uint64_t Count) const override;
-
- void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup,
- const MCValue &Target, MutableArrayRef<char> Data,
- uint64_t Value, bool IsResolved) const override;
-
- Optional<MCFixupKind> getFixupKind(StringRef Name) const override;
- const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const override;
-
- unsigned getNumFixupKinds() const override {
- return Nios2::NumTargetFixupKinds;
- }
-
- /// MayNeedRelaxation - Check whether the given instruction may need
- /// relaxation.
- ///
- /// \param Inst - The instruction to test.
- bool mayNeedRelaxation(const MCInst &Inst) const override { return false; }
-
- /// fixupNeedsRelaxation - Target specific predicate for whether a given
- /// fixup requires the associated instruction to be relaxed.
- bool fixupNeedsRelaxation(const MCFixup &Fixup, uint64_t Value,
- const MCRelaxableFragment *DF,
- const MCAsmLayout &Layout) const override {
- // FIXME.
- llvm_unreachable("RelaxInstruction() unimplemented");
- return false;
- }
-
- /// RelaxInstruction - Relax the instruction in the given fragment
- /// to the next wider instruction.
- ///
- /// \param Inst - The instruction to relax, which may be the same
- /// as the output.
- /// \param [out] Res On return, the relaxed instruction.
- void relaxInstruction(const MCInst &Inst, const MCSubtargetInfo &STI,
- MCInst &Res) const override {}
-
-}; // class Nios2AsmBackend
-
-} // namespace llvm
-
-#endif
diff --git a/llvm/lib/Target/Nios2/MCTargetDesc/Nios2BaseInfo.h b/llvm/lib/Target/Nios2/MCTargetDesc/Nios2BaseInfo.h
deleted file mode 100644
index 225671ebc8d..00000000000
--- a/llvm/lib/Target/Nios2/MCTargetDesc/Nios2BaseInfo.h
+++ /dev/null
@@ -1,38 +0,0 @@
-//===-- Nios2BaseInfo.h - Top level definitions for NIOS2 MC ----*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file contains small standalone helper functions and enum definitions for
-// the Nios2 target useful for the compiler back-end and the MC libraries.
-//
-//===----------------------------------------------------------------------===//
-#ifndef LLVM_LIB_TARGET_NIOS2_MCTARGETDESC_NIOS2BASEINFO_H
-#define LLVM_LIB_TARGET_NIOS2_MCTARGETDESC_NIOS2BASEINFO_H
-
-namespace llvm {
-
-/// Nios2FG - This namespace holds all of the target specific flags that
-/// instruction info tracks.
-namespace Nios2FG {
-/// Target Operand Flag enum.
-enum TOF {
- //===------------------------------------------------------------------===//
- // Nios2 Specific MachineOperand flags.
-
- MO_NO_FLAG,
-
- /// MO_ABS_HI/LO - Represents the hi or low part of an absolute symbol
- /// address.
- MO_ABS_HI,
- MO_ABS_LO,
-
-};
-} // namespace Nios2FG
-} // namespace llvm
-
-#endif
diff --git a/llvm/lib/Target/Nios2/MCTargetDesc/Nios2ELFObjectWriter.cpp b/llvm/lib/Target/Nios2/MCTargetDesc/Nios2ELFObjectWriter.cpp
deleted file mode 100644
index db432d15120..00000000000
--- a/llvm/lib/Target/Nios2/MCTargetDesc/Nios2ELFObjectWriter.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-//===-- Nios2ELFObjectWriter.cpp - Nios2 ELF Writer -----------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "MCTargetDesc/Nios2FixupKinds.h"
-#include "MCTargetDesc/Nios2MCExpr.h"
-#include "MCTargetDesc/Nios2MCTargetDesc.h"
-#include "llvm/MC/MCELFObjectWriter.h"
-#include "llvm/MC/MCObjectWriter.h"
-
-using namespace llvm;
-
-namespace {
-class Nios2ELFObjectWriter : public MCELFObjectTargetWriter {
-public:
- Nios2ELFObjectWriter(uint8_t OSABI)
- : MCELFObjectTargetWriter(false, OSABI, ELF::EM_ALTERA_NIOS2, false) {}
-
- ~Nios2ELFObjectWriter() override;
-
- unsigned getRelocType(MCContext &Ctx, const MCValue &Target,
- const MCFixup &Fixup, bool IsPCRel) const override;
-};
-} // namespace
-
-Nios2ELFObjectWriter::~Nios2ELFObjectWriter() {}
-
-unsigned Nios2ELFObjectWriter::getRelocType(MCContext &Ctx,
- const MCValue &Target,
- const MCFixup &Fixup,
- bool IsPCRel) const {
- return 0;
-}
-
-std::unique_ptr<MCObjectTargetWriter>
-llvm::createNios2ELFObjectWriter(uint8_t OSABI) {
- return llvm::make_unique<Nios2ELFObjectWriter>(OSABI);
-}
diff --git a/llvm/lib/Target/Nios2/MCTargetDesc/Nios2FixupKinds.h b/llvm/lib/Target/Nios2/MCTargetDesc/Nios2FixupKinds.h
deleted file mode 100644
index c169a1b1937..00000000000
--- a/llvm/lib/Target/Nios2/MCTargetDesc/Nios2FixupKinds.h
+++ /dev/null
@@ -1,41 +0,0 @@
-//===-- Nios2FixupKinds.h - Nios2 Specific Fixup Entries --------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_LIB_TARGET_NIOS2_MCTARGETDESC_NIOS2FIXUPKINDS_H
-#define LLVM_LIB_TARGET_NIOS2_MCTARGETDESC_NIOS2FIXUPKINDS_H
-
-#include "llvm/MC/MCFixup.h"
-
-namespace llvm {
-namespace Nios2 {
-// Although most of the current fixup types reflect a unique relocation
-// one can have multiple fixup types for a given relocation and thus need
-// to be uniquely named.
-//
-// This table *must* be in the save order of
-// MCFixupKindInfo Infos[Nios2::NumTargetFixupKinds]
-// in Nios2AsmBackend.cpp.
-enum Fixups {
- // Pure upper 32 bit fixup resulting in - R_NIOS2_32.
- fixup_Nios2_32 = FirstTargetFixupKind,
-
- // Pure upper 16 bit fixup resulting in - R_NIOS2_HI16.
- fixup_Nios2_HI16,
-
- // Pure lower 16 bit fixup resulting in - R_NIOS2_LO16.
- fixup_Nios2_LO16,
-
- // Marker
- LastTargetFixupKind,
- NumTargetFixupKinds = LastTargetFixupKind - FirstTargetFixupKind
-};
-} // namespace Nios2
-} // namespace llvm
-
-#endif // LLVM_NIOS2_NIOS2FIXUPKINDS_H
diff --git a/llvm/lib/Target/Nios2/MCTargetDesc/Nios2MCAsmInfo.cpp b/llvm/lib/Target/Nios2/MCTargetDesc/Nios2MCAsmInfo.cpp
deleted file mode 100644
index e3c66e6776c..00000000000
--- a/llvm/lib/Target/Nios2/MCTargetDesc/Nios2MCAsmInfo.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-//===-- Nios2MCAsmInfo.cpp - Nios2 Asm Properties -------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file contains the declarations of the Nios2MCAsmInfo properties.
-//
-//===----------------------------------------------------------------------===//
-
-#include "Nios2MCAsmInfo.h"
-
-#include "llvm/ADT/Triple.h"
-
-using namespace llvm;
-
-void Nios2MCAsmInfo::anchor() {}
-
-Nios2MCAsmInfo::Nios2MCAsmInfo(const Triple &TheTriple) {
- if ((TheTriple.getArch() == Triple::nios2))
- IsLittleEndian = true; // the default of IsLittleEndian is true
-
- AlignmentIsInBytes = false;
- Data16bitsDirective = "\t.2byte\t";
- Data32bitsDirective = "\t.4byte\t";
- Data64bitsDirective = "\t.8byte\t";
- PrivateLabelPrefix = ".LC";
- CommentString = "#";
- ZeroDirective = "\t.space\t";
- GPRel32Directive = "\t.gpword\t";
- GPRel64Directive = "\t.gpdword\t";
- WeakRefDirective = "\t.weak\t";
- GlobalDirective = "\t.global\t";
- AscizDirective = "\t.string\t";
- UseAssignmentForEHBegin = true;
-
- SupportsDebugInformation = true;
- ExceptionsType = ExceptionHandling::DwarfCFI;
- DwarfRegNumForCFI = true;
- UsesELFSectionDirectiveForBSS = true;
-}
diff --git a/llvm/lib/Target/Nios2/MCTargetDesc/Nios2MCAsmInfo.h b/llvm/lib/Target/Nios2/MCTargetDesc/Nios2MCAsmInfo.h
deleted file mode 100644
index 0c81276f84d..00000000000
--- a/llvm/lib/Target/Nios2/MCTargetDesc/Nios2MCAsmInfo.h
+++ /dev/null
@@ -1,31 +0,0 @@
-//===-- Nios2MCAsmInfo.h - Nios2 Asm Info ----------------------*- C++ -*--===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file contains the declaration of the Nios2MCAsmInfo class.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_LIB_TARGET_NIOS2_MCTARGETDESC_NIOS2MCASMINFO_H
-#define LLVM_LIB_TARGET_NIOS2_MCTARGETDESC_NIOS2MCASMINFO_H
-
-#include "llvm/MC/MCAsmInfoELF.h"
-
-namespace llvm {
-class Triple;
-
-class Nios2MCAsmInfo : public MCAsmInfoELF {
- void anchor() override;
-
-public:
- explicit Nios2MCAsmInfo(const Triple &TheTriple);
-};
-
-} // namespace llvm
-
-#endif
diff --git a/llvm/lib/Target/Nios2/MCTargetDesc/Nios2MCExpr.cpp b/llvm/lib/Target/Nios2/MCTargetDesc/Nios2MCExpr.cpp
deleted file mode 100644
index 0f12c9e9337..00000000000
--- a/llvm/lib/Target/Nios2/MCTargetDesc/Nios2MCExpr.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-//===-- Nios2MCExpr.cpp - Nios2 specific MC expression classes ------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "Nios2.h"
-
-#include "Nios2MCExpr.h"
-#include "llvm/MC/MCAsmInfo.h"
-#include "llvm/MC/MCAssembler.h"
-#include "llvm/MC/MCContext.h"
-#include "llvm/MC/MCObjectStreamer.h"
-#include "llvm/MC/MCSymbolELF.h"
-
-using namespace llvm;
-
-#define DEBUG_TYPE "nios2mcexpr"
-
-const Nios2MCExpr *Nios2MCExpr::create(Nios2MCExpr::Nios2ExprKind Kind,
- const MCExpr *Expr, MCContext &Ctx) {
- return new (Ctx) Nios2MCExpr(Kind, Expr);
-}
-
-const Nios2MCExpr *Nios2MCExpr::create(const MCSymbol *Symbol,
- Nios2MCExpr::Nios2ExprKind Kind,
- MCContext &Ctx) {
- const MCSymbolRefExpr *MCSym =
- MCSymbolRefExpr::create(Symbol, MCSymbolRefExpr::VK_None, Ctx);
- return new (Ctx) Nios2MCExpr(Kind, MCSym);
-}
-
-void Nios2MCExpr::printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const {
-
- switch (Kind) {
- case CEK_None:
- case CEK_Special:
- llvm_unreachable("CEK_None and CEK_Special are invalid");
- break;
- case CEK_ABS_HI:
- OS << "%hiadj";
- break;
- case CEK_ABS_LO:
- OS << "%lo";
- break;
- }
-
- OS << '(';
- Expr->print(OS, MAI, true);
- OS << ')';
-}
-
-bool Nios2MCExpr::evaluateAsRelocatableImpl(MCValue &Res,
- const MCAsmLayout *Layout,
- const MCFixup *Fixup) const {
- return getSubExpr()->evaluateAsRelocatable(Res, Layout, Fixup);
-}
-
-void Nios2MCExpr::visitUsedExpr(MCStreamer &Streamer) const {
- Streamer.visitUsedExpr(*getSubExpr());
-}
-
-void Nios2MCExpr::fixELFSymbolsInTLSFixups(MCAssembler &Asm) const {
- switch (getKind()) {
- case CEK_None:
- case CEK_Special:
- llvm_unreachable("CEK_None and CEK_Special are invalid");
- break;
- case CEK_ABS_HI:
- case CEK_ABS_LO:
- break;
- }
-}
diff --git a/llvm/lib/Target/Nios2/MCTargetDesc/Nios2MCExpr.h b/llvm/lib/Target/Nios2/MCTargetDesc/Nios2MCExpr.h
deleted file mode 100644
index 5b49005eb64..00000000000
--- a/llvm/lib/Target/Nios2/MCTargetDesc/Nios2MCExpr.h
+++ /dev/null
@@ -1,60 +0,0 @@
-//===-- Nios2MCExpr.h - Nios2 specific MC expression classes ----*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_LIB_TARGET_NIOS2_MCTARGETDESC_NIOS2MCEXPR_H
-#define LLVM_LIB_TARGET_NIOS2_MCTARGETDESC_NIOS2MCEXPR_H
-
-#include "llvm/MC/MCAsmLayout.h"
-#include "llvm/MC/MCExpr.h"
-#include "llvm/MC/MCValue.h"
-
-namespace llvm {
-
-class Nios2MCExpr : public MCTargetExpr {
-public:
- enum Nios2ExprKind {
- CEK_None,
- CEK_ABS_HI,
- CEK_ABS_LO,
- CEK_Special,
- };
-
-private:
- const Nios2ExprKind Kind;
- const MCExpr *Expr;
-
- explicit Nios2MCExpr(Nios2ExprKind Kind, const MCExpr *Expr)
- : Kind(Kind), Expr(Expr) {}
-
-public:
- static const Nios2MCExpr *create(Nios2ExprKind Kind, const MCExpr *Expr,
- MCContext &Ctx);
- static const Nios2MCExpr *create(const MCSymbol *Symbol,
- Nios2MCExpr::Nios2ExprKind Kind,
- MCContext &Ctx);
-
- /// Get the kind of this expression.
- Nios2ExprKind getKind() const { return Kind; }
-
- /// Get the child of this expression.
- const MCExpr *getSubExpr() const { return Expr; }
-
- void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override;
- bool evaluateAsRelocatableImpl(MCValue &Res, const MCAsmLayout *Layout,
- const MCFixup *Fixup) const override;
- void visitUsedExpr(MCStreamer &Streamer) const override;
- MCFragment *findAssociatedFragment() const override {
- return getSubExpr()->findAssociatedFragment();
- }
-
- void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const override;
-};
-} // end namespace llvm
-
-#endif
diff --git a/llvm/lib/Target/Nios2/MCTargetDesc/Nios2MCTargetDesc.cpp b/llvm/lib/Target/Nios2/MCTargetDesc/Nios2MCTargetDesc.cpp
deleted file mode 100644
index e57b44d3cfd..00000000000
--- a/llvm/lib/Target/Nios2/MCTargetDesc/Nios2MCTargetDesc.cpp
+++ /dev/null
@@ -1,102 +0,0 @@
-//===-- Nios2MCTargetDesc.cpp - Nios2 Target Descriptions -----------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file provides Nios2 specific target descriptions.
-//
-//===----------------------------------------------------------------------===//
-
-#include "Nios2MCTargetDesc.h"
-#include "InstPrinter/Nios2InstPrinter.h"
-#include "Nios2MCAsmInfo.h"
-#include "Nios2TargetStreamer.h"
-#include "llvm/MC/MCInstrInfo.h"
-#include "llvm/MC/MCRegisterInfo.h"
-#include "llvm/MC/MCSubtargetInfo.h"
-#include "llvm/Support/TargetRegistry.h"
-
-using namespace llvm;
-
-#define GET_INSTRINFO_MC_DESC
-#include "Nios2GenInstrInfo.inc"
-
-#define GET_SUBTARGETINFO_MC_DESC
-#include "Nios2GenSubtargetInfo.inc"
-
-#define GET_REGINFO_MC_DESC
-#include "Nios2GenRegisterInfo.inc"
-
-static MCInstrInfo *createNios2MCInstrInfo() {
- MCInstrInfo *X = new MCInstrInfo();
- InitNios2MCInstrInfo(X); // defined in Nios2GenInstrInfo.inc
- return X;
-}
-
-static MCRegisterInfo *createNios2MCRegisterInfo(const Triple &TT) {
- MCRegisterInfo *X = new MCRegisterInfo();
- InitNios2MCRegisterInfo(X, Nios2::R15); // defined in Nios2GenRegisterInfo.inc
- return X;
-}
-
-static MCSubtargetInfo *
-createNios2MCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS) {
- if (CPU.empty() || CPU == "generic")
- CPU = "nios2r1";
- return createNios2MCSubtargetInfoImpl(TT, CPU, FS);
- // createNios2MCSubtargetInfoImpl defined in Nios2GenSubtargetInfo.inc
-}
-
-static MCAsmInfo *createNios2MCAsmInfo(const MCRegisterInfo &MRI,
- const Triple &TT) {
- MCAsmInfo *MAI = new Nios2MCAsmInfo(TT);
-
- unsigned SP = MRI.getDwarfRegNum(Nios2::SP, true);
- MCCFIInstruction Inst = MCCFIInstruction::createDefCfa(nullptr, SP, 0);
- MAI->addInitialFrameState(Inst);
-
- return MAI;
-}
-
-static MCInstPrinter *createNios2MCInstPrinter(const Triple &T,
- unsigned SyntaxVariant,
- const MCAsmInfo &MAI,
- const MCInstrInfo &MII,
- const MCRegisterInfo &MRI) {
- return new Nios2InstPrinter(MAI, MII, MRI);
-}
-
-static MCTargetStreamer *createNios2AsmTargetStreamer(MCStreamer &S,
- formatted_raw_ostream &OS,
- MCInstPrinter *InstPrint,
- bool isVerboseAsm) {
- return new Nios2TargetAsmStreamer(S, OS);
-}
-
-extern "C" void LLVMInitializeNios2TargetMC() {
- Target *T = &getTheNios2Target();
-
- // Register the MC asm info.
- RegisterMCAsmInfoFn X(*T, createNios2MCAsmInfo);
-
- // Register the MC instruction info.
- TargetRegistry::RegisterMCInstrInfo(*T, createNios2MCInstrInfo);
-
- // Register the MC register info.
- TargetRegistry::RegisterMCRegInfo(*T, createNios2MCRegisterInfo);
-
- // Register the asm target streamer.
- TargetRegistry::RegisterAsmTargetStreamer(*T, createNios2AsmTargetStreamer);
-
- // Register the MC subtarget info.
- TargetRegistry::RegisterMCSubtargetInfo(*T, createNios2MCSubtargetInfo);
- // Register the MCInstPrinter.
- TargetRegistry::RegisterMCInstPrinter(*T, createNios2MCInstPrinter);
-
- // Register the asm backend.
- TargetRegistry::RegisterMCAsmBackend(*T, createNios2AsmBackend);
-}
diff --git a/llvm/lib/Target/Nios2/MCTargetDesc/Nios2MCTargetDesc.h b/llvm/lib/Target/Nios2/MCTargetDesc/Nios2MCTargetDesc.h
deleted file mode 100644
index a7c4b16c6a3..00000000000
--- a/llvm/lib/Target/Nios2/MCTargetDesc/Nios2MCTargetDesc.h
+++ /dev/null
@@ -1,52 +0,0 @@
-//===-- Nios2MCTargetDesc.h - Nios2 Target Descriptions ---------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file provides Nios2 specific target descriptions.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_LIB_TARGET_NIOS2_MCTARGETDESC_NIOS2MCTARGETDESC_H
-#define LLVM_LIB_TARGET_NIOS2_MCTARGETDESC_NIOS2MCTARGETDESC_H
-
-#include <memory>
-
-namespace llvm {
-class MCAsmBackend;
-class MCObjectTargetWriter;
-class MCRegisterInfo;
-class MCSubtargetInfo;
-class MCTargetOptions;
-class Target;
-class Triple;
-class StringRef;
-class raw_pwrite_stream;
-
-Target &getTheNios2Target();
-
-MCAsmBackend *createNios2AsmBackend(const Target &T, const MCSubtargetInfo &STI,
- const MCRegisterInfo &MRI,
- const MCTargetOptions &Options);
-
-std::unique_ptr<MCObjectTargetWriter> createNios2ELFObjectWriter(uint8_t OSABI);
-
-} // namespace llvm
-
-// Defines symbolic names for Nios2 registers. This defines a mapping from
-// register name to register number.
-#define GET_REGINFO_ENUM
-#include "Nios2GenRegisterInfo.inc"
-
-// Defines symbolic names for the Nios2 instructions.
-#define GET_INSTRINFO_ENUM
-#include "Nios2GenInstrInfo.inc"
-
-#define GET_SUBTARGETINFO_ENUM
-#include "Nios2GenSubtargetInfo.inc"
-
-#endif
diff --git a/llvm/lib/Target/Nios2/MCTargetDesc/Nios2TargetStreamer.cpp b/llvm/lib/Target/Nios2/MCTargetDesc/Nios2TargetStreamer.cpp
deleted file mode 100644
index 795fd0084aa..00000000000
--- a/llvm/lib/Target/Nios2/MCTargetDesc/Nios2TargetStreamer.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-//===-- Nios2TargetStreamer.cpp - Nios2 Target Streamer Methods -----------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file provides Nios2 specific target streamer methods.
-//
-//===----------------------------------------------------------------------===//
-
-#include "Nios2TargetStreamer.h"
-
-using namespace llvm;
-
-Nios2TargetStreamer::Nios2TargetStreamer(MCStreamer &S) : MCTargetStreamer(S) {}
-
-Nios2TargetAsmStreamer::Nios2TargetAsmStreamer(MCStreamer &S,
- formatted_raw_ostream &OS)
- : Nios2TargetStreamer(S) {}
diff --git a/llvm/lib/Target/Nios2/Nios2.h b/llvm/lib/Target/Nios2/Nios2.h
deleted file mode 100644
index d6c5c1e4966..00000000000
--- a/llvm/lib/Target/Nios2/Nios2.h
+++ /dev/null
@@ -1,35 +0,0 @@
-//===-- Nios2.h - Top-level interface for Nios2 representation --*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file contains the entry points for global functions defined in
-// the LLVM Nios2 back-end.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_LIB_TARGET_NIOS2_NIOS2_H
-#define LLVM_LIB_TARGET_NIOS2_NIOS2_H
-
-#include "MCTargetDesc/Nios2MCTargetDesc.h"
-#include "llvm/Target/TargetMachine.h"
-
-namespace llvm {
-class FunctionPass;
-class formatted_raw_ostream;
-class Nios2TargetMachine;
-class AsmPrinter;
-class MachineInstr;
-class MCInst;
-
-FunctionPass *createNios2ISelDag(Nios2TargetMachine &TM,
- CodeGenOpt::Level OptLevel);
-void LowerNios2MachineInstToMCInst(const MachineInstr *MI, MCInst &OutMI,
- AsmPrinter &AP);
-} // namespace llvm
-
-#endif
diff --git a/llvm/lib/Target/Nios2/Nios2.td b/llvm/lib/Target/Nios2/Nios2.td
deleted file mode 100644
index 1acf4c70c42..00000000000
--- a/llvm/lib/Target/Nios2/Nios2.td
+++ /dev/null
@@ -1,59 +0,0 @@
-//===-- Nios2.td - Describe the Nios2 Target Machine -------*- tablegen -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-//===----------------------------------------------------------------------===//
-// Calling Conv, Instruction Descriptions
-//===----------------------------------------------------------------------===//
-
-include "llvm/Target/Target.td"
-include "Nios2RegisterInfo.td"
-include "Nios2Schedule.td"
-include "Nios2InstrInfo.td"
-include "Nios2CallingConv.td"
-
-//===----------------------------------------------------------------------===//
-// Nios2 Subtarget features
-//===----------------------------------------------------------------------===//
-def FeatureNios2r1 : SubtargetFeature<"nios2r1", "Nios2ArchVersion",
- "Nios2r1", "Nios2 R1 ISA Support">;
-def FeatureNios2r2 : SubtargetFeature<"nios2r2", "Nios2ArchVersion",
- "Nios2r2", "Nios2 R2 ISA Support">;
-
-//===----------------------------------------------------------------------===//
-// Nios2 processors supported.
-//===----------------------------------------------------------------------===//
-
-class Proc<string Name, list<SubtargetFeature> Features>
- : Processor<Name, Nios2GenericItineraries, Features>;
-
-def : Proc<"nios2r1", [FeatureNios2r1]>;
-def : Proc<"nios2r2", [FeatureNios2r2]>;
-
-def Nios2InstrInfo : InstrInfo;
-
-def Nios2AsmParser : AsmParser {
- let ShouldEmitMatchRegisterName = 0;
-}
-
-//===----------------------------------------------------------------------===//
-// Declare the target which we are implementing
-//===----------------------------------------------------------------------===//
-
-def Nios2AsmWriter : AsmWriter {
- string AsmWriterClassName = "InstPrinter";
- int PassSubtarget = 1;
- int Variant = 0;
-}
-
-def Nios2 : Target {
-// def Nios2InstrInfo : InstrInfo as before.
- let InstructionSet = Nios2InstrInfo;
- let AssemblyParsers = [Nios2AsmParser];
- let AssemblyWriters = [Nios2AsmWriter];
-}
diff --git a/llvm/lib/Target/Nios2/Nios2AsmPrinter.cpp b/llvm/lib/Target/Nios2/Nios2AsmPrinter.cpp
deleted file mode 100644
index 1abf1959177..00000000000
--- a/llvm/lib/Target/Nios2/Nios2AsmPrinter.cpp
+++ /dev/null
@@ -1,153 +0,0 @@
-//===-- Nios2AsmPrinter.cpp - Nios2 LLVM Assembly Printer -----------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file contains a printer that converts from our internal representation
-// of machine-dependent LLVM code to GAS-format NIOS2 assembly language.
-//
-//===----------------------------------------------------------------------===//
-
-#include "InstPrinter/Nios2InstPrinter.h"
-#include "MCTargetDesc/Nios2BaseInfo.h"
-#include "Nios2.h"
-#include "Nios2TargetMachine.h"
-#include "llvm/CodeGen/AsmPrinter.h"
-#include "llvm/MC/MCStreamer.h"
-#include "llvm/Support/TargetRegistry.h"
-
-using namespace llvm;
-
-#define DEBUG_TYPE "nios2-asm-printer"
-
-namespace {
-
-class Nios2AsmPrinter : public AsmPrinter {
-
-public:
- explicit Nios2AsmPrinter(TargetMachine &TM,
- std::unique_ptr<MCStreamer> Streamer)
- : AsmPrinter(TM, std::move(Streamer)) {}
-
- StringRef getPassName() const override { return "Nios2 Assembly Printer"; }
-
- //- EmitInstruction() must exists or will have run time error.
- void EmitInstruction(const MachineInstr *MI) override;
- bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
- unsigned AsmVariant, const char *ExtraCode,
- raw_ostream &O) override;
- bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNum,
- unsigned AsmVariant, const char *ExtraCode,
- raw_ostream &O) override;
- void printOperand(const MachineInstr *MI, int opNum, raw_ostream &O);
- void EmitFunctionEntryLabel() override;
-};
-} // namespace
-
-//- EmitInstruction() must exists or will have run time error.
-void Nios2AsmPrinter::EmitInstruction(const MachineInstr *MI) {
-
- // Print out both ordinary instruction and boudle instruction
- MachineBasicBlock::const_instr_iterator I = MI->getIterator();
- MachineBasicBlock::const_instr_iterator E = MI->getParent()->instr_end();
-
- do {
-
- if (I->isPseudo()) {
- llvm_unreachable("Pseudo opcode found in EmitInstruction()");
- }
-
- MCInst TmpInst0;
- LowerNios2MachineInstToMCInst(&*I, TmpInst0, *this);
- EmitToStreamer(*OutStreamer, TmpInst0);
- } while ((++I != E) && I->isInsideBundle()); // Delay slot check
-}
-
-// .type main,@function
-//-> .ent main # @main
-// main:
-void Nios2AsmPrinter::EmitFunctionEntryLabel() {
- OutStreamer->EmitLabel(CurrentFnSym);
-}
-
-// Print out an operand for an inline asm expression.
-bool Nios2AsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNum,
- unsigned AsmVariant,
- const char *ExtraCode, raw_ostream &O) {
- printOperand(MI, OpNum, O);
- return false;
-}
-
-bool Nios2AsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI,
- unsigned OpNum, unsigned AsmVariant,
- const char *ExtraCode,
- raw_ostream &O) {
- if (ExtraCode && ExtraCode[0])
- return true; // Unknown modifier
-
- const MachineOperand &MO = MI->getOperand(OpNum);
- assert(MO.isReg() && "unexpected inline asm memory operand");
- O << "($" << Nios2InstPrinter::getRegisterName(MO.getReg()) << ")";
-
- return false;
-}
-
-void Nios2AsmPrinter::printOperand(const MachineInstr *MI, int opNum,
- raw_ostream &O) {
- const MachineOperand &MO = MI->getOperand(opNum);
- bool closeP = false;
-
- if (MO.getTargetFlags())
- closeP = true;
-
- switch (MO.getTargetFlags()) {
- case Nios2FG::MO_ABS_HI:
- O << "%hiadj(";
- break;
- case Nios2FG::MO_ABS_LO:
- O << "%lo(";
- break;
- }
-
- switch (MO.getType()) {
- case MachineOperand::MO_Register:
- O << '$'
- << StringRef(Nios2InstPrinter::getRegisterName(MO.getReg())).lower();
- break;
-
- case MachineOperand::MO_Immediate:
- O << MO.getImm();
- break;
-
- case MachineOperand::MO_MachineBasicBlock:
- MO.getMBB()->getSymbol()->print(O, MAI);
- return;
-
- case MachineOperand::MO_GlobalAddress:
- getSymbol(MO.getGlobal())->print(O, MAI);
- break;
-
- case MachineOperand::MO_BlockAddress:
- O << GetBlockAddressSymbol(MO.getBlockAddress())->getName();
- break;
-
- case MachineOperand::MO_ExternalSymbol:
- O << MO.getSymbolName();
- break;
-
- default:
- llvm_unreachable("<unknown operand type>");
- }
-
- if (closeP)
- O << ")";
-}
-
-// Force static initialization.
-extern "C" void LLVMInitializeNios2AsmPrinter() {
- RegisterAsmPrinter<Nios2AsmPrinter> X(getTheNios2Target());
-}
diff --git a/llvm/lib/Target/Nios2/Nios2CallingConv.td b/llvm/lib/Target/Nios2/Nios2CallingConv.td
deleted file mode 100644
index f0b172f8422..00000000000
--- a/llvm/lib/Target/Nios2/Nios2CallingConv.td
+++ /dev/null
@@ -1,34 +0,0 @@
-//===- Nios2CallingConv.td - Calling Conventions for Nios2 -*- tablegen -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-// This describes the calling conventions for Nios2 architecture.
-//===----------------------------------------------------------------------===//
-
-/// CCIfSubtarget - Match if the current subtarget has a feature F.
-class CCIfSubtarget<string F, CCAction A>:
- CCIf<!strconcat("State.getTarget().getSubtarget<Nios2Subtarget>().", F), A>;
-
-def CC_Nios2 : CallingConv<[
- // i32 f32 arguments get passed in integer registers if there is space.
- CCIfType<[i32, f32], CCAssignToReg<[R4, R5, R6, R7]>>,
-
- // Alternatively, they are assigned to the stack in 4-byte aligned units.
- CCAssignToStack<4, 4>
-]>;
-
-def RetCC_Nios2EABI : CallingConv<[
- // i32 are returned in registers R2, R3
- CCIfType<[i32], CCAssignToReg<[R2, R3]>>,
- // In case of floating point (FPH2 instr.) also use the same register set
- CCIfType<[f32], CCAssignToReg<[R2, R3]>>,
- CCIfByVal<CCPassByVal<4, 4>>,
- // Stack parameter slots for i32 is 32-bit words and 4-byte aligned.
- CCIfType<[i32], CCAssignToStack<4, 4>>
-]>;
-
-def CSR : CalleeSavedRegs<(add RA, FP, (sequence "R%u", 16, 23))>;
diff --git a/llvm/lib/Target/Nios2/Nios2FrameLowering.cpp b/llvm/lib/Target/Nios2/Nios2FrameLowering.cpp
deleted file mode 100644
index 6fb28a6fd63..00000000000
--- a/llvm/lib/Target/Nios2/Nios2FrameLowering.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
-//===-- Nios2FrameLowering.cpp - Nios2 Frame Information ------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file contains the Nios2 implementation of TargetFrameLowering class.
-//
-//===----------------------------------------------------------------------===//
-
-#include "Nios2FrameLowering.h"
-
-#include "Nios2Subtarget.h"
-#include "llvm/CodeGen/MachineFunction.h"
-
-using namespace llvm;
-
-bool Nios2FrameLowering::hasFP(const MachineFunction &MF) const { return true; }
-
-void Nios2FrameLowering::emitPrologue(MachineFunction &MF,
- MachineBasicBlock &MBB) const {}
-
-void Nios2FrameLowering::emitEpilogue(MachineFunction &MF,
- MachineBasicBlock &MBB) const {}
diff --git a/llvm/lib/Target/Nios2/Nios2FrameLowering.h b/llvm/lib/Target/Nios2/Nios2FrameLowering.h
deleted file mode 100644
index 4ffb01dda36..00000000000
--- a/llvm/lib/Target/Nios2/Nios2FrameLowering.h
+++ /dev/null
@@ -1,39 +0,0 @@
-//===-- Nios2FrameLowering.h - Define frame lowering for Nios2 --*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-//
-//
-//===----------------------------------------------------------------------===//
-#ifndef LLVM_LIB_TARGET_NIOS2_NIOS2FRAMELOWERING_H
-#define LLVM_LIB_TARGET_NIOS2_NIOS2FRAMELOWERING_H
-
-#include "Nios2.h"
-#include "llvm/CodeGen/TargetFrameLowering.h"
-
-namespace llvm {
-class Nios2Subtarget;
-
-class Nios2FrameLowering : public TargetFrameLowering {
-protected:
- const Nios2Subtarget &STI;
-
-public:
- explicit Nios2FrameLowering(const Nios2Subtarget &sti)
- : TargetFrameLowering(TargetFrameLowering::StackGrowsDown, 4, 0, 4),
- STI(sti) {}
-
- bool hasFP(const MachineFunction &MF) const override;
- /// emitProlog/emitEpilog - These methods insert prolog and epilog code into
- /// the function.
- void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
- void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
-};
-} // namespace llvm
-
-#endif
diff --git a/llvm/lib/Target/Nios2/Nios2ISelDAGToDAG.cpp b/llvm/lib/Target/Nios2/Nios2ISelDAGToDAG.cpp
deleted file mode 100644
index 5f967946611..00000000000
--- a/llvm/lib/Target/Nios2/Nios2ISelDAGToDAG.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-//===-- Nios2ISelDAGToDAG.cpp - A Dag to Dag Inst Selector for Nios2 ------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file defines an instruction selector for the NIOS2 target.
-//
-//===----------------------------------------------------------------------===//
-
-#include "Nios2.h"
-#include "Nios2TargetMachine.h"
-#include "llvm/CodeGen/SelectionDAGISel.h"
-#include "llvm/Support/Debug.h"
-using namespace llvm;
-
-#define DEBUG_TYPE "nios2-isel"
-
-//===----------------------------------------------------------------------===//
-// Instruction Selector Implementation
-//===----------------------------------------------------------------------===//
-
-//===----------------------------------------------------------------------===//
-// Nios2DAGToDAGISel - NIOS2 specific code to select NIOS2 machine
-// instructions for SelectionDAG operations.
-//===----------------------------------------------------------------------===//
-
-namespace {
-
-class Nios2DAGToDAGISel : public SelectionDAGISel {
- /// Subtarget - Keep a pointer to the Nios2 Subtarget around so that we can
- /// make the right decision when generating code for different targets.
- const Nios2Subtarget *Subtarget;
-
-public:
- explicit Nios2DAGToDAGISel(Nios2TargetMachine &TM, CodeGenOpt::Level OL)
- : SelectionDAGISel(TM, OL) {}
-
- bool runOnMachineFunction(MachineFunction &MF) override {
- Subtarget = &MF.getSubtarget<Nios2Subtarget>();
- return SelectionDAGISel::runOnMachineFunction(MF);
- }
-
- void Select(SDNode *N) override;
-
- // Pass Name
- StringRef getPassName() const override {
- return "NIOS2 DAG->DAG Pattern Instruction Selection";
- }
-
-#include "Nios2GenDAGISel.inc"
-};
-} // namespace
-
-// Select instructions not customized! Used for
-// expanded, promoted and normal instructions
-void Nios2DAGToDAGISel::Select(SDNode *Node) {
-
- // If we have a custom node, we already have selected!
- if (Node->isMachineOpcode()) {
- LLVM_DEBUG(errs() << "== "; Node->dump(CurDAG); errs() << "\n");
- Node->setNodeId(-1);
- return;
- }
-
- // Select the default instruction
- SelectCode(Node);
-}
-
-FunctionPass *llvm::createNios2ISelDag(Nios2TargetMachine &TM,
- CodeGenOpt::Level OptLevel) {
- return new Nios2DAGToDAGISel(TM, OptLevel);
-}
diff --git a/llvm/lib/Target/Nios2/Nios2ISelLowering.cpp b/llvm/lib/Target/Nios2/Nios2ISelLowering.cpp
deleted file mode 100644
index 008ce157072..00000000000
--- a/llvm/lib/Target/Nios2/Nios2ISelLowering.cpp
+++ /dev/null
@@ -1,188 +0,0 @@
-//===-- Nios2ISelLowering.cpp - Nios2 DAG Lowering Implementation ---------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file implements the interfaces that Nios2 uses to lower LLVM code into a
-// selection DAG.
-//
-//===----------------------------------------------------------------------===//
-
-#include "Nios2ISelLowering.h"
-#include "Nios2MachineFunction.h"
-#include "Nios2TargetMachine.h"
-#include "llvm/CodeGen/CallingConvLower.h"
-#include "llvm/CodeGen/MachineRegisterInfo.h"
-
-using namespace llvm;
-
-//===----------------------------------------------------------------------===//
-// Calling Convention Implementation
-//===----------------------------------------------------------------------===//
-
-#include "Nios2GenCallingConv.inc"
-
-SDValue
-Nios2TargetLowering::LowerReturn(SDValue Chain, CallingConv::ID CallConv,
- bool IsVarArg,
- const SmallVectorImpl<ISD::OutputArg> &Outs,
- const SmallVectorImpl<SDValue> &OutVals,
- const SDLoc &DL, SelectionDAG &DAG) const {
- // CCValAssign - represent the assignment of
- // the return value to a location
- SmallVector<CCValAssign, 16> RVLocs;
- MachineFunction &MF = DAG.getMachineFunction();
-
- // CCState - Info about the registers and stack slot.
- CCState CCInfo(CallConv, IsVarArg, MF, RVLocs, *DAG.getContext());
- // Analyze return values.
- CCInfo.CheckReturn(Outs, RetCC_Nios2EABI);
-
- SDValue Flag;
- SmallVector<SDValue, 4> RetOps(1, Chain);
-
- // Copy the result values into the output registers.
- for (unsigned i = 0; i != RVLocs.size(); ++i) {
- SDValue Val = OutVals[i];
- CCValAssign &VA = RVLocs[i];
- assert(VA.isRegLoc() && "Can only return in registers!");
-
- if (RVLocs[i].getValVT() != RVLocs[i].getLocVT())
- Val = DAG.getNode(ISD::BITCAST, DL, RVLocs[i].getLocVT(), Val);
-
- Chain = DAG.getCopyToReg(Chain, DL, VA.getLocReg(), Val, Flag);
-
- // Guarantee that all emitted copies are stuck together with flags.
- Flag = Chain.getValue(1);
- RetOps.push_back(DAG.getRegister(VA.getLocReg(), VA.getLocVT()));
- }
-
- if (Flag.getNode())
- RetOps.push_back(Flag);
-
- return DAG.getNode(Nios2ISD::Ret, DL, MVT::Other, RetOps);
-}
-
-// addLiveIn - This helper function adds the specified physical register to the
-// MachineFunction as a live in value. It also creates a corresponding
-// virtual register for it.
-static unsigned addLiveIn(MachineFunction &MF, unsigned PReg,
- const TargetRegisterClass *RC) {
- unsigned VReg = MF.getRegInfo().createVirtualRegister(RC);
- MF.getRegInfo().addLiveIn(PReg, VReg);
- return VReg;
-}
-
-//===----------------------------------------------------------------------===//
-// Formal Arguments Calling Convention Implementation
-//===----------------------------------------------------------------------===//
-
-// LowerFormalArguments - transform physical registers into virtual registers
-// and generate load operations for arguments places on the stack.
-SDValue Nios2TargetLowering::LowerFormalArguments(
- SDValue Chain, CallingConv::ID CallConv, bool IsVarArg,
- const SmallVectorImpl<ISD::InputArg> &Ins, const SDLoc &DL,
- SelectionDAG &DAG, SmallVectorImpl<SDValue> &InVals) const {
- MachineFunction &MF = DAG.getMachineFunction();
- MachineFrameInfo &MFI = MF.getFrameInfo();
-
- // Assign locations to all of the incoming arguments.
- SmallVector<CCValAssign, 16> ArgLocs;
- CCState CCInfo(CallConv, IsVarArg, DAG.getMachineFunction(), ArgLocs,
- *DAG.getContext());
-
- CCInfo.AnalyzeFormalArguments(Ins, CC_Nios2);
-
- // Used with vargs to acumulate store chains.
- std::vector<SDValue> OutChains;
-
- for (unsigned i = 0, e = ArgLocs.size(); i != e; ++i) {
- CCValAssign &VA = ArgLocs[i];
-
- EVT ValVT = VA.getValVT();
-
- // Arguments stored on registers
- if (VA.isRegLoc()) {
- MVT RegVT = VA.getLocVT();
- unsigned ArgReg = VA.getLocReg();
- const TargetRegisterClass *RC = getRegClassFor(RegVT);
-
- // Transform the arguments stored on
- // physical registers into virtual ones
- unsigned Reg = addLiveIn(MF, ArgReg, RC);
- SDValue ArgValue = DAG.getCopyFromReg(Chain, DL, Reg, RegVT);
-
- // If this is an 8 or 16-bit value, it has been passed promoted
- // to 32 bits. Insert an assert[sz]ext to capture this, then
- // truncate to the right size.
- if (VA.getLocInfo() != CCValAssign::Full) {
- unsigned Opcode = 0;
- if (VA.getLocInfo() == CCValAssign::SExt)
- Opcode = ISD::AssertSext;
- else if (VA.getLocInfo() == CCValAssign::ZExt)
- Opcode = ISD::AssertZext;
- if (Opcode)
- ArgValue =
- DAG.getNode(Opcode, DL, RegVT, ArgValue, DAG.getValueType(ValVT));
- ArgValue = DAG.getNode(ISD::TRUNCATE, DL, ValVT, ArgValue);
- }
-
- // Handle floating point arguments passed in integer registers.
- if ((RegVT == MVT::i32 && ValVT == MVT::f32) ||
- (RegVT == MVT::i64 && ValVT == MVT::f64))
- ArgValue = DAG.getNode(ISD::BITCAST, DL, ValVT, ArgValue);
- InVals.push_back(ArgValue);
- } else { // VA.isRegLoc()
- MVT LocVT = VA.getLocVT();
-
- // sanity check
- assert(VA.isMemLoc());
-
- // The stack pointer offset is relative to the caller stack frame.
- int FI = MFI.CreateFixedObject(ValVT.getSizeInBits() / 8,
- VA.getLocMemOffset(), true);
-
- // Create load nodes to retrieve arguments from the stack
- SDValue FIN = DAG.getFrameIndex(FI, getPointerTy(DAG.getDataLayout()));
- SDValue Load = DAG.getLoad(
- LocVT, DL, Chain, FIN,
- MachinePointerInfo::getFixedStack(DAG.getMachineFunction(), FI));
- InVals.push_back(Load);
- OutChains.push_back(Load.getValue(1));
- }
- }
- if (!OutChains.empty()) {
- OutChains.push_back(Chain);
- Chain = DAG.getNode(ISD::TokenFactor, DL, MVT::Other, OutChains);
- }
-
- return Chain;
-}
-
-//===----------------------------------------------------------------------===//
-// TargetLowering Implementation
-//===----------------------------------------------------------------------===//
-
-Nios2TargetLowering::Nios2TargetLowering(const TargetMachine &TM,
- const Nios2Subtarget &STI)
- : TargetLowering(TM), Subtarget(&STI) {
-
- addRegisterClass(MVT::i32, &Nios2::CPURegsRegClass);
- computeRegisterProperties(Subtarget->getRegisterInfo());
-}
-
-const char *Nios2TargetLowering::getTargetNodeName(unsigned Opcode) const {
- switch (Opcode) {
- case Nios2ISD::Hi:
- return "Nios2ISD::Hi";
- case Nios2ISD::Lo:
- return "Nios2ISD::Lo";
- case Nios2ISD::Ret:
- return "Nios2ISD::Ret";
- }
- return nullptr;
-}
diff --git a/llvm/lib/Target/Nios2/Nios2ISelLowering.h b/llvm/lib/Target/Nios2/Nios2ISelLowering.h
deleted file mode 100644
index c3c8179054b..00000000000
--- a/llvm/lib/Target/Nios2/Nios2ISelLowering.h
+++ /dev/null
@@ -1,63 +0,0 @@
-//===-- Nios2ISelLowering.h - Nios2 DAG Lowering Interface ------*- 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 interfaces that Nios2 uses to lower LLVM code into a
-// selection DAG.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_LIB_TARGET_NIOS2_NIOS2ISELLOWERING_H
-#define LLVM_LIB_TARGET_NIOS2_NIOS2ISELLOWERING_H
-
-#include "Nios2.h"
-#include "llvm/CodeGen/TargetLowering.h"
-
-namespace llvm {
-class Nios2Subtarget;
-
-namespace Nios2ISD {
-enum NodeType {
- // Start the numbering from where ISD NodeType finishes.
- FIRST_NUMBER = ISD::BUILTIN_OP_END,
-
- // Get the Higher 16 bits from a 32-bit immediate
- // No relation with Nios2 Hi register
- Hi,
- // Get the Lower 16 bits from a 32-bit immediate
- // No relation with Nios2 Lo register
- Lo,
- // Return
- Ret
-};
-}
-
-class Nios2TargetLowering : public TargetLowering {
- const Nios2Subtarget *Subtarget;
-
-public:
- Nios2TargetLowering(const TargetMachine &TM, const Nios2Subtarget &STI);
-
- /// getTargetNodeName - This method returns the name of a target specific
- // DAG node.
- const char *getTargetNodeName(unsigned Opcode) const override;
-
- SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv,
- bool IsVarArg,
- const SmallVectorImpl<ISD::InputArg> &Ins,
- const SDLoc &dl, SelectionDAG &DAG,
- SmallVectorImpl<SDValue> &InVals) const override;
-
- SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
- const SmallVectorImpl<ISD::OutputArg> &Outs,
- const SmallVectorImpl<SDValue> &OutVals, const SDLoc &dl,
- SelectionDAG &DAG) const override;
-};
-} // end namespace llvm
-
-#endif // NIOS2_ISELLOWERING_H
diff --git a/llvm/lib/Target/Nios2/Nios2InstrFormats.td b/llvm/lib/Target/Nios2/Nios2InstrFormats.td
deleted file mode 100644
index f57bf03bba3..00000000000
--- a/llvm/lib/Target/Nios2/Nios2InstrFormats.td
+++ /dev/null
@@ -1,235 +0,0 @@
-//===-- Nios2InstrFormats.td - Nios2 Instruction Formats ---*- tablegen -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-//===----------------------------------------------------------------------===//
-// Describe NIOS2 instructions format
-//
-//
-//===----------------------------------------------------------------------===//
-
-// Format specifies the encoding used by the instruction. This is part of the
-// ad-hoc solution used to emit machine instruction encodings by our machine
-// code emitter.
-class Format<bits<6> val> {
- bits<6> Value = val;
-}
-
-def Pseudo : Format<0>;
-// Nios2 R1 instr formats:
-def FrmI : Format<1>;
-def FrmR : Format<2>;
-def FrmJ : Format<3>;
-def FrmOther : Format<4>; // Instruction w/ a custom format
-// Nios2 R2 instr 32-bit formats:
-def FrmL26 : Format<5>; // corresponds to J format in R1
-def FrmF2I16 : Format<6>; // corresponds to I format in R1
-def FrmF2X4I12 : Format<7>;
-def FrmF1X4I12 : Format<8>;
-def FrmF1X4L17 : Format<9>;
-def FrmF3X6L5 : Format<10>; // corresponds to R format in R1
-def FrmF2X6L10 : Format<11>;
-def FrmF3X6 : Format<12>; // corresponds to R format in R1
-def FrmF3X8 : Format<13>; // corresponds to custom format in R1
-// Nios2 R2 instr 16-bit formats:
-def FrmI10 : Format<14>;
-def FrmT1I7 : Format<15>;
-def FrmT2I4 : Format<16>;
-def FrmT1X1I6 : Format<17>;
-def FrmX1I7 : Format<18>;
-def FrmL5I4X1 : Format<19>;
-def FrmT2X1L3 : Format<20>;
-def FrmT2X1I3 : Format<21>;
-def FrmT3X1 : Format<22>;
-def FrmT2X3 : Format<23>;
-def FrmF1X1 : Format<24>;
-def FrmX2L5 : Format<25>;
-def FrmF1I5 : Format<26>;
-def FrmF2 : Format<27>;
-
-//===----------------------------------------------------------------------===//
-// Instruction Predicates:
-//===----------------------------------------------------------------------===//
-
-def isNios2r1 : Predicate<"Subtarget->isNios2r1()">;
-def isNios2r2 : Predicate<"Subtarget->isNios2r2()">;
-
-class PredicateControl {
- // Predicates related to specific target CPU features
- list<Predicate> FeaturePredicates = [];
- // Predicates for the instruction group membership in given ISA
- list<Predicate> InstrPredicates = [];
-
- list<Predicate> Predicates = !listconcat(FeaturePredicates, InstrPredicates);
-}
-
-//===----------------------------------------------------------------------===//
-// Base classes for 32-bit, 16-bit and pseudo instructions
-//===----------------------------------------------------------------------===//
-
-class Nios2Inst32<dag outs, dag ins, string asmstr, list<dag> pattern,
- InstrItinClass itin, Format f>: Instruction,
- PredicateControl {
- field bits<32> Inst;
- Format Form = f;
-
- let Namespace = "Nios2";
- let Size = 4;
-
- bits<6> Opcode = 0;
-
- // Bottom 6 bits are the 'opcode' field
- let Inst{5-0} = Opcode;
-
- let OutOperandList = outs;
- let InOperandList = ins;
-
- let AsmString = asmstr;
- let Pattern = pattern;
- let Itinerary = itin;
-
- // Attributes specific to Nios2 instructions:
-
- // TSFlags layout should be kept in sync with Nios2InstrInfo.h.
- let TSFlags{5-0} = Form.Value;
- let DecoderNamespace = "Nios2";
- field bits<32> SoftFail = 0;
-}
-
-class Nios2Pseudo<dag outs, dag ins, string asmstr, list<dag> pattern,
- InstrItinClass Itin = IIPseudo>:
- Nios2Inst32<outs, ins, asmstr, pattern, Itin, Pseudo> {
-
- let isCodeGenOnly = 1;
- let isPseudo = 1;
-}
-
-//===----------------------------------------------------------------------===//
-// Base classes for R1 and R2 instructions
-//===----------------------------------------------------------------------===//
-
-class Nios2R1Inst32<dag outs, dag ins, string asmstr, list<dag> pattern,
- InstrItinClass itin, Format f>:
- Nios2Inst32<outs, ins, asmstr, pattern, itin, f> {
- let DecoderNamespace = "Nios2";
- let InstrPredicates = [isNios2r1];
-}
-
-class Nios2R2Inst32<dag outs, dag ins, string asmstr, list<dag> pattern,
- InstrItinClass itin, Format f>:
- Nios2Inst32<outs, ins, asmstr, pattern, itin, f> {
- let DecoderNamespace = "Nios2r2";
- let InstrPredicates = [isNios2r2];
-}
-
-//===----------------------------------------------------------------------===//
-// Format I instruction class in Nios2 : <|A|B|immediate|opcode|>
-//===----------------------------------------------------------------------===//
-
-class FI<bits<6> op, dag outs, dag ins, string asmstr, list<dag> pattern,
- InstrItinClass itin>: Nios2R1Inst32<outs, ins, asmstr,
- pattern, itin, FrmI> {
-
- bits<5> rA;
- bits<5> rB;
- bits<16> imm;
-
- let Opcode = op;
-
- let Inst{31-27} = rA;
- let Inst{26-22} = rB;
- let Inst{21-6} = imm;
-}
-
-
-//===----------------------------------------------------------------------===//
-// Format R instruction : <|A|B|C|opx|imm|opcode|>
-//===----------------------------------------------------------------------===//
-
-class FR<bits<6> opx, dag outs, dag ins, string asmstr, list<dag> pattern,
- InstrItinClass itin>: Nios2R1Inst32<outs, ins, asmstr,
- pattern, itin, FrmR> {
- bits<5> rA;
- bits<5> rB;
- bits<5> rC;
- bits<5> imm = 0;
-
- let Opcode = 0x3a; /* opcode is always 0x3a for R instr. */
-
- let Inst{31-27} = rA;
- let Inst{26-22} = rB;
- let Inst{21-17} = rC;
- let Inst{16-11} = opx; /* opx stands for opcode extension */
- let Inst{10-6} = imm; /* optional 5-bit immediate value */
-}
-
-//===----------------------------------------------------------------------===//
-// Format J instruction class in Nios2 : <|address|opcode|>
-//===----------------------------------------------------------------------===//
-
-class FJ<bits<6> op, dag outs, dag ins, string asmstr, list<dag> pattern,
- InstrItinClass itin>:
- Nios2R1Inst32<outs, ins, asmstr, pattern, itin, FrmJ> {
- bits<26> addr;
- let Opcode = op;
- let Inst{31-6} = addr;
-}
-
-//===----------------------------------------------------------------------===//
-// Format F3X6 (R2) instruction : <|opx|RSV|C|B|A|opcode|>
-//===----------------------------------------------------------------------===//
-
-class F3X6<bits<6> opx, dag outs, dag ins, string asmstr, list<dag> pattern,
- InstrItinClass itin>:
- Nios2R2Inst32<outs, ins, asmstr, pattern, itin, FrmF3X6> {
- bits<5> rC;
- bits<5> rB;
- bits<5> rA;
- bits<5> rsv = 0;
-
- let Opcode = 0x20; /* opcode is always 0x20 (OPX group) for F3X6 instr. */
-
- let Inst{31-26} = opx; /* opx stands for opcode extension */
- let Inst{25-21} = rsv;
- let Inst{20-16} = rC;
- let Inst{15-11} = rB;
- let Inst{10-6} = rA;
-}
-
-//===----------------------------------------------------------------------===//
-// Multiclasses for common instructions of both R1 and R2:
-//===----------------------------------------------------------------------===//
-
-// Multiclass for instructions that have R format in R1 and F3X6 format in R2
-// and their opx values differ between R1 and R2
-multiclass CommonInstr_R_F3X6_opx<bits<6> opxR1, bits<6> opxR2, dag outs,
- dag ins, string asmstr, list<dag> pattern,
- InstrItinClass itin> {
- def NAME#_R1 : FR<opxR1, outs, ins, asmstr, pattern, itin>;
- def NAME#_R2 : F3X6<opxR2, outs, ins, asmstr, pattern, itin>;
-}
-
-// Multiclass for instructions that have R format in R1 and F3X6 format in R2
-// and their opx values are the same in R1 and R2
-multiclass CommonInstr_R_F3X6<bits<6> opx, dag outs, dag ins, string asmstr,
- list<dag> pattern, InstrItinClass itin> :
- CommonInstr_R_F3X6_opx<opx, opx, outs, ins, asmstr, pattern, itin>;
-
-// Multiclass for instructions that have I format in R1 and F2I16 format in R2
-// and their op code values differ between R1 and R2
-multiclass CommonInstr_I_F2I16_op<bits<6> opR1, bits<6> opR2, dag outs, dag ins,
- string asmstr, list<dag> pattern,
- InstrItinClass itin> {
- def NAME#_R1 : FI<opR1, outs, ins, asmstr, pattern, itin>;
-}
-
-// Multiclass for instructions that have I format in R1 and F2I16 format in R2
-// and their op code values are the same in R1 and R2
-multiclass CommonInstr_I_F2I16<bits<6> op, dag outs, dag ins, string asmstr,
- list<dag> pattern, InstrItinClass itin> :
- CommonInstr_I_F2I16_op<op, op, outs, ins, asmstr, pattern, itin>;
diff --git a/llvm/lib/Target/Nios2/Nios2InstrInfo.cpp b/llvm/lib/Target/Nios2/Nios2InstrInfo.cpp
deleted file mode 100644
index 9700cba3595..00000000000
--- a/llvm/lib/Target/Nios2/Nios2InstrInfo.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-//===-- Nios2InstrInfo.cpp - Nios2 Instruction Information ----------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file contains the Nios2 implementation of the TargetInstrInfo class.
-//
-//===----------------------------------------------------------------------===//
-
-#include "Nios2InstrInfo.h"
-#include "Nios2TargetMachine.h"
-#include "llvm/CodeGen/MachineInstrBuilder.h"
-
-using namespace llvm;
-
-#define GET_INSTRINFO_CTOR_DTOR
-#include "Nios2GenInstrInfo.inc"
-
-// Pin the vtable to this file.
-void Nios2InstrInfo::anchor() {}
-
-Nios2InstrInfo::Nios2InstrInfo(Nios2Subtarget &ST)
- : Nios2GenInstrInfo(), RI(ST), Subtarget(ST) {}
-
-/// Expand Pseudo instructions into real backend instructions
-bool Nios2InstrInfo::expandPostRAPseudo(MachineInstr &MI) const {
- MachineBasicBlock &MBB = *MI.getParent();
-
- switch (MI.getDesc().getOpcode()) {
- default:
- return false;
- case Nios2::RetRA:
- BuildMI(MBB, MI, MI.getDebugLoc(), get(Nios2::RET_R1)).addReg(Nios2::RA);
- break;
- }
-
- MBB.erase(MI);
- return true;
-}
-
-void Nios2InstrInfo::copyPhysReg(MachineBasicBlock &MBB,
- MachineBasicBlock::iterator I,
- const DebugLoc &DL, unsigned DestReg,
- unsigned SrcReg, bool KillSrc) const {
- unsigned opc = Subtarget.hasNios2r2() ? Nios2::ADD_R2 : Nios2::ADD_R1;
- BuildMI(MBB, I, DL, get(opc))
- .addReg(DestReg, RegState::Define)
- .addReg(Nios2::ZERO)
- .addReg(SrcReg, getKillRegState(KillSrc));
-}
diff --git a/llvm/lib/Target/Nios2/Nios2InstrInfo.h b/llvm/lib/Target/Nios2/Nios2InstrInfo.h
deleted file mode 100644
index 52f6e7e9c7c..00000000000
--- a/llvm/lib/Target/Nios2/Nios2InstrInfo.h
+++ /dev/null
@@ -1,49 +0,0 @@
-//===-- Nios2InstrInfo.h - Nios2 Instruction Information --------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file contains the Nios2 implementation of the TargetInstrInfo class.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_LIB_TARGET_NIOS2_NIOS2INSTRINFO_H
-#define LLVM_LIB_TARGET_NIOS2_NIOS2INSTRINFO_H
-
-#include "Nios2RegisterInfo.h"
-#include "llvm/CodeGen/TargetInstrInfo.h"
-
-#define GET_INSTRINFO_HEADER
-#include "Nios2GenInstrInfo.inc"
-
-namespace llvm {
-
-class Nios2Subtarget;
-
-class Nios2InstrInfo : public Nios2GenInstrInfo {
- const Nios2RegisterInfo RI;
- const Nios2Subtarget &Subtarget;
- virtual void anchor();
-
-public:
- explicit Nios2InstrInfo(Nios2Subtarget &ST);
-
- /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info. As
- /// such, whenever a client has an instance of instruction info, it should
- /// always be able to get register info as well (through this method).
- ///
- const Nios2RegisterInfo &getRegisterInfo() const { return RI; };
-
- bool expandPostRAPseudo(MachineInstr &MI) const override;
-
- void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI,
- const DebugLoc &DL, unsigned DestReg, unsigned SrcReg,
- bool KillSrc) const override;
-};
-} // namespace llvm
-
-#endif
diff --git a/llvm/lib/Target/Nios2/Nios2InstrInfo.td b/llvm/lib/Target/Nios2/Nios2InstrInfo.td
deleted file mode 100644
index dee84f74bcb..00000000000
--- a/llvm/lib/Target/Nios2/Nios2InstrInfo.td
+++ /dev/null
@@ -1,109 +0,0 @@
-//===- Nios2InstrInfo.td - Target Description for Nios2 ------*- tablegen -*-=//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file contains the Nios2 implementation of the TargetInstrInfo class.
-//
-//===----------------------------------------------------------------------===//
-
-//===----------------------------------------------------------------------===//
-// Instruction format superclass
-//===----------------------------------------------------------------------===//
-
-include "Nios2InstrFormats.td"
-
-
-//===----------------------------------------------------------------------===//
-// Nios2 Operand, Complex Patterns and Transformations Definitions.
-//===----------------------------------------------------------------------===//
-
-def simm16 : Operand<i32> {
- let DecoderMethod= "DecodeSimm16";
-}
-
-// Node immediate fits as 16-bit sign extended on target immediate.
-// e.g. addi, andi
-def immSExt16 : PatLeaf<(imm), [{ return isInt<16>(N->getSExtValue()); }]>;
-
-// Custom return SDNode
-def Nios2Ret : SDNode<"Nios2ISD::Ret", SDTNone,
- [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
-
-//===----------------------------------------------------------------------===//
-// Instructions specific format
-//===----------------------------------------------------------------------===//
-
-// Arithmetic and logical instructions with 2 registers and 16-bit immediate
-// value.
-multiclass ArithLogicRegImm16<bits<6> op, string mnemonic, SDNode opNode,
- Operand immOp, PatLeaf immType>:
- CommonInstr_I_F2I16<op, (outs CPURegs:$rB),
- (ins CPURegs:$rA, immOp:$imm),
- !strconcat(mnemonic, "\t$rB, $rA, $imm"),
- [(set CPURegs:$rB,
- (opNode CPURegs:$rA, immType:$imm))],
- IIAlu>;
-
-// Arithmetic and logical instructions with 3 register operands.
-// Defines R1 and R2 instruction at the same time.
-multiclass ArithLogicReg<bits<6> opx, string mnemonic,
- SDNode opNode>:
- CommonInstr_R_F3X6<opx, (outs CPURegs:$rC),
- (ins CPURegs:$rA, CPURegs:$rB),
- !strconcat(mnemonic, "\t$rC, $rA, $rB"),
- [(set CPURegs:$rC, (opNode CPURegs:$rA, CPURegs:$rB))],
- IIAlu>;
-
-multiclass Return<bits<6> opx, dag outs, dag ins, string mnemonic> {
- let rB = 0, rC = 0,
- isReturn = 1,
- isCodeGenOnly = 1,
- hasCtrlDep = 1,
- hasExtraSrcRegAllocReq = 1 in {
- defm NAME# : CommonInstr_R_F3X6<opx, outs, ins, mnemonic, [], IIBranch>;
- }
-}
-
-//===----------------------------------------------------------------------===//
-// Nios2 Instructions
-//===----------------------------------------------------------------------===//
-
-/// Arithmetic instructions operating on registers.
-let isCommutable = 1 ,
- isReMaterializable = 1 in {
- defm ADD : ArithLogicReg<0x31, "add", add>;
- defm AND : ArithLogicReg<0x0e, "and", and>;
- defm OR : ArithLogicReg<0x16, "or", or>;
- defm XOR : ArithLogicReg<0x1e, "xor", xor>;
- defm MUL : ArithLogicReg<0x27, "mul", mul>;
-}
-
-let isReMaterializable = 1 in {
- defm SUB : ArithLogicReg<0x39, "sub", sub>;
-}
-
-defm DIVU : ArithLogicReg<0x24, "divu", udiv>;
-defm DIV : ArithLogicReg<0x25, "div", sdiv>;
-
-defm SLL : ArithLogicReg<0x13, "sll", shl>;
-defm SRL : ArithLogicReg<0x1b, "srl", srl>;
-defm SRA : ArithLogicReg<0x3b, "sra", sra>;
-
-/// Arithmetic Instructions (ALU Immediate)
-defm ADDI : ArithLogicRegImm16<0x04, "addi", add, simm16, immSExt16>;
-
-// Returns:
-defm RET : Return<0x05, (outs), (ins CPURegs:$rA), "ret">;
-
-//===----------------------------------------------------------------------===//
-// Pseudo instructions
-//===----------------------------------------------------------------------===//
-
-// Return RA.
-let isReturn=1, isTerminator=1, hasDelaySlot=1, isBarrier=1, hasCtrlDep=1 in
-def RetRA : Nios2Pseudo<(outs), (ins), "", [(Nios2Ret)]>;
diff --git a/llvm/lib/Target/Nios2/Nios2MCInstLower.cpp b/llvm/lib/Target/Nios2/Nios2MCInstLower.cpp
deleted file mode 100644
index c43af879b8a..00000000000
--- a/llvm/lib/Target/Nios2/Nios2MCInstLower.cpp
+++ /dev/null
@@ -1,117 +0,0 @@
-//===-- Nios2MCInstLower.cpp - Convert Nios2 MachineInstr to MCInst -------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file contains code to lower Nios2 MachineInstrs to their corresponding
-// MCInst records.
-//
-//===----------------------------------------------------------------------===//
-
-#include "MCTargetDesc/Nios2BaseInfo.h"
-#include "MCTargetDesc/Nios2MCExpr.h"
-#include "Nios2.h"
-#include "llvm/CodeGen/AsmPrinter.h"
-#include "llvm/CodeGen/MachineInstr.h"
-#include "llvm/CodeGen/MachineOperand.h"
-
-using namespace llvm;
-
-static MCOperand LowerSymbolOperand(const MachineOperand &MO, AsmPrinter &AP) {
- MCSymbolRefExpr::VariantKind Kind = MCSymbolRefExpr::VK_None;
- Nios2MCExpr::Nios2ExprKind TargetKind = Nios2MCExpr::CEK_None;
- const MCSymbol *Symbol;
-
- switch (MO.getTargetFlags()) {
- default:
- llvm_unreachable("Invalid target flag!");
- case Nios2FG::MO_NO_FLAG:
- break;
- case Nios2FG::MO_ABS_HI:
- TargetKind = Nios2MCExpr::CEK_ABS_HI;
- break;
- case Nios2FG::MO_ABS_LO:
- TargetKind = Nios2MCExpr::CEK_ABS_LO;
- break;
- }
-
- switch (MO.getType()) {
- case MachineOperand::MO_GlobalAddress:
- Symbol = AP.getSymbol(MO.getGlobal());
- break;
-
- case MachineOperand::MO_MachineBasicBlock:
- Symbol = MO.getMBB()->getSymbol();
- break;
-
- case MachineOperand::MO_BlockAddress:
- Symbol = AP.GetBlockAddressSymbol(MO.getBlockAddress());
- break;
-
- case MachineOperand::MO_ExternalSymbol:
- Symbol = AP.GetExternalSymbolSymbol(MO.getSymbolName());
- break;
-
- case MachineOperand::MO_JumpTableIndex:
- Symbol = AP.GetJTISymbol(MO.getIndex());
- break;
-
- case MachineOperand::MO_ConstantPoolIndex:
- Symbol = AP.GetCPISymbol(MO.getIndex());
- break;
-
- default:
- llvm_unreachable("<unknown operand type>");
- }
-
- const MCExpr *Expr = MCSymbolRefExpr::create(Symbol, Kind, AP.OutContext);
-
- if (TargetKind != Nios2MCExpr::CEK_None)
- Expr = Nios2MCExpr::create(TargetKind, Expr, AP.OutContext);
-
- return MCOperand::createExpr(Expr);
-}
-
-static MCOperand LowerOperand(const MachineOperand &MO, AsmPrinter &AP) {
-
- switch (MO.getType()) {
- default:
- llvm_unreachable("unknown operand type");
- case MachineOperand::MO_Register:
- // Ignore all implicit register operands.
- if (MO.isImplicit())
- break;
- return MCOperand::createReg(MO.getReg());
- case MachineOperand::MO_Immediate:
- return MCOperand::createImm(MO.getImm());
- case MachineOperand::MO_MachineBasicBlock:
- case MachineOperand::MO_ExternalSymbol:
- case MachineOperand::MO_JumpTableIndex:
- case MachineOperand::MO_BlockAddress:
- case MachineOperand::MO_GlobalAddress:
- case MachineOperand::MO_ConstantPoolIndex:
- return LowerSymbolOperand(MO, AP);
- case MachineOperand::MO_RegisterMask:
- break;
- }
-
- return MCOperand();
-}
-
-void llvm::LowerNios2MachineInstToMCInst(const MachineInstr *MI, MCInst &OutMI,
- AsmPrinter &AP) {
-
- OutMI.setOpcode(MI->getOpcode());
-
- for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
- const MachineOperand &MO = MI->getOperand(i);
- MCOperand MCOp = LowerOperand(MO, AP);
-
- if (MCOp.isValid())
- OutMI.addOperand(MCOp);
- }
-}
diff --git a/llvm/lib/Target/Nios2/Nios2MachineFunction.cpp b/llvm/lib/Target/Nios2/Nios2MachineFunction.cpp
deleted file mode 100644
index be5b8829fe3..00000000000
--- a/llvm/lib/Target/Nios2/Nios2MachineFunction.cpp
+++ /dev/null
@@ -1,14 +0,0 @@
-//===-- Nios2MachineFunctionInfo.cpp - Private data used for Nios2 --------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "Nios2MachineFunction.h"
-
-using namespace llvm;
-
-void Nios2FunctionInfo::anchor() {}
diff --git a/llvm/lib/Target/Nios2/Nios2MachineFunction.h b/llvm/lib/Target/Nios2/Nios2MachineFunction.h
deleted file mode 100644
index 73baf969479..00000000000
--- a/llvm/lib/Target/Nios2/Nios2MachineFunction.h
+++ /dev/null
@@ -1,62 +0,0 @@
-//===-- Nios2MachineFunctionInfo.h - Private data used for Nios2 --*- 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 the Nios2 specific subclass of MachineFunctionInfo.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_LIB_TARGET_NIOS2_NIOS2MACHINEFUNCTION_H
-#define LLVM_LIB_TARGET_NIOS2_NIOS2MACHINEFUNCTION_H
-
-#include "llvm/CodeGen/MachineFunction.h"
-
-namespace llvm {
-
-/// Nios2FunctionInfo - This class is derived from MachineFunction private
-/// Nios2 target-specific information for each MachineFunction.
-class Nios2FunctionInfo : public MachineFunctionInfo {
- virtual void anchor();
-
-private:
- unsigned GlobalBaseReg;
-
- /// VarArgsFrameOffset - Frame offset to start of varargs area.
- int VarArgsFrameOffset;
-
- /// SRetReturnReg - Holds the virtual register into which the sret
- /// argument is passed.
- unsigned SRetReturnReg;
-
- /// IsLeafProc - True if the function is a leaf procedure.
- bool IsLeafProc;
-
-public:
- Nios2FunctionInfo()
- : GlobalBaseReg(0), VarArgsFrameOffset(0), SRetReturnReg(0),
- IsLeafProc(false) {}
- explicit Nios2FunctionInfo(MachineFunction &MF)
- : GlobalBaseReg(0), VarArgsFrameOffset(0), SRetReturnReg(0),
- IsLeafProc(false) {}
-
- unsigned getGlobalBaseReg() const { return GlobalBaseReg; }
- void setGlobalBaseReg(unsigned Reg) { GlobalBaseReg = Reg; }
-
- int getVarArgsFrameOffset() const { return VarArgsFrameOffset; }
- void setVarArgsFrameOffset(int Offset) { VarArgsFrameOffset = Offset; }
-
- unsigned getSRetReturnReg() const { return SRetReturnReg; }
- void setSRetReturnReg(unsigned Reg) { SRetReturnReg = Reg; }
-
- void setLeafProc(bool rhs) { IsLeafProc = rhs; }
- bool isLeafProc() const { return IsLeafProc; }
-};
-
-} // end of namespace llvm
-
-#endif // NIOS2_MACHINE_FUNCTION_INFO_H
diff --git a/llvm/lib/Target/Nios2/Nios2RegisterInfo.cpp b/llvm/lib/Target/Nios2/Nios2RegisterInfo.cpp
deleted file mode 100644
index 9b892f91753..00000000000
--- a/llvm/lib/Target/Nios2/Nios2RegisterInfo.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-//===-- Nios2RegisterInfo.cpp - Nios2 Register Information -== ------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file contains the Nios2 implementation of the TargetRegisterInfo class.
-//
-//===----------------------------------------------------------------------===//
-
-#define DEBUG_TYPE "nios2-reg-info"
-
-#include "Nios2RegisterInfo.h"
-
-#include "Nios2.h"
-#include "Nios2Subtarget.h"
-
-#define GET_REGINFO_TARGET_DESC
-#include "Nios2GenRegisterInfo.inc"
-
-using namespace llvm;
-
-Nios2RegisterInfo::Nios2RegisterInfo(const Nios2Subtarget &ST)
- : Nios2GenRegisterInfo(Nios2::RA), Subtarget(ST) {}
-
-const TargetRegisterClass *Nios2RegisterInfo::intRegClass(unsigned Size) const {
- return &Nios2::CPURegsRegClass;
-}
-
-const MCPhysReg *
-Nios2RegisterInfo::getCalleeSavedRegs(const MachineFunction *MF) const {
- return CSR_SaveList;
-}
-
-BitVector Nios2RegisterInfo::getReservedRegs(const MachineFunction &MF) const {
- static const MCPhysReg ReservedCPURegs[] = {Nios2::ZERO, Nios2::AT, Nios2::SP,
- Nios2::RA, Nios2::PC, Nios2::GP};
- BitVector Reserved(getNumRegs());
-
- for (unsigned I = 0; I < array_lengthof(ReservedCPURegs); ++I)
- Reserved.set(ReservedCPURegs[I]);
-
- return Reserved;
-}
-
-void Nios2RegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II,
- int SPAdj, unsigned FIOperandNum,
- RegScavenger *RS) const {}
-
-unsigned Nios2RegisterInfo::getFrameRegister(const MachineFunction &MF) const {
- return Nios2::SP;
-}
diff --git a/llvm/lib/Target/Nios2/Nios2RegisterInfo.h b/llvm/lib/Target/Nios2/Nios2RegisterInfo.h
deleted file mode 100644
index 3658343b1d2..00000000000
--- a/llvm/lib/Target/Nios2/Nios2RegisterInfo.h
+++ /dev/null
@@ -1,52 +0,0 @@
-//===-- Nios2RegisterInfo.h - Nios2 Register Information Impl ---*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file contains the Nios2 implementation of the TargetRegisterInfo class.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_LIB_TARGET_NIOS2_NIOS2REGISTERINFO_H
-#define LLVM_LIB_TARGET_NIOS2_NIOS2REGISTERINFO_H
-
-#include "Nios2.h"
-#include "llvm/CodeGen/TargetRegisterInfo.h"
-
-#define GET_REGINFO_HEADER
-#include "Nios2GenRegisterInfo.inc"
-
-namespace llvm {
-class Nios2Subtarget;
-class TargetInstrInfo;
-class Type;
-
-class Nios2RegisterInfo : public Nios2GenRegisterInfo {
-protected:
- const Nios2Subtarget &Subtarget;
-
-public:
- Nios2RegisterInfo(const Nios2Subtarget &Subtarget);
-
- const MCPhysReg *getCalleeSavedRegs(const MachineFunction *MF) const override;
-
- BitVector getReservedRegs(const MachineFunction &MF) const override;
-
- /// Stack Frame Processing Methods
- void eliminateFrameIndex(MachineBasicBlock::iterator II, int SPAdj,
- unsigned FIOperandNum,
- RegScavenger *RS = nullptr) const override;
-
- /// Debug information queries.
- unsigned getFrameRegister(const MachineFunction &MF) const override;
-
- /// Return GPR register class.
- const TargetRegisterClass *intRegClass(unsigned Size) const;
-};
-
-} // end namespace llvm
-#endif
diff --git a/llvm/lib/Target/Nios2/Nios2RegisterInfo.td b/llvm/lib/Target/Nios2/Nios2RegisterInfo.td
deleted file mode 100644
index 1808815816f..00000000000
--- a/llvm/lib/Target/Nios2/Nios2RegisterInfo.td
+++ /dev/null
@@ -1,60 +0,0 @@
-//===-- Nios2RegisterInfo.td - Nios2 Register defs ---------*- tablegen -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// We have bank of 32 registers.
-class Nios2Reg<string n> : Register<n> {
- field bits<5> Num;
- let Namespace = "Nios2";
-}
-
-// Nios2 CPU Registers
-class Nios2GPRReg<bits<5> num, string n> : Nios2Reg<n> {
- let Num = num;
-}
-
-//===----------------------------------------------------------------------===//
-// Registers
-//===----------------------------------------------------------------------===//
-
-let Namespace = "Nios2" in {
- // General Purpose Registers
- def ZERO : Nios2GPRReg<0, "zero">, DwarfRegNum<[ 0 ]>;
- def AT : Nios2GPRReg<1, "at">, DwarfRegNum<[ 1 ]>;
- foreach RegNum = 2 - 23 in {
- def R #RegNum : Nios2GPRReg<RegNum, "r" #RegNum>, DwarfRegNum<[ RegNum ]>;
- }
- def ET : Nios2GPRReg<24, "et">, DwarfRegNum<[ 24 ]>;
- def BT : Nios2GPRReg<25, "bt">, DwarfRegNum<[ 25 ]>;
- def GP : Nios2GPRReg<26, "gp">, DwarfRegNum<[ 26 ]>;
- def SP : Nios2GPRReg<27, "sp">, DwarfRegNum<[ 27 ]>;
- def FP : Nios2GPRReg<28, "fp">, DwarfRegNum<[ 28 ]>;
- def EA : Nios2GPRReg<29, "ea">, DwarfRegNum<[ 29 ]>;
- def BA : Nios2GPRReg<30, "ba">, DwarfRegNum<[ 30 ]>;
- def RA : Nios2GPRReg<31, "ra">, DwarfRegNum<[ 31 ]>;
- def PC : Nios2Reg<"pc">, DwarfRegNum<[ 32 ]>;
-}
-
-//===----------------------------------------------------------------------===//
-// Register Classes
-//===----------------------------------------------------------------------===//
-
-def CPURegs : RegisterClass<"Nios2", [ i32 ], 32,
- (add
- // Reserved
- ZERO,
- AT,
- // Return Values and Arguments
- (sequence "R%u", 2, 7),
- // Not preserved across procedure calls
- // Caller saved
- (sequence "R%u", 8, 15),
- // Callee saved
- (sequence "R%u", 16, 23),
- // Reserved
- ET, BT, GP, SP, FP, EA, BA, RA, PC)>;
diff --git a/llvm/lib/Target/Nios2/Nios2Schedule.td b/llvm/lib/Target/Nios2/Nios2Schedule.td
deleted file mode 100644
index 2d1d9d5e5f3..00000000000
--- a/llvm/lib/Target/Nios2/Nios2Schedule.td
+++ /dev/null
@@ -1,39 +0,0 @@
-//===-- Nios2Schedule.td - Nios2 Scheduling Definitions ----*- tablegen -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-//===----------------------------------------------------------------------===//
-// Functional units across Nios2 chips sets. Based on GCC/Nios2 backend files.
-//===----------------------------------------------------------------------===//
-def ALU : FuncUnit;
-def IMULDIV : FuncUnit;
-
-//===----------------------------------------------------------------------===//
-// Instruction Itinerary classes used for Nios2
-//===----------------------------------------------------------------------===//
-def IIAlu : InstrItinClass;
-def IILoad : InstrItinClass;
-def IIStore : InstrItinClass;
-def IIFlush : InstrItinClass;
-def IIIdiv : InstrItinClass;
-def IIBranch : InstrItinClass;
-
-def IIPseudo : InstrItinClass;
-
-//===----------------------------------------------------------------------===//
-// Nios2 Generic instruction itineraries.
-//===----------------------------------------------------------------------===//
-//@ http://llvm.org/docs/doxygen/html/structllvm_1_1InstrStage.html
-def Nios2GenericItineraries : ProcessorItineraries<[ALU, IMULDIV], [], [
- InstrItinData<IIAlu , [InstrStage<1, [ALU]>]>,
- InstrItinData<IILoad , [InstrStage<3, [ALU]>]>,
- InstrItinData<IIStore , [InstrStage<1, [ALU]>]>,
- InstrItinData<IIFlush , [InstrStage<1, [ALU]>]>,
- InstrItinData<IIIdiv , [InstrStage<38, [IMULDIV]>]>,
- InstrItinData<IIBranch , [InstrStage<1, [ALU]>]>
-]>;
diff --git a/llvm/lib/Target/Nios2/Nios2Subtarget.cpp b/llvm/lib/Target/Nios2/Nios2Subtarget.cpp
deleted file mode 100644
index 196bed20cdc..00000000000
--- a/llvm/lib/Target/Nios2/Nios2Subtarget.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-//===-- Nios2Subtarget.cpp - Nios2 Subtarget Information ------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file implements the Nios2 specific subclass of TargetSubtargetInfo.
-//
-//===----------------------------------------------------------------------===//
-
-#include "Nios2Subtarget.h"
-#include "Nios2.h"
-
-using namespace llvm;
-
-#define DEBUG_TYPE "nios2-subtarget"
-
-#define GET_SUBTARGETINFO_TARGET_DESC
-#define GET_SUBTARGETINFO_CTOR
-#include "Nios2GenSubtargetInfo.inc"
-
-void Nios2Subtarget::anchor() {}
-
-Nios2Subtarget::Nios2Subtarget(const Triple &TT, const std::string &CPU,
- const std::string &FS, const TargetMachine &TM)
- :
-
- // Nios2GenSubtargetInfo will display features by llc -march=nios2
- // -mcpu=help
- Nios2GenSubtargetInfo(TT, CPU, FS), TargetTriple(TT),
- InstrInfo(initializeSubtargetDependencies(CPU, FS)), TLInfo(TM, *this),
- FrameLowering(*this) {}
-
-Nios2Subtarget &Nios2Subtarget::initializeSubtargetDependencies(StringRef CPU,
- StringRef FS) {
- if (TargetTriple.getArch() == Triple::nios2) {
- if (CPU != "nios2r2") {
- CPU = "nios2r1";
- Nios2ArchVersion = Nios2r1;
- } else {
- Nios2ArchVersion = Nios2r2;
- }
- } else {
- errs() << "!!!Error, TargetTriple.getArch() = " << TargetTriple.getArch()
- << "CPU = " << CPU << "\n";
- exit(0);
- }
-
- // Parse features string.
- ParseSubtargetFeatures(CPU, FS);
-
- return *this;
-}
diff --git a/llvm/lib/Target/Nios2/Nios2Subtarget.h b/llvm/lib/Target/Nios2/Nios2Subtarget.h
deleted file mode 100644
index a822dff33b5..00000000000
--- a/llvm/lib/Target/Nios2/Nios2Subtarget.h
+++ /dev/null
@@ -1,97 +0,0 @@
-//===-- Nios2Subtarget.h - Define Subtarget for the Nios2 -------*- 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 the Nios2 specific subclass of TargetSubtargetInfo.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_LIB_TARGET_NIOS2_NIOS2SUBTARGET_H
-#define LLVM_LIB_TARGET_NIOS2_NIOS2SUBTARGET_H
-
-#include "Nios2FrameLowering.h"
-#include "Nios2ISelLowering.h"
-#include "Nios2InstrInfo.h"
-#include "llvm/CodeGen/SelectionDAGTargetInfo.h"
-#include "llvm/CodeGen/TargetFrameLowering.h"
-#include "llvm/CodeGen/TargetSubtargetInfo.h"
-
-#define GET_SUBTARGETINFO_HEADER
-#include "Nios2GenSubtargetInfo.inc"
-
-namespace llvm {
-class StringRef;
-
-class Nios2TargetMachine;
-
-class Nios2Subtarget : public Nios2GenSubtargetInfo {
- virtual void anchor();
-
-public:
- // Nios2 R2 features
- // Bit manipulation instructions extension
- bool HasBMX;
- // Code Density instructions extension
- bool HasCDX;
- // Multi-Processor instructions extension
- bool HasMPX;
- // New mandatory instructions
- bool HasR2Mandatory;
-
-protected:
- enum Nios2ArchEnum {
- // Nios2 R1 ISA
- Nios2r1,
- // Nios2 R2 ISA
- Nios2r2
- };
-
- // Nios2 architecture version
- Nios2ArchEnum Nios2ArchVersion;
-
- Triple TargetTriple;
-
- Nios2InstrInfo InstrInfo;
- Nios2TargetLowering TLInfo;
- SelectionDAGTargetInfo TSInfo;
- Nios2FrameLowering FrameLowering;
-
-public:
- /// This constructor initializes the data members to match that
- /// of the specified triple.
- Nios2Subtarget(const Triple &TT, const std::string &CPU,
- const std::string &FS, const TargetMachine &TM);
-
- /// ParseSubtargetFeatures - Parses features string setting specified
- /// subtarget options. Definition of function is auto generated by tblgen.
- void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
-
- bool hasNios2r1() const { return Nios2ArchVersion >= Nios2r1; }
- bool isNios2r1() const { return Nios2ArchVersion == Nios2r1; }
- bool hasNios2r2() const { return Nios2ArchVersion >= Nios2r2; }
- bool isNios2r2() const { return Nios2ArchVersion == Nios2r2; }
-
- Nios2Subtarget &initializeSubtargetDependencies(StringRef CPU, StringRef FS);
-
- const Nios2InstrInfo *getInstrInfo() const override { return &InstrInfo; }
- const TargetFrameLowering *getFrameLowering() const override {
- return &FrameLowering;
- }
- const Nios2RegisterInfo *getRegisterInfo() const override {
- return &InstrInfo.getRegisterInfo();
- }
- const Nios2TargetLowering *getTargetLowering() const override {
- return &TLInfo;
- }
- const SelectionDAGTargetInfo *getSelectionDAGInfo() const override {
- return &TSInfo;
- }
-};
-} // namespace llvm
-
-#endif
diff --git a/llvm/lib/Target/Nios2/Nios2TargetMachine.cpp b/llvm/lib/Target/Nios2/Nios2TargetMachine.cpp
deleted file mode 100644
index 4f90db9e6f6..00000000000
--- a/llvm/lib/Target/Nios2/Nios2TargetMachine.cpp
+++ /dev/null
@@ -1,111 +0,0 @@
-//===-- Nios2TargetMachine.cpp - Define TargetMachine for Nios2 -----------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// Implements the info about Nios2 target spec.
-//
-//===----------------------------------------------------------------------===//
-
-#include "Nios2TargetMachine.h"
-#include "Nios2.h"
-#include "Nios2TargetObjectFile.h"
-
-#include "llvm/CodeGen/TargetPassConfig.h"
-#include "llvm/Support/TargetRegistry.h"
-
-using namespace llvm;
-
-#define DEBUG_TYPE "nios2"
-
-extern "C" void LLVMInitializeNios2Target() {
- // Register the target.
- RegisterTargetMachine<Nios2TargetMachine> X(getTheNios2Target());
-}
-
-static std::string computeDataLayout() {
- return "e-p:32:32:32-i8:8:32-i16:16:32-n32";
-}
-
-static Reloc::Model getEffectiveRelocModel(Optional<Reloc::Model> RM) {
- if (!RM.hasValue())
- return Reloc::Static;
- return *RM;
-}
-
-Nios2TargetMachine::Nios2TargetMachine(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, CPU, FS, Options,
- getEffectiveRelocModel(RM),
- getEffectiveCodeModel(CM, CodeModel::Small), OL),
- TLOF(make_unique<Nios2TargetObjectFile>()),
- Subtarget(TT, CPU, FS, *this) {
- initAsmInfo();
-}
-
-Nios2TargetMachine::~Nios2TargetMachine() {}
-
-const Nios2Subtarget *
-Nios2TargetMachine::getSubtargetImpl(const Function &F) const {
- Attribute CPUAttr = F.getFnAttribute("target-cpu");
- Attribute FSAttr = F.getFnAttribute("target-features");
-
- std::string CPU = !CPUAttr.hasAttribute(Attribute::None)
- ? CPUAttr.getValueAsString().str()
- : TargetCPU;
- std::string FS = !FSAttr.hasAttribute(Attribute::None)
- ? FSAttr.getValueAsString().str()
- : TargetFS;
-
- auto &I = SubtargetMap[CPU + FS];
- if (!I) {
- // This needs to be done before we create a new subtarget since any
- // creation will depend on the TM and the code generation flags on the
- // function that reside in TargetOptions.
- resetTargetOptions(F);
- I = llvm::make_unique<Nios2Subtarget>(TargetTriple, CPU, FS, *this);
- }
- return I.get();
-}
-
-namespace {
-/// Nios2 Code Generator Pass Configuration Options.
-class Nios2PassConfig : public TargetPassConfig {
-public:
- Nios2PassConfig(Nios2TargetMachine &TM, PassManagerBase *PM)
- : TargetPassConfig(TM, *PM) {}
-
- Nios2TargetMachine &getNios2TargetMachine() const {
- return getTM<Nios2TargetMachine>();
- }
-
- void addCodeGenPrepare() override;
- bool addInstSelector() override;
- void addIRPasses() override;
-};
-} // namespace
-
-TargetPassConfig *Nios2TargetMachine::createPassConfig(PassManagerBase &PM) {
- return new Nios2PassConfig(*this, &PM);
-}
-
-void Nios2PassConfig::addCodeGenPrepare() {
- TargetPassConfig::addCodeGenPrepare();
-}
-
-void Nios2PassConfig::addIRPasses() { TargetPassConfig::addIRPasses(); }
-
-// Install an instruction selector pass using
-// the ISelDag to gen Nios2 code.
-bool Nios2PassConfig::addInstSelector() {
- addPass(createNios2ISelDag(getNios2TargetMachine(), getOptLevel()));
- return false;
-}
diff --git a/llvm/lib/Target/Nios2/Nios2TargetMachine.h b/llvm/lib/Target/Nios2/Nios2TargetMachine.h
deleted file mode 100644
index 1ebfb397383..00000000000
--- a/llvm/lib/Target/Nios2/Nios2TargetMachine.h
+++ /dev/null
@@ -1,45 +0,0 @@
-//===-- Nios2TargetMachine.h - Define TargetMachine for Nios2 ---*- 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 the Nios2 specific subclass of TargetMachine.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_LIB_TARGET_NIOS2_NIOS2TARGETMACHINE_H
-#define LLVM_LIB_TARGET_NIOS2_NIOS2TARGETMACHINE_H
-
-#include "Nios2Subtarget.h"
-#include "llvm/Target/TargetMachine.h"
-
-namespace llvm {
-class Nios2TargetMachine : public LLVMTargetMachine {
- mutable StringMap<std::unique_ptr<Nios2Subtarget>> SubtargetMap;
- std::unique_ptr<TargetLoweringObjectFile> TLOF;
- Nios2Subtarget Subtarget;
-
-public:
- Nios2TargetMachine(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);
- ~Nios2TargetMachine() override;
-
- const Nios2Subtarget *getSubtargetImpl() const { return &Subtarget; }
- const Nios2Subtarget *getSubtargetImpl(const Function &F) const override;
-
- TargetLoweringObjectFile *getObjFileLowering() const override {
- return TLOF.get();
- }
-
- // Pass Pipeline Configuration
- TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
-};
-} // namespace llvm
-
-#endif
diff --git a/llvm/lib/Target/Nios2/Nios2TargetObjectFile.cpp b/llvm/lib/Target/Nios2/Nios2TargetObjectFile.cpp
deleted file mode 100644
index 5fc85ef487e..00000000000
--- a/llvm/lib/Target/Nios2/Nios2TargetObjectFile.cpp
+++ /dev/null
@@ -1,18 +0,0 @@
-//===-- Nios2TargetObjectFile.cpp - Nios2 Object Files --------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "Nios2TargetObjectFile.h"
-
-using namespace llvm;
-
-void Nios2TargetObjectFile::Initialize(MCContext &Ctx,
- const TargetMachine &TM) {
- TargetLoweringObjectFileELF::Initialize(Ctx, TM);
- InitializeELF(TM.Options.UseInitArray);
-}
diff --git a/llvm/lib/Target/Nios2/Nios2TargetObjectFile.h b/llvm/lib/Target/Nios2/Nios2TargetObjectFile.h
deleted file mode 100644
index e9ed6e31d93..00000000000
--- a/llvm/lib/Target/Nios2/Nios2TargetObjectFile.h
+++ /dev/null
@@ -1,26 +0,0 @@
-//===-- llvm/Target/Nios2TargetObjectFile.h - Nios2 Object Info -*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_LIB_TARGET_NIOS2_NIOS2TARGETOBJECTFILE_H
-#define LLVM_LIB_TARGET_NIOS2_NIOS2TARGETOBJECTFILE_H
-
-#include "Nios2TargetMachine.h"
-#include "llvm/CodeGen/TargetLoweringObjectFileImpl.h"
-
-namespace llvm {
-
-class Nios2TargetObjectFile : public TargetLoweringObjectFileELF {
-public:
- Nios2TargetObjectFile() : TargetLoweringObjectFileELF() {}
-
- void Initialize(MCContext &Ctx, const TargetMachine &TM) override;
-};
-} // end namespace llvm
-
-#endif
diff --git a/llvm/lib/Target/Nios2/Nios2TargetStreamer.h b/llvm/lib/Target/Nios2/Nios2TargetStreamer.h
deleted file mode 100644
index 1520ac27e94..00000000000
--- a/llvm/lib/Target/Nios2/Nios2TargetStreamer.h
+++ /dev/null
@@ -1,30 +0,0 @@
-//===-- Nios2TargetStreamer.h - Nios2 Target Streamer ----------*- C++ -*--===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_LIB_TARGET_NIOS2_NIOS2TARGETSTREAMER_H
-#define LLVM_LIB_TARGET_NIOS2_NIOS2TARGETSTREAMER_H
-
-#include "llvm/MC/MCRegisterInfo.h"
-#include "llvm/MC/MCStreamer.h"
-
-namespace llvm {
-
-class Nios2TargetStreamer : public MCTargetStreamer {
-public:
- Nios2TargetStreamer(MCStreamer &S);
-};
-
-// This part is for ascii assembly output
-class Nios2TargetAsmStreamer : public Nios2TargetStreamer {
-public:
- Nios2TargetAsmStreamer(MCStreamer &S, formatted_raw_ostream &OS);
-};
-
-} // namespace llvm
-#endif
diff --git a/llvm/lib/Target/Nios2/TargetInfo/CMakeLists.txt b/llvm/lib/Target/Nios2/TargetInfo/CMakeLists.txt
deleted file mode 100644
index 394d2c2680b..00000000000
--- a/llvm/lib/Target/Nios2/TargetInfo/CMakeLists.txt
+++ /dev/null
@@ -1 +0,0 @@
-add_llvm_library(LLVMNios2Info Nios2TargetInfo.cpp)
diff --git a/llvm/lib/Target/Nios2/TargetInfo/LLVMBuild.txt b/llvm/lib/Target/Nios2/TargetInfo/LLVMBuild.txt
deleted file mode 100644
index 558f7501ea6..00000000000
--- a/llvm/lib/Target/Nios2/TargetInfo/LLVMBuild.txt
+++ /dev/null
@@ -1,23 +0,0 @@
-;===- ./lib/Target/Nios2/TargetInfo/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 = Nios2Info
-parent = Nios2
-required_libraries = Support
-add_to_library_groups = Nios2
diff --git a/llvm/lib/Target/Nios2/TargetInfo/Nios2TargetInfo.cpp b/llvm/lib/Target/Nios2/TargetInfo/Nios2TargetInfo.cpp
deleted file mode 100644
index d808a96db77..00000000000
--- a/llvm/lib/Target/Nios2/TargetInfo/Nios2TargetInfo.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-//===-- Nios2TargetInfo.cpp - Nios2 Target Implementation -----------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "Nios2.h"
-#include "llvm/Support/TargetRegistry.h"
-
-using namespace llvm;
-
-Target &llvm::getTheNios2Target() {
- static Target TheNios2Target;
- return TheNios2Target;
-}
-
-extern "C" void LLVMInitializeNios2TargetInfo() {
- RegisterTarget<Triple::nios2,
- /*HasJIT=*/true>
- X(getTheNios2Target(), "nios2", "Nios2", "Nios2");
-}
diff --git a/llvm/test/CodeGen/Nios2/add-sub.ll b/llvm/test/CodeGen/Nios2/add-sub.ll
deleted file mode 100644
index 7c9a2896ed9..00000000000
--- a/llvm/test/CodeGen/Nios2/add-sub.ll
+++ /dev/null
@@ -1,19 +0,0 @@
-; RUN: llc < %s -march=nios2 2>&1 | FileCheck %s
-; RUN: llc < %s -march=nios2 -target-abi=nios2r2 2>&1 | FileCheck %s
-
-define i32 @add_reg(i32 %a, i32 %b) nounwind {
-entry:
-; CHECK: add_reg:
-; CHECK: add r2, r4, r5
- %c = add i32 %a, %b
- ret i32 %c
-}
-
-define i32 @sub_reg(i32 %a, i32 %b) nounwind {
-entry:
-; CHECK: sub_reg:
-; CHECK: sub r2, r4, r5
- %c = sub i32 %a, %b
- ret i32 %c
-}
-
diff --git a/llvm/test/CodeGen/Nios2/lit.local.cfg b/llvm/test/CodeGen/Nios2/lit.local.cfg
deleted file mode 100644
index 84c8b039391..00000000000
--- a/llvm/test/CodeGen/Nios2/lit.local.cfg
+++ /dev/null
@@ -1,3 +0,0 @@
-if not 'Nios2' in config.root.targets:
- config.unsupported = True
-
diff --git a/llvm/test/CodeGen/Nios2/mul-div.ll b/llvm/test/CodeGen/Nios2/mul-div.ll
deleted file mode 100644
index 8327823cf14..00000000000
--- a/llvm/test/CodeGen/Nios2/mul-div.ll
+++ /dev/null
@@ -1,27 +0,0 @@
-; RUN: llc < %s -march=nios2 2>&1 | FileCheck %s
-; RUN: llc < %s -march=nios2 -target-abi=nios2r2 2>&1 | FileCheck %s
-
-define i32 @mul_reg(i32 %a, i32 %b) nounwind {
-entry:
-; CHECK: mul_reg:
-; CHECK: mul r2, r4, r5
- %c = mul i32 %a, %b
- ret i32 %c
-}
-
-define i32 @div_signed(i32 %a, i32 %b) nounwind {
-entry:
-; CHECK: div_signed:
-; CHECK: div r2, r4, r5
- %c = sdiv i32 %a, %b
- ret i32 %c
-}
-
-define i32 @div_unsigned(i32 %a, i32 %b) nounwind {
-entry:
-; CHECK: div_unsigned:
-; CHECK: divu r2, r4, r5
- %c = udiv i32 %a, %b
- ret i32 %c
-}
-
diff --git a/llvm/test/CodeGen/Nios2/proc_support.ll b/llvm/test/CodeGen/Nios2/proc_support.ll
deleted file mode 100644
index c83c105724a..00000000000
--- a/llvm/test/CodeGen/Nios2/proc_support.ll
+++ /dev/null
@@ -1,10 +0,0 @@
-; This tests that llc accepts Nios2 processors.
-
-; RUN: not not llc < %s -asm-verbose=false -march=nios2 -mcpu=nios2r1 2>&1 | FileCheck %s --check-prefix=ARCH
-; RUN: not not llc < %s -asm-verbose=false -march=nios2 -mcpu=nios2r2 2>&1 | FileCheck %s --check-prefix=ARCH
-
-; ARCH-NOT: is not a recognized processor
-
-define i32 @f(i32 %i) {
- ret i32 %i
-}
diff --git a/llvm/test/CodeGen/Nios2/ret_generated.ll b/llvm/test/CodeGen/Nios2/ret_generated.ll
deleted file mode 100644
index 986c65751df..00000000000
--- a/llvm/test/CodeGen/Nios2/ret_generated.ll
+++ /dev/null
@@ -1,9 +0,0 @@
-; This tests that llc generates 'ret' instruction in assembly output.
-
-; RUN: llc < %s -march=nios2 2>&1 | FileCheck %s --check-prefix=ARCH
-
-; ARCH: ret
-
-define i32 @f(i32 %i) {
- ret i32 %i
-}
diff --git a/llvm/test/CodeGen/Nios2/shift-rotate.ll b/llvm/test/CodeGen/Nios2/shift-rotate.ll
deleted file mode 100644
index d3084b5fb59..00000000000
--- a/llvm/test/CodeGen/Nios2/shift-rotate.ll
+++ /dev/null
@@ -1,26 +0,0 @@
-; RUN: llc < %s -march=nios2 2>&1 | FileCheck %s
-; RUN: llc < %s -march=nios2 -target-abi=nios2r2 2>&1 | FileCheck %s
-
-define i32 @sll_reg(i32 %a, i32 %b) nounwind {
-entry:
-; CHECK: sll_reg:
-; CHECK: sll r2, r4, r5
- %c = shl i32 %a, %b
- ret i32 %c
-}
-
-define i32 @srl_reg(i32 %a, i32 %b) nounwind {
-entry:
-; CHECK: srl_reg:
-; CHECK: srl r2, r4, r5
- %c = lshr i32 %a, %b
- ret i32 %c
-}
-
-define i32 @sra_reg(i32 %a, i32 %b) nounwind {
-entry:
-; CHECK: sra_reg:
-; CHECK: sra r2, r4, r5
- %c = ashr i32 %a, %b
- ret i32 %c
-}
diff --git a/llvm/test/CodeGen/Nios2/target_support.ll b/llvm/test/CodeGen/Nios2/target_support.ll
deleted file mode 100644
index 90e7020b2fc..00000000000
--- a/llvm/test/CodeGen/Nios2/target_support.ll
+++ /dev/null
@@ -1,11 +0,0 @@
-; This tests that llc accepts Nios2 target.
-
-; RUN: not not llc < %s -asm-verbose=false -march=nios2 2>&1 | FileCheck %s --check-prefix=ARCH
-; RUN: not not llc < %s -asm-verbose=false -mtriple=nios2 2>&1 | FileCheck %s --check-prefix=TRIPLE
-
-; ARCH-NOT: invalid target
-; TRIPLE-NOT: unable to get target
-
-define i32 @f(i32 %i) {
- ret i32 %i
-}
diff --git a/llvm/utils/gn/secondary/clang/lib/Basic/BUILD.gn b/llvm/utils/gn/secondary/clang/lib/Basic/BUILD.gn
index 60323db120a..4d0578b0867 100644
--- a/llvm/utils/gn/secondary/clang/lib/Basic/BUILD.gn
+++ b/llvm/utils/gn/secondary/clang/lib/Basic/BUILD.gn
@@ -58,7 +58,6 @@ static_library("Basic") {
"Targets/MSP430.cpp",
"Targets/Mips.cpp",
"Targets/NVPTX.cpp",
- "Targets/Nios2.cpp",
"Targets/OSTargets.cpp",
"Targets/PNaCl.cpp",
"Targets/PPC.cpp",