forked from OSchip/llvm-project
Hexagon: Use multiclass for aslh, asrh, sxtb, sxth, zxtb and zxth.
llvm-svn: 178032
This commit is contained in:
parent
8a51d8ea95
commit
15957b129f
|
@ -446,38 +446,58 @@ def MUX_ii : ALU32_ii<(outs IntRegs:$dst), (ins PredRegs:$src1, s8Ext:$src2,
|
|||
s8ExtPred:$src2,
|
||||
s8ImmPred:$src3)))]>;
|
||||
|
||||
// Shift halfword.
|
||||
let isPredicable = 1 in
|
||||
def ASLH : ALU32_rr<(outs IntRegs:$dst), (ins IntRegs:$src1),
|
||||
"$dst = aslh($src1)",
|
||||
[(set (i32 IntRegs:$dst), (shl 16, (i32 IntRegs:$src1)))]>;
|
||||
// ALU32 - aslh, asrh, sxtb, sxth, zxtb, zxth
|
||||
multiclass ALU32_2op_Pbase<string mnemonic, bit isNot, bit isPredNew> {
|
||||
let isPredicatedNew = isPredNew in
|
||||
def NAME : ALU32Inst<(outs IntRegs:$dst),
|
||||
(ins PredRegs:$src1, IntRegs:$src2),
|
||||
!if(isNot, "if (!$src1", "if ($src1")#!if(isPredNew,".new) $dst = ",
|
||||
") $dst = ")#mnemonic#"($src2)">,
|
||||
Requires<[HasV4T]>;
|
||||
}
|
||||
|
||||
let isPredicable = 1 in
|
||||
def ASRH : ALU32_rr<(outs IntRegs:$dst), (ins IntRegs:$src1),
|
||||
"$dst = asrh($src1)",
|
||||
[(set (i32 IntRegs:$dst), (sra 16, (i32 IntRegs:$src1)))]>;
|
||||
multiclass ALU32_2op_Pred<string mnemonic, bit PredNot> {
|
||||
let isPredicatedFalse = PredNot in {
|
||||
defm _c#NAME : ALU32_2op_Pbase<mnemonic, PredNot, 0>;
|
||||
// Predicate new
|
||||
defm _cdn#NAME : ALU32_2op_Pbase<mnemonic, PredNot, 1>;
|
||||
}
|
||||
}
|
||||
|
||||
// Sign extend.
|
||||
let isPredicable = 1 in
|
||||
def SXTB : ALU32_rr<(outs IntRegs:$dst), (ins IntRegs:$src1),
|
||||
"$dst = sxtb($src1)",
|
||||
[(set (i32 IntRegs:$dst), (sext_inreg (i32 IntRegs:$src1), i8))]>;
|
||||
|
||||
let isPredicable = 1 in
|
||||
def SXTH : ALU32_rr<(outs IntRegs:$dst), (ins IntRegs:$src1),
|
||||
"$dst = sxth($src1)",
|
||||
[(set (i32 IntRegs:$dst), (sext_inreg (i32 IntRegs:$src1), i16))]>;
|
||||
|
||||
// Zero extend.
|
||||
multiclass ALU32_2op_base<string mnemonic> {
|
||||
let BaseOpcode = mnemonic in {
|
||||
let isPredicable = 1, neverHasSideEffects = 1 in
|
||||
def ZXTB : ALU32_rr<(outs IntRegs:$dst), (ins IntRegs:$src1),
|
||||
"$dst = zxtb($src1)",
|
||||
[]>;
|
||||
def NAME : ALU32Inst<(outs IntRegs:$dst),
|
||||
(ins IntRegs:$src1),
|
||||
"$dst = "#mnemonic#"($src1)">;
|
||||
|
||||
let Predicates = [HasV4T], validSubTargets = HasV4SubT, isPredicated = 1,
|
||||
neverHasSideEffects = 1 in {
|
||||
defm Pt_V4 : ALU32_2op_Pred<mnemonic, 0>;
|
||||
defm NotPt_V4 : ALU32_2op_Pred<mnemonic, 1>;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
defm ASLH : ALU32_2op_base<"aslh">, PredNewRel;
|
||||
defm ASRH : ALU32_2op_base<"asrh">, PredNewRel;
|
||||
defm SXTB : ALU32_2op_base<"sxtb">, PredNewRel;
|
||||
defm SXTH : ALU32_2op_base<"sxth">, PredNewRel;
|
||||
defm ZXTB : ALU32_2op_base<"zxtb">, PredNewRel;
|
||||
defm ZXTH : ALU32_2op_base<"zxth">, PredNewRel;
|
||||
|
||||
def : Pat <(shl (i32 IntRegs:$src1), (i32 16)),
|
||||
(ASLH IntRegs:$src1)>;
|
||||
|
||||
def : Pat <(sra (i32 IntRegs:$src1), (i32 16)),
|
||||
(ASRH IntRegs:$src1)>;
|
||||
|
||||
def : Pat <(sext_inreg (i32 IntRegs:$src1), i8),
|
||||
(SXTB IntRegs:$src1)>;
|
||||
|
||||
def : Pat <(sext_inreg (i32 IntRegs:$src1), i16),
|
||||
(SXTH IntRegs:$src1)>;
|
||||
|
||||
let isPredicable = 1, neverHasSideEffects = 1 in
|
||||
def ZXTH : ALU32_rr<(outs IntRegs:$dst), (ins IntRegs:$src1),
|
||||
"$dst = zxth($src1)",
|
||||
[]>;
|
||||
//===----------------------------------------------------------------------===//
|
||||
// ALU32/PERM -
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
|
@ -95,164 +95,6 @@ def NumUsesBelowThresCONST32 : PatFrag<(ops node:$addr),
|
|||
//===----------------------------------------------------------------------===//
|
||||
// ALU32 +
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// Shift halfword.
|
||||
|
||||
let isPredicated = 1, neverHasSideEffects = 1, validSubTargets = HasV4SubT in {
|
||||
def ASLH_cPt_V4 : ALU32_rr<(outs IntRegs:$dst),
|
||||
(ins PredRegs:$src1, IntRegs:$src2),
|
||||
"if ($src1) $dst = aslh($src2)",
|
||||
[]>,
|
||||
Requires<[HasV4T]>;
|
||||
|
||||
def ASLH_cNotPt_V4 : ALU32_rr<(outs IntRegs:$dst),
|
||||
(ins PredRegs:$src1, IntRegs:$src2),
|
||||
"if (!$src1) $dst = aslh($src2)",
|
||||
[]>,
|
||||
Requires<[HasV4T]>;
|
||||
|
||||
def ASLH_cdnPt_V4 : ALU32_rr<(outs IntRegs:$dst),
|
||||
(ins PredRegs:$src1, IntRegs:$src2),
|
||||
"if ($src1.new) $dst = aslh($src2)",
|
||||
[]>,
|
||||
Requires<[HasV4T]>;
|
||||
|
||||
def ASLH_cdnNotPt_V4 : ALU32_rr<(outs IntRegs:$dst),
|
||||
(ins PredRegs:$src1, IntRegs:$src2),
|
||||
"if (!$src1.new) $dst = aslh($src2)",
|
||||
[]>,
|
||||
Requires<[HasV4T]>;
|
||||
|
||||
def ASRH_cPt_V4 : ALU32_rr<(outs IntRegs:$dst),
|
||||
(ins PredRegs:$src1, IntRegs:$src2),
|
||||
"if ($src1) $dst = asrh($src2)",
|
||||
[]>,
|
||||
Requires<[HasV4T]>;
|
||||
|
||||
def ASRH_cNotPt_V4 : ALU32_rr<(outs IntRegs:$dst),
|
||||
(ins PredRegs:$src1, IntRegs:$src2),
|
||||
"if (!$src1) $dst = asrh($src2)",
|
||||
[]>,
|
||||
Requires<[HasV4T]>;
|
||||
|
||||
def ASRH_cdnPt_V4 : ALU32_rr<(outs IntRegs:$dst),
|
||||
(ins PredRegs:$src1, IntRegs:$src2),
|
||||
"if ($src1.new) $dst = asrh($src2)",
|
||||
[]>,
|
||||
Requires<[HasV4T]>;
|
||||
|
||||
def ASRH_cdnNotPt_V4 : ALU32_rr<(outs IntRegs:$dst),
|
||||
(ins PredRegs:$src1, IntRegs:$src2),
|
||||
"if (!$src1.new) $dst = asrh($src2)",
|
||||
[]>,
|
||||
Requires<[HasV4T]>;
|
||||
}
|
||||
|
||||
// Sign extend.
|
||||
|
||||
let isPredicated = 1, neverHasSideEffects = 1, validSubTargets = HasV4SubT in {
|
||||
def SXTB_cPt_V4 : ALU32_rr<(outs IntRegs:$dst),
|
||||
(ins PredRegs:$src1, IntRegs:$src2),
|
||||
"if ($src1) $dst = sxtb($src2)",
|
||||
[]>,
|
||||
Requires<[HasV4T]>;
|
||||
|
||||
def SXTB_cNotPt_V4 : ALU32_rr<(outs IntRegs:$dst),
|
||||
(ins PredRegs:$src1, IntRegs:$src2),
|
||||
"if (!$src1) $dst = sxtb($src2)",
|
||||
[]>,
|
||||
Requires<[HasV4T]>;
|
||||
|
||||
def SXTB_cdnPt_V4 : ALU32_rr<(outs IntRegs:$dst),
|
||||
(ins PredRegs:$src1, IntRegs:$src2),
|
||||
"if ($src1.new) $dst = sxtb($src2)",
|
||||
[]>,
|
||||
Requires<[HasV4T]>;
|
||||
|
||||
def SXTB_cdnNotPt_V4 : ALU32_rr<(outs IntRegs:$dst),
|
||||
(ins PredRegs:$src1, IntRegs:$src2),
|
||||
"if (!$src1.new) $dst = sxtb($src2)",
|
||||
[]>,
|
||||
Requires<[HasV4T]>;
|
||||
|
||||
|
||||
def SXTH_cPt_V4 : ALU32_rr<(outs IntRegs:$dst),
|
||||
(ins PredRegs:$src1, IntRegs:$src2),
|
||||
"if ($src1) $dst = sxth($src2)",
|
||||
[]>,
|
||||
Requires<[HasV4T]>;
|
||||
|
||||
def SXTH_cNotPt_V4 : ALU32_rr<(outs IntRegs:$dst),
|
||||
(ins PredRegs:$src1, IntRegs:$src2),
|
||||
"if (!$src1) $dst = sxth($src2)",
|
||||
[]>,
|
||||
Requires<[HasV4T]>;
|
||||
|
||||
def SXTH_cdnPt_V4 : ALU32_rr<(outs IntRegs:$dst),
|
||||
(ins PredRegs:$src1, IntRegs:$src2),
|
||||
"if ($src1.new) $dst = sxth($src2)",
|
||||
[]>,
|
||||
Requires<[HasV4T]>;
|
||||
|
||||
def SXTH_cdnNotPt_V4 : ALU32_rr<(outs IntRegs:$dst),
|
||||
(ins PredRegs:$src1, IntRegs:$src2),
|
||||
"if (!$src1.new) $dst = sxth($src2)",
|
||||
[]>,
|
||||
Requires<[HasV4T]>;
|
||||
}
|
||||
|
||||
// Zero exten.
|
||||
|
||||
let neverHasSideEffects = 1, isPredicated = 1, validSubTargets = HasV4SubT in {
|
||||
def ZXTB_cPt_V4 : ALU32_rr<(outs IntRegs:$dst),
|
||||
(ins PredRegs:$src1, IntRegs:$src2),
|
||||
"if ($src1) $dst = zxtb($src2)",
|
||||
[]>,
|
||||
Requires<[HasV4T]>;
|
||||
|
||||
def ZXTB_cNotPt_V4 : ALU32_rr<(outs IntRegs:$dst),
|
||||
(ins PredRegs:$src1, IntRegs:$src2),
|
||||
"if (!$src1) $dst = zxtb($src2)",
|
||||
[]>,
|
||||
Requires<[HasV4T]>;
|
||||
|
||||
def ZXTB_cdnPt_V4 : ALU32_rr<(outs IntRegs:$dst),
|
||||
(ins PredRegs:$src1, IntRegs:$src2),
|
||||
"if ($src1.new) $dst = zxtb($src2)",
|
||||
[]>,
|
||||
Requires<[HasV4T]>;
|
||||
|
||||
def ZXTB_cdnNotPt_V4 : ALU32_rr<(outs IntRegs:$dst),
|
||||
(ins PredRegs:$src1, IntRegs:$src2),
|
||||
"if (!$src1.new) $dst = zxtb($src2)",
|
||||
[]>,
|
||||
Requires<[HasV4T]>;
|
||||
|
||||
def ZXTH_cPt_V4 : ALU32_rr<(outs IntRegs:$dst),
|
||||
(ins PredRegs:$src1, IntRegs:$src2),
|
||||
"if ($src1) $dst = zxth($src2)",
|
||||
[]>,
|
||||
Requires<[HasV4T]>;
|
||||
|
||||
def ZXTH_cNotPt_V4 : ALU32_rr<(outs IntRegs:$dst),
|
||||
(ins PredRegs:$src1, IntRegs:$src2),
|
||||
"if (!$src1) $dst = zxth($src2)",
|
||||
[]>,
|
||||
Requires<[HasV4T]>;
|
||||
|
||||
def ZXTH_cdnPt_V4 : ALU32_rr<(outs IntRegs:$dst),
|
||||
(ins PredRegs:$src1, IntRegs:$src2),
|
||||
"if ($src1.new) $dst = zxth($src2)",
|
||||
[]>,
|
||||
Requires<[HasV4T]>;
|
||||
|
||||
def ZXTH_cdnNotPt_V4 : ALU32_rr<(outs IntRegs:$dst),
|
||||
(ins PredRegs:$src1, IntRegs:$src2),
|
||||
"if (!$src1.new) $dst = zxth($src2)",
|
||||
[]>,
|
||||
Requires<[HasV4T]>;
|
||||
}
|
||||
|
||||
// Generate frame index addresses.
|
||||
let neverHasSideEffects = 1, isReMaterializable = 1,
|
||||
isExtended = 1, opExtendable = 2, validSubTargets = HasV4SubT in
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
; RUN: llc -march=hexagon -mcpu=hexagonv4 < %s | FileCheck %s
|
||||
|
||||
define i32 @foo(i32 %a, i32 %b) nounwind readnone {
|
||||
; CHECK: lsl
|
||||
; CHECK: aslh
|
||||
entry:
|
||||
%shl1 = shl i32 16, %a
|
||||
%shl2 = shl i32 %b, 16
|
||||
%ret = mul i32 %shl1, %shl2
|
||||
ret i32 %ret
|
||||
}
|
||||
|
||||
define i32 @bar(i32 %a, i32 %b) nounwind readnone {
|
||||
; CHECK: asrh
|
||||
; CHECK: lsr
|
||||
entry:
|
||||
%shl1 = ashr i32 16, %a
|
||||
%shl2 = ashr i32 %b, 16
|
||||
%ret = mul i32 %shl1, %shl2
|
||||
ret i32 %ret
|
||||
}
|
Loading…
Reference in New Issue