Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for TC4 devices #7

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
17 changes: 15 additions & 2 deletions gcc/common/config/tricore/tricore-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,24 @@ tric_opt_error (int value, const char *op1, const char *op2, location_t loc)
}



/*
Configures options for the specific devices. For example, tc45xx shall have soft double precision hardware by default
*/
void tric_configure_options_for_device(const char *name, struct gcc_options *opts)
{
const char* tc45xx = "tc45xx";
if(name
&& 0 == strcmp (name, tc45xx))
{
//By default, tc45xx shall have soft double precision operations
opts->x_target_flags |= MASK_DP_SOFT_FLOAT;
}
}

/* Implement `TARGET_HANDLE_OPTION' */

static bool
tric_handle_option (struct gcc_options *opts ATTRIBUTE_UNUSED,
tric_handle_option (struct gcc_options *opts,
struct gcc_options *opts_set ATTRIBUTE_UNUSED,
const struct cl_decoded_option *decoded, location_t loc)
{
Expand Down Expand Up @@ -237,6 +249,7 @@ tric_handle_option (struct gcc_options *opts ATTRIBUTE_UNUSED,

case OPT_mcpu_:
tric_set_device (arg);
tric_configure_options_for_device(arg, opts);
return true;

case OPT_mtc:
Expand Down
8 changes: 6 additions & 2 deletions gcc/config/tricore/devices.def
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,9 @@ DEF_DEVICE ("tc2d5d", "0x2d5d", "161", "tc161")
DEF_DEVICE ("tc33xx", "0x3300", "162", "tc162")
DEF_DEVICE ("tc38xx", "0x3800", "162", "tc162") /* since v4.9.1.0-infineon-2.0 */
DEF_DEVICE ("tc39xx", "0x3900", "162", "tc162") /* since v4.6.6.0 */
DEF_DEVICE ("tc49Ax", "0x4900", "18", "tc18") /* updated */
DEF_DEVICE ("tc4DAx", "0x4D00", "18", "tc18") /* updated */
DEF_DEVICE ("tc49Ax", "0x49A0", "18", "tc18")
DEF_DEVICE ("tc4DAx", "0x4D00", "18", "tc18")
DEF_DEVICE ("tc49xx", "0x4900", "18", "tc18")
DEF_DEVICE ("tc48xx", "0x4800", "18", "tc18")
DEF_DEVICE ("tc46xx", "0x4600", "18", "tc18")
DEF_DEVICE ("tc45xx", "0x4500", "18", "tc18")
191 changes: 186 additions & 5 deletions gcc/config/tricore/memory.x
Original file line number Diff line number Diff line change
Expand Up @@ -1064,7 +1064,7 @@ __ISTACK_SIZE = 256;
__HEAP_MIN = 8K;
__CSA_SIZE = 16K;

#elif __TRICORE_NAME__ == 0x4900
#elif __TRICORE_NAME__ == 0x49A0
#define __MESSAGE__ "Using wrong Memory Map. This Map is for TC49Ax"
#define I_C_F_B 0x80000000
#define I_C_F_S 4M
Expand Down Expand Up @@ -1097,10 +1097,191 @@ __CSA_SIZE = 16K;
#define P_D_R_B 0
#define P_D_R_S 0

__USTACK_SIZE = 4K;
__ISTACK_SIZE = 256;
__HEAP_MIN = 8K;
__CSA_SIZE = 16K;
/* Values taken from TC4 iLLDs */
__USTACK_SIZE = 2K;
__ISTACK_SIZE = 1k;
__HEAP_MIN = 4K;
__CSA_SIZE = 8K;

#elif __TRICORE_NAME__ == 0x4900
#define __MESSAGE__ "Using wrong Memory Map. This Map is for TC49xx"
#define I_C_F_B 0x80000000
#define I_C_F_S 4M
#define I_C_F_B_0 0x80000000
#define I_C_F_S_0 4M
#define I_C_F_B_1 0x80400000
#define I_C_F_S_1 4M
#define I_C_F_B_2 0x80800000
#define I_C_F_S_2 4M
#define I_C_F_B_3 0x80C00000
#define I_C_F_S_3 4M
#define I_C_F_B_4 0x81000000
#define I_C_F_S_4 4M
#define I_D_F_B 0xAE000000
#define I_D_F_S 1M
#define I_D_F_B_0 0xAE000000
#define I_D_F_S_0 1M
#define E_C_R_B 0
#define E_C_R_S 0
#define E_D_R_B 0
#define E_D_R_S 0
#define I_C_R_B 0xC0000000
#define I_C_R_S 64K
#define I_D_R_B 0xD0000000
#define I_D_R_S 240K
#define P_C_R_B 0
#define P_C_R_S 0
#define P_D_R_B 0
#define P_D_R_S 0

/* Values taken from TC4 iLLDs */
__USTACK_SIZE = 2K;
__ISTACK_SIZE = 1k;
__HEAP_MIN = 4K;
__CSA_SIZE = 8K;

#elif __TRICORE_NAME__ == 0x4D00
#define __MESSAGE__ "Using wrong Memory Map. This Map is for TC4Dxx"
#define I_C_F_B 0x80000000
#define I_C_F_S 4M
#define I_C_F_B_0 0x80000000
#define I_C_F_S_0 4M
#define I_C_F_B_1 0x80400000
#define I_C_F_S_1 4M
#define I_C_F_B_2 0x80800000
#define I_C_F_S_2 2M
#define I_C_F_B_3 0x80A00000
#define I_C_F_S_3 4M
#define I_C_F_B_4 0x80E00000
#define I_C_F_S_4 4M
#define I_C_F_B_5 0x81200000
#define I_C_F_S_5 2M
#define I_D_F_B 0xAE000000
#define I_D_F_S 1M
#define I_D_F_B_0 0xAE000000
#define I_D_F_S_0 1M
#define E_C_R_B 0
#define E_C_R_S 0
#define E_D_R_B 0
#define E_D_R_S 0
#define I_C_R_B 0xC0000000
#define I_C_R_S 64K
#define I_D_R_B 0xD0000000
#define I_D_R_S 240K
#define P_C_R_B 0
#define P_C_R_S 0
#define P_D_R_B 0
#define P_D_R_S 0

/* Values taken from TC4 iLLDs */
__USTACK_SIZE = 2K;
__ISTACK_SIZE = 1k;
__HEAP_MIN = 4K;
__CSA_SIZE = 8K;


#elif __TRICORE_NAME__ == 0x4800
#define __MESSAGE__ "Using wrong Memory Map. This Map is for TC48xx"
#define I_C_F_B 0x80000000
#define I_C_F_S 4M
#define I_C_F_B_0 0x80000000
#define I_C_F_S_0 4M
#define I_C_F_B_1 0x80400000
#define I_C_F_S_1 4M
#define I_C_F_B_2 0x80800000
#define I_C_F_S_2 4M
#define I_C_F_B_3 0x80C00000
#define I_C_F_S_3 4M
#define I_D_F_B 0xAE000000
#define I_D_F_S 256K
#define I_D_F_B_0 0xAE000000
#define I_D_F_S_0 256K
#define E_C_R_B 0
#define E_C_R_S 0
#define E_D_R_B 0
#define E_D_R_S 0
#define I_C_R_B 0xC0000000
#define I_C_R_S 64K
#define I_D_R_B 0xD0000000
#define I_D_R_S 240K
#define P_C_R_B 0
#define P_C_R_S 0
#define P_D_R_B 0
#define P_D_R_S 0

/* Values taken from TC4 iLLDs */
__USTACK_SIZE = 2K;
__ISTACK_SIZE = 1k;
__HEAP_MIN = 4K;
__CSA_SIZE = 8K;


#elif __TRICORE_NAME__ == 0x4600
#define __MESSAGE__ "Using wrong Memory Map. This Map is for TC46xx"
#define I_C_F_B 0x80000000
#define I_C_F_S 4M
#define I_C_F_B_0 0x80000000
#define I_C_F_S_0 4M
#define I_C_F_B_1 0x80400000
#define I_C_F_S_1 4M
#define I_C_F_B_2 0x80800000
#define I_C_F_S_2 2M
#define I_C_F_B_3 0x80A00000
#define I_C_F_S_3 2M
#define I_D_F_B 0xAE000000
#define I_D_F_S 512K
#define I_D_F_B_0 0xAE000000
#define I_D_F_S_0 512K
#define E_C_R_B 0
#define E_C_R_S 0
#define E_D_R_B 0
#define E_D_R_S 0
#define I_C_R_B 0xC0000000
#define I_C_R_S 64K
#define I_D_R_B 0xD0000000
#define I_D_R_S 240K
#define P_C_R_B 0
#define P_C_R_S 0
#define P_D_R_B 0
#define P_D_R_S 0

/* Values taken from TC4 iLLDs */
__USTACK_SIZE = 2K;
__ISTACK_SIZE = 1k;
__HEAP_MIN = 4K;
__CSA_SIZE = 8K;


#elif __TRICORE_NAME__ == 0x4500
#define __MESSAGE__ "Using wrong Memory Map. This Map is for TC45xx"
#define I_C_F_B 0x80000000
#define I_C_F_S 2M
#define I_C_F_B_0 0x80000000
#define I_C_F_S_0 2M
#define I_C_F_B_1 0x80200000
#define I_C_F_S_1 2M
#define I_D_F_B 0xAE000000
#define I_D_F_S 64K
#define I_D_F_B_0 0xAE000000
#define I_D_F_S_0 64K
#define E_C_R_B 0
#define E_C_R_S 0
#define E_D_R_B 0
#define E_D_R_S 0
#define I_C_R_B 0xC0000000
#define I_C_R_S 32K
#define I_D_R_B 0xD0000000
#define I_D_R_S 240K
#define P_C_R_B 0
#define P_C_R_S 0
#define P_D_R_B 0
#define P_D_R_S 0

/* Values taken from TC4 iLLDs */
__USTACK_SIZE = 2K;
__ISTACK_SIZE = 1k;
__HEAP_MIN = 4K;
__CSA_SIZE = 8K;

#endif

Expand Down
8 changes: 6 additions & 2 deletions gcc/config/tricore/t-multilib
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ MULTILIB_MATCHES = \
mtc162=mcpu?tc38xx \
mtc162=mcpu?tc39xx \
mtc18=mcpu?tc49Ax \
mtc18=mcpu?tc4DAx
mtc18=mcpu?tc4DAx \
mtc18=mcpu?tc49xx \
mtc18=mcpu?tc48xx \
mtc18=mcpu?tc46xx \
mtc18=mcpu?tc45xx

TRIC_DEVICES = tc1796 tc1130 tc116x tc1161 tc1162 tc1762 tc1764 tc1766 tc1792 tc1920 tc1167 tc1197 tc1337 tc1367 tc1387 tc1724 tc1728 tc1736 tc1767 tc1782 tc1783 tc1784 tc1797 tc1791 tc1793 tc1798 tc22xx tc23xx tc26xx tc27xx tc29xx tc2d5d tc33xx tc38xx tc39xx tc49Ax tc4DAx
TRIC_DEVICES = tc1796 tc1130 tc116x tc1161 tc1162 tc1762 tc1764 tc1766 tc1792 tc1920 tc1167 tc1197 tc1337 tc1367 tc1387 tc1724 tc1728 tc1736 tc1767 tc1782 tc1783 tc1784 tc1797 tc1791 tc1793 tc1798 tc22xx tc23xx tc26xx tc27xx tc29xx tc2d5d tc33xx tc38xx tc39xx tc49Ax tc4DAx tc49xx tc48xx tc46xx tc45xx
12 changes: 10 additions & 2 deletions gcc/config/tricore/t-tricore
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,20 @@ install-devices: installdirs $(MEMORY_CPU) $(CRT0_CPU) $(CRT0_S) crti.S crtn.S
$(INSTALL_DATA) crt0-tc1x.S $(DESTDIR)$(libsubdir)
$(INSTALL_DATA) crt0-tc2x.S $(DESTDIR)$(libsubdir)

MULTILIB_OPTIONS = mtc131/mtc16/mtc161/mtc162/mtc18 fshort-double
MULTILIB_DIRNAMES = tc131 tc16 tc161 tc162 tc18 short-double
MULTILIB_OPTIONS = mtc131/mtc16/mtc161/mtc162/mtc18 fshort-double msoft-sp-float msoft-dp-float
MULTILIB_DIRNAMES = tc131 tc16 tc161 tc162 tc18 short-double soft-single-float soft-double-float
#MULTILIB_OPTIONS = mtc161 fshort-double
#MULTILIB_DIRNAMES = tc161 short-double

MULTILIB_EXCEPTIONS =
# a library with msoft-sp-float without any device specified is not interesting
MULTILIB_EXCEPTIONS += msoft-sp-float*
# a library with msoft-dp-float without any device specified is not interesting
MULTILIB_EXCEPTIONS += msoft-dp-float*
# msoft-dp-float makes no sense for tc131, which doesn't have a dp float hardware to disable
MULTILIB_EXCEPTIONS += mtc131/msoft-dp-float
# msoft-dp-float makes no sense for tc16*, which doesn't have a dp float hardware to disable
MULTILIB_EXCEPTIONS += mtc16*/msoft-dp-float

# MULTILIB_MATCHES
# TRIC_DEVICES
Expand Down
18 changes: 9 additions & 9 deletions gcc/config/tricore/tricore-devices.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,16 @@ tric_set_device (const char *name)
if (tric_core && tric_device)
return;
if(tric_core)
{
for (device = tric_devices; device->name != NULL; device++)
{
for (device = tric_devices; device->name != NULL; device++)
{
if (!STREQ (tric_core->name, device->core_mtc))
continue;
/* Found the device */
tric_device = device;
return;
}
if (!STREQ (tric_core->name, device->core_mtc))
continue;
/* Found the device */
tric_device = device;
return;
}
}
else
name = tric_devices[0].name;
}
Expand Down Expand Up @@ -161,4 +161,4 @@ tric_set_device (const char *name)

break;
}
}
}
12 changes: 12 additions & 0 deletions gcc/config/tricore/tricore-mcpu.opt
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,18 @@ Enum(tric_mcpu) String(tc49Ax) Value(35)
EnumValue
Enum(tric_mcpu) String(tc4DAx) Value(36)

