[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@intel.com>
llvm-svn: 304144
2017-05-29 17:48:30 +08:00
|
|
|
//===- 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"
|
|
|
|
|
2017-12-07 20:35:02 +08:00
|
|
|
|
[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@intel.com>
llvm-svn: 304144
2017-05-29 17:48:30 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Nios2 Operand, Complex Patterns and Transformations Definitions.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2017-12-07 20:35:02 +08:00
|
|
|
def simm16 : Operand<i32> {
|
[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@intel.com>
llvm-svn: 304144
2017-05-29 17:48:30 +08:00
|
|
|
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()); }]>;
|
|
|
|
|
2018-01-09 19:15:08 +08:00
|
|
|
// Custom return SDNode
|
|
|
|
def Nios2Ret : SDNode<"Nios2ISD::Ret", SDTNone,
|
|
|
|
[SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
|
|
|
|
|
[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@intel.com>
llvm-svn: 304144
2017-05-29 17:48:30 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Instructions specific format
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2017-12-07 20:35:02 +08:00
|
|
|
// 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>;
|
|
|
|
|
2018-01-09 19:15:08 +08:00
|
|
|
// 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>;
|
|
|
|
|
2017-12-07 20:35:02 +08:00
|
|
|
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] 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@intel.com>
llvm-svn: 304144
2017-05-29 17:48:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
2017-12-07 20:35:02 +08:00
|
|
|
// Nios2 Instructions
|
[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@intel.com>
llvm-svn: 304144
2017-05-29 17:48:30 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2018-01-09 19:15:08 +08:00
|
|
|
/// 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>;
|
|
|
|
|
[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@intel.com>
llvm-svn: 304144
2017-05-29 17:48:30 +08:00
|
|
|
/// Arithmetic Instructions (ALU Immediate)
|
2017-12-07 20:35:02 +08:00
|
|
|
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)]>;
|