Mercurial > hg > CbC > CbC_gcc
comparison gcc/config/ft32/ft32.c @ 131:84e7813d76e9
gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 07:37:49 +0900 |
parents | 04ced10e8804 |
children | 1830386684a0 |
comparison
equal
deleted
inserted
replaced
111:04ced10e8804 | 131:84e7813d76e9 |
---|---|
1 /* Target Code for ft32 | 1 /* Target Code for ft32 |
2 Copyright (C) 2015-2017 Free Software Foundation, Inc. | 2 Copyright (C) 2015-2018 Free Software Foundation, Inc. |
3 Contributed by FTDI <support@ftdi.com> | 3 Contributed by FTDI <support@ftdi.com> |
4 | 4 |
5 This file is part of GCC. | 5 This file is part of GCC. |
6 | 6 |
7 GCC is free software; you can redistribute it and/or modify it | 7 GCC is free software; you can redistribute it and/or modify it |
15 License for more details. | 15 License for more details. |
16 | 16 |
17 You should have received a copy of the GNU General Public License | 17 You should have received a copy of the GNU General Public License |
18 along with GCC; see the file COPYING3. If not see | 18 along with GCC; see the file COPYING3. If not see |
19 <http://www.gnu.org/licenses/>. */ | 19 <http://www.gnu.org/licenses/>. */ |
20 | |
21 #define IN_TARGET_CODE 1 | |
20 | 22 |
21 #include "config.h" | 23 #include "config.h" |
22 #include "system.h" | 24 #include "system.h" |
23 #include "coretypes.h" | 25 #include "coretypes.h" |
24 #include "backend.h" | 26 #include "backend.h" |
261 const char * | 263 const char * |
262 ft32_load_immediate (rtx dst, int32_t i) | 264 ft32_load_immediate (rtx dst, int32_t i) |
263 { | 265 { |
264 char pattern[100]; | 266 char pattern[100]; |
265 | 267 |
266 if ((-524288 <= i) && (i <= 524287)) | 268 if (i >= -524288 && i <= 524287) |
267 { | 269 { |
268 sprintf (pattern, "ldk.l %%0,%d", i); | 270 sprintf (pattern, "ldk.l %%0,%d", i); |
269 output_asm_insn (pattern, &dst); | 271 output_asm_insn (pattern, &dst); |
270 } | 272 } |
271 else if ((-536870912 <= i) && (i <= 536870911)) | 273 else if (i >= -536870912 && i <= 536870911) |
272 { | 274 { |
273 ft32_load_immediate (dst, i >> 10); | 275 ft32_load_immediate (dst, i >> 10); |
274 sprintf (pattern, "ldl.l %%0,%%0,%d", i & 1023); | 276 sprintf (pattern, "ldl.l %%0,%%0,%d", i & 1023); |
275 output_asm_insn (pattern, &dst); | 277 output_asm_insn (pattern, &dst); |
276 } | 278 } |
279 int rd; // rotate distance | 281 int rd; // rotate distance |
280 uint32_t u = i; | 282 uint32_t u = i; |
281 for (rd = 1; rd < 32; rd++) | 283 for (rd = 1; rd < 32; rd++) |
282 { | 284 { |
283 u = ((u >> 31) & 1) | (u << 1); | 285 u = ((u >> 31) & 1) | (u << 1); |
284 if ((-524288 <= (int32_t) u) && ((int32_t) u <= 524287)) | 286 if ((int32_t) u >= -524288 && (int32_t) u <= 524287) |
285 { | 287 { |
286 ft32_load_immediate (dst, (int32_t) u); | 288 ft32_load_immediate (dst, (int32_t) u); |
287 sprintf (pattern, "ror.l %%0,%%0,%d", rd); | 289 sprintf (pattern, "ror.l %%0,%%0,%d", rd); |
288 output_asm_insn (pattern, &dst); | 290 output_asm_insn (pattern, &dst); |
289 return ""; | 291 return ""; |
413 cfun->machine->callee_saved_reg_size += 4; | 415 cfun->machine->callee_saved_reg_size += 4; |
414 | 416 |
415 cfun->machine->size_for_adjusting_sp = | 417 cfun->machine->size_for_adjusting_sp = |
416 0 // crtl->args.pretend_args_size | 418 0 // crtl->args.pretend_args_size |
417 + cfun->machine->local_vars_size | 419 + cfun->machine->local_vars_size |
418 + (ACCUMULATE_OUTGOING_ARGS ? crtl->outgoing_args_size : 0); | 420 + (ACCUMULATE_OUTGOING_ARGS |
421 ? (HOST_WIDE_INT) crtl->outgoing_args_size : 0); | |
419 } | 422 } |
420 | 423 |
421 // Must use LINK/UNLINK when... | 424 // Must use LINK/UNLINK when... |
422 // the frame is bigger than 512 bytes so cannot just "SUB" from SP | 425 // the frame is bigger than 512 bytes so cannot just "SUB" from SP |
423 // the function actually uses $fp | 426 // the function actually uses $fp |
492 RTX_FRAME_RELATED_P (insn) = 1; | 495 RTX_FRAME_RELATED_P (insn) = 1; |
493 } | 496 } |
494 } | 497 } |
495 } | 498 } |
496 | 499 |
497 if (65536 <= cfun->machine->size_for_adjusting_sp) | 500 if (cfun->machine->size_for_adjusting_sp >= 65536) |
498 { | 501 { |
499 error ("stack frame must be smaller than 64K"); | 502 error ("stack frame must be smaller than 64K"); |
500 return; | 503 return; |
501 } | 504 } |
502 if (must_link ()) | 505 if (must_link ()) |
864 | 867 |
865 static bool | 868 static bool |
866 ft32_addr_space_legitimate_address_p (machine_mode mode, rtx x, bool strict, | 869 ft32_addr_space_legitimate_address_p (machine_mode mode, rtx x, bool strict, |
867 addr_space_t as ATTRIBUTE_UNUSED) | 870 addr_space_t as ATTRIBUTE_UNUSED) |
868 { | 871 { |
872 int max_offset = TARGET_FT32B ? 16384 : 128; | |
873 | |
869 if (mode != BLKmode) | 874 if (mode != BLKmode) |
870 { | 875 { |
871 if (GET_CODE (x) == PLUS) | 876 if (GET_CODE (x) == PLUS) |
872 { | 877 { |
873 rtx op1, op2; | 878 rtx op1, op2; |
874 op1 = XEXP (x, 0); | 879 op1 = XEXP (x, 0); |
875 op2 = XEXP (x, 1); | 880 op2 = XEXP (x, 1); |
876 if (GET_CODE (op1) == REG | 881 if (GET_CODE (op1) == REG |
877 && CONST_INT_P (op2) | 882 && CONST_INT_P (op2) |
878 && INTVAL (op2) >= -128 | 883 && (-max_offset <= INTVAL (op2)) |
879 && INTVAL (op2) < 128 && reg_ok_for_base_p (op1, strict)) | 884 && (INTVAL (op2) < max_offset) |
885 && reg_ok_for_base_p (op1, strict)) | |
880 goto yes; | 886 goto yes; |
881 if (GET_CODE (op1) == SYMBOL_REF && CONST_INT_P (op2)) | 887 if (GET_CODE (op1) == SYMBOL_REF && CONST_INT_P (op2)) |
882 goto yes; | 888 goto yes; |
883 } | 889 } |
884 if (REG_P (x) && reg_ok_for_base_p (x, strict)) | 890 if (REG_P (x) && reg_ok_for_base_p (x, strict)) |