]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/config/avr/driver-avr.c
Update Copyright years for files modified in 2011 and/or 2012.
[thirdparty/gcc.git] / gcc / config / avr / driver-avr.c
CommitLineData
795cff42 1/* Subroutines for the gcc driver.
71e45bc2 2 Copyright (C) 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
795cff42 3 Contributed by Anatoly Sokolov <aesok@post.ru>
4
5This file is part of GCC.
6
7GCC is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 3, or (at your option)
10any later version.
11
12GCC is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with GCC; see the file COPYING3. If not see
19<http://www.gnu.org/licenses/>. */
20
21#include "config.h"
22#include "system.h"
23#include "coretypes.h"
24#include "tm.h"
795cff42 25
26/* Current architecture. */
27const struct base_arch_s *avr_current_arch = NULL;
28
29/* Current device. */
30const struct mcu_type_s *avr_current_device = NULL;
31
32/* Initialize avr_current_arch and avr_current_device variables. */
33
34static void
35avr_set_current_device (const char *name)
36{
37
38 if (NULL != avr_current_arch)
39 return;
40
41 for (avr_current_device = avr_mcu_types; avr_current_device->name;
42 avr_current_device++)
43 {
44 if (strcmp (avr_current_device->name, name) == 0)
45 break;
46 }
47
48 avr_current_arch = &avr_arch_types[avr_current_device->arch];
49}
50
51/* Returns command line parameters that describe the device architecture. */
52
53const char *
54avr_device_to_arch (int argc, const char **argv)
55{
56 if (0 == argc)
36f949a2 57 return NULL;
795cff42 58
59 avr_set_current_device (argv[0]);
60
61 return concat ("-m ", avr_current_arch->arch_name, NULL);
62}
63
64/* Returns command line parameters that describe start of date section. */
65
66const char *
67avr_device_to_data_start (int argc, const char **argv)
68{
69 unsigned long data_section_start;
70 char data_section_start_str[16];
71
72 if (0 == argc)
36f949a2 73 return NULL;
795cff42 74
75 avr_set_current_device (argv[0]);
76
77 if (avr_current_device->data_section_start
78 == avr_current_arch->default_data_section_start)
79 return NULL;
80
81 data_section_start = 0x800000 + avr_current_device->data_section_start;
82
83 snprintf (data_section_start_str, sizeof(data_section_start_str) - 1,
84 "0x%lX", data_section_start);
85
86 return concat ("-Tdata ", data_section_start_str, NULL);
87}
88
89/* Returns command line parameters that describe the device startfile. */
90
91const char *
92avr_device_to_startfiles (int argc, const char **argv)
93{
94 if (0 == argc)
36f949a2 95 return NULL;
795cff42 96
97 avr_set_current_device (argv[0]);
98
99 return concat ("crt", avr_current_device->library_name, ".o%s", NULL);
100}
101
102/* Returns command line parameters that describe the device library. */
103
104const char *
105avr_device_to_devicelib (int argc, const char **argv)
106{
107 if (0 == argc)
36f949a2 108 return NULL;
795cff42 109
110 avr_set_current_device (argv[0]);
111
112 return concat ("-l", avr_current_device->library_name, NULL);
113}
114
d32d7e3a 115const char*
116avr_device_to_sp8 (int argc, const char **argv)
117{
118 if (0 == argc)
119 return NULL;
120
121 avr_set_current_device (argv[0]);
122
123 /* Leave "avr2" and "avr25" alone. These two architectures are
124 the only ones that mix devices with 8-bit SP and 16-bit SP.
125 -msp8 is set by mmultilib machinery. */
126
127 if (avr_current_device->macro == NULL
128 && (avr_current_device->arch == ARCH_AVR2
129 || avr_current_device->arch == ARCH_AVR25))
130 return "";
131
132 return avr_current_device->short_sp
133 ? "-msp8"
134 : "%<msp8";
135}