Skip to content

Commit

Permalink
[Hexagon] Adding A2_and instruction.
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222274 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
Colin LeMahieu committed Nov 18, 2014
1 parent 32dc2de commit 642bb08
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
6 changes: 4 additions & 2 deletions lib/Target/Hexagon/HexagonInstrInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1299,12 +1299,14 @@ bool HexagonInstrInfo::isConditionalALU32 (const MachineInstr* MI) const {
case Hexagon::A2_paddfnew:
case Hexagon::A2_paddt:
case Hexagon::A2_paddtnew:
case Hexagon::A2_pandf:
case Hexagon::A2_pandfnew:
case Hexagon::A2_pandt:
case Hexagon::A2_pandtnew:
case Hexagon::ADD_ri_cPt:
case Hexagon::ADD_ri_cNotPt:
case Hexagon::XOR_rr_cPt:
case Hexagon::XOR_rr_cNotPt:
case Hexagon::AND_rr_cPt:
case Hexagon::AND_rr_cNotPt:
case Hexagon::OR_rr_cPt:
case Hexagon::OR_rr_cNotPt:
case Hexagon::SUB_rr_cPt:
Expand Down
5 changes: 3 additions & 2 deletions lib/Target/Hexagon/HexagonInstrInfo.td
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ multiclass T_ALU32_3op_A2<string mnemonic, bits<3> MajOp, bits<3> MinOp,

let isCodeGenOnly = 0 in
defm add : T_ALU32_3op_A2<"add", 0b011, 0b000, 0, 1>;
defm and : T_ALU32_3op_A2<"and", 0b001, 0b000, 0, 1>;
defm sub : T_ALU32_3op_A2<"sub", 0b011, 0b001, 1, 0>;

// Pats for instruction selection.
Expand All @@ -170,6 +171,7 @@ class BinOp32_pat<SDNode Op, InstHexagon MI, ValueType ResT>
(ResT (MI IntRegs:$Rs, IntRegs:$Rt))>;

def: BinOp32_pat<add, A2_add, i32>;
def: BinOp32_pat<and, A2_and, i32>;
def: BinOp32_pat<sub, A2_sub, i32>;

multiclass ALU32_Pbase<string mnemonic, RegisterClass RC, bit isNot,
Expand Down Expand Up @@ -208,7 +210,6 @@ multiclass ALU32_base<string mnemonic, string CextOp, SDNode OpNode> {
}

let isCommutable = 1 in {
defm AND_rr : ALU32_base<"and", "AND", and>, ImmRegRel, PredNewRel;
defm XOR_rr : ALU32_base<"xor", "XOR", xor>, ImmRegRel, PredNewRel;
defm OR_rr : ALU32_base<"or", "OR", or>, ImmRegRel, PredNewRel;
}
Expand Down Expand Up @@ -2291,7 +2292,7 @@ def : Pat <(i64 (zextloadi1 (HexagonCONST32 tglobaladdr:$global))),
// Map from i1 loads to 32 bits. This assumes that the i1* is byte aligned.
let AddedComplexity = 10 in
def : Pat <(i32 (zextloadi1 ADDRriS11_0:$addr)),
(i32 (AND_rr (i32 (LDrib ADDRriS11_0:$addr)), (TFRI 0x1)))>;
(i32 (A2_and (i32 (LDrib ADDRriS11_0:$addr)), (TFRI 0x1)))>;

// Map from Rdd = sign_extend_inreg(Rss, i32) -> Rdd = SXTW(Rss.lo).
def : Pat <(i64 (sext_inreg (i64 DoubleRegs:$src1), i32)),
Expand Down
10 changes: 10 additions & 0 deletions test/MC/Hexagon/inst_and.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
;; RUN: llc -mtriple=hexagon-unknown-elf -filetype=obj %s -o - \
;; RUN: | llvm-objdump -s - | FileCheck %s

define i32 @foo (i32 %a, i32 %b)
{
%1 = and i32 %a, %b
ret i32 %1
}

; CHECK: 0000 004100f1 00c09f52

0 comments on commit 642bb08

Please sign in to comment.