2010-08-18 00:20:04 +08:00
|
|
|
//===- MBlazeInstrInfo.td - MBlaze Instruction defs --------*- tablegen -*-===//
|
2010-02-24 03:15:24 +08:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Instruction format superclass
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
include "MBlazeInstrFormats.td"
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
2010-10-21 11:57:26 +08:00
|
|
|
// MBlaze type profiles
|
2010-02-24 03:15:24 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
2010-10-21 11:57:26 +08:00
|
|
|
|
|
|
|
// def SDTMBlazeSelectCC : SDTypeProfile<1, 3, [SDTCisSameAs<0, 1>]>;
|
2010-02-24 03:15:24 +08:00
|
|
|
def SDT_MBlazeRet : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
|
|
|
|
def SDT_MBlazeJmpLink : SDTypeProfile<0, 1, [SDTCisVT<0, i32>]>;
|
2010-10-21 11:57:26 +08:00
|
|
|
def SDT_MBCallSeqStart : SDCallSeqStart<[SDTCisVT<0, i32>]>;
|
|
|
|
def SDT_MBCallSeqEnd : SDCallSeqEnd<[SDTCisVT<0, i32>, SDTCisVT<1, i32>]>;
|
2010-02-24 03:15:24 +08:00
|
|
|
|
2010-10-21 11:57:26 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// MBlaze specific nodes
|
|
|
|
//===----------------------------------------------------------------------===//
|
2010-02-24 03:15:24 +08:00
|
|
|
|
2010-10-21 11:57:26 +08:00
|
|
|
def MBlazeRet : SDNode<"MBlazeISD::Ret", SDT_MBlazeRet,
|
2010-02-24 03:15:24 +08:00
|
|
|
[SDNPHasChain, SDNPOptInFlag]>;
|
|
|
|
|
2010-10-21 11:57:26 +08:00
|
|
|
def MBlazeJmpLink : SDNode<"MBlazeISD::JmpLink",SDT_MBlazeJmpLink,
|
|
|
|
[SDNPHasChain,SDNPOptInFlag,SDNPOutFlag]>;
|
2010-10-21 11:34:22 +08:00
|
|
|
|
2010-10-21 11:57:26 +08:00
|
|
|
def MBWrapper : SDNode<"MBlazeISD::Wrap", SDTIntUnaryOp>;
|
2010-02-24 03:15:24 +08:00
|
|
|
|
|
|
|
def callseq_start : SDNode<"ISD::CALLSEQ_START", SDT_MBCallSeqStart,
|
|
|
|
[SDNPHasChain, SDNPOutFlag]>;
|
2010-10-21 11:57:26 +08:00
|
|
|
|
2010-02-24 03:15:24 +08:00
|
|
|
def callseq_end : SDNode<"ISD::CALLSEQ_END", SDT_MBCallSeqEnd,
|
|
|
|
[SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// MBlaze Instruction Predicate Definitions.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
def HasPipe3 : Predicate<"Subtarget.hasPipe3()">;
|
|
|
|
def HasBarrel : Predicate<"Subtarget.hasBarrel()">;
|
|
|
|
def NoBarrel : Predicate<"!Subtarget.hasBarrel()">;
|
|
|
|
def HasDiv : Predicate<"Subtarget.hasDiv()">;
|
|
|
|
def HasMul : Predicate<"Subtarget.hasMul()">;
|
|
|
|
def HasFSL : Predicate<"Subtarget.hasFSL()">;
|
|
|
|
def HasEFSL : Predicate<"Subtarget.hasEFSL()">;
|
|
|
|
def HasMSRSet : Predicate<"Subtarget.hasMSRSet()">;
|
|
|
|
def HasException : Predicate<"Subtarget.hasException()">;
|
|
|
|
def HasPatCmp : Predicate<"Subtarget.hasPatCmp()">;
|
|
|
|
def HasFPU : Predicate<"Subtarget.hasFPU()">;
|
|
|
|
def HasESR : Predicate<"Subtarget.hasESR()">;
|
|
|
|
def HasPVR : Predicate<"Subtarget.hasPVR()">;
|
|
|
|
def HasMul64 : Predicate<"Subtarget.hasMul64()">;
|
|
|
|
def HasSqrt : Predicate<"Subtarget.hasSqrt()">;
|
|
|
|
def HasMMU : Predicate<"Subtarget.hasMMU()">;
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// MBlaze Operand, Complex Patterns and Transformations Definitions.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
// Instruction operand types
|
|
|
|
def brtarget : Operand<OtherVT>;
|
|
|
|
def calltarget : Operand<i32>;
|
|
|
|
def simm16 : Operand<i32>;
|
|
|
|
def uimm5 : Operand<i32>;
|
|
|
|
def fimm : Operand<f32>;
|
|
|
|
|
|
|
|
// Unsigned Operand
|
|
|
|
def uimm16 : Operand<i32> {
|
|
|
|
let PrintMethod = "printUnsignedImm";
|
|
|
|
}
|
|
|
|
|
|
|
|
// FSL Operand
|
|
|
|
def fslimm : Operand<i32> {
|
|
|
|
let PrintMethod = "printFSLImm";
|
|
|
|
}
|
|
|
|
|
|
|
|
// Address operand
|
|
|
|
def memri : Operand<i32> {
|
|
|
|
let PrintMethod = "printMemOperand";
|
2010-10-22 03:48:38 +08:00
|
|
|
let MIOperandInfo = (ops simm16, GPR);
|
2010-02-24 03:15:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
def memrr : Operand<i32> {
|
|
|
|
let PrintMethod = "printMemOperand";
|
2010-10-22 03:48:38 +08:00
|
|
|
let MIOperandInfo = (ops GPR, GPR);
|
2010-02-24 03:15:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Node immediate fits as 16-bit sign extended on target immediate.
|
|
|
|
def immSExt16 : PatLeaf<(imm), [{
|
|
|
|
return (N->getZExtValue() >> 16) == 0;
|
|
|
|
}]>;
|
|
|
|
|
|
|
|
// Node immediate fits as 16-bit zero extended on target immediate.
|
|
|
|
// The LO16 param means that only the lower 16 bits of the node
|
|
|
|
// immediate are caught.
|
|
|
|
// e.g. addiu, sltiu
|
|
|
|
def immZExt16 : PatLeaf<(imm), [{
|
|
|
|
return (N->getZExtValue() >> 16) == 0;
|
2010-10-21 11:57:26 +08:00
|
|
|
}]>;
|
2010-02-24 03:15:24 +08:00
|
|
|
|
|
|
|
// FSL immediate field must fit in 4 bits.
|
|
|
|
def immZExt4 : PatLeaf<(imm), [{
|
2010-10-21 11:57:26 +08:00
|
|
|
return N->getZExtValue() == ((N->getZExtValue()) & 0xf) ;
|
2010-02-24 03:15:24 +08:00
|
|
|
}]>;
|
|
|
|
|
|
|
|
// shamt field must fit in 5 bits.
|
|
|
|
def immZExt5 : PatLeaf<(imm), [{
|
2010-10-21 11:57:26 +08:00
|
|
|
return N->getZExtValue() == ((N->getZExtValue()) & 0x1f) ;
|
2010-02-24 03:15:24 +08:00
|
|
|
}]>;
|
|
|
|
|
2010-10-21 11:57:26 +08:00
|
|
|
// MBlaze Address Mode. SDNode frameindex could possibily be a match
|
2010-02-24 03:15:24 +08:00
|
|
|
// since load and store instructions from stack used it.
|
|
|
|
def iaddr : ComplexPattern<i32, 2, "SelectAddrRegImm", [frameindex], []>;
|
|
|
|
def xaddr : ComplexPattern<i32, 2, "SelectAddrRegReg", [], []>;
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Pseudo instructions
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
// As stack alignment is always done with addiu, we need a 16-bit immediate
|
2010-11-03 07:57:05 +08:00
|
|
|
let Defs = [R1], Uses = [R1] in {
|
2010-02-24 03:15:24 +08:00
|
|
|
def ADJCALLSTACKDOWN : MBlazePseudo<(outs), (ins simm16:$amt),
|
2010-10-21 11:57:26 +08:00
|
|
|
"#ADJCALLSTACKDOWN $amt",
|
2010-02-24 03:15:24 +08:00
|
|
|
[(callseq_start timm:$amt)]>;
|
|
|
|
def ADJCALLSTACKUP : MBlazePseudo<(outs),
|
|
|
|
(ins uimm16:$amt1, simm16:$amt2),
|
2010-10-21 11:57:26 +08:00
|
|
|
"#ADJCALLSTACKUP $amt1",
|
2010-02-24 03:15:24 +08:00
|
|
|
[(callseq_end timm:$amt1, timm:$amt2)]>;
|
|
|
|
}
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Instructions specific format
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Arithmetic Instructions
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
class Arith<bits<6> op, bits<11> flags, string instr_asm, SDNode OpNode,
|
|
|
|
InstrItinClass itin> :
|
2010-10-22 03:48:38 +08:00
|
|
|
TA<op, flags, (outs GPR:$dst), (ins GPR:$b, GPR:$c),
|
2010-02-24 03:15:24 +08:00
|
|
|
!strconcat(instr_asm, " $dst, $b, $c"),
|
2010-10-22 03:48:38 +08:00
|
|
|
[(set GPR:$dst, (OpNode GPR:$b, GPR:$c))], itin>;
|
2010-02-24 03:15:24 +08:00
|
|
|
|
|
|
|
class ArithI<bits<6> op, string instr_asm, SDNode OpNode,
|
|
|
|
Operand Od, PatLeaf imm_type> :
|
2010-10-22 03:48:38 +08:00
|
|
|
TB<op, (outs GPR:$dst), (ins GPR:$b, Od:$c),
|
2010-10-21 11:57:26 +08:00
|
|
|
!strconcat(instr_asm, " $dst, $b, $c"),
|
2010-10-22 03:48:38 +08:00
|
|
|
[(set GPR:$dst, (OpNode GPR:$b, imm_type:$c))], IIAlu>;
|
2010-02-24 03:15:24 +08:00
|
|
|
|
|
|
|
class ArithR<bits<6> op, bits<11> flags, string instr_asm, SDNode OpNode,
|
|
|
|
InstrItinClass itin> :
|
2010-10-22 03:48:38 +08:00
|
|
|
TA<op, flags, (outs GPR:$dst), (ins GPR:$c, GPR:$b),
|
2010-10-21 11:57:26 +08:00
|
|
|
!strconcat(instr_asm, " $dst, $c, $b"),
|
2010-10-22 03:48:38 +08:00
|
|
|
[(set GPR:$dst, (OpNode GPR:$b, GPR:$c))], itin>;
|
2010-02-24 03:15:24 +08:00
|
|
|
|
|
|
|
class ArithRI<bits<6> op, string instr_asm, SDNode OpNode,
|
|
|
|
Operand Od, PatLeaf imm_type> :
|
2010-10-22 03:48:38 +08:00
|
|
|
TBR<op, (outs GPR:$dst), (ins Od:$b, GPR:$c),
|
2010-02-24 03:15:24 +08:00
|
|
|
!strconcat(instr_asm, " $dst, $c, $b"),
|
2010-10-22 03:48:38 +08:00
|
|
|
[(set GPR:$dst, (OpNode imm_type:$b, GPR:$c))], IIAlu>;
|
2010-02-24 03:15:24 +08:00
|
|
|
|
|
|
|
class ArithN<bits<6> op, bits<11> flags, string instr_asm,
|
|
|
|
InstrItinClass itin> :
|
2010-10-22 03:48:38 +08:00
|
|
|
TA<op, flags, (outs GPR:$dst), (ins GPR:$b, GPR:$c),
|
2010-02-24 03:15:24 +08:00
|
|
|
!strconcat(instr_asm, " $dst, $b, $c"),
|
|
|
|
[], itin>;
|
|
|
|
|
|
|
|
class ArithNI<bits<6> op, string instr_asm,Operand Od, PatLeaf imm_type> :
|
2010-10-22 03:48:38 +08:00
|
|
|
TB<op, (outs GPR:$dst), (ins GPR:$b, Od:$c),
|
2010-10-21 11:57:26 +08:00
|
|
|
!strconcat(instr_asm, " $dst, $b, $c"),
|
|
|
|
[], IIAlu>;
|
2010-02-24 03:15:24 +08:00
|
|
|
|
|
|
|
class ArithRN<bits<6> op, bits<11> flags, string instr_asm,
|
|
|
|
InstrItinClass itin> :
|
2010-10-22 03:48:38 +08:00
|
|
|
TA<op, flags, (outs GPR:$dst), (ins GPR:$c, GPR:$b),
|
2010-02-24 03:15:24 +08:00
|
|
|
!strconcat(instr_asm, " $dst, $b, $c"),
|
|
|
|
[], itin>;
|
|
|
|
|
|
|
|
class ArithRNI<bits<6> op, string instr_asm,Operand Od, PatLeaf imm_type> :
|
2010-10-22 03:48:38 +08:00
|
|
|
TB<op, (outs GPR:$dst), (ins Od:$c, GPR:$b),
|
2010-10-21 11:57:26 +08:00
|
|
|
!strconcat(instr_asm, " $dst, $b, $c"),
|
|
|
|
[], IIAlu>;
|
2010-02-24 03:15:24 +08:00
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Misc Arithmetic Instructions
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
class Logic<bits<6> op, bits<11> flags, string instr_asm, SDNode OpNode> :
|
2010-10-22 03:48:38 +08:00
|
|
|
TA<op, flags, (outs GPR:$dst), (ins GPR:$b, GPR:$c),
|
2010-02-24 03:15:24 +08:00
|
|
|
!strconcat(instr_asm, " $dst, $b, $c"),
|
2010-10-22 03:48:38 +08:00
|
|
|
[(set GPR:$dst, (OpNode GPR:$b, GPR:$c))], IIAlu>;
|
2010-02-24 03:15:24 +08:00
|
|
|
|
|
|
|
class LogicI<bits<6> op, string instr_asm, SDNode OpNode> :
|
2010-10-22 03:48:38 +08:00
|
|
|
TB<op, (outs GPR:$dst), (ins GPR:$b, uimm16:$c),
|
2010-10-21 11:57:26 +08:00
|
|
|
!strconcat(instr_asm, " $dst, $b, $c"),
|
2010-10-22 03:48:38 +08:00
|
|
|
[(set GPR:$dst, (OpNode GPR:$b, immZExt16:$c))],
|
2010-10-21 11:57:26 +08:00
|
|
|
IIAlu>;
|
2010-02-24 03:15:24 +08:00
|
|
|
|
2010-10-27 08:23:01 +08:00
|
|
|
class PatCmp<bits<6> op, bits<11> flags, string instr_asm> :
|
|
|
|
TA<op, flags, (outs GPR:$dst), (ins GPR:$b, GPR:$c),
|
|
|
|
!strconcat(instr_asm, " $dst, $b, $c"),
|
|
|
|
[], IIAlu>;
|
|
|
|
|
2010-02-24 03:15:24 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Memory Access Instructions
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
class LoadM<bits<6> op, string instr_asm, PatFrag OpNode> :
|
2010-10-22 03:48:38 +08:00
|
|
|
TA<op, 0x000, (outs GPR:$dst), (ins memrr:$addr),
|
2010-02-24 03:15:24 +08:00
|
|
|
!strconcat(instr_asm, " $dst, $addr"),
|
2010-10-22 03:48:38 +08:00
|
|
|
[(set (i32 GPR:$dst), (OpNode xaddr:$addr))], IILoad>;
|
2010-02-24 03:15:24 +08:00
|
|
|
|
2010-10-27 08:23:01 +08:00
|
|
|
class LoadW<bits<6> op, bits<11> flags, string instr_asm> :
|
|
|
|
TA<op, flags, (outs GPR:$dst), (ins memrr:$addr),
|
|
|
|
!strconcat(instr_asm, " $dst, $addr"),
|
|
|
|
[], IILoad>;
|
|
|
|
|
2010-02-24 03:15:24 +08:00
|
|
|
class LoadMI<bits<6> op, string instr_asm, PatFrag OpNode> :
|
2010-10-22 03:48:38 +08:00
|
|
|
TBR<op, (outs GPR:$dst), (ins memri:$addr),
|
2010-02-24 03:15:24 +08:00
|
|
|
!strconcat(instr_asm, " $dst, $addr"),
|
2010-10-22 03:48:38 +08:00
|
|
|
[(set (i32 GPR:$dst), (OpNode iaddr:$addr))], IILoad>;
|
2010-02-24 03:15:24 +08:00
|
|
|
|
|
|
|
class StoreM<bits<6> op, string instr_asm, PatFrag OpNode> :
|
2010-10-22 03:48:38 +08:00
|
|
|
TA<op, 0x000, (outs), (ins GPR:$dst, memrr:$addr),
|
2010-02-24 03:15:24 +08:00
|
|
|
!strconcat(instr_asm, " $dst, $addr"),
|
2010-10-22 03:48:38 +08:00
|
|
|
[(OpNode (i32 GPR:$dst), xaddr:$addr)], IIStore>;
|
2010-02-24 03:15:24 +08:00
|
|
|
|
2010-10-27 08:23:01 +08:00
|
|
|
class StoreW<bits<6> op, bits<11> flags, string instr_asm> :
|
|
|
|
TA<op, flags, (outs), (ins GPR:$dst, memrr:$addr),
|
|
|
|
!strconcat(instr_asm, " $dst, $addr"),
|
|
|
|
[], IIStore>;
|
|
|
|
|
2010-02-24 03:15:24 +08:00
|
|
|
class StoreMI<bits<6> op, string instr_asm, PatFrag OpNode> :
|
2010-10-22 03:48:38 +08:00
|
|
|
TBR<op, (outs), (ins GPR:$dst, memri:$addr),
|
2010-02-24 03:15:24 +08:00
|
|
|
!strconcat(instr_asm, " $dst, $addr"),
|
2010-10-22 03:48:38 +08:00
|
|
|
[(OpNode (i32 GPR:$dst), iaddr:$addr)], IIStore>;
|
2010-02-24 03:15:24 +08:00
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Branch Instructions
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
class Branch<bits<6> op, bits<5> br, bits<11> flags, string instr_asm> :
|
2010-10-22 03:48:38 +08:00
|
|
|
TA<op, flags, (outs), (ins GPR:$target),
|
2010-10-27 08:23:01 +08:00
|
|
|
!strconcat(instr_asm, " $target"),
|
|
|
|
[], IIBranch> {
|
2010-10-21 11:57:26 +08:00
|
|
|
let rd = 0x0;
|
|
|
|
let ra = br;
|
2010-10-27 08:23:01 +08:00
|
|
|
let Form = FCCR;
|
2010-10-21 11:57:26 +08:00
|
|
|
}
|
2010-02-24 03:15:24 +08:00
|
|
|
|
2010-10-21 11:57:26 +08:00
|
|
|
class BranchI<bits<6> op, bits<5> br, string instr_asm> :
|
|
|
|
TB<op, (outs), (ins brtarget:$target),
|
|
|
|
!strconcat(instr_asm, " $target"),
|
|
|
|
[], IIBranch> {
|
|
|
|
let rd = 0;
|
|
|
|
let ra = br;
|
2010-10-27 08:23:01 +08:00
|
|
|
let Form = FCCI;
|
2010-10-21 11:57:26 +08:00
|
|
|
}
|
2010-02-24 03:15:24 +08:00
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Branch and Link Instructions
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
class BranchL<bits<6> op, bits<5> br, bits<11> flags, string instr_asm> :
|
2010-10-27 08:23:01 +08:00
|
|
|
TA<op, flags, (outs), (ins GPR:$link, GPR:$target),
|
|
|
|
!strconcat(instr_asm, " $link, $target"),
|
2010-10-21 11:57:26 +08:00
|
|
|
[], IIBranch> {
|
|
|
|
let ra = br;
|
2010-10-27 08:23:01 +08:00
|
|
|
let Form = FRCR;
|
2010-10-21 11:57:26 +08:00
|
|
|
}
|
2010-02-24 03:15:24 +08:00
|
|
|
|
|
|
|
class BranchLI<bits<6> op, bits<5> br, string instr_asm> :
|
2010-10-27 08:23:01 +08:00
|
|
|
TB<op, (outs), (ins GPR:$link, calltarget:$target),
|
|
|
|
!strconcat(instr_asm, " $link, $target"),
|
2010-10-21 11:57:26 +08:00
|
|
|
[], IIBranch> {
|
|
|
|
let ra = br;
|
2010-10-27 08:23:01 +08:00
|
|
|
let Form = FRCI;
|
2010-10-21 11:57:26 +08:00
|
|
|
}
|
2010-02-24 03:15:24 +08:00
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Conditional Branch Instructions
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
class BranchC<bits<6> op, bits<5> br, bits<11> flags, string instr_asm,
|
|
|
|
PatFrag cond_op> :
|
2010-10-21 11:57:26 +08:00
|
|
|
TA<op, flags, (outs),
|
2010-10-22 03:48:38 +08:00
|
|
|
(ins GPR:$a, GPR:$b, brtarget:$offset),
|
2010-10-21 11:57:26 +08:00
|
|
|
!strconcat(instr_asm, " $a, $b, $offset"),
|
|
|
|
[], IIBranch> {
|
|
|
|
let rd = br;
|
2010-10-27 08:23:01 +08:00
|
|
|
let Form = FCRR;
|
2010-10-21 11:57:26 +08:00
|
|
|
}
|
2010-02-24 03:15:24 +08:00
|
|
|
|
|
|
|
class BranchCI<bits<6> op, bits<5> br, string instr_asm, PatFrag cond_op> :
|
2010-10-22 03:48:38 +08:00
|
|
|
TB<op, (outs), (ins GPR:$a, brtarget:$offset),
|
2010-10-21 11:57:26 +08:00
|
|
|
!strconcat(instr_asm, " $a, $offset"),
|
|
|
|
[], IIBranch> {
|
|
|
|
let rd = br;
|
2010-10-27 08:23:01 +08:00
|
|
|
let Form = FCRI;
|
2010-10-21 11:57:26 +08:00
|
|
|
}
|
2010-02-24 03:15:24 +08:00
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// MBlaze arithmetic instructions
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
let isCommutable = 1, isAsCheapAsAMove = 1 in {
|
2010-10-21 11:57:26 +08:00
|
|
|
def ADD : Arith<0x00, 0x000, "add ", add, IIAlu>;
|
|
|
|
def ADDC : Arith<0x02, 0x000, "addc ", adde, IIAlu>;
|
|
|
|
def ADDK : Arith<0x04, 0x000, "addk ", addc, IIAlu>;
|
|
|
|
def ADDKC : ArithN<0x06, 0x000, "addkc ", IIAlu>;
|
|
|
|
def AND : Logic<0x21, 0x000, "and ", and>;
|
|
|
|
def OR : Logic<0x20, 0x000, "or ", or>;
|
|
|
|
def XOR : Logic<0x22, 0x000, "xor ", xor>;
|
2010-10-27 08:23:01 +08:00
|
|
|
def PCMPBF : PatCmp<0x20, 0x400, "pcmpbf ">;
|
|
|
|
def PCMPEQ : PatCmp<0x23, 0x400, "pcmpeq ">;
|
|
|
|
def PCMPNE : PatCmp<0x22, 0x400, "pcmpne ">;
|
2010-02-24 03:15:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
let isAsCheapAsAMove = 1 in {
|
2010-10-21 11:57:26 +08:00
|
|
|
def ANDN : ArithN<0x23, 0x000, "andn ", IIAlu>;
|
|
|
|
def CMP : ArithN<0x05, 0x001, "cmp ", IIAlu>;
|
|
|
|
def CMPU : ArithN<0x05, 0x003, "cmpu ", IIAlu>;
|
|
|
|
def RSUB : ArithR<0x01, 0x000, "rsub ", sub, IIAlu>;
|
|
|
|
def RSUBC : ArithR<0x03, 0x000, "rsubc ", sube, IIAlu>;
|
|
|
|
def RSUBK : ArithR<0x05, 0x000, "rsubk ", subc, IIAlu>;
|
|
|
|
def RSUBKC : ArithRN<0x07, 0x000, "rsubkc ", IIAlu>;
|
2010-02-24 03:15:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
let isCommutable = 1, Predicates=[HasMul] in {
|
2010-10-21 11:57:26 +08:00
|
|
|
def MUL : Arith<0x10, 0x000, "mul ", mul, IIAlu>;
|
2010-02-24 03:15:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
let isCommutable = 1, Predicates=[HasMul,HasMul64] in {
|
2010-10-21 11:57:26 +08:00
|
|
|
def MULH : Arith<0x10, 0x001, "mulh ", mulhs, IIAlu>;
|
|
|
|
def MULHU : Arith<0x10, 0x003, "mulhu ", mulhu, IIAlu>;
|
2010-02-24 03:15:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
let Predicates=[HasMul,HasMul64] in {
|
2010-10-21 11:57:26 +08:00
|
|
|
def MULHSU : ArithN<0x10, 0x002, "mulhsu ", IIAlu>;
|
2010-02-24 03:15:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
let Predicates=[HasBarrel] in {
|
2010-10-21 11:57:26 +08:00
|
|
|
def BSRL : Arith<0x11, 0x000, "bsrl ", srl, IIAlu>;
|
|
|
|
def BSRA : Arith<0x11, 0x200, "bsra ", sra, IIAlu>;
|
|
|
|
def BSLL : Arith<0x11, 0x400, "bsll ", shl, IIAlu>;
|
|
|
|
def BSRLI : ArithI<0x11, "bsrli ", srl, uimm5, immZExt5>;
|
|
|
|
def BSRAI : ArithI<0x11, "bsrai ", sra, uimm5, immZExt5>;
|
|
|
|
def BSLLI : ArithI<0x11, "bslli ", shl, uimm5, immZExt5>;
|
2010-02-24 03:15:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
let Predicates=[HasDiv] in {
|
2010-10-21 11:57:26 +08:00
|
|
|
def IDIV : Arith<0x12, 0x000, "idiv ", sdiv, IIAlu>;
|
|
|
|
def IDIVU : Arith<0x12, 0x002, "idivu ", udiv, IIAlu>;
|
2010-02-24 03:15:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// MBlaze immediate mode arithmetic instructions
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
let isAsCheapAsAMove = 1 in {
|
2010-10-21 11:57:26 +08:00
|
|
|
def ADDI : ArithI<0x08, "addi ", add, simm16, immSExt16>;
|
|
|
|
def ADDIC : ArithNI<0x0A, "addic ", simm16, immSExt16>;
|
|
|
|
def ADDIK : ArithNI<0x0C, "addik ", simm16, immSExt16>;
|
|
|
|
def ADDIKC : ArithI<0x0E, "addikc ", addc, simm16, immSExt16>;
|
|
|
|
def RSUBI : ArithRI<0x09, "rsubi ", sub, simm16, immSExt16>;
|
|
|
|
def RSUBIC : ArithRNI<0x0B, "rsubi ", simm16, immSExt16>;
|
|
|
|
def RSUBIK : ArithRNI<0x0E, "rsubic ", simm16, immSExt16>;
|
|
|
|
def RSUBIKC : ArithRI<0x0F, "rsubikc", subc, simm16, immSExt16>;
|
|
|
|
def ANDNI : ArithNI<0x2B, "andni ", uimm16, immZExt16>;
|
|
|
|
def ANDI : LogicI<0x29, "andi ", and>;
|
|
|
|
def ORI : LogicI<0x28, "ori ", or>;
|
|
|
|
def XORI : LogicI<0x2A, "xori ", xor>;
|
2010-02-24 03:15:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
let Predicates=[HasMul] in {
|
2010-10-21 11:57:26 +08:00
|
|
|
def MULI : ArithI<0x18, "muli ", mul, simm16, immSExt16>;
|
2010-02-24 03:15:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// MBlaze memory access instructions
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
let canFoldAsLoad = 1, isReMaterializable = 1 in {
|
2010-10-21 11:57:26 +08:00
|
|
|
def LBU : LoadM<0x30, "lbu ", zextloadi8>;
|
|
|
|
def LHU : LoadM<0x31, "lhu ", zextloadi16>;
|
2010-10-27 08:23:01 +08:00
|
|
|
|
|
|
|
def LW : LoadW<0x32, 0x0, "lw ">;
|
|
|
|
def LWR : LoadW<0x32, 0x2, "lwr ">;
|
|
|
|
def LWX : LoadW<0x32, 0x4, "lwx ">;
|
2010-02-24 03:15:24 +08:00
|
|
|
|
2010-10-21 11:57:26 +08:00
|
|
|
def LBUI : LoadMI<0x38, "lbui ", zextloadi8>;
|
|
|
|
def LHUI : LoadMI<0x39, "lhui ", zextloadi16>;
|
|
|
|
def LWI : LoadMI<0x3A, "lwi ", load>;
|
2010-02-24 03:15:24 +08:00
|
|
|
}
|
|
|
|
|
2010-10-21 11:57:26 +08:00
|
|
|
def SB : StoreM<0x34, "sb ", truncstorei8>;
|
|
|
|
def SH : StoreM<0x35, "sh ", truncstorei16>;
|
2010-10-27 08:23:01 +08:00
|
|
|
|
|
|
|
def SW : StoreW<0x36, 0x0, "sw ">;
|
|
|
|
def SWR : StoreW<0x36, 0x2, "swr ">;
|
|
|
|
def SWX : StoreW<0x36, 0x4, "swx ">;
|
2010-02-24 03:15:24 +08:00
|
|
|
|
2010-10-21 11:57:26 +08:00
|
|
|
def SBI : StoreMI<0x3C, "sbi ", truncstorei8>;
|
|
|
|
def SHI : StoreMI<0x3D, "shi ", truncstorei16>;
|
|
|
|
def SWI : StoreMI<0x3E, "swi ", store>;
|
2010-02-24 03:15:24 +08:00
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// MBlaze branch instructions
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2010-10-27 08:23:01 +08:00
|
|
|
let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, isBarrier = 1 in {
|
2010-10-21 11:57:26 +08:00
|
|
|
def BRI : BranchI<0x2E, 0x00, "bri ">;
|
|
|
|
def BRAI : BranchI<0x2E, 0x08, "brai ">;
|
2010-02-24 03:15:24 +08:00
|
|
|
}
|
|
|
|
|
2010-10-27 08:23:01 +08:00
|
|
|
let isBranch = 1, isTerminator = 1, hasCtrlDep = 1 in {
|
2010-10-21 11:57:26 +08:00
|
|
|
def BEQI : BranchCI<0x2F, 0x00, "beqi ", seteq>;
|
|
|
|
def BNEI : BranchCI<0x2F, 0x01, "bnei ", setne>;
|
|
|
|
def BLTI : BranchCI<0x2F, 0x02, "blti ", setlt>;
|
|
|
|
def BLEI : BranchCI<0x2F, 0x03, "blei ", setle>;
|
|
|
|
def BGTI : BranchCI<0x2F, 0x04, "bgti ", setgt>;
|
|
|
|
def BGEI : BranchCI<0x2F, 0x05, "bgei ", setge>;
|
2010-02-24 03:15:24 +08:00
|
|
|
}
|
|
|
|
|
2010-10-21 11:57:26 +08:00
|
|
|
let isBranch = 1, isIndirectBranch = 1, isTerminator = 1, hasCtrlDep = 1,
|
2010-10-27 08:23:01 +08:00
|
|
|
isBarrier = 1 in {
|
2010-10-21 11:57:26 +08:00
|
|
|
def BR : Branch<0x26, 0x00, 0x000, "br ">;
|
|
|
|
def BRA : Branch<0x26, 0x08, 0x000, "bra ">;
|
|
|
|
}
|
|
|
|
|
2010-10-27 08:23:01 +08:00
|
|
|
let isBranch = 1, isIndirectBranch = 1, isTerminator = 1, hasCtrlDep = 1 in {
|
2010-10-21 11:57:26 +08:00
|
|
|
def BEQ : BranchC<0x27, 0x00, 0x000, "beq ", seteq>;
|
|
|
|
def BNE : BranchC<0x27, 0x01, 0x000, "bne ", setne>;
|
|
|
|
def BLT : BranchC<0x27, 0x02, 0x000, "blt ", setlt>;
|
|
|
|
def BLE : BranchC<0x27, 0x03, 0x000, "ble ", setle>;
|
|
|
|
def BGT : BranchC<0x27, 0x04, 0x000, "bgt ", setgt>;
|
|
|
|
def BGE : BranchC<0x27, 0x05, 0x000, "bge ", setge>;
|
|
|
|
}
|
|
|
|
|
|
|
|
let isBranch = 1, isTerminator = 1, hasDelaySlot = 1, hasCtrlDep = 1,
|
2010-10-27 08:23:01 +08:00
|
|
|
isBarrier = 1 in {
|
2010-10-21 11:57:26 +08:00
|
|
|
def BRID : BranchI<0x2E, 0x10, "brid ">;
|
|
|
|
def BRAID : BranchI<0x2E, 0x18, "braid ">;
|
|
|
|
}
|
|
|
|
|
2010-10-27 08:23:01 +08:00
|
|
|
let isBranch = 1, isTerminator = 1, hasDelaySlot = 1, hasCtrlDep = 1 in {
|
2010-10-21 11:57:26 +08:00
|
|
|
def BEQID : BranchCI<0x2F, 0x10, "beqid ", seteq>;
|
|
|
|
def BNEID : BranchCI<0x2F, 0x11, "bneid ", setne>;
|
|
|
|
def BLTID : BranchCI<0x2F, 0x12, "bltid ", setlt>;
|
|
|
|
def BLEID : BranchCI<0x2F, 0x13, "bleid ", setle>;
|
|
|
|
def BGTID : BranchCI<0x2F, 0x14, "bgtid ", setgt>;
|
|
|
|
def BGEID : BranchCI<0x2F, 0x15, "bgeid ", setge>;
|
|
|
|
}
|
|
|
|
|
2010-10-27 08:23:01 +08:00
|
|
|
let isBranch = 1, isIndirectBranch = 1, isTerminator = 1,
|
2010-10-21 11:57:26 +08:00
|
|
|
hasDelaySlot = 1, hasCtrlDep = 1, isBarrier = 1 in {
|
|
|
|
def BRD : Branch<0x26, 0x10, 0x000, "brd ">;
|
|
|
|
def BRAD : Branch<0x26, 0x18, 0x000, "brad ">;
|
2010-02-24 03:15:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
let isBranch = 1, isIndirectBranch = 1, isTerminator = 1,
|
2010-10-27 08:23:01 +08:00
|
|
|
hasDelaySlot = 1, hasCtrlDep = 1 in {
|
2010-10-21 11:57:26 +08:00
|
|
|
def BEQD : BranchC<0x27, 0x10, 0x000, "beqd ", seteq>;
|
|
|
|
def BNED : BranchC<0x27, 0x11, 0x000, "bned ", setne>;
|
|
|
|
def BLTD : BranchC<0x27, 0x12, 0x000, "bltd ", setlt>;
|
|
|
|
def BLED : BranchC<0x27, 0x13, 0x000, "bled ", setle>;
|
|
|
|
def BGTD : BranchC<0x27, 0x14, 0x000, "bgtd ", setgt>;
|
|
|
|
def BGED : BranchC<0x27, 0x15, 0x000, "bged ", setge>;
|
2010-02-24 03:15:24 +08:00
|
|
|
}
|
|
|
|
|
2010-10-27 08:23:01 +08:00
|
|
|
let isCall = 1, hasDelaySlot = 1, hasCtrlDep = 1, isBarrier = 1,
|
2010-02-24 03:15:24 +08:00
|
|
|
Defs = [R3,R4,R5,R6,R7,R8,R9,R10,R11,R12],
|
|
|
|
Uses = [R1,R5,R6,R7,R8,R9,R10] in {
|
2010-10-21 11:57:26 +08:00
|
|
|
def BRLID : BranchLI<0x2E, 0x14, "brlid ">;
|
|
|
|
def BRALID : BranchLI<0x2E, 0x1C, "bralid ">;
|
2010-02-24 03:15:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
let isCall = 1, hasDelaySlot = 1, hasCtrlDep = 1, isIndirectBranch = 1,
|
2010-10-27 08:23:01 +08:00
|
|
|
isBarrier = 1,
|
2010-02-24 03:15:24 +08:00
|
|
|
Defs = [R3,R4,R5,R6,R7,R8,R9,R10,R11,R12],
|
|
|
|
Uses = [R1,R5,R6,R7,R8,R9,R10] in {
|
2010-10-21 11:57:26 +08:00
|
|
|
def BRLD : BranchL<0x26, 0x14, 0x000, "brld ">;
|
|
|
|
def BRALD : BranchL<0x26, 0x1C, 0x000, "brald ">;
|
2010-02-24 03:15:24 +08:00
|
|
|
}
|
|
|
|
|
2010-10-21 11:57:26 +08:00
|
|
|
let isReturn=1, isTerminator=1, hasDelaySlot=1, isBarrier=1,
|
2010-10-27 08:23:01 +08:00
|
|
|
hasCtrlDep=1, rd=0x10, Form=FCRI in {
|
|
|
|
def RTSD : TB<0x2D, (outs), (ins GPR:$target, simm16:$imm),
|
|
|
|
"rtsd $target, $imm",
|
|
|
|
[],
|
|
|
|
IIBranch>;
|
|
|
|
}
|
|
|
|
|
|
|
|
let isReturn=1, isTerminator=1, hasDelaySlot=1, isBarrier=1,
|
|
|
|
hasCtrlDep=1, rd=0x11, Form=FCRI in {
|
|
|
|
def RTID : TB<0x2D, (outs), (ins GPR:$target, simm16:$imm),
|
|
|
|
"rtsd $target, $imm",
|
|
|
|
[],
|
|
|
|
IIBranch>;
|
|
|
|
}
|
|
|
|
|
|
|
|
let isReturn=1, isTerminator=1, hasDelaySlot=1, isBarrier=1,
|
|
|
|
hasCtrlDep=1, rd=0x12, Form=FCRI in {
|
|
|
|
def RTBD : TB<0x2D, (outs), (ins GPR:$target, simm16:$imm),
|
|
|
|
"rtsd $target, $imm",
|
|
|
|
[],
|
|
|
|
IIBranch>;
|
|
|
|
}
|
|
|
|
|
|
|
|
let isReturn=1, isTerminator=1, hasDelaySlot=1, isBarrier=1,
|
|
|
|
hasCtrlDep=1, rd=0x14, Form=FCRI in {
|
|
|
|
def RTED : TB<0x2D, (outs), (ins GPR:$target, simm16:$imm),
|
|
|
|
"rtsd $target, $imm",
|
|
|
|
[],
|
2010-10-21 11:57:26 +08:00
|
|
|
IIBranch>;
|
2010-02-24 03:15:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// MBlaze misc instructions
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2010-10-21 11:57:26 +08:00
|
|
|
let neverHasSideEffects = 1 in {
|
2010-10-27 08:23:01 +08:00
|
|
|
def NOP : MBlazeInst< 0x20, FC, (outs), (ins), "nop ", [], IIAlu>;
|
2010-02-24 03:15:24 +08:00
|
|
|
}
|
|
|
|
|
2010-11-03 07:57:05 +08:00
|
|
|
let usesCustomInserter = 1 in {
|
2010-10-22 03:48:38 +08:00
|
|
|
def Select_CC : MBlazePseudo<(outs GPR:$dst),
|
|
|
|
(ins GPR:$T, GPR:$F, GPR:$CMP, i32imm:$CC),
|
2010-02-24 03:15:24 +08:00
|
|
|
"; SELECT_CC PSEUDO!",
|
|
|
|
[]>;
|
|
|
|
|
2010-10-22 03:48:38 +08:00
|
|
|
def ShiftL : MBlazePseudo<(outs GPR:$dst),
|
|
|
|
(ins GPR:$L, GPR:$R),
|
2010-02-24 03:15:24 +08:00
|
|
|
"; ShiftL PSEUDO!",
|
|
|
|
[]>;
|
|
|
|
|
2010-10-22 03:48:38 +08:00
|
|
|
def ShiftRA : MBlazePseudo<(outs GPR:$dst),
|
|
|
|
(ins GPR:$L, GPR:$R),
|
2010-02-24 03:15:24 +08:00
|
|
|
"; ShiftRA PSEUDO!",
|
|
|
|
[]>;
|
|
|
|
|
2010-10-22 03:48:38 +08:00
|
|
|
def ShiftRL : MBlazePseudo<(outs GPR:$dst),
|
|
|
|
(ins GPR:$L, GPR:$R),
|
2010-02-24 03:15:24 +08:00
|
|
|
"; ShiftRL PSEUDO!",
|
|
|
|
[]>;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
let rb = 0 in {
|
2010-10-22 03:48:38 +08:00
|
|
|
def SEXT16 : TA<0x24, 0x061, (outs GPR:$dst), (ins GPR:$src),
|
2010-10-21 11:57:26 +08:00
|
|
|
"sext16 $dst, $src", [], IIAlu>;
|
2010-10-22 03:48:38 +08:00
|
|
|
def SEXT8 : TA<0x24, 0x060, (outs GPR:$dst), (ins GPR:$src),
|
2010-10-21 11:57:26 +08:00
|
|
|
"sext8 $dst, $src", [], IIAlu>;
|
2010-10-22 03:48:38 +08:00
|
|
|
def SRL : TA<0x24, 0x041, (outs GPR:$dst), (ins GPR:$src),
|
2010-10-21 11:57:26 +08:00
|
|
|
"srl $dst, $src", [], IIAlu>;
|
2010-10-22 03:48:38 +08:00
|
|
|
def SRA : TA<0x24, 0x001, (outs GPR:$dst), (ins GPR:$src),
|
2010-10-21 11:57:26 +08:00
|
|
|
"sra $dst, $src", [], IIAlu>;
|
2010-10-22 03:48:38 +08:00
|
|
|
def SRC : TA<0x24, 0x021, (outs GPR:$dst), (ins GPR:$src),
|
2010-10-21 11:57:26 +08:00
|
|
|
"src $dst, $src", [], IIAlu>;
|
2010-02-24 03:15:24 +08:00
|
|
|
}
|
|
|
|
|
2010-11-01 03:10:56 +08:00
|
|
|
let opcode=0x08, isCodeGenOnly=1 in {
|
2010-10-22 03:48:38 +08:00
|
|
|
def LEA_ADDI : TB<0x08, (outs GPR:$dst), (ins memri:$addr),
|
2010-10-21 11:57:26 +08:00
|
|
|
"addi $dst, ${addr:stackloc}",
|
2010-10-22 03:48:38 +08:00
|
|
|
[(set GPR:$dst, iaddr:$addr)], IIAlu>;
|
2010-10-21 11:57:26 +08:00
|
|
|
}
|
2010-02-24 03:15:24 +08:00
|
|
|
|
2010-10-27 08:23:01 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Misc. instructions
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
def MFS : MBlazeInst<0x25, FPseudo, (outs), (ins), "mfs", [], IIAlu> {
|
|
|
|
}
|
|
|
|
|
|
|
|
def MTS : MBlazeInst<0x25, FPseudo, (outs), (ins), "mts", [], IIAlu> {
|
|
|
|
}
|
|
|
|
|
|
|
|
def MSRSET : MBlazeInst<0x25, FPseudo, (outs), (ins), "msrset", [], IIAlu> {
|
|
|
|
}
|
|
|
|
|
|
|
|
def MSRCLR : MBlazeInst<0x25, FPseudo, (outs), (ins), "msrclr", [], IIAlu> {
|
|
|
|
}
|
|
|
|
|
|
|
|
let rd=0x0, Form=FCRR in {
|
|
|
|
def WDC : TA<0x24, 0x64, (outs), (ins GPR:$a, GPR:$b),
|
|
|
|
"wdc $a, $b", [], IIAlu>;
|
|
|
|
def WDCF : TA<0x24, 0x74, (outs), (ins GPR:$a, GPR:$b),
|
|
|
|
"wdc.flush $a, $b", [], IIAlu>;
|
|
|
|
def WDCC : TA<0x24, 0x66, (outs), (ins GPR:$a, GPR:$b),
|
|
|
|
"wdc.clear $a, $b", [], IIAlu>;
|
|
|
|
def WIC : TA<0x24, 0x68, (outs), (ins GPR:$a, GPR:$b),
|
|
|
|
"wic $a, $b", [], IIAlu>;
|
|
|
|
}
|
|
|
|
|
|
|
|
def BRK : Branch<0x26, 0x0C, 0x000, "brk ">;
|
|
|
|
def BRKI : BranchI<0x2E, 0x0C, "brki ">;
|
|
|
|
|
|
|
|
def IMM : MBlazeInst<0x2C, FCCI, (outs), (ins simm16:$imm),
|
|
|
|
"imm $imm", [], IIAlu>;
|
|
|
|
|
2010-02-24 03:15:24 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Arbitrary patterns that map to one or more instructions
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
// Small immediates
|
2010-10-22 03:48:38 +08:00
|
|
|
def : Pat<(i32 0), (ADD (i32 R0), (i32 R0))>;
|
|
|
|
def : Pat<(i32 immSExt16:$imm), (ADDI (i32 R0), imm:$imm)>;
|
|
|
|
def : Pat<(i32 immZExt16:$imm), (ORI (i32 R0), imm:$imm)>;
|
2010-02-24 03:15:24 +08:00
|
|
|
|
|
|
|
// Arbitrary immediates
|
2010-10-22 03:48:38 +08:00
|
|
|
def : Pat<(i32 imm:$imm), (ADDI (i32 R0), imm:$imm)>;
|
2010-02-24 03:15:24 +08:00
|
|
|
|
|
|
|
// In register sign extension
|
2010-10-22 03:48:38 +08:00
|
|
|
def : Pat<(sext_inreg GPR:$src, i16), (SEXT16 GPR:$src)>;
|
|
|
|
def : Pat<(sext_inreg GPR:$src, i8), (SEXT8 GPR:$src)>;
|
2010-02-24 03:15:24 +08:00
|
|
|
|
|
|
|
// Call
|
2010-10-27 08:23:01 +08:00
|
|
|
def : Pat<(MBlazeJmpLink (i32 tglobaladdr:$dst)),
|
|
|
|
(BRLID (i32 R15), tglobaladdr:$dst)>;
|
|
|
|
|
|
|
|
def : Pat<(MBlazeJmpLink (i32 texternalsym:$dst)),
|
|
|
|
(BRLID (i32 R15), texternalsym:$dst)>;
|
|
|
|
|
|
|
|
def : Pat<(MBlazeJmpLink GPR:$dst),
|
|
|
|
(BRLD (i32 R15), GPR:$dst)>;
|
2010-02-24 03:15:24 +08:00
|
|
|
|
|
|
|
// Shift Instructions
|
2010-10-22 03:48:38 +08:00
|
|
|
def : Pat<(shl GPR:$L, GPR:$R), (ShiftL GPR:$L, GPR:$R)>;
|
|
|
|
def : Pat<(sra GPR:$L, GPR:$R), (ShiftRA GPR:$L, GPR:$R)>;
|
|
|
|
def : Pat<(srl GPR:$L, GPR:$R), (ShiftRL GPR:$L, GPR:$R)>;
|
2010-02-24 03:15:24 +08:00
|
|
|
|
|
|
|
// SET_CC operations
|
2010-10-22 03:48:38 +08:00
|
|
|
def : Pat<(setcc (i32 GPR:$L), (i32 GPR:$R), SETEQ),
|
|
|
|
(Select_CC (ADDI (i32 R0), 1), (ADDI (i32 R0), 0),
|
|
|
|
(CMP GPR:$L, GPR:$R), 1)>;
|
|
|
|
def : Pat<(setcc (i32 GPR:$L), (i32 GPR:$R), SETNE),
|
|
|
|
(Select_CC (ADDI (i32 R0), 1), (ADDI (i32 R0), 0),
|
|
|
|
(CMP GPR:$L, GPR:$R), 2)>;
|
|
|
|
def : Pat<(setcc (i32 GPR:$L), (i32 GPR:$R), SETGT),
|
|
|
|
(Select_CC (ADDI (i32 R0), 1), (ADDI (i32 R0), 0),
|
|
|
|
(CMP GPR:$L, GPR:$R), 3)>;
|
|
|
|
def : Pat<(setcc (i32 GPR:$L), (i32 GPR:$R), SETLT),
|
|
|
|
(Select_CC (ADDI (i32 R0), 1), (ADDI (i32 R0), 0),
|
|
|
|
(CMP GPR:$L, GPR:$R), 4)>;
|
|
|
|
def : Pat<(setcc (i32 GPR:$L), (i32 GPR:$R), SETGE),
|
|
|
|
(Select_CC (ADDI (i32 R0), 1), (ADDI (i32 R0), 0),
|
|
|
|
(CMP GPR:$L, GPR:$R), 5)>;
|
|
|
|
def : Pat<(setcc (i32 GPR:$L), (i32 GPR:$R), SETLE),
|
|
|
|
(Select_CC (ADDI (i32 R0), 1), (ADDI (i32 R0), 0),
|
|
|
|
(CMP GPR:$L, GPR:$R), 6)>;
|
|
|
|
def : Pat<(setcc (i32 GPR:$L), (i32 GPR:$R), SETUGT),
|
|
|
|
(Select_CC (ADDI (i32 R0), 1), (ADDI (i32 R0), 0),
|
|
|
|
(CMPU GPR:$L, GPR:$R), 3)>;
|
|
|
|
def : Pat<(setcc (i32 GPR:$L), (i32 GPR:$R), SETULT),
|
|
|
|
(Select_CC (ADDI (i32 R0), 1), (ADDI (i32 R0), 0),
|
|
|
|
(CMPU GPR:$L, GPR:$R), 4)>;
|
|
|
|
def : Pat<(setcc (i32 GPR:$L), (i32 GPR:$R), SETUGE),
|
|
|
|
(Select_CC (ADDI (i32 R0), 1), (ADDI (i32 R0), 0),
|
|
|
|
(CMPU GPR:$L, GPR:$R), 5)>;
|
|
|
|
def : Pat<(setcc (i32 GPR:$L), (i32 GPR:$R), SETULE),
|
|
|
|
(Select_CC (ADDI (i32 R0), 1), (ADDI (i32 R0), 0),
|
|
|
|
(CMPU GPR:$L, GPR:$R), 6)>;
|
2010-02-24 03:15:24 +08:00
|
|
|
|
|
|
|
// SELECT operations
|
2010-10-22 03:48:38 +08:00
|
|
|
def : Pat<(select (i32 GPR:$C), (i32 GPR:$T), (i32 GPR:$F)),
|
|
|
|
(Select_CC GPR:$T, GPR:$F, GPR:$C, 2)>;
|
2010-02-24 03:15:24 +08:00
|
|
|
|
|
|
|
// SELECT_CC
|
2010-10-22 03:48:38 +08:00
|
|
|
def : Pat<(selectcc (i32 GPR:$L), (i32 GPR:$R),
|
|
|
|
(i32 GPR:$T), (i32 GPR:$F), SETEQ),
|
|
|
|
(Select_CC GPR:$T, GPR:$F, (CMP GPR:$L, GPR:$R), 1)>;
|
|
|
|
def : Pat<(selectcc (i32 GPR:$L), (i32 GPR:$R),
|
|
|
|
(i32 GPR:$T), (i32 GPR:$F), SETNE),
|
|
|
|
(Select_CC GPR:$T, GPR:$F, (CMP GPR:$L, GPR:$R), 2)>;
|
|
|
|
def : Pat<(selectcc (i32 GPR:$L), (i32 GPR:$R),
|
|
|
|
(i32 GPR:$T), (i32 GPR:$F), SETGT),
|
|
|
|
(Select_CC GPR:$T, GPR:$F, (CMP GPR:$L, GPR:$R), 3)>;
|
|
|
|
def : Pat<(selectcc (i32 GPR:$L), (i32 GPR:$R),
|
|
|
|
(i32 GPR:$T), (i32 GPR:$F), SETLT),
|
|
|
|
(Select_CC GPR:$T, GPR:$F, (CMP GPR:$L, GPR:$R), 4)>;
|
|
|
|
def : Pat<(selectcc (i32 GPR:$L), (i32 GPR:$R),
|
|
|
|
(i32 GPR:$T), (i32 GPR:$F), SETGE),
|
|
|
|
(Select_CC GPR:$T, GPR:$F, (CMP GPR:$L, GPR:$R), 5)>;
|
|
|
|
def : Pat<(selectcc (i32 GPR:$L), (i32 GPR:$R),
|
|
|
|
(i32 GPR:$T), (i32 GPR:$F), SETLE),
|
|
|
|
(Select_CC GPR:$T, GPR:$F, (CMP GPR:$L, GPR:$R), 6)>;
|
|
|
|
def : Pat<(selectcc (i32 GPR:$L), (i32 GPR:$R),
|
|
|
|
(i32 GPR:$T), (i32 GPR:$F), SETUGT),
|
|
|
|
(Select_CC GPR:$T, GPR:$F, (CMPU GPR:$L, GPR:$R), 3)>;
|
|
|
|
def : Pat<(selectcc (i32 GPR:$L), (i32 GPR:$R),
|
|
|
|
(i32 GPR:$T), (i32 GPR:$F), SETULT),
|
|
|
|
(Select_CC GPR:$T, GPR:$F, (CMPU GPR:$L, GPR:$R), 4)>;
|
|
|
|
def : Pat<(selectcc (i32 GPR:$L), (i32 GPR:$R),
|
|
|
|
(i32 GPR:$T), (i32 GPR:$F), SETUGE),
|
|
|
|
(Select_CC GPR:$T, GPR:$F, (CMPU GPR:$L, GPR:$R), 5)>;
|
|
|
|
def : Pat<(selectcc (i32 GPR:$L), (i32 GPR:$R),
|
|
|
|
(i32 GPR:$T), (i32 GPR:$F), SETULE),
|
|
|
|
(Select_CC GPR:$T, GPR:$F, (CMPU GPR:$L, GPR:$R), 6)>;
|
2010-02-24 03:15:24 +08:00
|
|
|
|
2010-10-27 08:23:01 +08:00
|
|
|
// Ret instructions
|
|
|
|
def : Pat<(MBlazeRet GPR:$target), (RTSD GPR:$target, 0x8)>;
|
|
|
|
|
2010-10-21 11:57:26 +08:00
|
|
|
// BR instructions
|
|
|
|
def : Pat<(br bb:$T), (BRID bb:$T)>;
|
2010-10-22 03:48:38 +08:00
|
|
|
def : Pat<(brind GPR:$T), (BRD GPR:$T)>;
|
2010-10-21 11:57:26 +08:00
|
|
|
|
2010-02-24 03:15:24 +08:00
|
|
|
// BRCOND instructions
|
2010-10-22 03:48:38 +08:00
|
|
|
def : Pat<(brcond (setcc (i32 GPR:$L), (i32 GPR:$R), SETEQ), bb:$T),
|
|
|
|
(BEQID (CMP GPR:$R, GPR:$L), bb:$T)>;
|
|
|
|
def : Pat<(brcond (setcc (i32 GPR:$L), (i32 GPR:$R), SETNE), bb:$T),
|
|
|
|
(BNEID (CMP GPR:$R, GPR:$L), bb:$T)>;
|
|
|
|
def : Pat<(brcond (setcc (i32 GPR:$L), (i32 GPR:$R), SETGT), bb:$T),
|
|
|
|
(BGTID (CMP GPR:$R, GPR:$L), bb:$T)>;
|
|
|
|
def : Pat<(brcond (setcc (i32 GPR:$L), (i32 GPR:$R), SETLT), bb:$T),
|
|
|
|
(BLTID (CMP GPR:$R, GPR:$L), bb:$T)>;
|
|
|
|
def : Pat<(brcond (setcc (i32 GPR:$L), (i32 GPR:$R), SETGE), bb:$T),
|
|
|
|
(BGEID (CMP GPR:$R, GPR:$L), bb:$T)>;
|
|
|
|
def : Pat<(brcond (setcc (i32 GPR:$L), (i32 GPR:$R), SETLE), bb:$T),
|
|
|
|
(BLEID (CMP GPR:$R, GPR:$L), bb:$T)>;
|
|
|
|
def : Pat<(brcond (setcc (i32 GPR:$L), (i32 GPR:$R), SETUGT), bb:$T),
|
|
|
|
(BGTID (CMPU GPR:$R, GPR:$L), bb:$T)>;
|
|
|
|
def : Pat<(brcond (setcc (i32 GPR:$L), (i32 GPR:$R), SETULT), bb:$T),
|
|
|
|
(BLTID (CMPU GPR:$R, GPR:$L), bb:$T)>;
|
|
|
|
def : Pat<(brcond (setcc (i32 GPR:$L), (i32 GPR:$R), SETUGE), bb:$T),
|
|
|
|
(BGEID (CMPU GPR:$R, GPR:$L), bb:$T)>;
|
|
|
|
def : Pat<(brcond (setcc (i32 GPR:$L), (i32 GPR:$R), SETULE), bb:$T),
|
|
|
|
(BLEID (CMPU GPR:$R, GPR:$L), bb:$T)>;
|
|
|
|
def : Pat<(brcond (i32 GPR:$C), bb:$T),
|
|
|
|
(BNEID GPR:$C, bb:$T)>;
|
2010-02-24 03:15:24 +08:00
|
|
|
|
|
|
|
// Jump tables, global addresses, and constant pools
|
2010-10-22 03:48:38 +08:00
|
|
|
def : Pat<(MBWrapper tglobaladdr:$in), (ORI (i32 R0), tglobaladdr:$in)>;
|
|
|
|
def : Pat<(MBWrapper tjumptable:$in), (ORI (i32 R0), tjumptable:$in)>;
|
|
|
|
def : Pat<(MBWrapper tconstpool:$in), (ORI (i32 R0), tconstpool:$in)>;
|
2010-02-24 03:15:24 +08:00
|
|
|
|
|
|
|
// Misc instructions
|
2010-10-22 03:48:38 +08:00
|
|
|
def : Pat<(and (i32 GPR:$lh), (not (i32 GPR:$rh))),(ANDN GPR:$lh, GPR:$rh)>;
|
2010-02-24 03:15:24 +08:00
|
|
|
|
|
|
|
// Arithmetic with immediates
|
2010-10-22 03:48:38 +08:00
|
|
|
def : Pat<(add (i32 GPR:$in), imm:$imm),(ADDI GPR:$in, imm:$imm)>;
|
|
|
|
def : Pat<(or (i32 GPR:$in), imm:$imm),(ORI GPR:$in, imm:$imm)>;
|
|
|
|
def : Pat<(xor (i32 GPR:$in), imm:$imm),(XORI GPR:$in, imm:$imm)>;
|
|
|
|
|
|
|
|
// Convert any extend loads into zero extend loads
|
|
|
|
def : Pat<(extloadi8 iaddr:$src), (i32 (LBUI iaddr:$src))>;
|
|
|
|
def : Pat<(extloadi16 iaddr:$src), (i32 (LHUI iaddr:$src))>;
|
|
|
|
def : Pat<(extloadi8 xaddr:$src), (i32 (LBU xaddr:$src))>;
|
|
|
|
def : Pat<(extloadi16 xaddr:$src), (i32 (LHU xaddr:$src))>;
|
|
|
|
|
2010-10-27 08:23:01 +08:00
|
|
|
// 32-bit load and store
|
|
|
|
def : Pat<(store (i32 GPR:$dst), xaddr:$addr), (SW GPR:$dst, xaddr:$addr)>;
|
|
|
|
def : Pat<(load xaddr:$addr), (i32 (LW xaddr:$addr))>;
|
|
|
|
|
2010-10-22 03:48:38 +08:00
|
|
|
// Peepholes
|
|
|
|
def : Pat<(store (i32 0), iaddr:$dst), (SWI (i32 R0), iaddr:$dst)>;
|
2010-02-24 03:15:24 +08:00
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Floating Point Support
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
include "MBlazeInstrFSL.td"
|
|
|
|
include "MBlazeInstrFPU.td"
|