//=- HexagonInstrInfoV4.td - Target Desc. for Hexagon Target -*- tablegen -*-=// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // This file describes the Hexagon V4 instructions in TableGen format. // //===----------------------------------------------------------------------===// let hasSideEffects = 0 in class T_Immext : EXTENDERInst<(outs), (ins ImmType:$imm), "immext(#$imm)", []> { bits<32> imm; let IClass = 0b0000; let Inst{27-16} = imm{31-20}; let Inst{13-0} = imm{19-6}; } def A4_ext : T_Immext; let isCodeGenOnly = 1 in { let isBranch = 1 in def A4_ext_b : T_Immext; let isCall = 1 in def A4_ext_c : T_Immext; def A4_ext_g : T_Immext; } // Fold (add (CONST32 tglobaladdr:$addr) ) into a global address. def FoldGlobalAddr : ComplexPattern; // Fold (add (CONST32_GP tglobaladdr:$addr) ) into a global address. def FoldGlobalAddrGP : ComplexPattern; def NumUsesBelowThresCONST32 : PatFrag<(ops node:$addr), (HexagonCONST32 node:$addr), [{ return hasNumUsesBelowThresGA(N->getOperand(0).getNode()); }]>; // Hexagon V4 Architecture spec defines 8 instruction classes: // LD ST ALU32 XTYPE J JR MEMOP NV CR SYSTEM(system is not implemented in the // compiler) // LD Instructions: // ======================================== // Loads (8/16/32/64 bit) // Deallocframe // ST Instructions: // ======================================== // Stores (8/16/32/64 bit) // Allocframe // ALU32 Instructions: // ======================================== // Arithmetic / Logical (32 bit) // Vector Halfword // XTYPE Instructions (32/64 bit): // ======================================== // Arithmetic, Logical, Bit Manipulation // Multiply (Integer, Fractional, Complex) // Permute / Vector Permute Operations // Predicate Operations // Shift / Shift with Add/Sub/Logical // Vector Byte ALU // Vector Halfword (ALU, Shift, Multiply) // Vector Word (ALU, Shift) // J Instructions: // ======================================== // Jump/Call PC-relative // JR Instructions: // ======================================== // Jump/Call Register // MEMOP Instructions: // ======================================== // Operation on memory (8/16/32 bit) // NV Instructions: // ======================================== // New-value Jumps // New-value Stores // CR Instructions: // ======================================== // Control-Register Transfers // Hardware Loop Setup // Predicate Logicals & Reductions // SYSTEM Instructions (not implemented in the compiler): // ======================================== // Prefetch // Cache Maintenance // Bus Operations //===----------------------------------------------------------------------===// // ALU32 + //===----------------------------------------------------------------------===// class T_ALU32_3op_not MajOp, bits<3> MinOp, bit OpsRev> : T_ALU32_3op { let AsmString = "$Rd = "#mnemonic#"($Rs, ~$Rt)"; } let BaseOpcode = "andn_rr", CextOpcode = "andn", isCodeGenOnly = 0 in def A4_andn : T_ALU32_3op_not<"and", 0b001, 0b100, 1>; let BaseOpcode = "orn_rr", CextOpcode = "orn", isCodeGenOnly = 0 in def A4_orn : T_ALU32_3op_not<"or", 0b001, 0b101, 1>; let CextOpcode = "rcmp.eq", isCodeGenOnly = 0 in def A4_rcmpeq : T_ALU32_3op<"cmp.eq", 0b011, 0b010, 0, 1>; let CextOpcode = "!rcmp.eq", isCodeGenOnly = 0 in def A4_rcmpneq : T_ALU32_3op<"!cmp.eq", 0b011, 0b011, 0, 1>; let isCodeGenOnly = 0 in { def C4_cmpneq : T_ALU32_3op_cmp<"!cmp.eq", 0b00, 1, 1>; def C4_cmplte : T_ALU32_3op_cmp<"!cmp.gt", 0b10, 1, 0>; def C4_cmplteu : T_ALU32_3op_cmp<"!cmp.gtu", 0b11, 1, 0>; } // Pats for instruction selection. // A class to embed the usual comparison patfrags within a zext to i32. // The seteq/setne frags use "lhs" and "rhs" as operands, so use the same // names, or else the frag's "body" won't match the operands. class CmpInReg : PatFrag<(ops node:$lhs, node:$rhs),(i32 (zext (i1 Op.Fragment)))>; def: T_cmp32_rr_pat, i32>; def: T_cmp32_rr_pat, i32>; class T_CMP_rrbh MinOp, bit IsComm> : SInst<(outs PredRegs:$Pd), (ins IntRegs:$Rs, IntRegs:$Rt), "$Pd = "#mnemonic#"($Rs, $Rt)", [], "", S_3op_tc_2early_SLOT23>, ImmRegRel { let validSubTargets = HasV4SubT; let InputType = "reg"; let CextOpcode = mnemonic; let isCompare = 1; let isCommutable = IsComm; let hasSideEffects = 0; bits<2> Pd; bits<5> Rs; bits<5> Rt; let IClass = 0b1100; let Inst{27-21} = 0b0111110; let Inst{20-16} = Rs; let Inst{12-8} = Rt; let Inst{7-5} = MinOp; let Inst{1-0} = Pd; } let isCodeGenOnly = 0 in { def A4_cmpbeq : T_CMP_rrbh<"cmpb.eq", 0b110, 1>; def A4_cmpbgt : T_CMP_rrbh<"cmpb.gt", 0b010, 0>; def A4_cmpbgtu : T_CMP_rrbh<"cmpb.gtu", 0b111, 0>; def A4_cmpheq : T_CMP_rrbh<"cmph.eq", 0b011, 1>; def A4_cmphgt : T_CMP_rrbh<"cmph.gt", 0b100, 0>; def A4_cmphgtu : T_CMP_rrbh<"cmph.gtu", 0b101, 0>; } class T_CMP_ribh MajOp, bit IsHalf, bit IsComm, Operand ImmType, bit IsImmExt, bit IsImmSigned, int ImmBits> : ALU64Inst<(outs PredRegs:$Pd), (ins IntRegs:$Rs, ImmType:$Imm), "$Pd = "#mnemonic#"($Rs, #$Imm)", [], "", ALU64_tc_2early_SLOT23>, ImmRegRel { let validSubTargets = HasV4SubT; let InputType = "imm"; let CextOpcode = mnemonic; let isCompare = 1; let isCommutable = IsComm; let hasSideEffects = 0; let isExtendable = IsImmExt; let opExtendable = !if (IsImmExt, 2, 0); let isExtentSigned = IsImmSigned; let opExtentBits = ImmBits; bits<2> Pd; bits<5> Rs; bits<8> Imm; let IClass = 0b1101; let Inst{27-24} = 0b1101; let Inst{22-21} = MajOp; let Inst{20-16} = Rs; let Inst{12-5} = Imm; let Inst{4} = 0b0; let Inst{3} = IsHalf; let Inst{1-0} = Pd; } let isCodeGenOnly = 0 in { def A4_cmpbeqi : T_CMP_ribh<"cmpb.eq", 0b00, 0, 1, u8Imm, 0, 0, 8>; def A4_cmpbgti : T_CMP_ribh<"cmpb.gt", 0b01, 0, 0, s8Imm, 0, 1, 8>; def A4_cmpbgtui : T_CMP_ribh<"cmpb.gtu", 0b10, 0, 0, u7Ext, 1, 0, 7>; def A4_cmpheqi : T_CMP_ribh<"cmph.eq", 0b00, 1, 1, s8Ext, 1, 1, 8>; def A4_cmphgti : T_CMP_ribh<"cmph.gt", 0b01, 1, 0, s8Ext, 1, 1, 8>; def A4_cmphgtui : T_CMP_ribh<"cmph.gtu", 0b10, 1, 0, u7Ext, 1, 0, 7>; } class T_RCMP_EQ_ri : ALU32_ri<(outs IntRegs:$Rd), (ins IntRegs:$Rs, s8Ext:$s8), "$Rd = "#mnemonic#"($Rs, #$s8)", [], "", ALU32_2op_tc_1_SLOT0123>, ImmRegRel { let validSubTargets = HasV4SubT; let InputType = "imm"; let CextOpcode = !if (IsNeg, "!rcmp.eq", "rcmp.eq"); let isExtendable = 1; let opExtendable = 2; let isExtentSigned = 1; let opExtentBits = 8; let hasNewValue = 1; bits<5> Rd; bits<5> Rs; bits<8> s8; let IClass = 0b0111; let Inst{27-24} = 0b0011; let Inst{22} = 0b1; let Inst{21} = IsNeg; let Inst{20-16} = Rs; let Inst{13} = 0b1; let Inst{12-5} = s8; let Inst{4-0} = Rd; } let isCodeGenOnly = 0 in { def A4_rcmpeqi : T_RCMP_EQ_ri<"cmp.eq", 0>; def A4_rcmpneqi : T_RCMP_EQ_ri<"!cmp.eq", 1>; } def: Pat<(i32 (zext (i1 (seteq (i32 IntRegs:$Rs), s8ExtPred:$s8)))), (A4_rcmpeqi IntRegs:$Rs, s8ExtPred:$s8)>; def: Pat<(i32 (zext (i1 (setne (i32 IntRegs:$Rs), s8ExtPred:$s8)))), (A4_rcmpneqi IntRegs:$Rs, s8ExtPred:$s8)>; // Preserve the S2_tstbit_r generation def: Pat<(i32 (zext (i1 (setne (i32 (and (i32 (shl 1, (i32 IntRegs:$src2))), (i32 IntRegs:$src1))), 0)))), (C2_muxii (S2_tstbit_r IntRegs:$src1, IntRegs:$src2), 1, 0)>; //===----------------------------------------------------------------------===// // ALU32 - //===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===// // ALU32/PERM + //===----------------------------------------------------------------------===// // Combine a word and an immediate into a register pair. let hasSideEffects = 0, isExtentSigned = 1, isExtendable = 1, opExtentBits = 8 in class T_Combine1 MajOp, dag ins, string AsmStr> : ALU32Inst <(outs DoubleRegs:$Rdd), ins, AsmStr> { bits<5> Rdd; bits<5> Rs; bits<8> s8; let IClass = 0b0111; let Inst{27-24} = 0b0011; let Inst{22-21} = MajOp; let Inst{20-16} = Rs; let Inst{13} = 0b1; let Inst{12-5} = s8; let Inst{4-0} = Rdd; } let opExtendable = 2, isCodeGenOnly = 0 in def A4_combineri : T_Combine1<0b00, (ins IntRegs:$Rs, s8Ext:$s8), "$Rdd = combine($Rs, #$s8)">; let opExtendable = 1, isCodeGenOnly = 0 in def A4_combineir : T_Combine1<0b01, (ins s8Ext:$s8, IntRegs:$Rs), "$Rdd = combine(#$s8, $Rs)">; def HexagonWrapperCombineRI_V4 : SDNode<"HexagonISD::WrapperCombineRI_V4", SDTHexagonI64I32I32>; def HexagonWrapperCombineIR_V4 : SDNode<"HexagonISD::WrapperCombineIR_V4", SDTHexagonI64I32I32>; def : Pat <(HexagonWrapperCombineRI_V4 IntRegs:$r, s8ExtPred:$i), (A4_combineri IntRegs:$r, s8ExtPred:$i)>, Requires<[HasV4T]>; def : Pat <(HexagonWrapperCombineIR_V4 s8ExtPred:$i, IntRegs:$r), (A4_combineir s8ExtPred:$i, IntRegs:$r)>, Requires<[HasV4T]>; // A4_combineii: Set two small immediates. let hasSideEffects = 0, isExtendable = 1, opExtentBits = 6, opExtendable = 2 in def A4_combineii: ALU32Inst<(outs DoubleRegs:$Rdd), (ins s8Imm:$s8, u6Ext:$U6), "$Rdd = combine(#$s8, #$U6)"> { bits<5> Rdd; bits<8> s8; bits<6> U6; let IClass = 0b0111; let Inst{27-23} = 0b11001; let Inst{20-16} = U6{5-1}; let Inst{13} = U6{0}; let Inst{12-5} = s8; let Inst{4-0} = Rdd; } //===----------------------------------------------------------------------===// // ALU32/PERM - //===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===// // LD + //===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===// // Template class for load instructions with Absolute set addressing mode. //===----------------------------------------------------------------------===// let isExtended = 1, opExtendable = 2, hasSideEffects = 0, validSubTargets = HasV4SubT, addrMode = AbsoluteSet in class T_LD_abs_set: LDInst2<(outs RC:$dst1, IntRegs:$dst2), (ins u0AlwaysExt:$addr), "$dst1 = "#mnemonic#"($dst2=##$addr)", []>, Requires<[HasV4T]>; def LDrid_abs_set_V4 : T_LD_abs_set <"memd", DoubleRegs>; def LDrib_abs_set_V4 : T_LD_abs_set <"memb", IntRegs>; def LDriub_abs_set_V4 : T_LD_abs_set <"memub", IntRegs>; def LDrih_abs_set_V4 : T_LD_abs_set <"memh", IntRegs>; def LDriw_abs_set_V4 : T_LD_abs_set <"memw", IntRegs>; def LDriuh_abs_set_V4 : T_LD_abs_set <"memuh", IntRegs>; //===----------------------------------------------------------------------===// // Template classes for the non-predicated load instructions with // base + register offset addressing mode //===----------------------------------------------------------------------===// class T_load_rr MajOp>: LDInst<(outs RC:$dst), (ins IntRegs:$src1, IntRegs:$src2, u2Imm:$u2), "$dst = "#mnemonic#"($src1 + $src2<<#$u2)", [], "", V4LDST_tc_ld_SLOT01>, ImmRegShl, AddrModeRel { bits<5> dst; bits<5> src1; bits<5> src2; bits<2> u2; let IClass = 0b0011; let Inst{27-24} = 0b1010; let Inst{23-21} = MajOp; let Inst{20-16} = src1; let Inst{12-8} = src2; let Inst{13} = u2{1}; let Inst{7} = u2{0}; let Inst{4-0} = dst; } //===----------------------------------------------------------------------===// // Template classes for the predicated load instructions with // base + register offset addressing mode //===----------------------------------------------------------------------===// let isPredicated = 1 in class T_pload_rr MajOp, bit isNot, bit isPredNew>: LDInst <(outs RC:$dst), (ins PredRegs:$src1, IntRegs:$src2, IntRegs:$src3, u2Imm:$u2), !if(isNot, "if (!$src1", "if ($src1")#!if(isPredNew, ".new) ", ") ")#"$dst = "#mnemonic#"($src2+$src3<<#$u2)", [], "", V4LDST_tc_ld_SLOT01>, AddrModeRel { bits<5> dst; bits<2> src1; bits<5> src2; bits<5> src3; bits<2> u2; let isPredicatedFalse = isNot; let isPredicatedNew = isPredNew; let IClass = 0b0011; let Inst{27-26} = 0b00; let Inst{25} = isPredNew; let Inst{24} = isNot; let Inst{23-21} = MajOp; let Inst{20-16} = src2; let Inst{12-8} = src3; let Inst{13} = u2{1}; let Inst{7} = u2{0}; let Inst{6-5} = src1; let Inst{4-0} = dst; } //===----------------------------------------------------------------------===// // multiclass for load instructions with base + register offset // addressing mode //===----------------------------------------------------------------------===// let hasSideEffects = 0, addrMode = BaseRegOffset in multiclass ld_idxd_shl MajOp > { let CextOpcode = CextOp, BaseOpcode = CextOp#_indexed_shl, InputType = "reg" in { let isPredicable = 1 in def L4_#NAME#_rr : T_load_rr ; // Predicated def L4_p#NAME#t_rr : T_pload_rr ; def L4_p#NAME#f_rr : T_pload_rr ; // Predicated new def L4_p#NAME#tnew_rr : T_pload_rr ; def L4_p#NAME#fnew_rr : T_pload_rr ; } } let hasNewValue = 1, accessSize = ByteAccess, isCodeGenOnly = 0 in { defm loadrb : ld_idxd_shl<"memb", "LDrib", IntRegs, 0b000>; defm loadrub : ld_idxd_shl<"memub", "LDriub", IntRegs, 0b001>; } let hasNewValue = 1, accessSize = HalfWordAccess, isCodeGenOnly = 0 in { defm loadrh : ld_idxd_shl<"memh", "LDrih", IntRegs, 0b010>; defm loadruh : ld_idxd_shl<"memuh", "LDriuh", IntRegs, 0b011>; } let hasNewValue = 1, accessSize = WordAccess, isCodeGenOnly = 0 in defm loadri : ld_idxd_shl<"memw", "LDriw", IntRegs, 0b100>; let accessSize = DoubleWordAccess, isCodeGenOnly = 0 in defm loadrd : ld_idxd_shl<"memd", "LDrid", DoubleRegs, 0b110>; // 'def pats' for load instructions with base + register offset and non-zero // immediate value. Immediate value is used to left-shift the second // register operand. let AddedComplexity = 40 in { def : Pat <(i32 (sextloadi8 (add IntRegs:$src1, (shl IntRegs:$src2, u2ImmPred:$offset)))), (L4_loadrb_rr IntRegs:$src1, IntRegs:$src2, u2ImmPred:$offset)>, Requires<[HasV4T]>; def : Pat <(i32 (zextloadi8 (add IntRegs:$src1, (shl IntRegs:$src2, u2ImmPred:$offset)))), (L4_loadrub_rr IntRegs:$src1, IntRegs:$src2, u2ImmPred:$offset)>, Requires<[HasV4T]>; def : Pat <(i32 (extloadi8 (add IntRegs:$src1, (shl IntRegs:$src2, u2ImmPred:$offset)))), (L4_loadrub_rr IntRegs:$src1, IntRegs:$src2, u2ImmPred:$offset)>, Requires<[HasV4T]>; def : Pat <(i32 (sextloadi16 (add IntRegs:$src1, (shl IntRegs:$src2, u2ImmPred:$offset)))), (L4_loadrh_rr IntRegs:$src1, IntRegs:$src2, u2ImmPred:$offset)>, Requires<[HasV4T]>; def : Pat <(i32 (zextloadi16 (add IntRegs:$src1, (shl IntRegs:$src2, u2ImmPred:$offset)))), (L4_loadruh_rr IntRegs:$src1, IntRegs:$src2, u2ImmPred:$offset)>, Requires<[HasV4T]>; def : Pat <(i32 (extloadi16 (add IntRegs:$src1, (shl IntRegs:$src2, u2ImmPred:$offset)))), (L4_loadruh_rr IntRegs:$src1, IntRegs:$src2, u2ImmPred:$offset)>, Requires<[HasV4T]>; def : Pat <(i32 (load (add IntRegs:$src1, (shl IntRegs:$src2, u2ImmPred:$offset)))), (L4_loadri_rr IntRegs:$src1, IntRegs:$src2, u2ImmPred:$offset)>, Requires<[HasV4T]>; def : Pat <(i64 (load (add IntRegs:$src1, (shl IntRegs:$src2, u2ImmPred:$offset)))), (L4_loadrd_rr IntRegs:$src1, IntRegs:$src2, u2ImmPred:$offset)>, Requires<[HasV4T]>; } // 'def pats' for load instruction base + register offset and // zero immediate value. let AddedComplexity = 10 in { def : Pat <(i64 (load (add IntRegs:$src1, IntRegs:$src2))), (L4_loadrd_rr IntRegs:$src1, IntRegs:$src2, 0)>, Requires<[HasV4T]>; def : Pat <(i32 (sextloadi8 (add IntRegs:$src1, IntRegs:$src2))), (L4_loadrb_rr IntRegs:$src1, IntRegs:$src2, 0)>, Requires<[HasV4T]>; def : Pat <(i32 (zextloadi8 (add IntRegs:$src1, IntRegs:$src2))), (L4_loadrub_rr IntRegs:$src1, IntRegs:$src2, 0)>, Requires<[HasV4T]>; def : Pat <(i32 (extloadi8 (add IntRegs:$src1, IntRegs:$src2))), (L4_loadrub_rr IntRegs:$src1, IntRegs:$src2, 0)>, Requires<[HasV4T]>; def : Pat <(i32 (sextloadi16 (add IntRegs:$src1, IntRegs:$src2))), (L4_loadrh_rr IntRegs:$src1, IntRegs:$src2, 0)>, Requires<[HasV4T]>; def : Pat <(i32 (zextloadi16 (add IntRegs:$src1, IntRegs:$src2))), (L4_loadruh_rr IntRegs:$src1, IntRegs:$src2, 0)>, Requires<[HasV4T]>; def : Pat <(i32 (extloadi16 (add IntRegs:$src1, IntRegs:$src2))), (L4_loadruh_rr IntRegs:$src1, IntRegs:$src2, 0)>, Requires<[HasV4T]>; def : Pat <(i32 (load (add IntRegs:$src1, IntRegs:$src2))), (L4_loadri_rr IntRegs:$src1, IntRegs:$src2, 0)>, Requires<[HasV4T]>; } // zext i1->i64 def : Pat <(i64 (zext (i1 PredRegs:$src1))), (i64 (A4_combineir 0, (C2_muxii (i1 PredRegs:$src1), 1, 0)))>, Requires<[HasV4T]>; // zext i32->i64 def : Pat <(i64 (zext (i32 IntRegs:$src1))), (i64 (A4_combineir 0, (i32 IntRegs:$src1)))>, Requires<[HasV4T]>; // zext i8->i64 def: Pat <(i64 (zextloadi8 ADDRriS11_0:$src1)), (i64 (A4_combineir 0, (L2_loadrub_io AddrFI:$src1, 0)))>, Requires<[HasV4T]>; let AddedComplexity = 20 in def: Pat <(i64 (zextloadi8 (add (i32 IntRegs:$src1), s11_0ExtPred:$offset))), (i64 (A4_combineir 0, (L2_loadrub_io IntRegs:$src1, s11_0ExtPred:$offset)))>, Requires<[HasV4T]>; // zext i1->i64 def: Pat <(i64 (zextloadi1 ADDRriS11_0:$src1)), (i64 (A4_combineir 0, (L2_loadrub_io AddrFI:$src1, 0)))>, Requires<[HasV4T]>; let AddedComplexity = 20 in def: Pat <(i64 (zextloadi1 (add (i32 IntRegs:$src1), s11_0ExtPred:$offset))), (i64 (A4_combineir 0, (L2_loadrub_io IntRegs:$src1, s11_0ExtPred:$offset)))>, Requires<[HasV4T]>; // zext i16->i64 def: Pat <(i64 (zextloadi16 ADDRriS11_1:$src1)), (i64 (A4_combineir 0, (L2_loadruh_io AddrFI:$src1, 0)))>, Requires<[HasV4T]>; let AddedComplexity = 20 in def: Pat <(i64 (zextloadi16 (add (i32 IntRegs:$src1), s11_1ExtPred:$offset))), (i64 (A4_combineir 0, (L2_loadruh_io IntRegs:$src1, s11_1ExtPred:$offset)))>, Requires<[HasV4T]>; // anyext i16->i64 def: Pat <(i64 (extloadi16 ADDRriS11_2:$src1)), (i64 (A4_combineir 0, (L2_loadrh_io AddrFI:$src1, 0)))>, Requires<[HasV4T]>; let AddedComplexity = 20 in def: Pat <(i64 (extloadi16 (add (i32 IntRegs:$src1), s11_1ExtPred:$offset))), (i64 (A4_combineir 0, (L2_loadrh_io IntRegs:$src1, s11_1ExtPred:$offset)))>, Requires<[HasV4T]>; // zext i32->i64 def: Pat <(i64 (zextloadi32 ADDRriS11_2:$src1)), (i64 (A4_combineir 0, (L2_loadri_io AddrFI:$src1, 0)))>, Requires<[HasV4T]>; let AddedComplexity = 100 in def: Pat <(i64 (zextloadi32 (i32 (add IntRegs:$src1, s11_2ExtPred:$offset)))), (i64 (A4_combineir 0, (L2_loadri_io IntRegs:$src1, s11_2ExtPred:$offset)))>, Requires<[HasV4T]>; // anyext i32->i64 def: Pat <(i64 (extloadi32 ADDRriS11_2:$src1)), (i64 (A4_combineir 0, (L2_loadri_io AddrFI:$src1, 0)))>, Requires<[HasV4T]>; let AddedComplexity = 100 in def: Pat <(i64 (extloadi32 (i32 (add IntRegs:$src1, s11_2ExtPred:$offset)))), (i64 (A4_combineir 0, (L2_loadri_io IntRegs:$src1, s11_2ExtPred:$offset)))>, Requires<[HasV4T]>; //===----------------------------------------------------------------------===// // LD - //===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===// // ST + //===----------------------------------------------------------------------===// /// //===----------------------------------------------------------------------===// // Template class for store instructions with Absolute set addressing mode. //===----------------------------------------------------------------------===// let isExtended = 1, opExtendable = 2, validSubTargets = HasV4SubT, addrMode = AbsoluteSet in class T_ST_abs_set: STInst2<(outs IntRegs:$dst1), (ins RC:$src1, u0AlwaysExt:$src2), mnemonic#"($dst1=##$src2) = $src1", []>, Requires<[HasV4T]>; def STrid_abs_set_V4 : T_ST_abs_set <"memd", DoubleRegs>; def STrib_abs_set_V4 : T_ST_abs_set <"memb", IntRegs>; def STrih_abs_set_V4 : T_ST_abs_set <"memh", IntRegs>; def STriw_abs_set_V4 : T_ST_abs_set <"memw", IntRegs>; //===----------------------------------------------------------------------===// // Template classes for the non-predicated store instructions with // base + register offset addressing mode //===----------------------------------------------------------------------===// let isPredicable = 1 in class T_store_rr MajOp, bit isH> : STInst < (outs ), (ins IntRegs:$Rs, IntRegs:$Ru, u2Imm:$u2, RC:$Rt), mnemonic#"($Rs + $Ru<<#$u2) = $Rt"#!if(isH, ".h",""), [],"",V4LDST_tc_st_SLOT01>, ImmRegShl, AddrModeRel { bits<5> Rs; bits<5> Ru; bits<2> u2; bits<5> Rt; let IClass = 0b0011; let Inst{27-24} = 0b1011; let Inst{23-21} = MajOp; let Inst{20-16} = Rs; let Inst{12-8} = Ru; let Inst{13} = u2{1}; let Inst{7} = u2{0}; let Inst{4-0} = Rt; } //===----------------------------------------------------------------------===// // Template classes for the predicated store instructions with // base + register offset addressing mode //===----------------------------------------------------------------------===// let isPredicated = 1 in class T_pstore_rr MajOp, bit isNot, bit isPredNew, bit isH> : STInst <(outs), (ins PredRegs:$Pv, IntRegs:$Rs, IntRegs:$Ru, u2Imm:$u2, RC:$Rt), !if(isNot, "if (!$Pv", "if ($Pv")#!if(isPredNew, ".new) ", ") ")#mnemonic#"($Rs+$Ru<<#$u2) = $Rt"#!if(isH, ".h",""), [], "", V4LDST_tc_st_SLOT01> , AddrModeRel{ bits<2> Pv; bits<5> Rs; bits<5> Ru; bits<2> u2; bits<5> Rt; let isPredicatedFalse = isNot; let isPredicatedNew = isPredNew; let IClass = 0b0011; let Inst{27-26} = 0b01; let Inst{25} = isPredNew; let Inst{24} = isNot; let Inst{23-21} = MajOp; let Inst{20-16} = Rs; let Inst{12-8} = Ru; let Inst{13} = u2{1}; let Inst{7} = u2{0}; let Inst{6-5} = Pv; let Inst{4-0} = Rt; } //===----------------------------------------------------------------------===// // Template classes for the new-value store instructions with // base + register offset addressing mode //===----------------------------------------------------------------------===// let isPredicable = 1, isNewValue = 1, opNewValue = 3 in class T_store_new_rr MajOp> : NVInst < (outs ), (ins IntRegs:$Rs, IntRegs:$Ru, u2Imm:$u2, IntRegs:$Nt), mnemonic#"($Rs + $Ru<<#$u2) = $Nt.new", [],"",V4LDST_tc_st_SLOT0>, ImmRegShl, AddrModeRel { bits<5> Rs; bits<5> Ru; bits<2> u2; bits<3> Nt; let IClass = 0b0011; let Inst{27-21} = 0b1011101; let Inst{20-16} = Rs; let Inst{12-8} = Ru; let Inst{13} = u2{1}; let Inst{7} = u2{0}; let Inst{4-3} = MajOp; let Inst{2-0} = Nt; } //===----------------------------------------------------------------------===// // Template classes for the predicated new-value store instructions with // base + register offset addressing mode //===----------------------------------------------------------------------===// let isPredicated = 1, isNewValue = 1, opNewValue = 4 in class T_pstore_new_rr MajOp, bit isNot, bit isPredNew> : NVInst<(outs), (ins PredRegs:$Pv, IntRegs:$Rs, IntRegs:$Ru, u2Imm:$u2, IntRegs:$Nt), !if(isNot, "if (!$Pv", "if ($Pv")#!if(isPredNew, ".new) ", ") ")#mnemonic#"($Rs+$Ru<<#$u2) = $Nt.new", [], "", V4LDST_tc_st_SLOT0>, AddrModeRel { bits<2> Pv; bits<5> Rs; bits<5> Ru; bits<2> u2; bits<3> Nt; let isPredicatedFalse = isNot; let isPredicatedNew = isPredNew; let IClass = 0b0011; let Inst{27-26} = 0b01; let Inst{25} = isPredNew; let Inst{24} = isNot; let Inst{23-21} = 0b101; let Inst{20-16} = Rs; let Inst{12-8} = Ru; let Inst{13} = u2{1}; let Inst{7} = u2{0}; let Inst{6-5} = Pv; let Inst{4-3} = MajOp; let Inst{2-0} = Nt; } //===----------------------------------------------------------------------===// // multiclass for store instructions with base + register offset addressing // mode //===----------------------------------------------------------------------===// let isNVStorable = 1 in multiclass ST_Idxd_shl MajOp, bit isH = 0> { let CextOpcode = CextOp, BaseOpcode = CextOp#_indexed_shl in { def S4_#NAME#_rr : T_store_rr ; // Predicated def S4_p#NAME#t_rr : T_pstore_rr ; def S4_p#NAME#f_rr : T_pstore_rr ; // Predicated new def S4_p#NAME#tnew_rr : T_pstore_rr ; def S4_p#NAME#fnew_rr : T_pstore_rr ; } } //===----------------------------------------------------------------------===// // multiclass for new-value store instructions with base + register offset // addressing mode. //===----------------------------------------------------------------------===// let mayStore = 1, isNVStore = 1 in multiclass ST_Idxd_shl_nv MajOp> { let CextOpcode = CextOp, BaseOpcode = CextOp#_indexed_shl in { def S4_#NAME#new_rr : T_store_new_rr; // Predicated def S4_p#NAME#newt_rr : T_pstore_new_rr ; def S4_p#NAME#newf_rr : T_pstore_new_rr ; // Predicated new def S4_p#NAME#newtnew_rr : T_pstore_new_rr ; def S4_p#NAME#newfnew_rr : T_pstore_new_rr ; } } let addrMode = BaseRegOffset, InputType = "reg", hasSideEffects = 0, isCodeGenOnly = 0 in { let accessSize = ByteAccess in defm storerb: ST_Idxd_shl<"memb", "STrib", IntRegs, 0b000>, ST_Idxd_shl_nv<"memb", "STrib", IntRegs, 0b00>; let accessSize = HalfWordAccess in defm storerh: ST_Idxd_shl<"memh", "STrih", IntRegs, 0b010>, ST_Idxd_shl_nv<"memh", "STrih", IntRegs, 0b01>; let accessSize = WordAccess in defm storeri: ST_Idxd_shl<"memw", "STriw", IntRegs, 0b100>, ST_Idxd_shl_nv<"memw", "STriw", IntRegs, 0b10>; let isNVStorable = 0, accessSize = DoubleWordAccess in defm storerd: ST_Idxd_shl<"memd", "STrid", DoubleRegs, 0b110>; let isNVStorable = 0, accessSize = HalfWordAccess in defm storerf: ST_Idxd_shl<"memh", "STrif", IntRegs, 0b011, 1>; } let Predicates = [HasV4T], AddedComplexity = 10 in { def : Pat<(truncstorei8 (i32 IntRegs:$src4), (add IntRegs:$src1, (shl IntRegs:$src2, u2ImmPred:$src3))), (S4_storerb_rr IntRegs:$src1, IntRegs:$src2, u2ImmPred:$src3, IntRegs:$src4)>; def : Pat<(truncstorei16 (i32 IntRegs:$src4), (add IntRegs:$src1, (shl IntRegs:$src2, u2ImmPred:$src3))), (S4_storerh_rr IntRegs:$src1, IntRegs:$src2, u2ImmPred:$src3, IntRegs:$src4)>; def : Pat<(store (i32 IntRegs:$src4), (add IntRegs:$src1, (shl IntRegs:$src2, u2ImmPred:$src3))), (S4_storeri_rr IntRegs:$src1, IntRegs:$src2, u2ImmPred:$src3, IntRegs:$src4)>; def : Pat<(store (i64 DoubleRegs:$src4), (add IntRegs:$src1, (shl IntRegs:$src2, u2ImmPred:$src3))), (S4_storerd_rr IntRegs:$src1, IntRegs:$src2, u2ImmPred:$src3, DoubleRegs:$src4)>; } let isExtended = 1, opExtendable = 2 in class T_ST_LongOff : STInst<(outs), (ins IntRegs:$src1, u2Imm:$src2, u0AlwaysExt:$src3, RC:$src4), mnemonic#"($src1<<#$src2+##$src3) = $src4", [(stOp (VT RC:$src4), (add (shl (i32 IntRegs:$src1), u2ImmPred:$src2), u0AlwaysExtPred:$src3))]>, Requires<[HasV4T]>; let isExtended = 1, opExtendable = 2, mayStore = 1, isNVStore = 1 in class T_ST_LongOff_nv : NVInst_V4<(outs), (ins IntRegs:$src1, u2Imm:$src2, u0AlwaysExt:$src3, IntRegs:$src4), mnemonic#"($src1<<#$src2+##$src3) = $src4.new", []>, Requires<[HasV4T]>; multiclass ST_LongOff { let BaseOpcode = BaseOp#"_shl" in { let isNVStorable = 1 in def NAME#_V4 : T_ST_LongOff; def NAME#_nv_V4 : T_ST_LongOff_nv; } } let AddedComplexity = 10, validSubTargets = HasV4SubT in { def STrid_shl_V4 : T_ST_LongOff<"memd", store, DoubleRegs, i64>; defm STrib_shl : ST_LongOff <"memb", "STrib", truncstorei8>, NewValueRel; defm STrih_shl : ST_LongOff <"memh", "Strih", truncstorei16>, NewValueRel; defm STriw_shl : ST_LongOff <"memw", "STriw", store>, NewValueRel; } let AddedComplexity = 40 in multiclass T_ST_LOff_Pats { def : Pat<(stOp (VT RC:$src4), (add (shl IntRegs:$src1, u2ImmPred:$src2), (NumUsesBelowThresCONST32 tglobaladdr:$src3))), (I IntRegs:$src1, u2ImmPred:$src2, tglobaladdr:$src3, RC:$src4)>; def : Pat<(stOp (VT RC:$src4), (add IntRegs:$src1, (NumUsesBelowThresCONST32 tglobaladdr:$src3))), (I IntRegs:$src1, 0, tglobaladdr:$src3, RC:$src4)>; } defm : T_ST_LOff_Pats; defm : T_ST_LOff_Pats; defm : T_ST_LOff_Pats; defm : T_ST_LOff_Pats; // memd(Rx++#s4:3)=Rtt // memd(Rx++#s4:3:circ(Mu))=Rtt // memd(Rx++I:circ(Mu))=Rtt // memd(Rx++Mu)=Rtt // memd(Rx++Mu:brev)=Rtt // memd(gp+#u16:3)=Rtt // Store doubleword conditionally. // if ([!]Pv[.new]) memd(#u6)=Rtt // TODO: needs to be implemented. //===----------------------------------------------------------------------===// // Template class //===----------------------------------------------------------------------===// let isPredicable = 1, isExtendable = 1, isExtentSigned = 1, opExtentBits = 8, opExtendable = 2 in class T_StoreImm MajOp > : STInst <(outs ), (ins IntRegs:$Rs, OffsetOp:$offset, s8Ext:$S8), mnemonic#"($Rs+#$offset)=#$S8", [], "", V4LDST_tc_st_SLOT01>, ImmRegRel, PredNewRel { bits<5> Rs; bits<8> S8; bits<8> offset; bits<6> offsetBits; string OffsetOpStr = !cast(OffsetOp); let offsetBits = !if (!eq(OffsetOpStr, "u6_2Imm"), offset{7-2}, !if (!eq(OffsetOpStr, "u6_1Imm"), offset{6-1}, /* u6_0Imm */ offset{5-0})); let IClass = 0b0011; let Inst{27-25} = 0b110; let Inst{22-21} = MajOp; let Inst{20-16} = Rs; let Inst{12-7} = offsetBits; let Inst{13} = S8{7}; let Inst{6-0} = S8{6-0}; } let isPredicated = 1, isExtendable = 1, isExtentSigned = 1, opExtentBits = 6, opExtendable = 3 in class T_StoreImm_pred MajOp, bit isPredNot, bit isPredNew > : STInst <(outs ), (ins PredRegs:$Pv, IntRegs:$Rs, OffsetOp:$offset, s6Ext:$S6), !if(isPredNot, "if (!$Pv", "if ($Pv")#!if(isPredNew, ".new) ", ") ")#mnemonic#"($Rs+#$offset)=#$S6", [], "", V4LDST_tc_st_SLOT01>, ImmRegRel, PredNewRel { bits<2> Pv; bits<5> Rs; bits<6> S6; bits<8> offset; bits<6> offsetBits; string OffsetOpStr = !cast(OffsetOp); let offsetBits = !if (!eq(OffsetOpStr, "u6_2Imm"), offset{7-2}, !if (!eq(OffsetOpStr, "u6_1Imm"), offset{6-1}, /* u6_0Imm */ offset{5-0})); let isPredicatedNew = isPredNew; let isPredicatedFalse = isPredNot; let IClass = 0b0011; let Inst{27-25} = 0b100; let Inst{24} = isPredNew; let Inst{23} = isPredNot; let Inst{22-21} = MajOp; let Inst{20-16} = Rs; let Inst{13} = S6{5}; let Inst{12-7} = offsetBits; let Inst{6-5} = Pv; let Inst{4-0} = S6{4-0}; } //===----------------------------------------------------------------------===// // multiclass for store instructions with base + immediate offset // addressing mode and immediate stored value. // mem[bhw](Rx++#s4:3)=#s8 // if ([!]Pv[.new]) mem[bhw](Rx++#s4:3)=#s6 //===----------------------------------------------------------------------===// multiclass ST_Imm_Pred MajOp, bit PredNot> { def _io : T_StoreImm_pred ; // Predicate new def new_io : T_StoreImm_pred ; } multiclass ST_Imm MajOp> { let CextOpcode = CextOp, BaseOpcode = CextOp#_imm in { def _io : T_StoreImm ; defm t : ST_Imm_Pred ; defm f : ST_Imm_Pred ; } } let hasSideEffects = 0, validSubTargets = HasV4SubT, addrMode = BaseImmOffset, InputType = "imm", isCodeGenOnly = 0 in { let accessSize = ByteAccess in defm S4_storeirb : ST_Imm<"memb", "STrib", u6_0Imm, 0b00>; let accessSize = HalfWordAccess in defm S4_storeirh : ST_Imm<"memh", "STrih", u6_1Imm, 0b01>; let accessSize = WordAccess in defm S4_storeiri : ST_Imm<"memw", "STriw", u6_2Imm, 0b10>; } let Predicates = [HasV4T], AddedComplexity = 10 in { def: Pat<(truncstorei8 s8ExtPred:$src3, (add IntRegs:$src1, u6_0ImmPred:$src2)), (S4_storeirb_io IntRegs:$src1, u6_0ImmPred:$src2, s8ExtPred:$src3)>; def: Pat<(truncstorei16 s8ExtPred:$src3, (add IntRegs:$src1, u6_1ImmPred:$src2)), (S4_storeirh_io IntRegs:$src1, u6_1ImmPred:$src2, s8ExtPred:$src3)>; def: Pat<(store s8ExtPred:$src3, (add IntRegs:$src1, u6_2ImmPred:$src2)), (S4_storeiri_io IntRegs:$src1, u6_2ImmPred:$src2, s8ExtPred:$src3)>; } let AddedComplexity = 6 in def : Pat <(truncstorei8 s8ExtPred:$src2, (i32 IntRegs:$src1)), (S4_storeirb_io IntRegs:$src1, 0, s8ExtPred:$src2)>, Requires<[HasV4T]>; // memb(Rx++#s4:0:circ(Mu))=Rt // memb(Rx++I:circ(Mu))=Rt // memb(Rx++Mu)=Rt // memb(Rx++Mu:brev)=Rt // memb(gp+#u16:0)=Rt // Store halfword. // TODO: needs to be implemented // memh(Re=#U6)=Rt.H // memh(Rs+#s11:1)=Rt.H let AddedComplexity = 6 in def : Pat <(truncstorei16 s8ExtPred:$src2, (i32 IntRegs:$src1)), (S4_storeirh_io IntRegs:$src1, 0, s8ExtPred:$src2)>, Requires<[HasV4T]>; // memh(Rs+Ru<<#u2)=Rt.H // TODO: needs to be implemented. // memh(Ru<<#u2+#U6)=Rt.H // memh(Rx++#s4:1:circ(Mu))=Rt.H // memh(Rx++#s4:1:circ(Mu))=Rt // memh(Rx++I:circ(Mu))=Rt.H // memh(Rx++I:circ(Mu))=Rt // memh(Rx++Mu)=Rt.H // memh(Rx++Mu)=Rt // memh(Rx++Mu:brev)=Rt.H // memh(Rx++Mu:brev)=Rt // memh(gp+#u16:1)=Rt // if ([!]Pv[.new]) memh(#u6)=Rt.H // if ([!]Pv[.new]) memh(#u6)=Rt // if ([!]Pv[.new]) memh(Rs+#u6:1)=Rt.H // TODO: needs to be implemented. // if ([!]Pv[.new]) memh(Rx++#s4:1)=Rt.H // TODO: Needs to be implemented. // Store word. // memw(Re=#U6)=Rt // TODO: Needs to be implemented. // Store predicate: let hasSideEffects = 0 in def STriw_pred_V4 : STInst2<(outs), (ins MEMri:$addr, PredRegs:$src1), "Error; should not emit", []>, Requires<[HasV4T]>; let AddedComplexity = 6 in def : Pat <(store s8ExtPred:$src2, (i32 IntRegs:$src1)), (S4_storeiri_io IntRegs:$src1, 0, s8ExtPred:$src2)>, Requires<[HasV4T]>; // memw(Rx++#s4:2)=Rt // memw(Rx++#s4:2:circ(Mu))=Rt // memw(Rx++I:circ(Mu))=Rt // memw(Rx++Mu)=Rt // memw(Rx++Mu:brev)=Rt //===----------------------------------------------------------------------=== // ST - //===----------------------------------------------------------------------=== //===----------------------------------------------------------------------===// // NV/ST + //===----------------------------------------------------------------------===// let opNewValue = 2, opExtendable = 1, isExtentSigned = 1, isPredicable = 1 in class T_store_io_nv MajOp> : NVInst_V4 <(outs), (ins IntRegs:$src1, ImmOp:$src2, RC:$src3), mnemonic#"($src1+#$src2) = $src3.new", [],"",ST_tc_st_SLOT0> { bits<5> src1; bits<13> src2; // Actual address offset bits<3> src3; bits<11> offsetBits; // Represents offset encoding let opExtentBits = !if (!eq(mnemonic, "memb"), 11, !if (!eq(mnemonic, "memh"), 12, !if (!eq(mnemonic, "memw"), 13, 0))); let opExtentAlign = !if (!eq(mnemonic, "memb"), 0, !if (!eq(mnemonic, "memh"), 1, !if (!eq(mnemonic, "memw"), 2, 0))); let offsetBits = !if (!eq(mnemonic, "memb"), src2{10-0}, !if (!eq(mnemonic, "memh"), src2{11-1}, !if (!eq(mnemonic, "memw"), src2{12-2}, 0))); let IClass = 0b1010; let Inst{27} = 0b0; let Inst{26-25} = offsetBits{10-9}; let Inst{24-21} = 0b1101; let Inst{20-16} = src1; let Inst{13} = offsetBits{8}; let Inst{12-11} = MajOp; let Inst{10-8} = src3; let Inst{7-0} = offsetBits{7-0}; } let opExtendable = 2, opNewValue = 3, isPredicated = 1 in class T_pstore_io_nv MajOp, bit PredNot, bit isPredNew> : NVInst_V4 <(outs), (ins PredRegs:$src1, IntRegs:$src2, predImmOp:$src3, RC:$src4), !if(PredNot, "if (!$src1", "if ($src1")#!if(isPredNew, ".new) ", ") ")#mnemonic#"($src2+#$src3) = $src4.new", [],"",V2LDST_tc_st_SLOT0> { bits<2> src1; bits<5> src2; bits<9> src3; bits<3> src4; bits<6> offsetBits; // Represents offset encoding let isPredicatedNew = isPredNew; let isPredicatedFalse = PredNot; let opExtentBits = !if (!eq(mnemonic, "memb"), 6, !if (!eq(mnemonic, "memh"), 7, !if (!eq(mnemonic, "memw"), 8, 0))); let opExtentAlign = !if (!eq(mnemonic, "memb"), 0, !if (!eq(mnemonic, "memh"), 1, !if (!eq(mnemonic, "memw"), 2, 0))); let offsetBits = !if (!eq(mnemonic, "memb"), src3{5-0}, !if (!eq(mnemonic, "memh"), src3{6-1}, !if (!eq(mnemonic, "memw"), src3{7-2}, 0))); let IClass = 0b0100; let Inst{27} = 0b0; let Inst{26} = PredNot; let Inst{25} = isPredNew; let Inst{24-21} = 0b0101; let Inst{20-16} = src2; let Inst{13} = offsetBits{5}; let Inst{12-11} = MajOp; let Inst{10-8} = src4; let Inst{7-3} = offsetBits{4-0}; let Inst{2} = 0b0; let Inst{1-0} = src1; } // multiclass for new-value store instructions with base + immediate offset. // let mayStore = 1, isNVStore = 1, isNewValue = 1, hasSideEffects = 0, isExtendable = 1 in multiclass ST_Idxd_nv MajOp> { let CextOpcode = CextOp, BaseOpcode = CextOp#_indexed in { def S2_#NAME#new_io : T_store_io_nv ; // Predicated def S2_p#NAME#newt_io :T_pstore_io_nv ; def S2_p#NAME#newf_io :T_pstore_io_nv ; // Predicated new def S4_p#NAME#newtnew_io :T_pstore_io_nv ; def S4_p#NAME#newfnew_io :T_pstore_io_nv ; } } let addrMode = BaseImmOffset, InputType = "imm", isCodeGenOnly = 0 in { let accessSize = ByteAccess in defm storerb: ST_Idxd_nv<"memb", "STrib", IntRegs, s11_0Ext, u6_0Ext, 0b00>, AddrModeRel; let accessSize = HalfWordAccess, opExtentAlign = 1 in defm storerh: ST_Idxd_nv<"memh", "STrih", IntRegs, s11_1Ext, u6_1Ext, 0b01>, AddrModeRel; let accessSize = WordAccess, opExtentAlign = 2 in defm storeri: ST_Idxd_nv<"memw", "STriw", IntRegs, s11_2Ext, u6_2Ext, 0b10>, AddrModeRel; } //===----------------------------------------------------------------------===// // Template class for non-predicated post increment .new stores // mem[bhwd](Rx++#s4:[0123])=Nt.new //===----------------------------------------------------------------------===// let isPredicable = 1, hasSideEffects = 0, validSubTargets = HasV4SubT, addrMode = PostInc, isNVStore = 1, isNewValue = 1, opNewValue = 3 in class T_StorePI_nv MajOp > : NVInstPI_V4 <(outs IntRegs:$_dst_), (ins IntRegs:$src1, ImmOp:$offset, IntRegs:$src2), mnemonic#"($src1++#$offset) = $src2.new", [], "$src1 = $_dst_">, AddrModeRel { bits<5> src1; bits<3> src2; bits<7> offset; bits<4> offsetBits; string ImmOpStr = !cast(ImmOp); let offsetBits = !if (!eq(ImmOpStr, "s4_2Imm"), offset{5-2}, !if (!eq(ImmOpStr, "s4_1Imm"), offset{4-1}, /* s4_0Imm */ offset{3-0})); let IClass = 0b1010; let Inst{27-21} = 0b1011101; let Inst{20-16} = src1; let Inst{13} = 0b0; let Inst{12-11} = MajOp; let Inst{10-8} = src2; let Inst{7} = 0b0; let Inst{6-3} = offsetBits; let Inst{1} = 0b0; } //===----------------------------------------------------------------------===// // Template class for predicated post increment .new stores // if([!]Pv[.new]) mem[bhwd](Rx++#s4:[0123])=Nt.new //===----------------------------------------------------------------------===// let isPredicated = 1, hasSideEffects = 0, validSubTargets = HasV4SubT, addrMode = PostInc, isNVStore = 1, isNewValue = 1, opNewValue = 4 in class T_StorePI_nv_pred MajOp, bit isPredNot, bit isPredNew > : NVInstPI_V4 <(outs IntRegs:$_dst_), (ins PredRegs:$src1, IntRegs:$src2, ImmOp:$offset, IntRegs:$src3), !if(isPredNot, "if (!$src1", "if ($src1")#!if(isPredNew, ".new) ", ") ")#mnemonic#"($src2++#$offset) = $src3.new", [], "$src2 = $_dst_">, AddrModeRel { bits<2> src1; bits<5> src2; bits<3> src3; bits<7> offset; bits<4> offsetBits; string ImmOpStr = !cast(ImmOp); let offsetBits = !if (!eq(ImmOpStr, "s4_2Imm"), offset{5-2}, !if (!eq(ImmOpStr, "s4_1Imm"), offset{4-1}, /* s4_0Imm */ offset{3-0})); let isPredicatedNew = isPredNew; let isPredicatedFalse = isPredNot; let IClass = 0b1010; let Inst{27-21} = 0b1011101; let Inst{20-16} = src2; let Inst{13} = 0b1; let Inst{12-11} = MajOp; let Inst{10-8} = src3; let Inst{7} = isPredNew; let Inst{6-3} = offsetBits; let Inst{2} = isPredNot; let Inst{1-0} = src1; } multiclass ST_PostInc_Pred_nv MajOp, bit PredNot> { def _pi : T_StorePI_nv_pred ; // Predicate new def new_pi : T_StorePI_nv_pred ; } multiclass ST_PostInc_nv MajOp> { let BaseOpcode = "POST_"#BaseOp in { def S2_#NAME#_pi : T_StorePI_nv ; // Predicated defm S2_p#NAME#t : ST_PostInc_Pred_nv ; defm S2_p#NAME#f : ST_PostInc_Pred_nv ; } } let accessSize = ByteAccess, isCodeGenOnly = 0 in defm storerbnew: ST_PostInc_nv <"memb", "STrib", s4_0Imm, 0b00>; let accessSize = HalfWordAccess, isCodeGenOnly = 0 in defm storerhnew: ST_PostInc_nv <"memh", "STrih", s4_1Imm, 0b01>; let accessSize = WordAccess, isCodeGenOnly = 0 in defm storerinew: ST_PostInc_nv <"memw", "STriw", s4_2Imm, 0b10>; //===----------------------------------------------------------------------===// // Template class for post increment .new stores with register offset //===----------------------------------------------------------------------===// let isNewValue = 1, mayStore = 1, isNVStore = 1, opNewValue = 3 in class T_StorePI_RegNV MajOp, MemAccessSize AccessSz> : NVInstPI_V4 <(outs IntRegs:$_dst_), (ins IntRegs:$src1, ModRegs:$src2, IntRegs:$src3), #mnemonic#"($src1++$src2) = $src3.new", [], "$src1 = $_dst_"> { bits<5> src1; bits<1> src2; bits<3> src3; let accessSize = AccessSz; let IClass = 0b1010; let Inst{27-21} = 0b1101101; let Inst{20-16} = src1; let Inst{13} = src2; let Inst{12-11} = MajOp; let Inst{10-8} = src3; let Inst{7} = 0b0; } let isCodeGenOnly = 0 in { def S2_storerbnew_pr : T_StorePI_RegNV<"memb", 0b00, ByteAccess>; def S2_storerhnew_pr : T_StorePI_RegNV<"memh", 0b01, HalfWordAccess>; def S2_storerinew_pr : T_StorePI_RegNV<"memw", 0b10, WordAccess>; } // memb(Rx++#s4:0:circ(Mu))=Nt.new // memb(Rx++I:circ(Mu))=Nt.new // memb(Rx++Mu)=Nt.new // memb(Rx++Mu:brev)=Nt.new // memh(Rx++#s4:1:circ(Mu))=Nt.new // memh(Rx++I:circ(Mu))=Nt.new // memh(Rx++Mu)=Nt.new // memh(Rx++Mu:brev)=Nt.new // memw(Rx++#s4:2:circ(Mu))=Nt.new // memw(Rx++I:circ(Mu))=Nt.new // memw(Rx++Mu)=Nt.new // memw(Rx++Mu:brev)=Nt.new //===----------------------------------------------------------------------===// // NV/ST - //===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===// // NV/J + //===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===// // multiclass/template class for the new-value compare jumps with the register // operands. //===----------------------------------------------------------------------===// let isExtendable = 1, opExtendable = 2, isExtentSigned = 1, opExtentBits = 11, opExtentAlign = 2 in class NVJrr_template majOp, bit NvOpNum, bit isNegCond, bit isTak> : NVInst_V4<(outs), (ins IntRegs:$src1, IntRegs:$src2, brtarget:$offset), "if ("#!if(isNegCond, "!","")#mnemonic# "($src1"#!if(!eq(NvOpNum, 0),".new, ",", ")# "$src2"#!if(!eq(NvOpNum, 1),".new))","))")#" jump:" #!if(isTak, "t","nt")#" $offset", []> { bits<5> src1; bits<5> src2; bits<3> Ns; // New-Value Operand bits<5> RegOp; // Non-New-Value Operand bits<11> offset; let isTaken = isTak; let isPredicatedFalse = isNegCond; let opNewValue{0} = NvOpNum; let Ns = !if(!eq(NvOpNum, 0), src1{2-0}, src2{2-0}); let RegOp = !if(!eq(NvOpNum, 0), src2, src1); let IClass = 0b0010; let Inst{26} = 0b0; let Inst{25-23} = majOp; let Inst{22} = isNegCond; let Inst{18-16} = Ns; let Inst{13} = isTak; let Inst{12-8} = RegOp; let Inst{21-20} = offset{10-9}; let Inst{7-1} = offset{8-2}; } multiclass NVJrr_cond majOp, bit NvOpNum, bit isNegCond> { // Branch not taken: def _nt_V4: NVJrr_template; // Branch taken: def _t_V4: NVJrr_template; } // NvOpNum = 0 -> First Operand is a new-value Register // NvOpNum = 1 -> Second Operand is a new-value Register multiclass NVJrr_base majOp, bit NvOpNum> { let BaseOpcode = BaseOp#_NVJ in { defm _t_Jumpnv : NVJrr_cond; // True cond defm _f_Jumpnv : NVJrr_cond; // False cond } } // if ([!]cmp.eq(Ns.new,Rt)) jump:[n]t #r9:2 // if ([!]cmp.gt(Ns.new,Rt)) jump:[n]t #r9:2 // if ([!]cmp.gtu(Ns.new,Rt)) jump:[n]t #r9:2 // if ([!]cmp.gt(Rt,Ns.new)) jump:[n]t #r9:2 // if ([!]cmp.gtu(Rt,Ns.new)) jump:[n]t #r9:2 let isPredicated = 1, isBranch = 1, isNewValue = 1, isTerminator = 1, Defs = [PC], hasSideEffects = 0, validSubTargets = HasV4SubT, isCodeGenOnly = 0 in { defm CMPEQrr : NVJrr_base<"cmp.eq", "CMPEQ", 0b000, 0>, PredRel; defm CMPGTrr : NVJrr_base<"cmp.gt", "CMPGT", 0b001, 0>, PredRel; defm CMPGTUrr : NVJrr_base<"cmp.gtu", "CMPGTU", 0b010, 0>, PredRel; defm CMPLTrr : NVJrr_base<"cmp.gt", "CMPLT", 0b011, 1>, PredRel; defm CMPLTUrr : NVJrr_base<"cmp.gtu", "CMPLTU", 0b100, 1>, PredRel; } //===----------------------------------------------------------------------===// // multiclass/template class for the new-value compare jumps instruction // with a register and an unsigned immediate (U5) operand. //===----------------------------------------------------------------------===// let isExtendable = 1, opExtendable = 2, isExtentSigned = 1, opExtentBits = 11, opExtentAlign = 2 in class NVJri_template majOp, bit isNegCond, bit isTak> : NVInst_V4<(outs), (ins IntRegs:$src1, u5Imm:$src2, brtarget:$offset), "if ("#!if(isNegCond, "!","")#mnemonic#"($src1.new, #$src2)) jump:" #!if(isTak, "t","nt")#" $offset", []> { let isTaken = isTak; let isPredicatedFalse = isNegCond; let isTaken = isTak; bits<3> src1; bits<5> src2; bits<11> offset; let IClass = 0b0010; let Inst{26} = 0b1; let Inst{25-23} = majOp; let Inst{22} = isNegCond; let Inst{18-16} = src1; let Inst{13} = isTak; let Inst{12-8} = src2; let Inst{21-20} = offset{10-9}; let Inst{7-1} = offset{8-2}; } multiclass NVJri_cond majOp, bit isNegCond> { // Branch not taken: def _nt_V4: NVJri_template; // Branch taken: def _t_V4: NVJri_template; } multiclass NVJri_base majOp> { let BaseOpcode = BaseOp#_NVJri in { defm _t_Jumpnv : NVJri_cond; // True Cond defm _f_Jumpnv : NVJri_cond; // False cond } } // if ([!]cmp.eq(Ns.new,#U5)) jump:[n]t #r9:2 // if ([!]cmp.gt(Ns.new,#U5)) jump:[n]t #r9:2 // if ([!]cmp.gtu(Ns.new,#U5)) jump:[n]t #r9:2 let isPredicated = 1, isBranch = 1, isNewValue = 1, isTerminator = 1, Defs = [PC], hasSideEffects = 0, validSubTargets = HasV4SubT, isCodeGenOnly = 0 in { defm CMPEQri : NVJri_base<"cmp.eq", "CMPEQ", 0b000>, PredRel; defm CMPGTri : NVJri_base<"cmp.gt", "CMPGT", 0b001>, PredRel; defm CMPGTUri : NVJri_base<"cmp.gtu", "CMPGTU", 0b010>, PredRel; } //===----------------------------------------------------------------------===// // multiclass/template class for the new-value compare jumps instruction // with a register and an hardcoded 0/-1 immediate value. //===----------------------------------------------------------------------===// let isExtendable = 1, opExtendable = 1, isExtentSigned = 1, opExtentBits = 11, opExtentAlign = 2 in class NVJ_ConstImm_template majOp, string ImmVal, bit isNegCond, bit isTak> : NVInst_V4<(outs), (ins IntRegs:$src1, brtarget:$offset), "if ("#!if(isNegCond, "!","")#mnemonic #"($src1.new, #"#ImmVal#")) jump:" #!if(isTak, "t","nt")#" $offset", []> { let isTaken = isTak; let isPredicatedFalse = isNegCond; let isTaken = isTak; bits<3> src1; bits<11> offset; let IClass = 0b0010; let Inst{26} = 0b1; let Inst{25-23} = majOp; let Inst{22} = isNegCond; let Inst{18-16} = src1; let Inst{13} = isTak; let Inst{21-20} = offset{10-9}; let Inst{7-1} = offset{8-2}; } multiclass NVJ_ConstImm_cond majOp, string ImmVal, bit isNegCond> { // Branch not taken: def _nt_V4: NVJ_ConstImm_template; // Branch taken: def _t_V4: NVJ_ConstImm_template; } multiclass NVJ_ConstImm_base majOp, string ImmVal> { let BaseOpcode = BaseOp#_NVJ_ConstImm in { defm _t_Jumpnv : NVJ_ConstImm_cond; // True defm _f_Jumpnv : NVJ_ConstImm_cond; // False } } // if ([!]tstbit(Ns.new,#0)) jump:[n]t #r9:2 // if ([!]cmp.eq(Ns.new,#-1)) jump:[n]t #r9:2 // if ([!]cmp.gt(Ns.new,#-1)) jump:[n]t #r9:2 let isPredicated = 1, isBranch = 1, isNewValue = 1, isTerminator=1, Defs = [PC], hasSideEffects = 0, isCodeGenOnly = 0 in { defm TSTBIT0 : NVJ_ConstImm_base<"tstbit", "TSTBIT", 0b011, "0">, PredRel; defm CMPEQn1 : NVJ_ConstImm_base<"cmp.eq", "CMPEQ", 0b100, "-1">, PredRel; defm CMPGTn1 : NVJ_ConstImm_base<"cmp.gt", "CMPGT", 0b101, "-1">, PredRel; } // J4_hintjumpr: Hint indirect conditional jump. let isBranch = 1, isIndirectBranch = 1, hasSideEffects = 0, isCodeGenOnly = 0 in def J4_hintjumpr: JRInst < (outs), (ins IntRegs:$Rs), "hintjr($Rs)"> { bits<5> Rs; let IClass = 0b0101; let Inst{27-21} = 0b0010101; let Inst{20-16} = Rs; } //===----------------------------------------------------------------------===// // NV/J - //===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===// // CR + //===----------------------------------------------------------------------===// // PC-relative add let hasNewValue = 1, isExtendable = 1, opExtendable = 1, isExtentSigned = 0, opExtentBits = 6, hasSideEffects = 0, Uses = [PC], validSubTargets = HasV4SubT in def C4_addipc : CRInst <(outs IntRegs:$Rd), (ins u6Ext:$u6), "$Rd = add(pc, #$u6)", [], "", CR_tc_2_SLOT3 > { bits<5> Rd; bits<6> u6; let IClass = 0b0110; let Inst{27-16} = 0b101001001001; let Inst{12-7} = u6; let Inst{4-0} = Rd; } let hasSideEffects = 0 in class T_LOGICAL_3OP OpBits, bit IsNeg> : CRInst<(outs PredRegs:$Pd), (ins PredRegs:$Ps, PredRegs:$Pt, PredRegs:$Pu), "$Pd = " # MnOp1 # "($Ps, " # MnOp2 # "($Pt, " # !if (IsNeg,"!","") # "$Pu))", [], "", CR_tc_2early_SLOT23> { bits<2> Pd; bits<2> Ps; bits<2> Pt; bits<2> Pu; let IClass = 0b0110; let Inst{27-24} = 0b1011; let Inst{23} = IsNeg; let Inst{22-21} = OpBits; let Inst{20} = 0b1; let Inst{17-16} = Ps; let Inst{13} = 0b0; let Inst{9-8} = Pt; let Inst{7-6} = Pu; let Inst{1-0} = Pd; } let isCodeGenOnly = 0 in { def C4_and_and : T_LOGICAL_3OP<"and", "and", 0b00, 0>; def C4_and_or : T_LOGICAL_3OP<"and", "or", 0b01, 0>; def C4_or_and : T_LOGICAL_3OP<"or", "and", 0b10, 0>; def C4_or_or : T_LOGICAL_3OP<"or", "or", 0b11, 0>; def C4_and_andn : T_LOGICAL_3OP<"and", "and", 0b00, 1>; def C4_and_orn : T_LOGICAL_3OP<"and", "or", 0b01, 1>; def C4_or_andn : T_LOGICAL_3OP<"or", "and", 0b10, 1>; def C4_or_orn : T_LOGICAL_3OP<"or", "or", 0b11, 1>; } //===----------------------------------------------------------------------===// // CR - //===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===// // XTYPE/ALU + //===----------------------------------------------------------------------===// // Add and accumulate. // Rd=add(Rs,add(Ru,#s6)) let isExtendable = 1, opExtendable = 3, isExtentSigned = 1, opExtentBits = 6, validSubTargets = HasV4SubT in def ADDr_ADDri_V4 : MInst<(outs IntRegs:$dst), (ins IntRegs:$src1, IntRegs:$src2, s6Ext:$src3), "$dst = add($src1, add($src2, #$src3))", [(set (i32 IntRegs:$dst), (add (i32 IntRegs:$src1), (add (i32 IntRegs:$src2), s6_16ExtPred:$src3)))]>, Requires<[HasV4T]>; // Rd=add(Rs,sub(#s6,Ru)) let isExtendable = 1, opExtendable = 2, isExtentSigned = 1, opExtentBits = 6, validSubTargets = HasV4SubT in def ADDr_SUBri_V4 : MInst<(outs IntRegs:$dst), (ins IntRegs:$src1, s6Ext:$src2, IntRegs:$src3), "$dst = add($src1, sub(#$src2, $src3))", [(set (i32 IntRegs:$dst), (add (i32 IntRegs:$src1), (sub s6_10ExtPred:$src2, (i32 IntRegs:$src3))))]>, Requires<[HasV4T]>; // Generates the same instruction as ADDr_SUBri_V4 but matches different // pattern. // Rd=add(Rs,sub(#s6,Ru)) let isExtendable = 1, opExtendable = 2, isExtentSigned = 1, opExtentBits = 6, validSubTargets = HasV4SubT in def ADDri_SUBr_V4 : MInst<(outs IntRegs:$dst), (ins IntRegs:$src1, s6Ext:$src2, IntRegs:$src3), "$dst = add($src1, sub(#$src2, $src3))", [(set (i32 IntRegs:$dst), (sub (add (i32 IntRegs:$src1), s6_10ExtPred:$src2), (i32 IntRegs:$src3)))]>, Requires<[HasV4T]>; // Add or subtract doublewords with carry. //TODO: // Rdd=add(Rss,Rtt,Px):carry //TODO: // Rdd=sub(Rss,Rtt,Px):carry // Logical doublewords. // Rdd=and(Rtt,~Rss) let validSubTargets = HasV4SubT in def ANDd_NOTd_V4 : MInst<(outs DoubleRegs:$dst), (ins DoubleRegs:$src1, DoubleRegs:$src2), "$dst = and($src1, ~$src2)", [(set (i64 DoubleRegs:$dst), (and (i64 DoubleRegs:$src1), (not (i64 DoubleRegs:$src2))))]>, Requires<[HasV4T]>; // Rdd=or(Rtt,~Rss) let validSubTargets = HasV4SubT in def ORd_NOTd_V4 : MInst<(outs DoubleRegs:$dst), (ins DoubleRegs:$src1, DoubleRegs:$src2), "$dst = or($src1, ~$src2)", [(set (i64 DoubleRegs:$dst), (or (i64 DoubleRegs:$src1), (not (i64 DoubleRegs:$src2))))]>, Requires<[HasV4T]>; // Logical-logical doublewords. // Rxx^=xor(Rss,Rtt) let validSubTargets = HasV4SubT in def XORd_XORdd: MInst_acc<(outs DoubleRegs:$dst), (ins DoubleRegs:$src1, DoubleRegs:$src2, DoubleRegs:$src3), "$dst ^= xor($src2, $src3)", [(set (i64 DoubleRegs:$dst), (xor (i64 DoubleRegs:$src1), (xor (i64 DoubleRegs:$src2), (i64 DoubleRegs:$src3))))], "$src1 = $dst">, Requires<[HasV4T]>; // Logical-logical words. // Rx=or(Ru,and(Rx,#s10)) let isExtendable = 1, opExtendable = 3, isExtentSigned = 1, opExtentBits = 10, validSubTargets = HasV4SubT in def ORr_ANDri_V4 : MInst_acc<(outs IntRegs:$dst), (ins IntRegs:$src1, IntRegs: $src2, s10Ext:$src3), "$dst = or($src1, and($src2, #$src3))", [(set (i32 IntRegs:$dst), (or (i32 IntRegs:$src1), (and (i32 IntRegs:$src2), s10ExtPred:$src3)))], "$src2 = $dst">, Requires<[HasV4T]>; // Rx[&|^]=and(Rs,Rt) // Rx&=and(Rs,Rt) let validSubTargets = HasV4SubT in def ANDr_ANDrr_V4 : MInst_acc<(outs IntRegs:$dst), (ins IntRegs:$src1, IntRegs: $src2, IntRegs:$src3), "$dst &= and($src2, $src3)", [(set (i32 IntRegs:$dst), (and (i32 IntRegs:$src1), (and (i32 IntRegs:$src2), (i32 IntRegs:$src3))))], "$src1 = $dst">, Requires<[HasV4T]>; // Rx|=and(Rs,Rt) let validSubTargets = HasV4SubT, CextOpcode = "ORr_ANDr", InputType = "reg" in def ORr_ANDrr_V4 : MInst_acc<(outs IntRegs:$dst), (ins IntRegs:$src1, IntRegs: $src2, IntRegs:$src3), "$dst |= and($src2, $src3)", [(set (i32 IntRegs:$dst), (or (i32 IntRegs:$src1), (and (i32 IntRegs:$src2), (i32 IntRegs:$src3))))], "$src1 = $dst">, Requires<[HasV4T]>, ImmRegRel; // Rx^=and(Rs,Rt) let validSubTargets = HasV4SubT in def XORr_ANDrr_V4 : MInst_acc<(outs IntRegs:$dst), (ins IntRegs:$src1, IntRegs: $src2, IntRegs:$src3), "$dst ^= and($src2, $src3)", [(set (i32 IntRegs:$dst), (xor (i32 IntRegs:$src1), (and (i32 IntRegs:$src2), (i32 IntRegs:$src3))))], "$src1 = $dst">, Requires<[HasV4T]>; // Rx[&|^]=and(Rs,~Rt) // Rx&=and(Rs,~Rt) let validSubTargets = HasV4SubT in def ANDr_ANDr_NOTr_V4 : MInst_acc<(outs IntRegs:$dst), (ins IntRegs:$src1, IntRegs: $src2, IntRegs:$src3), "$dst &= and($src2, ~$src3)", [(set (i32 IntRegs:$dst), (and (i32 IntRegs:$src1), (and (i32 IntRegs:$src2), (not (i32 IntRegs:$src3)))))], "$src1 = $dst">, Requires<[HasV4T]>; // Rx|=and(Rs,~Rt) let validSubTargets = HasV4SubT in def ORr_ANDr_NOTr_V4 : MInst_acc<(outs IntRegs:$dst), (ins IntRegs:$src1, IntRegs: $src2, IntRegs:$src3), "$dst |= and($src2, ~$src3)", [(set (i32 IntRegs:$dst), (or (i32 IntRegs:$src1), (and (i32 IntRegs:$src2), (not (i32 IntRegs:$src3)))))], "$src1 = $dst">, Requires<[HasV4T]>; // Rx^=and(Rs,~Rt) let validSubTargets = HasV4SubT in def XORr_ANDr_NOTr_V4 : MInst_acc<(outs IntRegs:$dst), (ins IntRegs:$src1, IntRegs: $src2, IntRegs:$src3), "$dst ^= and($src2, ~$src3)", [(set (i32 IntRegs:$dst), (xor (i32 IntRegs:$src1), (and (i32 IntRegs:$src2), (not (i32 IntRegs:$src3)))))], "$src1 = $dst">, Requires<[HasV4T]>; // Rx[&|^]=or(Rs,Rt) // Rx&=or(Rs,Rt) let validSubTargets = HasV4SubT in def ANDr_ORrr_V4 : MInst_acc<(outs IntRegs:$dst), (ins IntRegs:$src1, IntRegs: $src2, IntRegs:$src3), "$dst &= or($src2, $src3)", [(set (i32 IntRegs:$dst), (and (i32 IntRegs:$src1), (or (i32 IntRegs:$src2), (i32 IntRegs:$src3))))], "$src1 = $dst">, Requires<[HasV4T]>; // Rx|=or(Rs,Rt) let validSubTargets = HasV4SubT, CextOpcode = "ORr_ORr", InputType = "reg" in def ORr_ORrr_V4 : MInst_acc<(outs IntRegs:$dst), (ins IntRegs:$src1, IntRegs: $src2, IntRegs:$src3), "$dst |= or($src2, $src3)", [(set (i32 IntRegs:$dst), (or (i32 IntRegs:$src1), (or (i32 IntRegs:$src2), (i32 IntRegs:$src3))))], "$src1 = $dst">, Requires<[HasV4T]>, ImmRegRel; // Rx^=or(Rs,Rt) let validSubTargets = HasV4SubT in def XORr_ORrr_V4 : MInst_acc<(outs IntRegs:$dst), (ins IntRegs:$src1, IntRegs: $src2, IntRegs:$src3), "$dst ^= or($src2, $src3)", [(set (i32 IntRegs:$dst), (xor (i32 IntRegs:$src1), (or (i32 IntRegs:$src2), (i32 IntRegs:$src3))))], "$src1 = $dst">, Requires<[HasV4T]>; // Rx[&|^]=xor(Rs,Rt) // Rx&=xor(Rs,Rt) let validSubTargets = HasV4SubT in def ANDr_XORrr_V4 : MInst_acc<(outs IntRegs:$dst), (ins IntRegs:$src1, IntRegs: $src2, IntRegs:$src3), "$dst &= xor($src2, $src3)", [(set (i32 IntRegs:$dst), (and (i32 IntRegs:$src1), (xor (i32 IntRegs:$src2), (i32 IntRegs:$src3))))], "$src1 = $dst">, Requires<[HasV4T]>; // Rx|=xor(Rs,Rt) let validSubTargets = HasV4SubT in def ORr_XORrr_V4 : MInst_acc<(outs IntRegs:$dst), (ins IntRegs:$src1, IntRegs: $src2, IntRegs:$src3), "$dst |= xor($src2, $src3)", [(set (i32 IntRegs:$dst), (and (i32 IntRegs:$src1), (xor (i32 IntRegs:$src2), (i32 IntRegs:$src3))))], "$src1 = $dst">, Requires<[HasV4T]>; // Rx^=xor(Rs,Rt) let validSubTargets = HasV4SubT in def XORr_XORrr_V4 : MInst_acc<(outs IntRegs:$dst), (ins IntRegs:$src1, IntRegs: $src2, IntRegs:$src3), "$dst ^= xor($src2, $src3)", [(set (i32 IntRegs:$dst), (and (i32 IntRegs:$src1), (xor (i32 IntRegs:$src2), (i32 IntRegs:$src3))))], "$src1 = $dst">, Requires<[HasV4T]>; // Rx|=and(Rs,#s10) let isExtendable = 1, opExtendable = 3, isExtentSigned = 1, opExtentBits = 10, validSubTargets = HasV4SubT, CextOpcode = "ORr_ANDr", InputType = "imm" in def ORr_ANDri2_V4 : MInst_acc<(outs IntRegs:$dst), (ins IntRegs:$src1, IntRegs: $src2, s10Ext:$src3), "$dst |= and($src2, #$src3)", [(set (i32 IntRegs:$dst), (or (i32 IntRegs:$src1), (and (i32 IntRegs:$src2), s10ExtPred:$src3)))], "$src1 = $dst">, Requires<[HasV4T]>, ImmRegRel; // Rx|=or(Rs,#s10) let isExtendable = 1, opExtendable = 3, isExtentSigned = 1, opExtentBits = 10, validSubTargets = HasV4SubT, CextOpcode = "ORr_ORr", InputType = "imm" in def ORr_ORri_V4 : MInst_acc<(outs IntRegs:$dst), (ins IntRegs:$src1, IntRegs: $src2, s10Ext:$src3), "$dst |= or($src2, #$src3)", [(set (i32 IntRegs:$dst), (or (i32 IntRegs:$src1), (and (i32 IntRegs:$src2), s10ExtPred:$src3)))], "$src1 = $dst">, Requires<[HasV4T]>, ImmRegRel; // Modulo wrap // Rd=modwrap(Rs,Rt) // Round // Rd=cround(Rs,#u5) // Rd=cround(Rs,Rt) // Rd=round(Rs,#u5)[:sat] // Rd=round(Rs,Rt)[:sat] // Vector reduce add unsigned halfwords // Rd=vraddh(Rss,Rtt) // Vector add bytes // Rdd=vaddb(Rss,Rtt) // Vector conditional negate // Rdd=vcnegh(Rss,Rt) // Rxx+=vrcnegh(Rss,Rt) // Vector maximum bytes // Rdd=vmaxb(Rtt,Rss) // Vector reduce maximum halfwords // Rxx=vrmaxh(Rss,Ru) // Rxx=vrmaxuh(Rss,Ru) // Vector reduce maximum words // Rxx=vrmaxuw(Rss,Ru) // Rxx=vrmaxw(Rss,Ru) // Vector minimum bytes // Rdd=vminb(Rtt,Rss) // Vector reduce minimum halfwords // Rxx=vrminh(Rss,Ru) // Rxx=vrminuh(Rss,Ru) // Vector reduce minimum words // Rxx=vrminuw(Rss,Ru) // Rxx=vrminw(Rss,Ru) // Vector subtract bytes // Rdd=vsubb(Rss,Rtt) //===----------------------------------------------------------------------===// // XTYPE/ALU - //===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===// // XTYPE/MPY + //===----------------------------------------------------------------------===// // Multiply and user lower result. // Rd=add(#u6,mpyi(Rs,#U6)) let isExtendable = 1, opExtendable = 1, isExtentSigned = 0, opExtentBits = 6, validSubTargets = HasV4SubT in def ADDi_MPYri_V4 : MInst<(outs IntRegs:$dst), (ins u6Ext:$src1, IntRegs:$src2, u6Imm:$src3), "$dst = add(#$src1, mpyi($src2, #$src3))", [(set (i32 IntRegs:$dst), (add (mul (i32 IntRegs:$src2), u6ImmPred:$src3), u6ExtPred:$src1))]>, Requires<[HasV4T]>; // Rd=add(##,mpyi(Rs,#U6)) def : Pat <(add (mul (i32 IntRegs:$src2), u6ImmPred:$src3), (HexagonCONST32 tglobaladdr:$src1)), (i32 (ADDi_MPYri_V4 tglobaladdr:$src1, IntRegs:$src2, u6ImmPred:$src3))>; // Rd=add(#u6,mpyi(Rs,Rt)) let isExtendable = 1, opExtendable = 1, isExtentSigned = 0, opExtentBits = 6, validSubTargets = HasV4SubT, InputType = "imm", CextOpcode = "ADD_MPY" in def ADDi_MPYrr_V4 : MInst<(outs IntRegs:$dst), (ins u6Ext:$src1, IntRegs:$src2, IntRegs:$src3), "$dst = add(#$src1, mpyi($src2, $src3))", [(set (i32 IntRegs:$dst), (add (mul (i32 IntRegs:$src2), (i32 IntRegs:$src3)), u6ExtPred:$src1))]>, Requires<[HasV4T]>, ImmRegRel; // Rd=add(##,mpyi(Rs,Rt)) def : Pat <(add (mul (i32 IntRegs:$src2), (i32 IntRegs:$src3)), (HexagonCONST32 tglobaladdr:$src1)), (i32 (ADDi_MPYrr_V4 tglobaladdr:$src1, IntRegs:$src2, IntRegs:$src3))>; // Rd=add(Ru,mpyi(#u6:2,Rs)) let validSubTargets = HasV4SubT in def ADDr_MPYir_V4 : MInst<(outs IntRegs:$dst), (ins IntRegs:$src1, u6Imm:$src2, IntRegs:$src3), "$dst = add($src1, mpyi(#$src2, $src3))", [(set (i32 IntRegs:$dst), (add (i32 IntRegs:$src1), (mul (i32 IntRegs:$src3), u6_2ImmPred:$src2)))]>, Requires<[HasV4T]>; // Rd=add(Ru,mpyi(Rs,#u6)) let isExtendable = 1, opExtendable = 3, isExtentSigned = 0, opExtentBits = 6, validSubTargets = HasV4SubT, InputType = "imm", CextOpcode = "ADD_MPY" in def ADDr_MPYri_V4 : MInst<(outs IntRegs:$dst), (ins IntRegs:$src1, IntRegs:$src2, u6Ext:$src3), "$dst = add($src1, mpyi($src2, #$src3))", [(set (i32 IntRegs:$dst), (add (i32 IntRegs:$src1), (mul (i32 IntRegs:$src2), u6ExtPred:$src3)))]>, Requires<[HasV4T]>, ImmRegRel; // Rx=add(Ru,mpyi(Rx,Rs)) let validSubTargets = HasV4SubT, InputType = "reg", CextOpcode = "ADD_MPY" in def ADDr_MPYrr_V4 : MInst_acc<(outs IntRegs:$dst), (ins IntRegs:$src1, IntRegs:$src2, IntRegs:$src3), "$dst = add($src1, mpyi($src2, $src3))", [(set (i32 IntRegs:$dst), (add (i32 IntRegs:$src1), (mul (i32 IntRegs:$src2), (i32 IntRegs:$src3))))], "$src2 = $dst">, Requires<[HasV4T]>, ImmRegRel; // Polynomial multiply words // Rdd=pmpyw(Rs,Rt) // Rxx^=pmpyw(Rs,Rt) // Vector reduce multiply word by signed half (32x16) // Rdd=vrmpyweh(Rss,Rtt)[:<<1] // Rdd=vrmpywoh(Rss,Rtt)[:<<1] // Rxx+=vrmpyweh(Rss,Rtt)[:<<1] // Rxx+=vrmpywoh(Rss,Rtt)[:<<1] // Multiply and use upper result // Rd=mpy(Rs,Rt.H):<<1:sat // Rd=mpy(Rs,Rt.L):<<1:sat // Rd=mpy(Rs,Rt):<<1 // Rd=mpy(Rs,Rt):<<1:sat // Rd=mpysu(Rs,Rt) // Rx+=mpy(Rs,Rt):<<1:sat // Rx-=mpy(Rs,Rt):<<1:sat // Vector multiply bytes // Rdd=vmpybsu(Rs,Rt) // Rdd=vmpybu(Rs,Rt) // Rxx+=vmpybsu(Rs,Rt) // Rxx+=vmpybu(Rs,Rt) // Vector polynomial multiply halfwords // Rdd=vpmpyh(Rs,Rt) // Rxx^=vpmpyh(Rs,Rt) //===----------------------------------------------------------------------===// // XTYPE/MPY - //===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===// // XTYPE/SHIFT + //===----------------------------------------------------------------------===// // Shift by immediate and accumulate. // Rx=add(#u8,asl(Rx,#U5)) let isExtendable = 1, opExtendable = 1, isExtentSigned = 0, opExtentBits = 8, validSubTargets = HasV4SubT in def ADDi_ASLri_V4 : MInst_acc<(outs IntRegs:$dst), (ins u8Ext:$src1, IntRegs:$src2, u5Imm:$src3), "$dst = add(#$src1, asl($src2, #$src3))", [(set (i32 IntRegs:$dst), (add (shl (i32 IntRegs:$src2), u5ImmPred:$src3), u8ExtPred:$src1))], "$src2 = $dst">, Requires<[HasV4T]>; // Rx=add(#u8,lsr(Rx,#U5)) let isExtendable = 1, opExtendable = 1, isExtentSigned = 0, opExtentBits = 8, validSubTargets = HasV4SubT in def ADDi_LSRri_V4 : MInst_acc<(outs IntRegs:$dst), (ins u8Ext:$src1, IntRegs:$src2, u5Imm:$src3), "$dst = add(#$src1, lsr($src2, #$src3))", [(set (i32 IntRegs:$dst), (add (srl (i32 IntRegs:$src2), u5ImmPred:$src3), u8ExtPred:$src1))], "$src2 = $dst">, Requires<[HasV4T]>; // Rx=sub(#u8,asl(Rx,#U5)) let isExtendable = 1, opExtendable = 1, isExtentSigned = 0, opExtentBits = 8, validSubTargets = HasV4SubT in def SUBi_ASLri_V4 : MInst_acc<(outs IntRegs:$dst), (ins u8Ext:$src1, IntRegs:$src2, u5Imm:$src3), "$dst = sub(#$src1, asl($src2, #$src3))", [(set (i32 IntRegs:$dst), (sub (shl (i32 IntRegs:$src2), u5ImmPred:$src3), u8ExtPred:$src1))], "$src2 = $dst">, Requires<[HasV4T]>; // Rx=sub(#u8,lsr(Rx,#U5)) let isExtendable = 1, opExtendable = 1, isExtentSigned = 0, opExtentBits = 8, validSubTargets = HasV4SubT in def SUBi_LSRri_V4 : MInst_acc<(outs IntRegs:$dst), (ins u8Ext:$src1, IntRegs:$src2, u5Imm:$src3), "$dst = sub(#$src1, lsr($src2, #$src3))", [(set (i32 IntRegs:$dst), (sub (srl (i32 IntRegs:$src2), u5ImmPred:$src3), u8ExtPred:$src1))], "$src2 = $dst">, Requires<[HasV4T]>; //Shift by immediate and logical. //Rx=and(#u8,asl(Rx,#U5)) let isExtendable = 1, opExtendable = 1, isExtentSigned = 0, opExtentBits = 8, validSubTargets = HasV4SubT in def ANDi_ASLri_V4 : MInst_acc<(outs IntRegs:$dst), (ins u8Ext:$src1, IntRegs:$src2, u5Imm:$src3), "$dst = and(#$src1, asl($src2, #$src3))", [(set (i32 IntRegs:$dst), (and (shl (i32 IntRegs:$src2), u5ImmPred:$src3), u8ExtPred:$src1))], "$src2 = $dst">, Requires<[HasV4T]>; //Rx=and(#u8,lsr(Rx,#U5)) let isExtendable = 1, opExtendable = 1, isExtentSigned = 0, opExtentBits = 8, validSubTargets = HasV4SubT in def ANDi_LSRri_V4 : MInst_acc<(outs IntRegs:$dst), (ins u8Ext:$src1, IntRegs:$src2, u5Imm:$src3), "$dst = and(#$src1, lsr($src2, #$src3))", [(set (i32 IntRegs:$dst), (and (srl (i32 IntRegs:$src2), u5ImmPred:$src3), u8ExtPred:$src1))], "$src2 = $dst">, Requires<[HasV4T]>; //Rx=or(#u8,asl(Rx,#U5)) let isExtendable = 1, opExtendable = 1, isExtentSigned = 0, opExtentBits = 8, AddedComplexity = 30, validSubTargets = HasV4SubT in def ORi_ASLri_V4 : MInst_acc<(outs IntRegs:$dst), (ins u8Ext:$src1, IntRegs:$src2, u5Imm:$src3), "$dst = or(#$src1, asl($src2, #$src3))", [(set (i32 IntRegs:$dst), (or (shl (i32 IntRegs:$src2), u5ImmPred:$src3), u8ExtPred:$src1))], "$src2 = $dst">, Requires<[HasV4T]>; //Rx=or(#u8,lsr(Rx,#U5)) let isExtendable = 1, opExtendable = 1, isExtentSigned = 0, opExtentBits = 8, AddedComplexity = 30, validSubTargets = HasV4SubT in def ORi_LSRri_V4 : MInst_acc<(outs IntRegs:$dst), (ins u8Ext:$src1, IntRegs:$src2, u5Imm:$src3), "$dst = or(#$src1, lsr($src2, #$src3))", [(set (i32 IntRegs:$dst), (or (srl (i32 IntRegs:$src2), u5ImmPred:$src3), u8ExtPred:$src1))], "$src2 = $dst">, Requires<[HasV4T]>; //Shift by register. //Rd=lsl(#s6,Rt) let validSubTargets = HasV4SubT in { def LSLi_V4 : MInst<(outs IntRegs:$dst), (ins s6Imm:$src1, IntRegs:$src2), "$dst = lsl(#$src1, $src2)", [(set (i32 IntRegs:$dst), (shl s6ImmPred:$src1, (i32 IntRegs:$src2)))]>, Requires<[HasV4T]>; //Shift by register and logical. //Rxx^=asl(Rss,Rt) def ASLd_rr_xor_V4 : MInst_acc<(outs DoubleRegs:$dst), (ins DoubleRegs:$src1, DoubleRegs:$src2, IntRegs:$src3), "$dst ^= asl($src2, $src3)", [(set (i64 DoubleRegs:$dst), (xor (i64 DoubleRegs:$src1), (shl (i64 DoubleRegs:$src2), (i32 IntRegs:$src3))))], "$src1 = $dst">, Requires<[HasV4T]>; //Rxx^=asr(Rss,Rt) def ASRd_rr_xor_V4 : MInst_acc<(outs DoubleRegs:$dst), (ins DoubleRegs:$src1, DoubleRegs:$src2, IntRegs:$src3), "$dst ^= asr($src2, $src3)", [(set (i64 DoubleRegs:$dst), (xor (i64 DoubleRegs:$src1), (sra (i64 DoubleRegs:$src2), (i32 IntRegs:$src3))))], "$src1 = $dst">, Requires<[HasV4T]>; //Rxx^=lsl(Rss,Rt) def LSLd_rr_xor_V4 : MInst_acc<(outs DoubleRegs:$dst), (ins DoubleRegs:$src1, DoubleRegs:$src2, IntRegs:$src3), "$dst ^= lsl($src2, $src3)", [(set (i64 DoubleRegs:$dst), (xor (i64 DoubleRegs:$src1), (shl (i64 DoubleRegs:$src2), (i32 IntRegs:$src3))))], "$src1 = $dst">, Requires<[HasV4T]>; //Rxx^=lsr(Rss,Rt) def LSRd_rr_xor_V4 : MInst_acc<(outs DoubleRegs:$dst), (ins DoubleRegs:$src1, DoubleRegs:$src2, IntRegs:$src3), "$dst ^= lsr($src2, $src3)", [(set (i64 DoubleRegs:$dst), (xor (i64 DoubleRegs:$src1), (srl (i64 DoubleRegs:$src2), (i32 IntRegs:$src3))))], "$src1 = $dst">, Requires<[HasV4T]>; } //===----------------------------------------------------------------------===// // XTYPE/SHIFT - //===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===// // MEMOP: Word, Half, Byte //===----------------------------------------------------------------------===// def MEMOPIMM : SDNodeXFormgetSExtValue(); return XformM5ToU5Imm(imm); }]>; def MEMOPIMM_HALF : SDNodeXFormgetSExtValue(); return XformM5ToU5Imm(imm); }]>; def MEMOPIMM_BYTE : SDNodeXFormgetSExtValue(); return XformM5ToU5Imm(imm); }]>; def SETMEMIMM : SDNodeXFormgetSExtValue(); return XformMskToBitPosU5Imm(imm); }]>; def CLRMEMIMM : SDNodeXFormgetSExtValue()); return XformMskToBitPosU5Imm(imm); }]>; def SETMEMIMM_SHORT : SDNodeXFormgetSExtValue(); return XformMskToBitPosU4Imm(imm); }]>; def CLRMEMIMM_SHORT : SDNodeXFormgetSExtValue()); return XformMskToBitPosU4Imm(imm); }]>; def SETMEMIMM_BYTE : SDNodeXFormgetSExtValue(); return XformMskToBitPosU3Imm(imm); }]>; def CLRMEMIMM_BYTE : SDNodeXFormgetSExtValue()); return XformMskToBitPosU3Imm(imm); }]>; //===----------------------------------------------------------------------===// // Template class for MemOp instructions with the register value. //===----------------------------------------------------------------------===// class MemOp_rr_base opcBits, Operand ImmOp, string memOp, bits<2> memOpBits> : MEMInst_V4<(outs), (ins IntRegs:$base, ImmOp:$offset, IntRegs:$delta), opc#"($base+#$offset)"#memOp#"$delta", []>, Requires<[HasV4T, UseMEMOP]> { bits<5> base; bits<5> delta; bits<32> offset; bits<6> offsetBits; // memb - u6:0 , memh - u6:1, memw - u6:2 let offsetBits = !if (!eq(opcBits, 0b00), offset{5-0}, !if (!eq(opcBits, 0b01), offset{6-1}, !if (!eq(opcBits, 0b10), offset{7-2},0))); let IClass = 0b0011; let Inst{27-24} = 0b1110; let Inst{22-21} = opcBits; let Inst{20-16} = base; let Inst{13} = 0b0; let Inst{12-7} = offsetBits; let Inst{6-5} = memOpBits; let Inst{4-0} = delta; } //===----------------------------------------------------------------------===// // Template class for MemOp instructions with the immediate value. //===----------------------------------------------------------------------===// class MemOp_ri_base opcBits, Operand ImmOp, string memOp, bits<2> memOpBits> : MEMInst_V4 <(outs), (ins IntRegs:$base, ImmOp:$offset, u5Imm:$delta), opc#"($base+#$offset)"#memOp#"#$delta" #!if(memOpBits{1},")", ""), // clrbit, setbit - include ')' []>, Requires<[HasV4T, UseMEMOP]> { bits<5> base; bits<5> delta; bits<32> offset; bits<6> offsetBits; // memb - u6:0 , memh - u6:1, memw - u6:2 let offsetBits = !if (!eq(opcBits, 0b00), offset{5-0}, !if (!eq(opcBits, 0b01), offset{6-1}, !if (!eq(opcBits, 0b10), offset{7-2},0))); let IClass = 0b0011; let Inst{27-24} = 0b1111; let Inst{22-21} = opcBits; let Inst{20-16} = base; let Inst{13} = 0b0; let Inst{12-7} = offsetBits; let Inst{6-5} = memOpBits; let Inst{4-0} = delta; } // multiclass to define MemOp instructions with register operand. multiclass MemOp_rr opcBits, Operand ImmOp> { def _ADD#NAME#_V4 : MemOp_rr_base ; def _SETBIT#NAME#_V4 : MemOp_ri_base; } multiclass MemOp_base opcBits, Operand ImmOp> { defm r : MemOp_rr ; defm i : MemOp_ri ; } // Define MemOp instructions. let isExtendable = 1, opExtendable = 1, isExtentSigned = 0, validSubTargets =HasV4SubT in { let opExtentBits = 6, accessSize = ByteAccess in defm MemOPb : MemOp_base <"memb", 0b00, u6_0Ext>; let opExtentBits = 7, accessSize = HalfWordAccess in defm MemOPh : MemOp_base <"memh", 0b01, u6_1Ext>; let opExtentBits = 8, accessSize = WordAccess in defm MemOPw : MemOp_base <"memw", 0b10, u6_2Ext>; } //===----------------------------------------------------------------------===// // Multiclass to define 'Def Pats' for ALU operations on the memory // Here value used for the ALU operation is an immediate value. // mem[bh](Rs+#0) += #U5 // mem[bh](Rs+#u6) += #U5 //===----------------------------------------------------------------------===// multiclass MemOpi_u5Pats { let AddedComplexity = 180 in def : Pat < (stOp (OpNode (ldOp IntRegs:$addr), u5ImmPred:$addend), IntRegs:$addr), (MI IntRegs:$addr, #0, u5ImmPred:$addend )>; let AddedComplexity = 190 in def : Pat <(stOp (OpNode (ldOp (add IntRegs:$base, ExtPred:$offset)), u5ImmPred:$addend), (add IntRegs:$base, ExtPred:$offset)), (MI IntRegs:$base, ExtPred:$offset, u5ImmPred:$addend)>; } multiclass MemOpi_u5ALUOp { defm : MemOpi_u5Pats; defm : MemOpi_u5Pats; } multiclass MemOpi_u5ExtType { // Half Word defm : MemOpi_u5ALUOp ; // Byte defm : MemOpi_u5ALUOp ; } let Predicates = [HasV4T, UseMEMOP] in { defm : MemOpi_u5ExtType; // zero extend defm : MemOpi_u5ExtType; // sign extend defm : MemOpi_u5ExtType; // any extend // Word defm : MemOpi_u5ALUOp ; } //===----------------------------------------------------------------------===// // multiclass to define 'Def Pats' for ALU operations on the memory. // Here value used for the ALU operation is a negative value. // mem[bh](Rs+#0) += #m5 // mem[bh](Rs+#u6) += #m5 //===----------------------------------------------------------------------===// multiclass MemOpi_m5Pats { let AddedComplexity = 190 in def : Pat <(stOp (add (ldOp IntRegs:$addr), immPred:$subend), IntRegs:$addr), (MI IntRegs:$addr, #0, (xformFunc immPred:$subend) )>; let AddedComplexity = 195 in def : Pat<(stOp (add (ldOp (add IntRegs:$base, extPred:$offset)), immPred:$subend), (add IntRegs:$base, extPred:$offset)), (MI IntRegs:$base, extPred:$offset, (xformFunc immPred:$subend))>; } multiclass MemOpi_m5ExtType { // Half Word defm : MemOpi_m5Pats ; // Byte defm : MemOpi_m5Pats ; } let Predicates = [HasV4T, UseMEMOP] in { defm : MemOpi_m5ExtType; // zero extend defm : MemOpi_m5ExtType; // sign extend defm : MemOpi_m5ExtType; // any extend // Word defm : MemOpi_m5Pats ; } //===----------------------------------------------------------------------===// // Multiclass to define 'def Pats' for bit operations on the memory. // mem[bhw](Rs+#0) = [clrbit|setbit](#U5) // mem[bhw](Rs+#u6) = [clrbit|setbit](#U5) //===----------------------------------------------------------------------===// multiclass MemOpi_bitPats { // mem[bhw](Rs+#u6:[012]) = [clrbit|setbit](#U5) let AddedComplexity = 250 in def : Pat<(stOp (OpNode (ldOp (add IntRegs:$base, extPred:$offset)), immPred:$bitend), (add IntRegs:$base, extPred:$offset)), (MI IntRegs:$base, extPred:$offset, (xformFunc immPred:$bitend))>; // mem[bhw](Rs+#0) = [clrbit|setbit](#U5) let AddedComplexity = 225 in def : Pat <(stOp (OpNode (ldOp (addrPred IntRegs:$addr, extPred:$offset)), immPred:$bitend), (addrPred (i32 IntRegs:$addr), extPred:$offset)), (MI IntRegs:$addr, extPred:$offset, (xformFunc immPred:$bitend))>; } multiclass MemOpi_bitExtType { // Byte - clrbit defm : MemOpi_bitPats; // Byte - setbit defm : MemOpi_bitPats; // Half Word - clrbit defm : MemOpi_bitPats; // Half Word - setbit defm : MemOpi_bitPats; } let Predicates = [HasV4T, UseMEMOP] in { // mem[bh](Rs+#0) = [clrbit|setbit](#U5) // mem[bh](Rs+#u6:[01]) = [clrbit|setbit](#U5) defm : MemOpi_bitExtType; // zero extend defm : MemOpi_bitExtType; // sign extend defm : MemOpi_bitExtType; // any extend // memw(Rs+#0) = [clrbit|setbit](#U5) // memw(Rs+#u6:2) = [clrbit|setbit](#U5) defm : MemOpi_bitPats; defm : MemOpi_bitPats; } //===----------------------------------------------------------------------===// // Multiclass to define 'def Pats' for ALU operations on the memory // where addend is a register. // mem[bhw](Rs+#0) [+-&|]= Rt // mem[bhw](Rs+#U6:[012]) [+-&|]= Rt //===----------------------------------------------------------------------===// multiclass MemOpr_Pats { let AddedComplexity = 141 in // mem[bhw](Rs+#0) [+-&|]= Rt def : Pat <(stOp (OpNode (ldOp (addrPred IntRegs:$addr, extPred:$offset)), (i32 IntRegs:$addend)), (addrPred (i32 IntRegs:$addr), extPred:$offset)), (MI IntRegs:$addr, extPred:$offset, (i32 IntRegs:$addend) )>; // mem[bhw](Rs+#U6:[012]) [+-&|]= Rt let AddedComplexity = 150 in def : Pat <(stOp (OpNode (ldOp (add IntRegs:$base, extPred:$offset)), (i32 IntRegs:$orend)), (add IntRegs:$base, extPred:$offset)), (MI IntRegs:$base, extPred:$offset, (i32 IntRegs:$orend) )>; } multiclass MemOPr_ALUOp { defm : MemOpr_Pats ; defm : MemOpr_Pats ; defm : MemOpr_Pats ; defm : MemOpr_Pats ; } multiclass MemOPr_ExtType { // Half Word defm : MemOPr_ALUOp ; // Byte defm : MemOPr_ALUOp ; } // Define 'def Pats' for MemOps with register addend. let Predicates = [HasV4T, UseMEMOP] in { // Byte, Half Word defm : MemOPr_ExtType; // zero extend defm : MemOPr_ExtType; // sign extend defm : MemOPr_ExtType; // any extend // Word defm : MemOPr_ALUOp ; } //===----------------------------------------------------------------------===// // XTYPE/PRED + //===----------------------------------------------------------------------===// // Hexagon V4 only supports these flavors of byte/half compare instructions: // EQ/GT/GTU. Other flavors like GE/GEU/LT/LTU/LE/LEU are not supported by // hardware. However, compiler can still implement these patterns through // appropriate patterns combinations based on current implemented patterns. // The implemented patterns are: EQ/GT/GTU. // Missing patterns are: GE/GEU/LT/LTU/LE/LEU. // Following instruction is not being extended as it results into the // incorrect code for negative numbers. // Pd=cmpb.eq(Rs,#u8) let isCompare = 1, isExtendable = 1, opExtendable = 2, hasSideEffects = 0, validSubTargets = HasV4SubT in class CMP_NOT_REG_IMM op, Operand ImmOp, list Pattern> : ALU32Inst <(outs PredRegs:$dst), (ins IntRegs:$src1, ImmOp:$src2), "$dst = !cmp."#OpName#"($src1, #$src2)", Pattern, "", ALU32_2op_tc_2early_SLOT0123> { bits<2> dst; bits<5> src1; bits<10> src2; let IClass = 0b0111; let Inst{27-24} = 0b0101; let Inst{23-22} = op; let Inst{20-16} = src1; let Inst{21} = !if (!eq(OpName, "gtu"), 0b0, src2{9}); let Inst{13-5} = src2{8-0}; let Inst{4-2} = 0b100; let Inst{1-0} = dst; } let opExtentBits = 10, isExtentSigned = 1 in { def C4_cmpneqi : CMP_NOT_REG_IMM <"eq", 0b00, s10Ext, [(set (i1 PredRegs:$dst), (setne (i32 IntRegs:$src1), s10ExtPred:$src2))]>; def C4_cmpltei : CMP_NOT_REG_IMM <"gt", 0b01, s10Ext, [(set (i1 PredRegs:$dst), (not (setgt (i32 IntRegs:$src1), s10ExtPred:$src2)))]>; } let opExtentBits = 9 in def C4_cmplteui : CMP_NOT_REG_IMM <"gtu", 0b10, u9Ext, [(set (i1 PredRegs:$dst), (not (setugt (i32 IntRegs:$src1), u9ExtPred:$src2)))]>; // p=!cmp.eq(r1,r2) let isCompare = 1, validSubTargets = HasV4SubT in def CMPnotEQ_rr : ALU32_rr<(outs PredRegs:$dst), (ins IntRegs:$src1, IntRegs:$src2), "$dst = !cmp.eq($src1, $src2)", [(set (i1 PredRegs:$dst), (setne (i32 IntRegs:$src1), (i32 IntRegs:$src2)))]>, Requires<[HasV4T]>; // p=!cmp.gt(r1,r2) let isCompare = 1, validSubTargets = HasV4SubT in def CMPnotGT_rr : ALU32_rr<(outs PredRegs:$dst), (ins IntRegs:$src1, IntRegs:$src2), "$dst = !cmp.gt($src1, $src2)", [(set (i1 PredRegs:$dst), (not (setgt (i32 IntRegs:$src1), (i32 IntRegs:$src2))))]>, Requires<[HasV4T]>; // p=!cmp.gtu(r1,r2) let isCompare = 1, validSubTargets = HasV4SubT in def CMPnotGTU_rr : ALU32_rr<(outs PredRegs:$dst), (ins IntRegs:$src1, IntRegs:$src2), "$dst = !cmp.gtu($src1, $src2)", [(set (i1 PredRegs:$dst), (not (setugt (i32 IntRegs:$src1), (i32 IntRegs:$src2))))]>, Requires<[HasV4T]>; let isCompare = 1, validSubTargets = HasV4SubT in def CMPbEQri_V4 : MInst<(outs PredRegs:$dst), (ins IntRegs:$src1, u8Imm:$src2), "$dst = cmpb.eq($src1, #$src2)", [(set (i1 PredRegs:$dst), (seteq (and (i32 IntRegs:$src1), 255), u8ImmPred:$src2))]>, Requires<[HasV4T]>; def : Pat <(brcond (i1 (setne (and (i32 IntRegs:$src1), 255), u8ImmPred:$src2)), bb:$offset), (J2_jumpf (CMPbEQri_V4 (i32 IntRegs:$src1), u8ImmPred:$src2), bb:$offset)>, Requires<[HasV4T]>; // Pd=cmpb.eq(Rs,Rt) let isCompare = 1, validSubTargets = HasV4SubT in def CMPbEQrr_ubub_V4 : MInst<(outs PredRegs:$dst), (ins IntRegs:$src1, IntRegs:$src2), "$dst = cmpb.eq($src1, $src2)", [(set (i1 PredRegs:$dst), (seteq (and (xor (i32 IntRegs:$src1), (i32 IntRegs:$src2)), 255), 0))]>, Requires<[HasV4T]>; // Pd=cmpb.eq(Rs,Rt) let isCompare = 1, validSubTargets = HasV4SubT in def CMPbEQrr_sbsb_V4 : MInst<(outs PredRegs:$dst), (ins IntRegs:$src1, IntRegs:$src2), "$dst = cmpb.eq($src1, $src2)", [(set (i1 PredRegs:$dst), (seteq (shl (i32 IntRegs:$src1), (i32 24)), (shl (i32 IntRegs:$src2), (i32 24))))]>, Requires<[HasV4T]>; // Pd=cmpb.gt(Rs,Rt) let isCompare = 1, validSubTargets = HasV4SubT in def CMPbGTrr_V4 : MInst<(outs PredRegs:$dst), (ins IntRegs:$src1, IntRegs:$src2), "$dst = cmpb.gt($src1, $src2)", [(set (i1 PredRegs:$dst), (setgt (shl (i32 IntRegs:$src1), (i32 24)), (shl (i32 IntRegs:$src2), (i32 24))))]>, Requires<[HasV4T]>; // Pd=cmpb.gtu(Rs,#u7) let isExtendable = 1, opExtendable = 2, isExtentSigned = 0, opExtentBits = 7, isCompare = 1, validSubTargets = HasV4SubT, CextOpcode = "CMPbGTU", InputType = "imm" in def CMPbGTUri_V4 : MInst<(outs PredRegs:$dst), (ins IntRegs:$src1, u7Ext:$src2), "$dst = cmpb.gtu($src1, #$src2)", [(set (i1 PredRegs:$dst), (setugt (and (i32 IntRegs:$src1), 255), u7ExtPred:$src2))]>, Requires<[HasV4T]>, ImmRegRel; // SDNode for converting immediate C to C-1. def DEC_CONST_BYTE : SDNodeXFormgetSExtValue(); return XformU7ToU7M1Imm(imm); }]>; // For the sequence // zext( seteq ( and(Rs, 255), u8)) // Generate // Pd=cmpb.eq(Rs, #u8) // if (Pd.new) Rd=#1 // if (!Pd.new) Rd=#0 def : Pat <(i32 (zext (i1 (seteq (i32 (and (i32 IntRegs:$Rs), 255)), u8ExtPred:$u8)))), (i32 (TFR_condset_ii (i1 (CMPbEQri_V4 (i32 IntRegs:$Rs), (u8ExtPred:$u8))), 1, 0))>, Requires<[HasV4T]>; // For the sequence // zext( setne ( and(Rs, 255), u8)) // Generate // Pd=cmpb.eq(Rs, #u8) // if (Pd.new) Rd=#0 // if (!Pd.new) Rd=#1 def : Pat <(i32 (zext (i1 (setne (i32 (and (i32 IntRegs:$Rs), 255)), u8ExtPred:$u8)))), (i32 (TFR_condset_ii (i1 (CMPbEQri_V4 (i32 IntRegs:$Rs), (u8ExtPred:$u8))), 0, 1))>, Requires<[HasV4T]>; // For the sequence // zext( seteq (Rs, and(Rt, 255))) // Generate // Pd=cmpb.eq(Rs, Rt) // if (Pd.new) Rd=#1 // if (!Pd.new) Rd=#0 def : Pat <(i32 (zext (i1 (seteq (i32 IntRegs:$Rt), (i32 (and (i32 IntRegs:$Rs), 255)))))), (i32 (TFR_condset_ii (i1 (CMPbEQrr_ubub_V4 (i32 IntRegs:$Rs), (i32 IntRegs:$Rt))), 1, 0))>, Requires<[HasV4T]>; // For the sequence // zext( setne (Rs, and(Rt, 255))) // Generate // Pd=cmpb.eq(Rs, Rt) // if (Pd.new) Rd=#0 // if (!Pd.new) Rd=#1 def : Pat <(i32 (zext (i1 (setne (i32 IntRegs:$Rt), (i32 (and (i32 IntRegs:$Rs), 255)))))), (i32 (TFR_condset_ii (i1 (CMPbEQrr_ubub_V4 (i32 IntRegs:$Rs), (i32 IntRegs:$Rt))), 0, 1))>, Requires<[HasV4T]>; // For the sequence // zext( setugt ( and(Rs, 255), u8)) // Generate // Pd=cmpb.gtu(Rs, #u8) // if (Pd.new) Rd=#1 // if (!Pd.new) Rd=#0 def : Pat <(i32 (zext (i1 (setugt (i32 (and (i32 IntRegs:$Rs), 255)), u8ExtPred:$u8)))), (i32 (TFR_condset_ii (i1 (CMPbGTUri_V4 (i32 IntRegs:$Rs), (u8ExtPred:$u8))), 1, 0))>, Requires<[HasV4T]>; // For the sequence // zext( setugt ( and(Rs, 254), u8)) // Generate // Pd=cmpb.gtu(Rs, #u8) // if (Pd.new) Rd=#1 // if (!Pd.new) Rd=#0 def : Pat <(i32 (zext (i1 (setugt (i32 (and (i32 IntRegs:$Rs), 254)), u8ExtPred:$u8)))), (i32 (TFR_condset_ii (i1 (CMPbGTUri_V4 (i32 IntRegs:$Rs), (u8ExtPred:$u8))), 1, 0))>, Requires<[HasV4T]>; // For the sequence // zext( setult ( Rs, Rt)) // Generate // Pd=cmp.ltu(Rs, Rt) // if (Pd.new) Rd=#1 // if (!Pd.new) Rd=#0 // cmp.ltu(Rs, Rt) -> cmp.gtu(Rt, Rs) def : Pat <(i32 (zext (i1 (setult (i32 IntRegs:$Rs), (i32 IntRegs:$Rt))))), (i32 (TFR_condset_ii (i1 (C2_cmpgtu (i32 IntRegs:$Rt), (i32 IntRegs:$Rs))), 1, 0))>, Requires<[HasV4T]>; // For the sequence // zext( setlt ( Rs, Rt)) // Generate // Pd=cmp.lt(Rs, Rt) // if (Pd.new) Rd=#1 // if (!Pd.new) Rd=#0 // cmp.lt(Rs, Rt) -> cmp.gt(Rt, Rs) def : Pat <(i32 (zext (i1 (setlt (i32 IntRegs:$Rs), (i32 IntRegs:$Rt))))), (i32 (TFR_condset_ii (i1 (C2_cmpgt (i32 IntRegs:$Rt), (i32 IntRegs:$Rs))), 1, 0))>, Requires<[HasV4T]>; // For the sequence // zext( setugt ( Rs, Rt)) // Generate // Pd=cmp.gtu(Rs, Rt) // if (Pd.new) Rd=#1 // if (!Pd.new) Rd=#0 def : Pat <(i32 (zext (i1 (setugt (i32 IntRegs:$Rs), (i32 IntRegs:$Rt))))), (i32 (TFR_condset_ii (i1 (C2_cmpgtu (i32 IntRegs:$Rs), (i32 IntRegs:$Rt))), 1, 0))>, Requires<[HasV4T]>; // This pattern interefers with coremark performance, not implementing at this // time. // For the sequence // zext( setgt ( Rs, Rt)) // Generate // Pd=cmp.gt(Rs, Rt) // if (Pd.new) Rd=#1 // if (!Pd.new) Rd=#0 // For the sequence // zext( setuge ( Rs, Rt)) // Generate // Pd=cmp.ltu(Rs, Rt) // if (Pd.new) Rd=#0 // if (!Pd.new) Rd=#1 // cmp.ltu(Rs, Rt) -> cmp.gtu(Rt, Rs) def : Pat <(i32 (zext (i1 (setuge (i32 IntRegs:$Rs), (i32 IntRegs:$Rt))))), (i32 (TFR_condset_ii (i1 (C2_cmpgtu (i32 IntRegs:$Rt), (i32 IntRegs:$Rs))), 0, 1))>, Requires<[HasV4T]>; // For the sequence // zext( setge ( Rs, Rt)) // Generate // Pd=cmp.lt(Rs, Rt) // if (Pd.new) Rd=#0 // if (!Pd.new) Rd=#1 // cmp.lt(Rs, Rt) -> cmp.gt(Rt, Rs) def : Pat <(i32 (zext (i1 (setge (i32 IntRegs:$Rs), (i32 IntRegs:$Rt))))), (i32 (TFR_condset_ii (i1 (C2_cmpgt (i32 IntRegs:$Rt), (i32 IntRegs:$Rs))), 0, 1))>, Requires<[HasV4T]>; // For the sequence // zext( setule ( Rs, Rt)) // Generate // Pd=cmp.gtu(Rs, Rt) // if (Pd.new) Rd=#0 // if (!Pd.new) Rd=#1 def : Pat <(i32 (zext (i1 (setule (i32 IntRegs:$Rs), (i32 IntRegs:$Rt))))), (i32 (TFR_condset_ii (i1 (C2_cmpgtu (i32 IntRegs:$Rs), (i32 IntRegs:$Rt))), 0, 1))>, Requires<[HasV4T]>; // For the sequence // zext( setle ( Rs, Rt)) // Generate // Pd=cmp.gt(Rs, Rt) // if (Pd.new) Rd=#0 // if (!Pd.new) Rd=#1 def : Pat <(i32 (zext (i1 (setle (i32 IntRegs:$Rs), (i32 IntRegs:$Rt))))), (i32 (TFR_condset_ii (i1 (C2_cmpgt (i32 IntRegs:$Rs), (i32 IntRegs:$Rt))), 0, 1))>, Requires<[HasV4T]>; // For the sequence // zext( setult ( and(Rs, 255), u8)) // Use the isdigit transformation below // Generate code of the form 'mux_ii(cmpbgtu(Rdd, C-1),0,1)' // for C code of the form r = ((c>='0') & (c<='9')) ? 1 : 0;. // The isdigit transformation relies on two 'clever' aspects: // 1) The data type is unsigned which allows us to eliminate a zero test after // biasing the expression by 48. We are depending on the representation of // the unsigned types, and semantics. // 2) The front end has converted <= 9 into < 10 on entry to LLVM // // For the C code: // retval = ((c>='0') & (c<='9')) ? 1 : 0; // The code is transformed upstream of llvm into // retval = (c-48) < 10 ? 1 : 0; let AddedComplexity = 139 in def : Pat <(i32 (zext (i1 (setult (i32 (and (i32 IntRegs:$src1), 255)), u7StrictPosImmPred:$src2)))), (i32 (C2_muxii (i1 (CMPbGTUri_V4 (i32 IntRegs:$src1), (DEC_CONST_BYTE u7StrictPosImmPred:$src2))), 0, 1))>, Requires<[HasV4T]>; // Pd=cmpb.gtu(Rs,Rt) let isCompare = 1, validSubTargets = HasV4SubT, CextOpcode = "CMPbGTU", InputType = "reg" in def CMPbGTUrr_V4 : MInst<(outs PredRegs:$dst), (ins IntRegs:$src1, IntRegs:$src2), "$dst = cmpb.gtu($src1, $src2)", [(set (i1 PredRegs:$dst), (setugt (and (i32 IntRegs:$src1), 255), (and (i32 IntRegs:$src2), 255)))]>, Requires<[HasV4T]>, ImmRegRel; // Following instruction is not being extended as it results into the incorrect // code for negative numbers. // Signed half compare(.eq) ri. // Pd=cmph.eq(Rs,#s8) let isCompare = 1, validSubTargets = HasV4SubT in def CMPhEQri_V4 : MInst<(outs PredRegs:$dst), (ins IntRegs:$src1, s8Imm:$src2), "$dst = cmph.eq($src1, #$src2)", [(set (i1 PredRegs:$dst), (seteq (and (i32 IntRegs:$src1), 65535), s8ImmPred:$src2))]>, Requires<[HasV4T]>; // Signed half compare(.eq) rr. // Case 1: xor + and, then compare: // r0=xor(r0,r1) // r0=and(r0,#0xffff) // p0=cmp.eq(r0,#0) // Pd=cmph.eq(Rs,Rt) let isCompare = 1, validSubTargets = HasV4SubT in def CMPhEQrr_xor_V4 : MInst<(outs PredRegs:$dst), (ins IntRegs:$src1, IntRegs:$src2), "$dst = cmph.eq($src1, $src2)", [(set (i1 PredRegs:$dst), (seteq (and (xor (i32 IntRegs:$src1), (i32 IntRegs:$src2)), 65535), 0))]>, Requires<[HasV4T]>; // Signed half compare(.eq) rr. // Case 2: shift left 16 bits then compare: // r0=asl(r0,16) // r1=asl(r1,16) // p0=cmp.eq(r0,r1) // Pd=cmph.eq(Rs,Rt) let isCompare = 1, validSubTargets = HasV4SubT in def CMPhEQrr_shl_V4 : MInst<(outs PredRegs:$dst), (ins IntRegs:$src1, IntRegs:$src2), "$dst = cmph.eq($src1, $src2)", [(set (i1 PredRegs:$dst), (seteq (shl (i32 IntRegs:$src1), (i32 16)), (shl (i32 IntRegs:$src2), (i32 16))))]>, Requires<[HasV4T]>; /* Incorrect Pattern -- immediate should be right shifted before being used in the cmph.gt instruction. // Signed half compare(.gt) ri. // Pd=cmph.gt(Rs,#s8) let isExtendable = 1, opExtendable = 2, isExtentSigned = 1, opExtentBits = 8, isCompare = 1, validSubTargets = HasV4SubT in def CMPhGTri_V4 : MInst<(outs PredRegs:$dst), (ins IntRegs:$src1, s8Ext:$src2), "$dst = cmph.gt($src1, #$src2)", [(set (i1 PredRegs:$dst), (setgt (shl (i32 IntRegs:$src1), (i32 16)), s8ExtPred:$src2))]>, Requires<[HasV4T]>; */ // Signed half compare(.gt) rr. // Pd=cmph.gt(Rs,Rt) let isCompare = 1, validSubTargets = HasV4SubT in def CMPhGTrr_shl_V4 : MInst<(outs PredRegs:$dst), (ins IntRegs:$src1, IntRegs:$src2), "$dst = cmph.gt($src1, $src2)", [(set (i1 PredRegs:$dst), (setgt (shl (i32 IntRegs:$src1), (i32 16)), (shl (i32 IntRegs:$src2), (i32 16))))]>, Requires<[HasV4T]>; // Unsigned half compare rr (.gtu). // Pd=cmph.gtu(Rs,Rt) let isCompare = 1, validSubTargets = HasV4SubT, CextOpcode = "CMPhGTU", InputType = "reg" in def CMPhGTUrr_V4 : MInst<(outs PredRegs:$dst), (ins IntRegs:$src1, IntRegs:$src2), "$dst = cmph.gtu($src1, $src2)", [(set (i1 PredRegs:$dst), (setugt (and (i32 IntRegs:$src1), 65535), (and (i32 IntRegs:$src2), 65535)))]>, Requires<[HasV4T]>, ImmRegRel; // Unsigned half compare ri (.gtu). // Pd=cmph.gtu(Rs,#u7) let isExtendable = 1, opExtendable = 2, isExtentSigned = 0, opExtentBits = 7, isCompare = 1, validSubTargets = HasV4SubT, CextOpcode = "CMPhGTU", InputType = "imm" in def CMPhGTUri_V4 : MInst<(outs PredRegs:$dst), (ins IntRegs:$src1, u7Ext:$src2), "$dst = cmph.gtu($src1, #$src2)", [(set (i1 PredRegs:$dst), (setugt (and (i32 IntRegs:$src1), 65535), u7ExtPred:$src2))]>, Requires<[HasV4T]>, ImmRegRel; let validSubTargets = HasV4SubT in def NTSTBIT_rr : SInst<(outs PredRegs:$dst), (ins IntRegs:$src1, IntRegs:$src2), "$dst = !tstbit($src1, $src2)", [(set (i1 PredRegs:$dst), (seteq (and (shl 1, (i32 IntRegs:$src2)), (i32 IntRegs:$src1)), 0))]>, Requires<[HasV4T]>; let validSubTargets = HasV4SubT in def NTSTBIT_ri : SInst<(outs PredRegs:$dst), (ins IntRegs:$src1, u5Imm:$src2), "$dst = !tstbit($src1, $src2)", [(set (i1 PredRegs:$dst), (seteq (and (shl 1, u5ImmPred:$src2), (i32 IntRegs:$src1)), 0))]>, Requires<[HasV4T]>; //===----------------------------------------------------------------------===// // XTYPE/PRED - //===----------------------------------------------------------------------===// //Deallocate frame and return. // dealloc_return let isReturn = 1, isTerminator = 1, isBarrier = 1, isPredicable = 1, Defs = [R29, R30, R31, PC], Uses = [R30], hasSideEffects = 0 in { let validSubTargets = HasV4SubT in def DEALLOC_RET_V4 : LD0Inst<(outs), (ins), "dealloc_return", []>, Requires<[HasV4T]>; } // Restore registers and dealloc return function call. let isCall = 1, isBarrier = 1, isReturn = 1, isTerminator = 1, Defs = [R29, R30, R31, PC] in { let validSubTargets = HasV4SubT in def RESTORE_DEALLOC_RET_JMP_V4 : JInst<(outs), (ins calltarget:$dst), "jump $dst", []>, Requires<[HasV4T]>; } // Restore registers and dealloc frame before a tail call. let isCall = 1, isBarrier = 1, Defs = [R29, R30, R31, PC] in { let validSubTargets = HasV4SubT in def RESTORE_DEALLOC_BEFORE_TAILCALL_V4 : JInst<(outs), (ins calltarget:$dst), "call $dst", []>, Requires<[HasV4T]>; } // Save registers function call. let isCall = 1, isBarrier = 1, Uses = [R29, R31] in { def SAVE_REGISTERS_CALL_V4 : JInst<(outs), (ins calltarget:$dst), "call $dst // Save_calle_saved_registers", []>, Requires<[HasV4T]>; } // if (Ps) dealloc_return let isReturn = 1, isTerminator = 1, Defs = [R29, R30, R31, PC], Uses = [R30], hasSideEffects = 0, isPredicated = 1 in { let validSubTargets = HasV4SubT in def DEALLOC_RET_cPt_V4 : LD0Inst<(outs), (ins PredRegs:$src1), "if ($src1) dealloc_return", []>, Requires<[HasV4T]>; } // if (!Ps) dealloc_return let isReturn = 1, isTerminator = 1, Defs = [R29, R30, R31, PC], Uses = [R30], hasSideEffects = 0, isPredicated = 1, isPredicatedFalse = 1 in { let validSubTargets = HasV4SubT in def DEALLOC_RET_cNotPt_V4 : LD0Inst<(outs), (ins PredRegs:$src1), "if (!$src1) dealloc_return", []>, Requires<[HasV4T]>; } // if (Ps.new) dealloc_return:nt let isReturn = 1, isTerminator = 1, Defs = [R29, R30, R31, PC], Uses = [R30], hasSideEffects = 0, isPredicated = 1 in { let validSubTargets = HasV4SubT in def DEALLOC_RET_cdnPnt_V4 : LD0Inst<(outs), (ins PredRegs:$src1), "if ($src1.new) dealloc_return:nt", []>, Requires<[HasV4T]>; } // if (!Ps.new) dealloc_return:nt let isReturn = 1, isTerminator = 1, Defs = [R29, R30, R31, PC], Uses = [R30], hasSideEffects = 0, isPredicated = 1, isPredicatedFalse = 1 in { let validSubTargets = HasV4SubT in def DEALLOC_RET_cNotdnPnt_V4 : LD0Inst<(outs), (ins PredRegs:$src1), "if (!$src1.new) dealloc_return:nt", []>, Requires<[HasV4T]>; } // if (Ps.new) dealloc_return:t let isReturn = 1, isTerminator = 1, Defs = [R29, R30, R31, PC], Uses = [R30], hasSideEffects = 0, isPredicated = 1 in { let validSubTargets = HasV4SubT in def DEALLOC_RET_cdnPt_V4 : LD0Inst<(outs), (ins PredRegs:$src1), "if ($src1.new) dealloc_return:t", []>, Requires<[HasV4T]>; } // if (!Ps.new) dealloc_return:nt let isReturn = 1, isTerminator = 1, Defs = [R29, R30, R31, PC], Uses = [R30], hasSideEffects = 0, isPredicated = 1, isPredicatedFalse = 1 in { let validSubTargets = HasV4SubT in def DEALLOC_RET_cNotdnPt_V4 : LD0Inst<(outs), (ins PredRegs:$src1), "if (!$src1.new) dealloc_return:t", []>, Requires<[HasV4T]>; } // Load/Store with absolute addressing mode // memw(#u6)=Rt multiclass ST_Abs_Predbase { let isPredicatedNew = isPredNew in def NAME#_V4 : STInst2<(outs), (ins PredRegs:$src1, u0AlwaysExt:$absaddr, RC: $src2), !if(isNot, "if (!$src1", "if ($src1")#!if(isPredNew, ".new) ", ") ")#mnemonic#"(##$absaddr) = $src2", []>, Requires<[HasV4T]>; } multiclass ST_Abs_Pred { let isPredicatedFalse = PredNot in { defm _c#NAME : ST_Abs_Predbase; // Predicate new defm _cdn#NAME : ST_Abs_Predbase; } } let isNVStorable = 1, isExtended = 1, hasSideEffects = 0 in multiclass ST_Abs { let CextOpcode = CextOp, BaseOpcode = CextOp#_abs in { let opExtendable = 0, isPredicable = 1 in def NAME#_V4 : STInst2<(outs), (ins u0AlwaysExt:$absaddr, RC:$src), mnemonic#"(##$absaddr) = $src", []>, Requires<[HasV4T]>; let opExtendable = 1, isPredicated = 1 in { defm Pt : ST_Abs_Pred; defm NotPt : ST_Abs_Pred; } } } multiclass ST_Abs_Predbase_nv { let isPredicatedNew = isPredNew in def NAME#_nv_V4 : NVInst_V4<(outs), (ins PredRegs:$src1, u0AlwaysExt:$absaddr, RC: $src2), !if(isNot, "if (!$src1", "if ($src1")#!if(isPredNew, ".new) ", ") ")#mnemonic#"(##$absaddr) = $src2.new", []>, Requires<[HasV4T]>; } multiclass ST_Abs_Pred_nv { let isPredicatedFalse = PredNot in { defm _c#NAME : ST_Abs_Predbase_nv; // Predicate new defm _cdn#NAME : ST_Abs_Predbase_nv; } } let mayStore = 1, isNVStore = 1, isExtended = 1, hasSideEffects = 0 in multiclass ST_Abs_nv { let CextOpcode = CextOp, BaseOpcode = CextOp#_abs in { let opExtendable = 0, isPredicable = 1 in def NAME#_nv_V4 : NVInst_V4<(outs), (ins u0AlwaysExt:$absaddr, RC:$src), mnemonic#"(##$absaddr) = $src.new", []>, Requires<[HasV4T]>; let opExtendable = 1, isPredicated = 1 in { defm Pt : ST_Abs_Pred_nv; defm NotPt : ST_Abs_Pred_nv; } } } let addrMode = Absolute in { let accessSize = ByteAccess in defm STrib_abs : ST_Abs<"memb", "STrib", IntRegs>, ST_Abs_nv<"memb", "STrib", IntRegs>, AddrModeRel; let accessSize = HalfWordAccess in defm STrih_abs : ST_Abs<"memh", "STrih", IntRegs>, ST_Abs_nv<"memh", "STrih", IntRegs>, AddrModeRel; let accessSize = WordAccess in defm STriw_abs : ST_Abs<"memw", "STriw", IntRegs>, ST_Abs_nv<"memw", "STriw", IntRegs>, AddrModeRel; let accessSize = DoubleWordAccess, isNVStorable = 0 in defm STrid_abs : ST_Abs<"memd", "STrid", DoubleRegs>, AddrModeRel; } let Predicates = [HasV4T], AddedComplexity = 30 in { def : Pat<(truncstorei8 (i32 IntRegs:$src1), (HexagonCONST32 tglobaladdr:$absaddr)), (STrib_abs_V4 tglobaladdr: $absaddr, IntRegs: $src1)>; def : Pat<(truncstorei16 (i32 IntRegs:$src1), (HexagonCONST32 tglobaladdr:$absaddr)), (STrih_abs_V4 tglobaladdr: $absaddr, IntRegs: $src1)>; def : Pat<(store (i32 IntRegs:$src1), (HexagonCONST32 tglobaladdr:$absaddr)), (STriw_abs_V4 tglobaladdr: $absaddr, IntRegs: $src1)>; def : Pat<(store (i64 DoubleRegs:$src1), (HexagonCONST32 tglobaladdr:$absaddr)), (STrid_abs_V4 tglobaladdr: $absaddr, DoubleRegs: $src1)>; } //===----------------------------------------------------------------------===// // multiclass for store instructions with GP-relative addressing mode. // mem[bhwd](#global)=Rt // if ([!]Pv[.new]) mem[bhwd](##global) = Rt //===----------------------------------------------------------------------===// let mayStore = 1, isNVStorable = 1 in multiclass ST_GP { let BaseOpcode = BaseOp, isPredicable = 1 in def NAME#_V4 : STInst2<(outs), (ins globaladdress:$global, RC:$src), mnemonic#"(#$global) = $src", []>; // When GP-relative instructions are predicated, their addressing mode is // changed to absolute and they are always constant extended. let BaseOpcode = BaseOp, isExtended = 1, opExtendable = 1, isPredicated = 1 in { defm Pt : ST_Abs_Pred ; defm NotPt : ST_Abs_Pred ; } } let mayStore = 1, isNVStore = 1 in multiclass ST_GP_nv { let BaseOpcode = BaseOp, isPredicable = 1 in def NAME#_nv_V4 : NVInst_V4<(outs), (ins u0AlwaysExt:$global, RC:$src), mnemonic#"(#$global) = $src.new", []>, Requires<[HasV4T]>; // When GP-relative instructions are predicated, their addressing mode is // changed to absolute and they are always constant extended. let BaseOpcode = BaseOp, isExtended = 1, opExtendable = 1, isPredicated = 1 in { defm Pt : ST_Abs_Pred_nv; defm NotPt : ST_Abs_Pred_nv; } } let validSubTargets = HasV4SubT, hasSideEffects = 0 in { let isNVStorable = 0 in defm STd_GP : ST_GP <"memd", "STd_GP", DoubleRegs>, PredNewRel; defm STb_GP : ST_GP<"memb", "STb_GP", IntRegs>, ST_GP_nv<"memb", "STb_GP", IntRegs>, NewValueRel; defm STh_GP : ST_GP<"memh", "STh_GP", IntRegs>, ST_GP_nv<"memh", "STh_GP", IntRegs>, NewValueRel; defm STw_GP : ST_GP<"memw", "STw_GP", IntRegs>, ST_GP_nv<"memw", "STw_GP", IntRegs>, NewValueRel; } // 64 bit atomic store def : Pat <(atomic_store_64 (HexagonCONST32_GP tglobaladdr:$global), (i64 DoubleRegs:$src1)), (STd_GP_V4 tglobaladdr:$global, (i64 DoubleRegs:$src1))>, Requires<[HasV4T]>; // Map from store(globaladdress) -> memd(#foo) let AddedComplexity = 100 in def : Pat <(store (i64 DoubleRegs:$src1), (HexagonCONST32_GP tglobaladdr:$global)), (STd_GP_V4 tglobaladdr:$global, (i64 DoubleRegs:$src1))>; // 8 bit atomic store def : Pat < (atomic_store_8 (HexagonCONST32_GP tglobaladdr:$global), (i32 IntRegs:$src1)), (STb_GP_V4 tglobaladdr:$global, (i32 IntRegs:$src1))>; // Map from store(globaladdress) -> memb(#foo) let AddedComplexity = 100 in def : Pat<(truncstorei8 (i32 IntRegs:$src1), (HexagonCONST32_GP tglobaladdr:$global)), (STb_GP_V4 tglobaladdr:$global, (i32 IntRegs:$src1))>; // Map from "i1 = constant<-1>; memw(CONST32(#foo)) = i1" // to "r0 = 1; memw(#foo) = r0" let AddedComplexity = 100 in def : Pat<(store (i1 -1), (HexagonCONST32_GP tglobaladdr:$global)), (STb_GP_V4 tglobaladdr:$global, (A2_tfrsi 1))>; def : Pat<(atomic_store_16 (HexagonCONST32_GP tglobaladdr:$global), (i32 IntRegs:$src1)), (STh_GP_V4 tglobaladdr:$global, (i32 IntRegs:$src1))>; // Map from store(globaladdress) -> memh(#foo) let AddedComplexity = 100 in def : Pat<(truncstorei16 (i32 IntRegs:$src1), (HexagonCONST32_GP tglobaladdr:$global)), (STh_GP_V4 tglobaladdr:$global, (i32 IntRegs:$src1))>; // 32 bit atomic store def : Pat<(atomic_store_32 (HexagonCONST32_GP tglobaladdr:$global), (i32 IntRegs:$src1)), (STw_GP_V4 tglobaladdr:$global, (i32 IntRegs:$src1))>; // Map from store(globaladdress) -> memw(#foo) let AddedComplexity = 100 in def : Pat<(store (i32 IntRegs:$src1), (HexagonCONST32_GP tglobaladdr:$global)), (STw_GP_V4 tglobaladdr:$global, (i32 IntRegs:$src1))>; //===----------------------------------------------------------------------===// // Multiclass for the load instructions with absolute addressing mode. //===----------------------------------------------------------------------===// multiclass LD_Abs_Predbase { let isPredicatedNew = isPredNew in def NAME : LDInst2<(outs RC:$dst), (ins PredRegs:$src1, u0AlwaysExt:$absaddr), !if(isNot, "if (!$src1", "if ($src1")#!if(isPredNew, ".new) ", ") ")#"$dst = "#mnemonic#"(##$absaddr)", []>, Requires<[HasV4T]>; } multiclass LD_Abs_Pred { let isPredicatedFalse = PredNot in { defm _c#NAME : LD_Abs_Predbase; // Predicate new defm _cdn#NAME : LD_Abs_Predbase; } } let isExtended = 1, hasSideEffects = 0 in multiclass LD_Abs { let CextOpcode = CextOp, BaseOpcode = CextOp#_abs in { let opExtendable = 1, isPredicable = 1 in def NAME#_V4 : LDInst2<(outs RC:$dst), (ins u0AlwaysExt:$absaddr), "$dst = "#mnemonic#"(##$absaddr)", []>, Requires<[HasV4T]>; let opExtendable = 2, isPredicated = 1 in { defm Pt_V4 : LD_Abs_Pred; defm NotPt_V4 : LD_Abs_Pred; } } } let addrMode = Absolute in { let accessSize = ByteAccess in { defm LDrib_abs : LD_Abs<"memb", "LDrib", IntRegs>, AddrModeRel; defm LDriub_abs : LD_Abs<"memub", "LDriub", IntRegs>, AddrModeRel; } let accessSize = HalfWordAccess in { defm LDrih_abs : LD_Abs<"memh", "LDrih", IntRegs>, AddrModeRel; defm LDriuh_abs : LD_Abs<"memuh", "LDriuh", IntRegs>, AddrModeRel; } let accessSize = WordAccess in defm LDriw_abs : LD_Abs<"memw", "LDriw", IntRegs>, AddrModeRel; let accessSize = DoubleWordAccess in defm LDrid_abs : LD_Abs<"memd", "LDrid", DoubleRegs>, AddrModeRel; } let Predicates = [HasV4T], AddedComplexity = 30 in { def : Pat<(i32 (load (HexagonCONST32 tglobaladdr:$absaddr))), (LDriw_abs_V4 tglobaladdr: $absaddr)>; def : Pat<(i32 (sextloadi8 (HexagonCONST32 tglobaladdr:$absaddr))), (LDrib_abs_V4 tglobaladdr:$absaddr)>; def : Pat<(i32 (zextloadi8 (HexagonCONST32 tglobaladdr:$absaddr))), (LDriub_abs_V4 tglobaladdr:$absaddr)>; def : Pat<(i32 (sextloadi16 (HexagonCONST32 tglobaladdr:$absaddr))), (LDrih_abs_V4 tglobaladdr:$absaddr)>; def : Pat<(i32 (zextloadi16 (HexagonCONST32 tglobaladdr:$absaddr))), (LDriuh_abs_V4 tglobaladdr:$absaddr)>; } //===----------------------------------------------------------------------===// // multiclass for load instructions with GP-relative addressing mode. // Rx=mem[bhwd](##global) // if ([!]Pv[.new]) Rx=mem[bhwd](##global) //===----------------------------------------------------------------------===// let hasSideEffects = 0, validSubTargets = HasV4SubT in multiclass LD_GP { let BaseOpcode = BaseOp in { let isPredicable = 1 in def NAME#_V4 : LDInst2<(outs RC:$dst), (ins globaladdress:$global), "$dst = "#mnemonic#"(#$global)", []>; let isExtended = 1, opExtendable = 2, isPredicated = 1 in { defm Pt_V4 : LD_Abs_Pred; defm NotPt_V4 : LD_Abs_Pred; } } } defm LDd_GP : LD_GP<"memd", "LDd_GP", DoubleRegs>, PredNewRel; defm LDb_GP : LD_GP<"memb", "LDb_GP", IntRegs>, PredNewRel; defm LDub_GP : LD_GP<"memub", "LDub_GP", IntRegs>, PredNewRel; defm LDh_GP : LD_GP<"memh", "LDh_GP", IntRegs>, PredNewRel; defm LDuh_GP : LD_GP<"memuh", "LDuh_GP", IntRegs>, PredNewRel; defm LDw_GP : LD_GP<"memw", "LDw_GP", IntRegs>, PredNewRel; def : Pat <(atomic_load_64 (HexagonCONST32_GP tglobaladdr:$global)), (i64 (LDd_GP_V4 tglobaladdr:$global))>; def : Pat <(atomic_load_32 (HexagonCONST32_GP tglobaladdr:$global)), (i32 (LDw_GP_V4 tglobaladdr:$global))>; def : Pat <(atomic_load_16 (HexagonCONST32_GP tglobaladdr:$global)), (i32 (LDuh_GP_V4 tglobaladdr:$global))>; def : Pat <(atomic_load_8 (HexagonCONST32_GP tglobaladdr:$global)), (i32 (LDub_GP_V4 tglobaladdr:$global))>; // Map from load(globaladdress) -> memw(#foo + 0) let AddedComplexity = 100 in def : Pat <(i64 (load (HexagonCONST32_GP tglobaladdr:$global))), (i64 (LDd_GP_V4 tglobaladdr:$global))>; // Map from Pd = load(globaladdress) -> Rd = memb(globaladdress), Pd = Rd let AddedComplexity = 100 in def : Pat <(i1 (load (HexagonCONST32_GP tglobaladdr:$global))), (i1 (C2_tfrrp (i32 (LDb_GP_V4 tglobaladdr:$global))))>; // When the Interprocedural Global Variable optimizer realizes that a certain // global variable takes only two constant values, it shrinks the global to // a boolean. Catch those loads here in the following 3 patterns. let AddedComplexity = 100 in def : Pat <(i32 (extloadi1 (HexagonCONST32_GP tglobaladdr:$global))), (i32 (LDb_GP_V4 tglobaladdr:$global))>; let AddedComplexity = 100 in def : Pat <(i32 (sextloadi1 (HexagonCONST32_GP tglobaladdr:$global))), (i32 (LDb_GP_V4 tglobaladdr:$global))>; // Map from load(globaladdress) -> memb(#foo) let AddedComplexity = 100 in def : Pat <(i32 (extloadi8 (HexagonCONST32_GP tglobaladdr:$global))), (i32 (LDb_GP_V4 tglobaladdr:$global))>; // Map from load(globaladdress) -> memb(#foo) let AddedComplexity = 100 in def : Pat <(i32 (sextloadi8 (HexagonCONST32_GP tglobaladdr:$global))), (i32 (LDb_GP_V4 tglobaladdr:$global))>; let AddedComplexity = 100 in def : Pat <(i32 (zextloadi1 (HexagonCONST32_GP tglobaladdr:$global))), (i32 (LDub_GP_V4 tglobaladdr:$global))>; // Map from load(globaladdress) -> memub(#foo) let AddedComplexity = 100 in def : Pat <(i32 (zextloadi8 (HexagonCONST32_GP tglobaladdr:$global))), (i32 (LDub_GP_V4 tglobaladdr:$global))>; // Map from load(globaladdress) -> memh(#foo) let AddedComplexity = 100 in def : Pat <(i32 (extloadi16 (HexagonCONST32_GP tglobaladdr:$global))), (i32 (LDh_GP_V4 tglobaladdr:$global))>; // Map from load(globaladdress) -> memh(#foo) let AddedComplexity = 100 in def : Pat <(i32 (sextloadi16 (HexagonCONST32_GP tglobaladdr:$global))), (i32 (LDh_GP_V4 tglobaladdr:$global))>; // Map from load(globaladdress) -> memuh(#foo) let AddedComplexity = 100 in def : Pat <(i32 (zextloadi16 (HexagonCONST32_GP tglobaladdr:$global))), (i32 (LDuh_GP_V4 tglobaladdr:$global))>; // Map from load(globaladdress) -> memw(#foo) let AddedComplexity = 100 in def : Pat <(i32 (load (HexagonCONST32_GP tglobaladdr:$global))), (i32 (LDw_GP_V4 tglobaladdr:$global))>; // Transfer global address into a register let isExtended = 1, opExtendable = 1, AddedComplexity=50, isMoveImm = 1, isAsCheapAsAMove = 1, isReMaterializable = 1, validSubTargets = HasV4SubT in def TFRI_V4 : ALU32_ri<(outs IntRegs:$dst), (ins s16Ext:$src1), "$dst = #$src1", [(set IntRegs:$dst, (HexagonCONST32 tglobaladdr:$src1))]>, Requires<[HasV4T]>; // Transfer a block address into a register def : Pat<(HexagonCONST32_GP tblockaddress:$src1), (TFRI_V4 tblockaddress:$src1)>, Requires<[HasV4T]>; let isExtended = 1, opExtendable = 2, AddedComplexity=50, hasSideEffects = 0, isPredicated = 1, validSubTargets = HasV4SubT in def TFRI_cPt_V4 : ALU32_ri<(outs IntRegs:$dst), (ins PredRegs:$src1, s16Ext:$src2), "if($src1) $dst = #$src2", []>, Requires<[HasV4T]>; let isExtended = 1, opExtendable = 2, AddedComplexity=50, isPredicatedFalse = 1, hasSideEffects = 0, isPredicated = 1, validSubTargets = HasV4SubT in def TFRI_cNotPt_V4 : ALU32_ri<(outs IntRegs:$dst), (ins PredRegs:$src1, s16Ext:$src2), "if(!$src1) $dst = #$src2", []>, Requires<[HasV4T]>; let isExtended = 1, opExtendable = 2, AddedComplexity=50, hasSideEffects = 0, isPredicated = 1, validSubTargets = HasV4SubT in def TFRI_cdnPt_V4 : ALU32_ri<(outs IntRegs:$dst), (ins PredRegs:$src1, s16Ext:$src2), "if($src1.new) $dst = #$src2", []>, Requires<[HasV4T]>; let isExtended = 1, opExtendable = 2, AddedComplexity=50, isPredicatedFalse = 1, hasSideEffects = 0, isPredicated = 1, validSubTargets = HasV4SubT in def TFRI_cdnNotPt_V4 : ALU32_ri<(outs IntRegs:$dst), (ins PredRegs:$src1, s16Ext:$src2), "if(!$src1.new) $dst = #$src2", []>, Requires<[HasV4T]>; let AddedComplexity = 50, Predicates = [HasV4T] in def : Pat<(HexagonCONST32_GP tglobaladdr:$src1), (TFRI_V4 tglobaladdr:$src1)>, Requires<[HasV4T]>; // Load - Indirect with long offset: These instructions take global address // as an operand let isExtended = 1, opExtendable = 3, AddedComplexity = 40, validSubTargets = HasV4SubT in def LDrid_ind_lo_V4 : LDInst<(outs DoubleRegs:$dst), (ins IntRegs:$src1, u2Imm:$src2, globaladdressExt:$offset), "$dst=memd($src1<<#$src2+##$offset)", [(set (i64 DoubleRegs:$dst), (load (add (shl IntRegs:$src1, u2ImmPred:$src2), (HexagonCONST32 tglobaladdr:$offset))))]>, Requires<[HasV4T]>; let AddedComplexity = 40 in multiclass LD_indirect_lo { let isExtended = 1, opExtendable = 3, validSubTargets = HasV4SubT in def _lo_V4 : LDInst<(outs IntRegs:$dst), (ins IntRegs:$src1, u2Imm:$src2, globaladdressExt:$offset), !strconcat("$dst = ", !strconcat(OpcStr, "($src1<<#$src2+##$offset)")), [(set IntRegs:$dst, (i32 (OpNode (add (shl IntRegs:$src1, u2ImmPred:$src2), (HexagonCONST32 tglobaladdr:$offset)))))]>, Requires<[HasV4T]>; } defm LDrib_ind : LD_indirect_lo<"memb", sextloadi8>; defm LDriub_ind : LD_indirect_lo<"memub", zextloadi8>; defm LDriub_ind_anyext : LD_indirect_lo<"memub", extloadi8>; defm LDrih_ind : LD_indirect_lo<"memh", sextloadi16>; defm LDriuh_ind : LD_indirect_lo<"memuh", zextloadi16>; defm LDriuh_ind_anyext : LD_indirect_lo<"memuh", extloadi16>; defm LDriw_ind : LD_indirect_lo<"memw", load>; let AddedComplexity = 40 in def : Pat <(i32 (sextloadi8 (add IntRegs:$src1, (NumUsesBelowThresCONST32 tglobaladdr:$offset)))), (i32 (LDrib_ind_lo_V4 IntRegs:$src1, 0, tglobaladdr:$offset))>, Requires<[HasV4T]>; let AddedComplexity = 40 in def : Pat <(i32 (zextloadi8 (add IntRegs:$src1, (NumUsesBelowThresCONST32 tglobaladdr:$offset)))), (i32 (LDriub_ind_lo_V4 IntRegs:$src1, 0, tglobaladdr:$offset))>, Requires<[HasV4T]>; let Predicates = [HasV4T], AddedComplexity = 30 in { def : Pat<(truncstorei8 (i32 IntRegs:$src1), u0AlwaysExtPred:$src2), (STrib_abs_V4 u0AlwaysExtPred:$src2, IntRegs: $src1)>; def : Pat<(truncstorei16 (i32 IntRegs:$src1), u0AlwaysExtPred:$src2), (STrih_abs_V4 u0AlwaysExtPred:$src2, IntRegs: $src1)>; def : Pat<(store (i32 IntRegs:$src1), u0AlwaysExtPred:$src2), (STriw_abs_V4 u0AlwaysExtPred:$src2, IntRegs: $src1)>; } let Predicates = [HasV4T], AddedComplexity = 30 in { def : Pat<(i32 (load u0AlwaysExtPred:$src)), (LDriw_abs_V4 u0AlwaysExtPred:$src)>; def : Pat<(i32 (sextloadi8 u0AlwaysExtPred:$src)), (LDrib_abs_V4 u0AlwaysExtPred:$src)>; def : Pat<(i32 (zextloadi8 u0AlwaysExtPred:$src)), (LDriub_abs_V4 u0AlwaysExtPred:$src)>; def : Pat<(i32 (sextloadi16 u0AlwaysExtPred:$src)), (LDrih_abs_V4 u0AlwaysExtPred:$src)>; def : Pat<(i32 (zextloadi16 u0AlwaysExtPred:$src)), (LDriuh_abs_V4 u0AlwaysExtPred:$src)>; } // Indexed store word - global address. // memw(Rs+#u6:2)=#S8 let AddedComplexity = 10 in def STriw_offset_ext_V4 : STInst<(outs), (ins IntRegs:$src1, u6_2Imm:$src2, globaladdress:$src3), "memw($src1+#$src2) = ##$src3", [(store (HexagonCONST32 tglobaladdr:$src3), (add IntRegs:$src1, u6_2ImmPred:$src2))]>, Requires<[HasV4T]>; def : Pat<(i64 (ctlz (i64 DoubleRegs:$src1))), (i64 (A4_combineir (i32 0), (i32 (CTLZ64_rr DoubleRegs:$src1))))>, Requires<[HasV4T]>; def : Pat<(i64 (cttz (i64 DoubleRegs:$src1))), (i64 (A4_combineir (i32 0), (i32 (CTTZ64_rr DoubleRegs:$src1))))>, Requires<[HasV4T]>; // i8 -> i64 loads // We need a complexity of 120 here to override preceding handling of // zextloadi8. let Predicates = [HasV4T], AddedComplexity = 120 in { def: Pat <(i64 (extloadi8 (NumUsesBelowThresCONST32 tglobaladdr:$addr))), (i64 (A4_combineir 0, (LDrib_abs_V4 tglobaladdr:$addr)))>; def: Pat <(i64 (zextloadi8 (NumUsesBelowThresCONST32 tglobaladdr:$addr))), (i64 (A4_combineir 0, (LDriub_abs_V4 tglobaladdr:$addr)))>; def: Pat <(i64 (sextloadi8 (NumUsesBelowThresCONST32 tglobaladdr:$addr))), (i64 (A2_sxtw (LDrib_abs_V4 tglobaladdr:$addr)))>; def: Pat <(i64 (extloadi8 FoldGlobalAddr:$addr)), (i64 (A4_combineir 0, (LDrib_abs_V4 FoldGlobalAddr:$addr)))>; def: Pat <(i64 (zextloadi8 FoldGlobalAddr:$addr)), (i64 (A4_combineir 0, (LDriub_abs_V4 FoldGlobalAddr:$addr)))>; def: Pat <(i64 (sextloadi8 FoldGlobalAddr:$addr)), (i64 (A2_sxtw (LDrib_abs_V4 FoldGlobalAddr:$addr)))>; } // i16 -> i64 loads // We need a complexity of 120 here to override preceding handling of // zextloadi16. let AddedComplexity = 120 in { def: Pat <(i64 (extloadi16 (NumUsesBelowThresCONST32 tglobaladdr:$addr))), (i64 (A4_combineir 0, (LDrih_abs_V4 tglobaladdr:$addr)))>, Requires<[HasV4T]>; def: Pat <(i64 (zextloadi16 (NumUsesBelowThresCONST32 tglobaladdr:$addr))), (i64 (A4_combineir 0, (LDriuh_abs_V4 tglobaladdr:$addr)))>, Requires<[HasV4T]>; def: Pat <(i64 (sextloadi16 (NumUsesBelowThresCONST32 tglobaladdr:$addr))), (i64 (A2_sxtw (LDrih_abs_V4 tglobaladdr:$addr)))>, Requires<[HasV4T]>; def: Pat <(i64 (extloadi16 FoldGlobalAddr:$addr)), (i64 (A4_combineir 0, (LDrih_abs_V4 FoldGlobalAddr:$addr)))>, Requires<[HasV4T]>; def: Pat <(i64 (zextloadi16 FoldGlobalAddr:$addr)), (i64 (A4_combineir 0, (LDriuh_abs_V4 FoldGlobalAddr:$addr)))>, Requires<[HasV4T]>; def: Pat <(i64 (sextloadi16 FoldGlobalAddr:$addr)), (i64 (A2_sxtw (LDrih_abs_V4 FoldGlobalAddr:$addr)))>, Requires<[HasV4T]>; } // i32->i64 loads // We need a complexity of 120 here to override preceding handling of // zextloadi32. let AddedComplexity = 120 in { def: Pat <(i64 (extloadi32 (NumUsesBelowThresCONST32 tglobaladdr:$addr))), (i64 (A4_combineir 0, (LDriw_abs_V4 tglobaladdr:$addr)))>, Requires<[HasV4T]>; def: Pat <(i64 (zextloadi32 (NumUsesBelowThresCONST32 tglobaladdr:$addr))), (i64 (A4_combineir 0, (LDriw_abs_V4 tglobaladdr:$addr)))>, Requires<[HasV4T]>; def: Pat <(i64 (sextloadi32 (NumUsesBelowThresCONST32 tglobaladdr:$addr))), (i64 (A2_sxtw (LDriw_abs_V4 tglobaladdr:$addr)))>, Requires<[HasV4T]>; def: Pat <(i64 (extloadi32 FoldGlobalAddr:$addr)), (i64 (A4_combineir 0, (LDriw_abs_V4 FoldGlobalAddr:$addr)))>, Requires<[HasV4T]>; def: Pat <(i64 (zextloadi32 FoldGlobalAddr:$addr)), (i64 (A4_combineir 0, (LDriw_abs_V4 FoldGlobalAddr:$addr)))>, Requires<[HasV4T]>; def: Pat <(i64 (sextloadi32 FoldGlobalAddr:$addr)), (i64 (A2_sxtw (LDriw_abs_V4 FoldGlobalAddr:$addr)))>, Requires<[HasV4T]>; } // Indexed store double word - global address. // memw(Rs+#u6:2)=#S8 let AddedComplexity = 10 in def STrih_offset_ext_V4 : STInst<(outs), (ins IntRegs:$src1, u6_1Imm:$src2, globaladdress:$src3), "memh($src1+#$src2) = ##$src3", [(truncstorei16 (HexagonCONST32 tglobaladdr:$src3), (add IntRegs:$src1, u6_1ImmPred:$src2))]>, Requires<[HasV4T]>; // Map from store(globaladdress + x) -> memd(#foo + x) let AddedComplexity = 100 in def : Pat<(store (i64 DoubleRegs:$src1), FoldGlobalAddrGP:$addr), (STrid_abs_V4 FoldGlobalAddrGP:$addr, (i64 DoubleRegs:$src1))>, Requires<[HasV4T]>; def : Pat<(atomic_store_64 FoldGlobalAddrGP:$addr, (i64 DoubleRegs:$src1)), (STrid_abs_V4 FoldGlobalAddrGP:$addr, (i64 DoubleRegs:$src1))>, Requires<[HasV4T]>; // Map from store(globaladdress + x) -> memb(#foo + x) let AddedComplexity = 100 in def : Pat<(truncstorei8 (i32 IntRegs:$src1), FoldGlobalAddrGP:$addr), (STrib_abs_V4 FoldGlobalAddrGP:$addr, (i32 IntRegs:$src1))>, Requires<[HasV4T]>; def : Pat<(atomic_store_8 FoldGlobalAddrGP:$addr, (i32 IntRegs:$src1)), (STrib_abs_V4 FoldGlobalAddrGP:$addr, (i32 IntRegs:$src1))>, Requires<[HasV4T]>; // Map from store(globaladdress + x) -> memh(#foo + x) let AddedComplexity = 100 in def : Pat<(truncstorei16 (i32 IntRegs:$src1), FoldGlobalAddrGP:$addr), (STrih_abs_V4 FoldGlobalAddrGP:$addr, (i32 IntRegs:$src1))>, Requires<[HasV4T]>; def : Pat<(atomic_store_16 FoldGlobalAddrGP:$addr, (i32 IntRegs:$src1)), (STrih_abs_V4 FoldGlobalAddrGP:$addr, (i32 IntRegs:$src1))>, Requires<[HasV4T]>; // Map from store(globaladdress + x) -> memw(#foo + x) let AddedComplexity = 100 in def : Pat<(store (i32 IntRegs:$src1), FoldGlobalAddrGP:$addr), (STriw_abs_V4 FoldGlobalAddrGP:$addr, (i32 IntRegs:$src1))>, Requires<[HasV4T]>; def : Pat<(atomic_store_32 FoldGlobalAddrGP:$addr, (i32 IntRegs:$src1)), (STriw_abs_V4 FoldGlobalAddrGP:$addr, (i32 IntRegs:$src1))>, Requires<[HasV4T]>; // Map from load(globaladdress + x) -> memd(#foo + x) let AddedComplexity = 100 in def : Pat<(i64 (load FoldGlobalAddrGP:$addr)), (i64 (LDrid_abs_V4 FoldGlobalAddrGP:$addr))>, Requires<[HasV4T]>; def : Pat<(atomic_load_64 FoldGlobalAddrGP:$addr), (i64 (LDrid_abs_V4 FoldGlobalAddrGP:$addr))>, Requires<[HasV4T]>; // Map from load(globaladdress + x) -> memb(#foo + x) let AddedComplexity = 100 in def : Pat<(i32 (extloadi8 FoldGlobalAddrGP:$addr)), (i32 (LDrib_abs_V4 FoldGlobalAddrGP:$addr))>, Requires<[HasV4T]>; // Map from load(globaladdress + x) -> memb(#foo + x) let AddedComplexity = 100 in def : Pat<(i32 (sextloadi8 FoldGlobalAddrGP:$addr)), (i32 (LDrib_abs_V4 FoldGlobalAddrGP:$addr))>, Requires<[HasV4T]>; //let AddedComplexity = 100 in let AddedComplexity = 100 in def : Pat<(i32 (extloadi16 FoldGlobalAddrGP:$addr)), (i32 (LDrih_abs_V4 FoldGlobalAddrGP:$addr))>, Requires<[HasV4T]>; // Map from load(globaladdress + x) -> memh(#foo + x) let AddedComplexity = 100 in def : Pat<(i32 (sextloadi16 FoldGlobalAddrGP:$addr)), (i32 (LDrih_abs_V4 FoldGlobalAddrGP:$addr))>, Requires<[HasV4T]>; // Map from load(globaladdress + x) -> memuh(#foo + x) let AddedComplexity = 100 in def : Pat<(i32 (zextloadi16 FoldGlobalAddrGP:$addr)), (i32 (LDriuh_abs_V4 FoldGlobalAddrGP:$addr))>, Requires<[HasV4T]>; def : Pat<(atomic_load_16 FoldGlobalAddrGP:$addr), (i32 (LDriuh_abs_V4 FoldGlobalAddrGP:$addr))>, Requires<[HasV4T]>; // Map from load(globaladdress + x) -> memub(#foo + x) let AddedComplexity = 100 in def : Pat<(i32 (zextloadi8 FoldGlobalAddrGP:$addr)), (i32 (LDriub_abs_V4 FoldGlobalAddrGP:$addr))>, Requires<[HasV4T]>; def : Pat<(atomic_load_8 FoldGlobalAddrGP:$addr), (i32 (LDriub_abs_V4 FoldGlobalAddrGP:$addr))>, Requires<[HasV4T]>; // Map from load(globaladdress + x) -> memw(#foo + x) let AddedComplexity = 100 in def : Pat<(i32 (load FoldGlobalAddrGP:$addr)), (i32 (LDriw_abs_V4 FoldGlobalAddrGP:$addr))>, Requires<[HasV4T]>; def : Pat<(atomic_load_32 FoldGlobalAddrGP:$addr), (i32 (LDriw_abs_V4 FoldGlobalAddrGP:$addr))>, Requires<[HasV4T]>;