Colin LeMahieu | cefca69 | 2015-01-30 21:58:46 +0000 | [diff] [blame] | 1 | //===- HexagonInstrInfoVector.td - Hexagon Vector Patterns -*- tablegen -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file describes the Hexagon Vector instructions in TableGen format. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
Colin LeMahieu | cefca69 | 2015-01-30 21:58:46 +0000 | [diff] [blame] | 14 | // Vector shift support. Vector shifting in Hexagon is rather different |
| 15 | // from internal representation of LLVM. |
| 16 | // LLVM assumes all shifts (in vector case) will have the form |
| 17 | // <VT> = SHL/SRA/SRL <VT> by <VT> |
| 18 | // while Hexagon has the following format: |
| 19 | // <VT> = SHL/SRA/SRL <VT> by <IT/i32> |
| 20 | // As a result, special care is needed to guarantee correctness and |
| 21 | // performance. |
| 22 | class vshift_v4i16<SDNode Op, string Str, bits<3>MajOp, bits<3>MinOp> |
Krzysztof Parzyszek | a8d63dc | 2016-11-05 15:01:38 +0000 | [diff] [blame] | 23 | : S_2OpInstImm<Str, MajOp, MinOp, u4_0Imm, []> { |
Colin LeMahieu | cefca69 | 2015-01-30 21:58:46 +0000 | [diff] [blame] | 24 | bits<4> src2; |
| 25 | let Inst{11-8} = src2; |
| 26 | } |
| 27 | |
| 28 | class vshift_v2i32<SDNode Op, string Str, bits<3>MajOp, bits<3>MinOp> |
Krzysztof Parzyszek | a8d63dc | 2016-11-05 15:01:38 +0000 | [diff] [blame] | 29 | : S_2OpInstImm<Str, MajOp, MinOp, u5_0Imm, []> { |
Colin LeMahieu | cefca69 | 2015-01-30 21:58:46 +0000 | [diff] [blame] | 30 | bits<5> src2; |
| 31 | let Inst{12-8} = src2; |
| 32 | } |
| 33 | |
Colin LeMahieu | cefca69 | 2015-01-30 21:58:46 +0000 | [diff] [blame] | 34 | def S2_asr_i_vw : vshift_v2i32<sra, "vasrw", 0b010, 0b000>; |
| 35 | def S2_lsr_i_vw : vshift_v2i32<srl, "vlsrw", 0b010, 0b001>; |
| 36 | def S2_asl_i_vw : vshift_v2i32<shl, "vaslw", 0b010, 0b010>; |
| 37 | |
| 38 | def S2_asr_i_vh : vshift_v4i16<sra, "vasrh", 0b100, 0b000>; |
| 39 | def S2_lsr_i_vh : vshift_v4i16<srl, "vlsrh", 0b100, 0b001>; |
| 40 | def S2_asl_i_vh : vshift_v4i16<shl, "vaslh", 0b100, 0b010>; |
| 41 | |
| 42 | // Vector shift words by register |
| 43 | def S2_asr_r_vw : T_S3op_shiftVect < "vasrw", 0b00, 0b00>; |
| 44 | def S2_lsr_r_vw : T_S3op_shiftVect < "vlsrw", 0b00, 0b01>; |
| 45 | def S2_asl_r_vw : T_S3op_shiftVect < "vaslw", 0b00, 0b10>; |
| 46 | def S2_lsl_r_vw : T_S3op_shiftVect < "vlslw", 0b00, 0b11>; |
| 47 | |
| 48 | // Vector shift halfwords by register |
| 49 | def S2_asr_r_vh : T_S3op_shiftVect < "vasrh", 0b01, 0b00>; |
| 50 | def S2_lsr_r_vh : T_S3op_shiftVect < "vlsrh", 0b01, 0b01>; |
| 51 | def S2_asl_r_vh : T_S3op_shiftVect < "vaslh", 0b01, 0b10>; |
| 52 | def S2_lsl_r_vh : T_S3op_shiftVect < "vlslh", 0b01, 0b11>; |
Krzysztof Parzyszek | 4211334 | 2015-03-19 16:33:08 +0000 | [diff] [blame] | 53 | |
Krzysztof Parzyszek | 4211334 | 2015-03-19 16:33:08 +0000 | [diff] [blame] | 54 | |
| 55 | // Hexagon doesn't have a vector multiply with C semantics. |
| 56 | // Instead, generate a pseudo instruction that gets expaneded into two |
| 57 | // scalar MPYI instructions. |
| 58 | // This is expanded by ExpandPostRAPseudos. |
| 59 | let isPseudo = 1 in |
Krzysztof Parzyszek | 1d01a79 | 2016-08-16 18:08:40 +0000 | [diff] [blame] | 60 | def PS_vmulw : PseudoM<(outs DoubleRegs:$Rd), |
Krzysztof Parzyszek | a8d63dc | 2016-11-05 15:01:38 +0000 | [diff] [blame] | 61 | (ins DoubleRegs:$Rs, DoubleRegs:$Rt), "", []>; |
Krzysztof Parzyszek | 4211334 | 2015-03-19 16:33:08 +0000 | [diff] [blame] | 62 | |
| 63 | let isPseudo = 1 in |
Krzysztof Parzyszek | 1d01a79 | 2016-08-16 18:08:40 +0000 | [diff] [blame] | 64 | def PS_vmulw_acc : PseudoM<(outs DoubleRegs:$Rd), |
Krzysztof Parzyszek | a8d63dc | 2016-11-05 15:01:38 +0000 | [diff] [blame] | 65 | (ins DoubleRegs:$Rx, DoubleRegs:$Rs, DoubleRegs:$Rt), "", [], |
Krzysztof Parzyszek | 4211334 | 2015-03-19 16:33:08 +0000 | [diff] [blame] | 66 | "$Rd = $Rx">; |
| 67 | |
Krzysztof Parzyszek | 4211334 | 2015-03-19 16:33:08 +0000 | [diff] [blame] | 68 | |
| 69 | |