comparison gcc/config/nds32/nds32-memory-manipulation.c @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
comparison
equal deleted inserted replaced
131:84e7813d76e9 145:1830386684a0
1 /* Auxiliary functions for expand movmem, setmem, cmpmem, load_multiple 1 /* Auxiliary functions for expand cpymem, setmem, cmpmem, load_multiple
2 and store_multiple pattern of Andes NDS32 cpu for GNU compiler 2 and store_multiple pattern of Andes NDS32 cpu for GNU compiler
3 Copyright (C) 2012-2018 Free Software Foundation, Inc. 3 Copyright (C) 2012-2020 Free Software Foundation, Inc.
4 Contributed by Andes Technology Corporation. 4 Contributed by Andes Technology Corporation.
5 5
6 This file is part of GCC. 6 This file is part of GCC.
7 7
8 GCC is free software; you can redistribute it and/or modify it 8 GCC is free software; you can redistribute it and/or modify it
118 } 118 }
119 } 119 }
120 120
121 /* ------------------------------------------------------------------------ */ 121 /* ------------------------------------------------------------------------ */
122 122
123 /* Auxiliary function for expand movmem pattern. */ 123 /* Auxiliary function for expand cpymem pattern. */
124 124
125 static bool 125 static bool
126 nds32_expand_movmemsi_loop_unknown_size (rtx dstmem, rtx srcmem, 126 nds32_expand_cpymemsi_loop_unknown_size (rtx dstmem, rtx srcmem,
127 rtx size, 127 rtx size,
128 rtx alignment) 128 rtx alignment)
129 { 129 {
130 /* Emit loop version of movmem. 130 /* Emit loop version of cpymem.
131 131
132 andi $size_least_3_bit, $size, #~7 132 andi $size_least_3_bit, $size, #~7
133 add $dst_end, $dst, $size 133 add $dst_end, $dst, $size
134 move $dst_itr, $dst 134 move $dst_itr, $dst
135 move $src_itr, $src 135 move $src_itr, $src
252 252
253 return true; 253 return true;
254 } 254 }
255 255
256 static bool 256 static bool
257 nds32_expand_movmemsi_loop_known_size (rtx dstmem, rtx srcmem, 257 nds32_expand_cpymemsi_loop_known_size (rtx dstmem, rtx srcmem,
258 rtx size, rtx alignment) 258 rtx size, rtx alignment)
259 { 259 {
260 rtx dst_base_reg, src_base_reg; 260 rtx dst_base_reg, src_base_reg;
261 rtx dst_itr, src_itr; 261 rtx dst_itr, src_itr;
262 rtx dstmem_m, srcmem_m, dst_itr_m, src_itr_m; 262 rtx dstmem_m, srcmem_m, dst_itr_m, src_itr_m;
286 dst_base_reg = copy_to_mode_reg (Pmode, XEXP (dstmem, 0)); 286 dst_base_reg = copy_to_mode_reg (Pmode, XEXP (dstmem, 0));
287 src_base_reg = copy_to_mode_reg (Pmode, XEXP (srcmem, 0)); 287 src_base_reg = copy_to_mode_reg (Pmode, XEXP (srcmem, 0));
288 288
289 if (total_bytes < 8) 289 if (total_bytes < 8)
290 { 290 {
291 /* Emit total_bytes less than 8 loop version of movmem. 291 /* Emit total_bytes less than 8 loop version of cpymem.
292 add $dst_end, $dst, $size 292 add $dst_end, $dst, $size
293 move $dst_itr, $dst 293 move $dst_itr, $dst
294 .Lbyte_mode_loop: 294 .Lbyte_mode_loop:
295 lbi.bi $tmp, [$src_itr], #1 295 lbi.bi $tmp, [$src_itr], #1
296 sbi.bi $tmp, [$dst_itr], #1 296 sbi.bi $tmp, [$dst_itr], #1
319 SImode, 1, byte_mode_loop); 319 SImode, 1, byte_mode_loop);
320 return true; 320 return true;
321 } 321 }
322 else if (total_bytes % 8 == 0) 322 else if (total_bytes % 8 == 0)
323 { 323 {
324 /* Emit multiple of 8 loop version of movmem. 324 /* Emit multiple of 8 loop version of cpymem.
325 325
326 add $dst_end, $dst, $size 326 add $dst_end, $dst, $size
327 move $dst_itr, $dst 327 move $dst_itr, $dst
328 move $src_itr, $src 328 move $src_itr, $src
329 329
368 Pmode, 1, double_word_mode_loop); 368 Pmode, 1, double_word_mode_loop);
369 } 369 }
370 else 370 else
371 { 371 {
372 /* Handle size greater than 8, and not a multiple of 8. */ 372 /* Handle size greater than 8, and not a multiple of 8. */
373 return nds32_expand_movmemsi_loop_unknown_size (dstmem, srcmem, 373 return nds32_expand_cpymemsi_loop_unknown_size (dstmem, srcmem,
374 size, alignment); 374 size, alignment);
375 } 375 }
376 376
377 return true; 377 return true;
378 } 378 }
379 379
380 static bool 380 static bool
381 nds32_expand_movmemsi_loop (rtx dstmem, rtx srcmem, 381 nds32_expand_cpymemsi_loop (rtx dstmem, rtx srcmem,
382 rtx size, rtx alignment) 382 rtx size, rtx alignment)
383 { 383 {
384 if (CONST_INT_P (size)) 384 if (CONST_INT_P (size))
385 return nds32_expand_movmemsi_loop_known_size (dstmem, srcmem, 385 return nds32_expand_cpymemsi_loop_known_size (dstmem, srcmem,
386 size, alignment); 386 size, alignment);
387 else 387 else
388 return nds32_expand_movmemsi_loop_unknown_size (dstmem, srcmem, 388 return nds32_expand_cpymemsi_loop_unknown_size (dstmem, srcmem,
389 size, alignment); 389 size, alignment);
390 } 390 }
391 391
392 static bool 392 static bool
393 nds32_expand_movmemsi_unroll (rtx dstmem, rtx srcmem, 393 nds32_expand_cpymemsi_unroll (rtx dstmem, rtx srcmem,
394 rtx total_bytes, rtx alignment) 394 rtx total_bytes, rtx alignment)
395 { 395 {
396 rtx dst_base_reg, src_base_reg; 396 rtx dst_base_reg, src_base_reg;
397 rtx tmp_reg; 397 rtx tmp_reg;
398 int maximum_bytes; 398 int maximum_bytes;
531 /* Function to move block memory content by 531 /* Function to move block memory content by
532 using load_multiple and store_multiple. 532 using load_multiple and store_multiple.
533 This is auxiliary extern function to help create rtx template. 533 This is auxiliary extern function to help create rtx template.
534 Check nds32-multiple.md file for the patterns. */ 534 Check nds32-multiple.md file for the patterns. */
535 bool 535 bool
536 nds32_expand_movmemsi (rtx dstmem, rtx srcmem, rtx total_bytes, rtx alignment) 536 nds32_expand_cpymemsi (rtx dstmem, rtx srcmem, rtx total_bytes, rtx alignment)
537 { 537 {
538 if (nds32_expand_movmemsi_unroll (dstmem, srcmem, total_bytes, alignment)) 538 if (nds32_expand_cpymemsi_unroll (dstmem, srcmem, total_bytes, alignment))
539 return true; 539 return true;
540 540
541 if (!optimize_size && optimize > 2) 541 if (!optimize_size && optimize > 2)
542 return nds32_expand_movmemsi_loop (dstmem, srcmem, total_bytes, alignment); 542 return nds32_expand_cpymemsi_loop (dstmem, srcmem, total_bytes, alignment);
543 543
544 return false; 544 return false;
545 } 545 }
546 546
547 /* ------------------------------------------------------------------------ */ 547 /* ------------------------------------------------------------------------ */