1 ;; Intrinsic patterns description of Andes NDS32 cpu for GNU compiler
2 ;; Copyright (C) 2012-2018 Free Software Foundation, Inc.
3 ;; Contributed by Andes Technology Corporation.
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 ;; ------------------------------------------------------------------------
25 (define_insn "unspec_volatile_mfsr"
26 [(set (match_operand:SI 0 "register_operand" "=r")
27 (unspec_volatile:SI [(match_operand:SI 1 "immediate_operand" "i")] UNSPEC_VOLATILE_MFSR))]
30 [(set_attr "type" "misc")
31 (set_attr "length" "4")]
34 (define_insn "unspec_volatile_mfusr"
35 [(set (match_operand:SI 0 "register_operand" "=r")
36 (unspec_volatile:SI [(match_operand:SI 1 "immediate_operand" "i")] UNSPEC_VOLATILE_MFUSR))]
39 [(set_attr "type" "misc")
40 (set_attr "length" "4")]
43 (define_insn "unspec_volatile_mtsr"
44 [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")
45 (match_operand:SI 1 "immediate_operand" "i")] UNSPEC_VOLATILE_MTSR)]
48 [(set_attr "type" "misc")
49 (set_attr "length" "4")]
52 (define_insn "unspec_volatile_mtusr"
53 [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")
54 (match_operand:SI 1 "immediate_operand" "i")] UNSPEC_VOLATILE_MTUSR)]
57 [(set_attr "type" "misc")
58 (set_attr "length" "4")]
61 ;; ------------------------------------------------------------------------
63 ;; Interrupt Instructions.
65 (define_insn "unspec_volatile_setgie_en"
66 [(unspec_volatile:SI [(const_int 0)] UNSPEC_VOLATILE_SETGIE_EN)]
69 [(set_attr "type" "misc")]
72 (define_insn "unspec_volatile_setgie_dis"
73 [(unspec_volatile:SI [(const_int 0)] UNSPEC_VOLATILE_SETGIE_DIS)]
76 [(set_attr "type" "misc")]
79 ;; ------------------------------------------------------------------------
81 ;; Cache Synchronization Instructions
83 (define_insn "unspec_volatile_isync"
84 [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")] UNSPEC_VOLATILE_ISYNC)]
87 [(set_attr "type" "misc")]
90 (define_insn "unspec_volatile_isb"
91 [(unspec_volatile:SI [(const_int 0)] UNSPEC_VOLATILE_ISB)]
94 [(set_attr "type" "misc")]
99 (define_insn "unspec_ffb"
100 [(set (match_operand:SI 0 "register_operand" "=r, r")
101 (unspec:SI [(match_operand:SI 1 "register_operand" "r, r")
102 (match_operand:SI 2 "nonmemory_operand" "Iu08, r")] UNSPEC_FFB))]
107 [(set_attr "type" "alu")
108 (set_attr "length" "4")]
111 (define_insn "unspec_ffmism"
112 [(set (match_operand:SI 0 "register_operand" "=r")
113 (unspec:SI [(match_operand:SI 1 "register_operand" "r")
114 (match_operand:SI 2 "register_operand" "r")] UNSPEC_FFMISM))]
117 [(set_attr "type" "alu")
118 (set_attr "length" "4")]
121 (define_insn "unspec_flmism"
122 [(set (match_operand:SI 0 "register_operand" "=r")
123 (unspec:SI [(match_operand:SI 1 "register_operand" "r")
124 (match_operand:SI 2 "register_operand" "r")] UNSPEC_FLMISM))]
127 [(set_attr "type" "alu")
128 (set_attr "length" "4")]
131 ;;Unaligned Load/Store
133 (define_expand "unaligned_load_hw"
134 [(set (match_operand:HI 0 "register_operand" "")
135 (unspec:HI [(mem:HI (match_operand:SI 1 "register_operand" ""))] UNSPEC_UALOAD_HW))]
138 operands[0] = simplify_gen_subreg (SImode, operands[0],
139 GET_MODE (operands[0]), 0);
142 nds32_expand_unaligned_load (operands, HImode);
146 emit_insn (gen_unaligned_load_w (operands[0],
147 gen_rtx_MEM (SImode, operands[1])));
149 if (WORDS_BIG_ENDIAN)
150 emit_insn (gen_lshrsi3 (operands[0], operands[0], GEN_INT(16)));
152 emit_insn (gen_andsi3 (operands[0], operands[0], GEN_INT (0xffff)));
158 (define_expand "unaligned_loadsi"
159 [(set (match_operand:SI 0 "register_operand" "=r")
160 (unspec:SI [(mem:SI (match_operand:SI 1 "register_operand" "r"))] UNSPEC_UALOAD_W))]
164 nds32_expand_unaligned_load (operands, SImode);
166 emit_insn (gen_unaligned_load_w (operands[0],
167 gen_rtx_MEM (SImode, (operands[1]))));
171 (define_insn "unaligned_load_w"
172 [(set (match_operand:SI 0 "register_operand" "= r")
173 (unspec:SI [(match_operand:SI 1 "nds32_lmw_smw_base_operand" " Umw")] UNSPEC_UALOAD_W))]
176 return nds32_output_lmw_single_word (operands);
178 [(set_attr "type" "load")
179 (set_attr "length" "4")]
182 (define_expand "unaligned_loaddi"
183 [(set (match_operand:DI 0 "register_operand" "=r")
184 (unspec:DI [(mem:DI (match_operand:SI 1 "register_operand" "r"))] UNSPEC_UALOAD_DW))]
189 nds32_expand_unaligned_load (operands, DImode);
192 emit_insn (gen_unaligned_load_dw (operands[0], operands[1]));
196 (define_insn "unaligned_load_dw"
197 [(set (match_operand:DI 0 "register_operand" "=r")
198 (unspec:DI [(mem:DI (match_operand:SI 1 "register_operand" "r"))] UNSPEC_UALOAD_DW))]
202 otherops[0] = gen_rtx_REG (SImode, REGNO (operands[0]));
203 otherops[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
204 otherops[2] = operands[1];
206 output_asm_insn ("lmw.bi\t%0, [%2], %1, 0", otherops);
209 [(set_attr "type" "load")
210 (set_attr "length" "4")]
213 (define_expand "unaligned_store_hw"
214 [(set (mem:SI (match_operand:SI 0 "register_operand" ""))
215 (unspec:HI [(match_operand:HI 1 "register_operand" "")] UNSPEC_UASTORE_HW))]
218 operands[1] = simplify_gen_subreg (SImode, operands[1],
219 GET_MODE (operands[1]), 0);
220 nds32_expand_unaligned_store (operands, HImode);
224 (define_expand "unaligned_storesi"
225 [(set (mem:SI (match_operand:SI 0 "register_operand" "r"))
226 (unspec:SI [(match_operand:SI 1 "register_operand" "r")] UNSPEC_UASTORE_W))]
230 nds32_expand_unaligned_store (operands, SImode);
232 emit_insn (gen_unaligned_store_w (gen_rtx_MEM (SImode, operands[0]),
237 (define_insn "unaligned_store_w"
238 [(set (match_operand:SI 0 "nds32_lmw_smw_base_operand" "=Umw")
239 (unspec:SI [(match_operand:SI 1 "register_operand" " r")] UNSPEC_UASTORE_W))]
242 return nds32_output_smw_single_word (operands);
244 [(set_attr "type" "store")
245 (set_attr "length" "4")]
248 (define_expand "unaligned_storedi"
249 [(set (mem:DI (match_operand:SI 0 "register_operand" "r"))
250 (unspec:DI [(match_operand:DI 1 "register_operand" "r")] UNSPEC_UASTORE_DW))]
254 nds32_expand_unaligned_store (operands, DImode);
256 emit_insn (gen_unaligned_store_dw (operands[0], operands[1]));
260 (define_insn "unaligned_store_dw"
261 [(set (mem:DI (match_operand:SI 0 "register_operand" "r"))
262 (unspec:DI [(match_operand:DI 1 "register_operand" "r")] UNSPEC_UASTORE_DW))]
266 otherops[0] = gen_rtx_REG (SImode, REGNO (operands[1]));
267 otherops[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
268 otherops[2] = operands[0];
270 output_asm_insn ("smw.bi\t%0, [%2], %1, 0", otherops);
273 [(set_attr "type" "store")
274 (set_attr "length" "4")]
277 ;; ------------------------------------------------------------------------