[llvm] r304144 - [Nios2] Target registration
Nikolai Bozhenov via llvm-commits
llvm-commits at lists.llvm.org
Mon May 29 02:48:31 PDT 2017
Author: n.bozhenov
Date: Mon May 29 04:48:30 2017
New Revision: 304144
URL: http://llvm.org/viewvc/llvm-project?rev=304144&view=rev
Log:
[Nios2] Target registration
Reviewers: craig.topper, hfinkel, joerg, lattner, zvi
Reviewed By: craig.topper
Subscribers: oren_ben_simhon, igorb, belickim, tvvikram, mgorny, llvm-commits, pavel.v.chupin, DavidKreitzer
Differential Revision: https://reviews.llvm.org/D32669
Patch by AndreiGrischenko <andrei.l.grischenko at intel.com>
Added:
llvm/trunk/lib/Target/Nios2/
llvm/trunk/lib/Target/Nios2/CMakeLists.txt (with props)
llvm/trunk/lib/Target/Nios2/LLVMBuild.txt (with props)
llvm/trunk/lib/Target/Nios2/MCTargetDesc/
llvm/trunk/lib/Target/Nios2/MCTargetDesc/CMakeLists.txt (with props)
llvm/trunk/lib/Target/Nios2/MCTargetDesc/LLVMBuild.txt (with props)
llvm/trunk/lib/Target/Nios2/MCTargetDesc/Nios2MCTargetDesc.cpp (with props)
llvm/trunk/lib/Target/Nios2/MCTargetDesc/Nios2MCTargetDesc.h (with props)
llvm/trunk/lib/Target/Nios2/Nios2.h (with props)
llvm/trunk/lib/Target/Nios2/Nios2.td
llvm/trunk/lib/Target/Nios2/Nios2InstrFormats.td
llvm/trunk/lib/Target/Nios2/Nios2InstrInfo.td
llvm/trunk/lib/Target/Nios2/Nios2RegisterInfo.td
llvm/trunk/lib/Target/Nios2/Nios2TargetMachine.cpp (with props)
llvm/trunk/lib/Target/Nios2/Nios2TargetMachine.h (with props)
llvm/trunk/lib/Target/Nios2/TargetInfo/
llvm/trunk/lib/Target/Nios2/TargetInfo/CMakeLists.txt (with props)
llvm/trunk/lib/Target/Nios2/TargetInfo/LLVMBuild.txt (with props)
llvm/trunk/lib/Target/Nios2/TargetInfo/Nios2TargetInfo.cpp (with props)
llvm/trunk/test/CodeGen/Nios2/
llvm/trunk/test/CodeGen/Nios2/lit.local.cfg (with props)
llvm/trunk/test/CodeGen/Nios2/target_support.ll
Modified:
llvm/trunk/include/llvm/ADT/Triple.h
llvm/trunk/lib/Support/Triple.cpp
llvm/trunk/lib/Target/LLVMBuild.txt
Modified: llvm/trunk/include/llvm/ADT/Triple.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/Triple.h?rev=304144&r1=304143&r2=304144&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/Triple.h (original)
+++ llvm/trunk/include/llvm/ADT/Triple.h Mon May 29 04:48:30 2017
@@ -59,6 +59,7 @@ public:
mips64, // MIPS64: mips64
mips64el, // MIPS64EL: mips64el
msp430, // MSP430: msp430
+ nios2, // NIOSII: nios2
ppc, // PPC: powerpc
ppc64, // PPC64: powerpc64, ppu
ppc64le, // PPC64LE: powerpc64le
Modified: llvm/trunk/lib/Support/Triple.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Triple.cpp?rev=304144&r1=304143&r2=304144&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Triple.cpp (original)
+++ llvm/trunk/lib/Support/Triple.cpp Mon May 29 04:48:30 2017
@@ -34,6 +34,7 @@ StringRef Triple::getArchTypeName(ArchTy
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";
@@ -98,6 +99,8 @@ StringRef Triple::getArchTypePrefix(Arch
case mips64:
case mips64el: return "mips";
+ case nios2: return "nios2";
+
case hexagon: return "hexagon";
case amdgcn: return "amdgcn";
@@ -262,6 +265,7 @@ Triple::ArchType Triple::getArchTypeForL
.Case("mips64", mips64)
.Case("mips64el", mips64el)
.Case("msp430", msp430)
+ .Case("nios2", nios2)
.Case("ppc64", ppc64)
.Case("ppc32", ppc)
.Case("ppc", ppc)
@@ -384,6 +388,7 @@ static Triple::ArchType parseArch(String
.Cases("mipsel", "mipsallegrexel", Triple::mipsel)
.Cases("mips64", "mips64eb", Triple::mips64)
.Case("mips64el", Triple::mips64el)
+ .Case("nios2", Triple::nios2)
.Case("r600", Triple::r600)
.Case("amdgcn", Triple::amdgcn)
.Case("riscv32", Triple::riscv32)
@@ -625,6 +630,7 @@ static Triple::ObjectFormatType getDefau
case Triple::mips64el:
case Triple::mipsel:
case Triple::msp430:
+ case Triple::nios2:
case Triple::nvptx:
case Triple::nvptx64:
case Triple::ppc64le:
@@ -1162,6 +1168,7 @@ static unsigned getArchPointerBitWidth(l
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:
@@ -1245,6 +1252,7 @@ Triple Triple::get32BitArchVariant() con
case Triple::le32:
case Triple::mips:
case Triple::mipsel:
+ case Triple::nios2:
case Triple::nvptx:
case Triple::ppc:
case Triple::r600:
@@ -1292,6 +1300,7 @@ Triple Triple::get64BitArchVariant() con
case Triple::kalimba:
case Triple::lanai:
case Triple::msp430:
+ case Triple::nios2:
case Triple::r600:
case Triple::tce:
case Triple::tcele:
@@ -1363,6 +1372,7 @@ Triple Triple::getBigEndianArchVariant()
case Triple::le32:
case Triple::le64:
case Triple::msp430:
+ case Triple::nios2:
case Triple::nvptx64:
case Triple::nvptx:
case Triple::r600:
@@ -1449,6 +1459,7 @@ 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:
Modified: llvm/trunk/lib/Target/LLVMBuild.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/LLVMBuild.txt?rev=304144&r1=304143&r2=304144&view=diff
==============================================================================
--- llvm/trunk/lib/Target/LLVMBuild.txt (original)
+++ llvm/trunk/lib/Target/LLVMBuild.txt Mon May 29 04:48:30 2017
@@ -29,6 +29,7 @@ subdirectories =
MSP430
NVPTX
Mips
+ Nios2
PowerPC
RISCV
Sparc
Added: llvm/trunk/lib/Target/Nios2/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Nios2/CMakeLists.txt?rev=304144&view=auto
==============================================================================
--- llvm/trunk/lib/Target/Nios2/CMakeLists.txt (added)
+++ llvm/trunk/lib/Target/Nios2/CMakeLists.txt Mon May 29 04:48:30 2017
@@ -0,0 +1,18 @@
+set(LLVM_TARGET_DEFINITIONS Nios2.td)
+
+#Generate Nios2GenRegisterInfo.inc and Nios2GenInstrInfo.inc which included by
+#your hand code C++ files.
+#Nios2GenRegisterInfo.inc came from Nios2RegisterInfo.td, Nios2GenInstrInfo.inc
+#came from Nios2InstrInfo.td.
+tablegen(LLVM Nios2GenRegisterInfo.inc -gen-register-info)
+tablegen(LLVM Nios2GenInstrInfo.inc -gen-instr-info)
+
+#Nios2CommonTableGen must be defined
+add_public_tablegen_target(Nios2CommonTableGen)
+
+#Nios2CodeGen should match with LLVMBuild.txt Nios2CodeGen
+add_llvm_target(Nios2CodeGen Nios2TargetMachine.cpp)
+
+#Should match with "subdirectories = MCTargetDesc TargetInfo" in LLVMBuild.txt
+add_subdirectory(TargetInfo)
+add_subdirectory(MCTargetDesc)
Propchange: llvm/trunk/lib/Target/Nios2/CMakeLists.txt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: llvm/trunk/lib/Target/Nios2/CMakeLists.txt
------------------------------------------------------------------------------
svn:keywords = Author Date Id Rev URL
Propchange: llvm/trunk/lib/Target/Nios2/CMakeLists.txt
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: llvm/trunk/lib/Target/Nios2/LLVMBuild.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Nios2/LLVMBuild.txt?rev=304144&view=auto
==============================================================================
--- llvm/trunk/lib/Target/Nios2/LLVMBuild.txt (added)
+++ llvm/trunk/lib/Target/Nios2/LLVMBuild.txt Mon May 29 04:48:30 2017
@@ -0,0 +1,61 @@
+;===- ./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 =
+ 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.
+
+[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 = CodeGen
+ Core
+ GlobalISel
+ MC
+ Nios2Desc
+ Nios2Info
+ 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
Propchange: llvm/trunk/lib/Target/Nios2/LLVMBuild.txt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: llvm/trunk/lib/Target/Nios2/LLVMBuild.txt
------------------------------------------------------------------------------
svn:keywords = Author Date Id Rev URL
Propchange: llvm/trunk/lib/Target/Nios2/LLVMBuild.txt
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: llvm/trunk/lib/Target/Nios2/MCTargetDesc/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Nios2/MCTargetDesc/CMakeLists.txt?rev=304144&view=auto
==============================================================================
--- llvm/trunk/lib/Target/Nios2/MCTargetDesc/CMakeLists.txt (added)
+++ llvm/trunk/lib/Target/Nios2/MCTargetDesc/CMakeLists.txt Mon May 29 04:48:30 2017
@@ -0,0 +1,2 @@
+#MCTargetDesc / CMakeLists.txt
+add_llvm_library(LLVMNios2Desc Nios2MCTargetDesc.cpp)
Propchange: llvm/trunk/lib/Target/Nios2/MCTargetDesc/CMakeLists.txt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: llvm/trunk/lib/Target/Nios2/MCTargetDesc/CMakeLists.txt
------------------------------------------------------------------------------
svn:keywords = Author Date Id Rev URL
Propchange: llvm/trunk/lib/Target/Nios2/MCTargetDesc/CMakeLists.txt
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: llvm/trunk/lib/Target/Nios2/MCTargetDesc/LLVMBuild.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Nios2/MCTargetDesc/LLVMBuild.txt?rev=304144&view=auto
==============================================================================
--- llvm/trunk/lib/Target/Nios2/MCTargetDesc/LLVMBuild.txt (added)
+++ llvm/trunk/lib/Target/Nios2/MCTargetDesc/LLVMBuild.txt Mon May 29 04:48:30 2017
@@ -0,0 +1,25 @@
+;===- ./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
+ Nios2Info
+ Support
+add_to_library_groups = Nios2
Propchange: llvm/trunk/lib/Target/Nios2/MCTargetDesc/LLVMBuild.txt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: llvm/trunk/lib/Target/Nios2/MCTargetDesc/LLVMBuild.txt
------------------------------------------------------------------------------
svn:keywords = Author Date Id Rev URL
Propchange: llvm/trunk/lib/Target/Nios2/MCTargetDesc/LLVMBuild.txt
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: llvm/trunk/lib/Target/Nios2/MCTargetDesc/Nios2MCTargetDesc.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Nios2/MCTargetDesc/Nios2MCTargetDesc.cpp?rev=304144&view=auto
==============================================================================
--- llvm/trunk/lib/Target/Nios2/MCTargetDesc/Nios2MCTargetDesc.cpp (added)
+++ llvm/trunk/lib/Target/Nios2/MCTargetDesc/Nios2MCTargetDesc.cpp Mon May 29 04:48:30 2017
@@ -0,0 +1,25 @@
+//===-- 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 "llvm/MC/MCInstrInfo.h"
+
+using namespace llvm;
+
+#define GET_INSTRINFO_MC_DESC
+#include "Nios2GenInstrInfo.inc"
+
+#define GET_REGINFO_MC_DESC
+#include "Nios2GenRegisterInfo.inc"
+
+extern "C" void LLVMInitializeNios2TargetMC() {}
Propchange: llvm/trunk/lib/Target/Nios2/MCTargetDesc/Nios2MCTargetDesc.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: llvm/trunk/lib/Target/Nios2/MCTargetDesc/Nios2MCTargetDesc.cpp
------------------------------------------------------------------------------
svn:keywords = Author Date Id Rev URL
Propchange: llvm/trunk/lib/Target/Nios2/MCTargetDesc/Nios2MCTargetDesc.cpp
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: llvm/trunk/lib/Target/Nios2/MCTargetDesc/Nios2MCTargetDesc.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Nios2/MCTargetDesc/Nios2MCTargetDesc.h?rev=304144&view=auto
==============================================================================
--- llvm/trunk/lib/Target/Nios2/MCTargetDesc/Nios2MCTargetDesc.h (added)
+++ llvm/trunk/lib/Target/Nios2/MCTargetDesc/Nios2MCTargetDesc.h Mon May 29 04:48:30 2017
@@ -0,0 +1,34 @@
+//===-- 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
+
+namespace llvm {
+class Target;
+class Triple;
+
+Target &getTheNios2Target();
+
+} // 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"
+
+#endif
Propchange: llvm/trunk/lib/Target/Nios2/MCTargetDesc/Nios2MCTargetDesc.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: llvm/trunk/lib/Target/Nios2/MCTargetDesc/Nios2MCTargetDesc.h
------------------------------------------------------------------------------
svn:keywords = Author Date Id Rev URL
Propchange: llvm/trunk/lib/Target/Nios2/MCTargetDesc/Nios2MCTargetDesc.h
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: llvm/trunk/lib/Target/Nios2/Nios2.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Nios2/Nios2.h?rev=304144&view=auto
==============================================================================
--- llvm/trunk/lib/Target/Nios2/Nios2.h (added)
+++ llvm/trunk/lib/Target/Nios2/Nios2.h Mon May 29 04:48:30 2017
@@ -0,0 +1,25 @@
+//===-- 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 Nios2TargetMachine;
+} // namespace llvm
+
+#endif
Propchange: llvm/trunk/lib/Target/Nios2/Nios2.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: llvm/trunk/lib/Target/Nios2/Nios2.h
------------------------------------------------------------------------------
svn:keywords = Author Date Id Rev URL
Propchange: llvm/trunk/lib/Target/Nios2/Nios2.h
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: llvm/trunk/lib/Target/Nios2/Nios2.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Nios2/Nios2.td?rev=304144&view=auto
==============================================================================
--- llvm/trunk/lib/Target/Nios2/Nios2.td (added)
+++ llvm/trunk/lib/Target/Nios2/Nios2.td Mon May 29 04:48:30 2017
@@ -0,0 +1,29 @@
+//===-- 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.
+//
+//===----------------------------------------------------------------------===//
+
+//===----------------------------------------------------------------------===//
+// Target-independent interfaces
+//===----------------------------------------------------------------------===//
+
+include "llvm/Target/Target.td"
+
+//===----------------------------------------------------------------------===//
+// Target-dependent interfaces
+//===----------------------------------------------------------------------===//
+
+//===----------------------------------------------------------------------===//
+// Calling Conv, Instruction Descriptions
+//===----------------------------------------------------------------------===//
+
+include "Nios2RegisterInfo.td"
+include "Nios2InstrInfo.td"
+
+def Nios2InstrInfo : InstrInfo;
+
+def Nios2 : Target { let InstructionSet = Nios2InstrInfo; }
Added: llvm/trunk/lib/Target/Nios2/Nios2InstrFormats.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Nios2/Nios2InstrFormats.td?rev=304144&view=auto
==============================================================================
--- llvm/trunk/lib/Target/Nios2/Nios2InstrFormats.td (added)
+++ llvm/trunk/lib/Target/Nios2/Nios2InstrFormats.td Mon May 29 04:48:30 2017
@@ -0,0 +1,117 @@
+//===-- 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<3> val> {
+ bits<3> Value = val;
+}
+
+def Pseudo : Format<0>;
+def FrmI : Format<1>;
+def FrmR : Format<2>;
+def FrmJ : Format<3>;
+def FrmOther : Format<4>; // Instruction w/ a custom format
+
+// Generic Nios2 Format
+class Nios2Inst<dag outs, dag ins, string asmstr, list<dag> pattern, Format f>
+ : Instruction {
+ 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;
+
+ //
+ // Attributes specific to Nios2 instructions:
+ //
+ bits<3> FormBits = Form.Value;
+
+ // TSFlags layout should be kept in sync with Nios2InstrInfo.h.
+ let TSFlags{2 - 0} = FormBits;
+
+ let DecoderNamespace = "Nios2";
+}
+
+// Nios2 Instruction Format
+class InstSE<dag outs, dag ins, string asmstr, list<dag> pattern, Format f>
+ : Nios2Inst<outs, ins, asmstr, pattern, f> {
+}
+
+//===----------------------------------------------------------------------===//
+// Format I instruction class in Nios2 : <|A|B|immediate|opcode|>
+//===----------------------------------------------------------------------===//
+
+class FI<bits<6> op, dag outs, dag ins, string asmstr, list<dag> pattern>
+ : InstSE<outs, ins, asmstr, pattern, 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>
+ : InstSE<outs, ins, asmstr, pattern, FrmR> {
+ bits<5> rA;
+ bits<5> rB;
+ bits<5> rC;
+ bits<5> imm = 0;
+
+ // opcode is always 0x3a for R instr.
+ let Opcode = 0x3a;
+
+ let Inst{31 - 27} = rA;
+ let Inst{26 - 22} = rB;
+ let Inst{21 - 17} = rC;
+ // opx stands for opcode extension
+ let Inst{16 - 11} = opx;
+ // optional 5-bit immediate value
+ let Inst{10 - 6} = imm;
+}
+
+//===----------------------------------------------------------------------===//
+// Format J instruction class in Nios2 : <|address|opcode|>
+//===----------------------------------------------------------------------===//
+
+class FJ<bits<6> op, dag outs, dag ins, string asmstr, list<dag> pattern>
+ : InstSE<outs, ins, asmstr, pattern, FrmJ> {
+ bits<26> addr;
+
+ let Opcode = op;
+
+ let Inst{31 - 6} = addr;
+}
Added: llvm/trunk/lib/Target/Nios2/Nios2InstrInfo.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Nios2/Nios2InstrInfo.td?rev=304144&view=auto
==============================================================================
--- llvm/trunk/lib/Target/Nios2/Nios2InstrInfo.td (added)
+++ llvm/trunk/lib/Target/Nios2/Nios2InstrInfo.td Mon May 29 04:48:30 2017
@@ -0,0 +1,50 @@
+//===- 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()); }]>;
+
+//===----------------------------------------------------------------------===//
+// Instructions specific format
+//===----------------------------------------------------------------------===//
+
+// Arithmetic and logical instructions with 2 register operands.
+class ArithLogicI<bits<6> op, string instr_asm, SDNode OpNode,
+ Operand Od, PatLeaf imm_type, RegisterClass RC> :
+ FI<op, (outs RC:$rB), (ins RC:$rA, Od:$imm16),
+ !strconcat(instr_asm, "\t$rB, $rA, $imm16"),
+ [(set RC:$rB, (OpNode RC:$rA, imm_type:$imm16))]> {
+ let isReMaterializable = 1;
+}
+
+//===----------------------------------------------------------------------===//
+// Nios2 R1 Instructions
+//===----------------------------------------------------------------------===//
+
+/// Arithmetic Instructions (ALU Immediate)
+def ADDi : ArithLogicI<0x04, "addi", add, simm16, immSExt16, CPURegs>;
Added: llvm/trunk/lib/Target/Nios2/Nios2RegisterInfo.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Nios2/Nios2RegisterInfo.td?rev=304144&view=auto
==============================================================================
--- llvm/trunk/lib/Target/Nios2/Nios2RegisterInfo.td (added)
+++ llvm/trunk/lib/Target/Nios2/Nios2RegisterInfo.td Mon May 29 04:48:30 2017
@@ -0,0 +1,60 @@
+//===-- 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)>;
Added: llvm/trunk/lib/Target/Nios2/Nios2TargetMachine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Nios2/Nios2TargetMachine.cpp?rev=304144&view=auto
==============================================================================
--- llvm/trunk/lib/Target/Nios2/Nios2TargetMachine.cpp (added)
+++ llvm/trunk/lib/Target/Nios2/Nios2TargetMachine.cpp Mon May 29 04:48:30 2017
@@ -0,0 +1,46 @@
+//===-- 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"
+
+using namespace llvm;
+
+#define DEBUG_TYPE "nios2"
+
+extern "C" void LLVMInitializeNios2Target() {
+ // Register the target.
+}
+
+static std::string computeDataLayout(const Triple &TT, StringRef CPU,
+ const TargetOptions &Options) {
+ return "e-p:32:32:32-i8:8:32-i16:16:32-n32";
+}
+
+static Reloc::Model getEffectiveRelocModel(CodeModel::Model CM,
+ Optional<Reloc::Model> RM) {
+ if (!RM.hasValue() || CM == CodeModel::JITDefault)
+ return Reloc::Static;
+ return *RM;
+}
+
+Nios2TargetMachine::Nios2TargetMachine(const Target &T, const Triple &TT,
+ StringRef CPU, StringRef FS,
+ const TargetOptions &Options,
+ Optional<Reloc::Model> RM,
+ CodeModel::Model CM,
+ CodeGenOpt::Level OL)
+ : LLVMTargetMachine(T, computeDataLayout(TT, CPU, Options), TT, CPU, FS,
+ Options, getEffectiveRelocModel(CM, RM), CM, OL) {}
+
+Nios2TargetMachine::~Nios2TargetMachine() {}
Propchange: llvm/trunk/lib/Target/Nios2/Nios2TargetMachine.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: llvm/trunk/lib/Target/Nios2/Nios2TargetMachine.cpp
------------------------------------------------------------------------------
svn:keywords = Author Date Id Rev URL
Propchange: llvm/trunk/lib/Target/Nios2/Nios2TargetMachine.cpp
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: llvm/trunk/lib/Target/Nios2/Nios2TargetMachine.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Nios2/Nios2TargetMachine.h?rev=304144&view=auto
==============================================================================
--- llvm/trunk/lib/Target/Nios2/Nios2TargetMachine.h (added)
+++ llvm/trunk/lib/Target/Nios2/Nios2TargetMachine.h Mon May 29 04:48:30 2017
@@ -0,0 +1,30 @@
+//===-- 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 "llvm/Target/TargetMachine.h"
+
+namespace llvm {
+class Nios2TargetMachine : public LLVMTargetMachine {
+public:
+ Nios2TargetMachine(const Target &T, const Triple &TT, StringRef CPU,
+ StringRef FS, const TargetOptions &Options,
+ Optional<Reloc::Model> RM, CodeModel::Model CM,
+ CodeGenOpt::Level OL);
+ ~Nios2TargetMachine() override;
+};
+} // namespace llvm
+
+#endif
Propchange: llvm/trunk/lib/Target/Nios2/Nios2TargetMachine.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: llvm/trunk/lib/Target/Nios2/Nios2TargetMachine.h
------------------------------------------------------------------------------
svn:keywords = Author Date Id Rev URL
Propchange: llvm/trunk/lib/Target/Nios2/Nios2TargetMachine.h
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: llvm/trunk/lib/Target/Nios2/TargetInfo/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Nios2/TargetInfo/CMakeLists.txt?rev=304144&view=auto
==============================================================================
--- llvm/trunk/lib/Target/Nios2/TargetInfo/CMakeLists.txt (added)
+++ llvm/trunk/lib/Target/Nios2/TargetInfo/CMakeLists.txt Mon May 29 04:48:30 2017
@@ -0,0 +1 @@
+add_llvm_library(LLVMNios2Info Nios2TargetInfo.cpp)
Propchange: llvm/trunk/lib/Target/Nios2/TargetInfo/CMakeLists.txt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: llvm/trunk/lib/Target/Nios2/TargetInfo/CMakeLists.txt
------------------------------------------------------------------------------
svn:keywords = Author Date Id Rev URL
Propchange: llvm/trunk/lib/Target/Nios2/TargetInfo/CMakeLists.txt
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: llvm/trunk/lib/Target/Nios2/TargetInfo/LLVMBuild.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Nios2/TargetInfo/LLVMBuild.txt?rev=304144&view=auto
==============================================================================
--- llvm/trunk/lib/Target/Nios2/TargetInfo/LLVMBuild.txt (added)
+++ llvm/trunk/lib/Target/Nios2/TargetInfo/LLVMBuild.txt Mon May 29 04:48:30 2017
@@ -0,0 +1,23 @@
+;===- ./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
Propchange: llvm/trunk/lib/Target/Nios2/TargetInfo/LLVMBuild.txt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: llvm/trunk/lib/Target/Nios2/TargetInfo/LLVMBuild.txt
------------------------------------------------------------------------------
svn:keywords = Author Date Id Rev URL
Propchange: llvm/trunk/lib/Target/Nios2/TargetInfo/LLVMBuild.txt
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: llvm/trunk/lib/Target/Nios2/TargetInfo/Nios2TargetInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Nios2/TargetInfo/Nios2TargetInfo.cpp?rev=304144&view=auto
==============================================================================
--- llvm/trunk/lib/Target/Nios2/TargetInfo/Nios2TargetInfo.cpp (added)
+++ llvm/trunk/lib/Target/Nios2/TargetInfo/Nios2TargetInfo.cpp Mon May 29 04:48:30 2017
@@ -0,0 +1,24 @@
+//===-- 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");
+}
Propchange: llvm/trunk/lib/Target/Nios2/TargetInfo/Nios2TargetInfo.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: llvm/trunk/lib/Target/Nios2/TargetInfo/Nios2TargetInfo.cpp
------------------------------------------------------------------------------
svn:keywords = Author Date Id Rev URL
Propchange: llvm/trunk/lib/Target/Nios2/TargetInfo/Nios2TargetInfo.cpp
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: llvm/trunk/test/CodeGen/Nios2/lit.local.cfg
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Nios2/lit.local.cfg?rev=304144&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/Nios2/lit.local.cfg (added)
+++ llvm/trunk/test/CodeGen/Nios2/lit.local.cfg Mon May 29 04:48:30 2017
@@ -0,0 +1,3 @@
+if not 'Nios2' in config.root.targets:
+ config.unsupported = True
+
Propchange: llvm/trunk/test/CodeGen/Nios2/lit.local.cfg
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: llvm/trunk/test/CodeGen/Nios2/lit.local.cfg
------------------------------------------------------------------------------
svn:keywords = Author Date Id Rev URL
Propchange: llvm/trunk/test/CodeGen/Nios2/lit.local.cfg
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: llvm/trunk/test/CodeGen/Nios2/target_support.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Nios2/target_support.ll?rev=304144&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/Nios2/target_support.ll (added)
+++ llvm/trunk/test/CodeGen/Nios2/target_support.ll Mon May 29 04:48:30 2017
@@ -0,0 +1,11 @@
+; 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
+}
More information about the llvm-commits
mailing list