2018-02-09 Sebastian Perta <sebastian.perta@renesas.com>
[official-gcc.git] / gcc / config / powerpcspe / crypto.md
blob0f34e141580ae600f1c085a8511b9072f81c9d0b
1 ;; Cryptographic instructions added in ISA 2.07
2 ;; Copyright (C) 2012-2018 Free Software Foundation, Inc.
3 ;; Contributed by Michael Meissner (meissner@linux.vnet.ibm.com)
5 ;; This file is part of GCC.
7 ;; GCC is free software; you can redistribute it and/or modify it
8 ;; under the terms of the GNU General Public License as published
9 ;; by the Free Software Foundation; either version 3, or (at your
10 ;; option) any later version.
12 ;; GCC is distributed in the hope that it will be useful, but WITHOUT
13 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 ;; or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
15 ;; License for more details.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GCC; see the file COPYING3.  If not see
19 ;; <http://www.gnu.org/licenses/>.
21 ;; NOTE: Although this file contains all the instructions from
22 ;; section 5.11 of ISA 2.07, only those in sections 5.11.1 and
23 ;; 5.11.2 are in Category:Vector.Crypto.  Those are the only
24 ;; ones controlled by -m[no-]crypto.
26 ;; FIXME: The builtin names for the instructions in this file
27 ;; are likely to be deprecated in favor of other names to be
28 ;; agreed upon with the XL compilers and LLVM.
30 (define_c_enum "unspec"
31   [UNSPEC_VCIPHER
32    UNSPEC_VNCIPHER
33    UNSPEC_VCIPHERLAST
34    UNSPEC_VNCIPHERLAST
35    UNSPEC_VSBOX
36    UNSPEC_VSHASIGMA
37    UNSPEC_VPERMXOR
38    UNSPEC_VPMSUM])
40 ;; Iterator for VPMSUM/VPERMXOR
41 (define_mode_iterator CR_mode [V16QI V8HI V4SI V2DI])
43 (define_mode_attr CR_char [(V16QI "b")
44                            (V8HI  "h")
45                            (V4SI  "w")
46                            (V2DI  "d")])
48 ;; Iterator for VSHASIGMAD/VSHASIGMAW
49 (define_mode_iterator CR_hash [V4SI V2DI])
51 ;; Iterator for the other crypto functions
52 (define_int_iterator CR_code   [UNSPEC_VCIPHER
53                                 UNSPEC_VNCIPHER
54                                 UNSPEC_VCIPHERLAST
55                                 UNSPEC_VNCIPHERLAST])
57 (define_int_attr CR_insn [(UNSPEC_VCIPHER      "vcipher")
58                           (UNSPEC_VNCIPHER     "vncipher")
59                           (UNSPEC_VCIPHERLAST  "vcipherlast")
60                           (UNSPEC_VNCIPHERLAST "vncipherlast")])
62 ;; 2 operand crypto instructions
63 (define_insn "crypto_<CR_insn>"
64   [(set (match_operand:V2DI 0 "register_operand" "=v")
65         (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "v")
66                       (match_operand:V2DI 2 "register_operand" "v")]
67                      CR_code))]
68   "TARGET_CRYPTO"
69   "<CR_insn> %0,%1,%2"
70   [(set_attr "type" "crypto")])
72 (define_insn "crypto_vpmsum<CR_char>"
73   [(set (match_operand:CR_mode 0 "register_operand" "=v")
74         (unspec:CR_mode [(match_operand:CR_mode 1 "register_operand" "v")
75                          (match_operand:CR_mode 2 "register_operand" "v")]
76                         UNSPEC_VPMSUM))]
77   "TARGET_P8_VECTOR"
78   "vpmsum<CR_char> %0,%1,%2"
79   [(set_attr "type" "crypto")])
81 ;; 3 operand crypto instructions
82 (define_insn "crypto_vpermxor_<mode>"
83   [(set (match_operand:CR_mode 0 "register_operand" "=v")
84         (unspec:CR_mode [(match_operand:CR_mode 1 "register_operand" "v")
85                          (match_operand:CR_mode 2 "register_operand" "v")
86                          (match_operand:CR_mode 3 "register_operand" "v")]
87                         UNSPEC_VPERMXOR))]
88   "TARGET_P8_VECTOR"
89   "vpermxor %0,%1,%2,%3"
90   [(set_attr "type" "vecperm")])
92 ;; 1 operand crypto instruction
93 (define_insn "crypto_vsbox"
94   [(set (match_operand:V2DI 0 "register_operand" "=v")
95         (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "v")]
96                      UNSPEC_VSBOX))]
97   "TARGET_CRYPTO"
98   "vsbox %0,%1"
99   [(set_attr "type" "crypto")])
101 ;; Hash crypto instructions
102 (define_insn "crypto_vshasigma<CR_char>"
103   [(set (match_operand:CR_hash 0 "register_operand" "=v")
104         (unspec:CR_hash [(match_operand:CR_hash 1 "register_operand" "v")
105                          (match_operand:SI 2 "const_0_to_1_operand" "n")
106                          (match_operand:SI 3 "const_0_to_15_operand" "n")]
107                         UNSPEC_VSHASIGMA))]
108   "TARGET_CRYPTO"
109   "vshasigma<CR_char> %0,%1,%2,%3"
110   [(set_attr "type" "vecsimple")])