1 /* Subroutines for the gcc driver.
2 Copyright (C) 2009-2013 Free Software Foundation, Inc.
3 Contributed by Anatoly Sokolov <aesok@post.ru>
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
12 GCC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public 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/>. */
23 #include "coretypes.h"
26 /* Current architecture. */
27 const avr_arch_t
*avr_current_arch
= NULL
;
30 const avr_mcu_t
*avr_current_device
= NULL
;
32 /* Initialize avr_current_arch and avr_current_device variables. */
35 avr_set_current_device (const char *name
)
38 if (NULL
!= avr_current_arch
)
41 for (avr_current_device
= avr_mcu_types
; avr_current_device
->name
;
44 if (strcmp (avr_current_device
->name
, name
) == 0)
48 avr_current_arch
= &avr_arch_types
[avr_current_device
->arch
];
51 /* Returns command line parameters to pass to as. */
54 avr_device_to_as (int argc
, const char **argv
)
59 avr_set_current_device (argv
[0]);
61 return concat ("-mmcu=", avr_current_arch
->arch_name
,
62 avr_current_device
->errata_skip
? "" : " -mno-skip-bug",
66 /* Returns command line parameters to pass to ld. */
69 avr_device_to_ld (int argc
, const char **argv
)
74 avr_set_current_device (argv
[0]);
76 return concat ("-m ", avr_current_arch
->arch_name
, NULL
);
79 /* Returns command line parameters that describe start of date section. */
82 avr_device_to_data_start (int argc
, const char **argv
)
84 unsigned long data_section_start
;
85 char data_section_start_str
[16];
90 avr_set_current_device (argv
[0]);
92 if (avr_current_device
->data_section_start
93 == avr_current_arch
->default_data_section_start
)
96 data_section_start
= 0x800000 + avr_current_device
->data_section_start
;
98 snprintf (data_section_start_str
, sizeof(data_section_start_str
) - 1,
99 "0x%lX", data_section_start
);
101 return concat ("-Tdata ", data_section_start_str
, NULL
);
104 /* Returns command line parameters that describe the device startfile. */
107 avr_device_to_startfiles (int argc
, const char **argv
)
112 avr_set_current_device (argv
[0]);
114 return concat ("crt", avr_current_device
->library_name
, ".o%s", NULL
);
117 /* Returns command line parameters that describe the device library. */
120 avr_device_to_devicelib (int argc
, const char **argv
)
125 avr_set_current_device (argv
[0]);
127 return concat ("-l", avr_current_device
->library_name
, NULL
);
131 avr_device_to_sp8 (int argc
, const char **argv
)
136 avr_set_current_device (argv
[0]);
138 /* Leave "avr2" and "avr25" alone. These two architectures are
139 the only ones that mix devices with 8-bit SP and 16-bit SP.
140 -msp8 is set by mmultilib machinery. */
142 if (avr_current_device
->macro
== NULL
143 && (avr_current_device
->arch
== ARCH_AVR2
144 || avr_current_device
->arch
== ARCH_AVR25
))
147 return avr_current_device
->short_sp