EnumValue
Enum(tric_mcpu) String(tc49xx) Value(36)

EnumValue
Enum(tric_mcpu) String(tc45xx) Value(37)

EnumValue
Enum(tric_mcpu) String(tc48xx) Value(38)

EnumValue
Enum(tric_mcpu) String(tc46xx) Value(39)

EnumValue
Enum(tric_merrata) String(cpu048) Value(tric_errata_cpu048)

Expand Down
4 changes: 3 additions & 1 deletion gcc/config/tricore/tricore.c
Original file line number Diff line number Diff line change
Expand Up @@ -5370,7 +5370,7 @@ tric_option_override (void)
flag_finite_math_only = 1;
}

if (flag_pic)
if (flag_pic == 1 || flag_pic == 2)
error ("%qs: position independent code is not supported for "
"this machine, try %qs", "-fpic", "-mcode-pic");

Expand Down Expand Up @@ -10130,6 +10130,8 @@ tric_eabi_round_type_align (tree type, unsigned computed, unsigned specified)
unsigned
tric_eabi_data_alignment (tree type, unsigned basic_align)
{
if(tric_opt_force_align_arrays == 0) return basic_align;

unsigned best_align = BITS_PER_WORD;
if (TREE_CODE (type) == ARRAY_TYPE)
{
Expand Down
3 changes: 3 additions & 0 deletions gcc/config/tricore/tricore.h
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,9 @@ typedef struct GTY(()) tric_section

#define INIT_EXPANDERS tric_init_expanders()

#define SP_FPU_ENABLED (!TARGET_SP_SOFT_FLOAT)
#define DP_FPU_ENABLED (!TARGET_DP_SOFT_FLOAT)

/* Helper functions for late backend optimizations */
bool copy_constant_string (rtx_insn *, rtx *);
bool remove_strcmp (rtx_insn *, rtx *);
Loading