CBMC
Loading...
Searching...
No Matches
armcc_mode.cpp
Go to the documentation of this file.
1/*******************************************************************\
2
3Module: Command line option container
4
5Author: CM Wintersteiger, 2006
6
7\*******************************************************************/
8
11
12#include "armcc_mode.h"
13
14#ifdef _WIN32
15#define EX_OK 0
16#define EX_USAGE 64
17#define EX_SOFTWARE 70
18#else
19#include <sysexits.h>
20#endif
21
22#include <iostream>
23
24#include <util/message.h>
25#include <util/config.h>
26
27#include "compile.h"
28
31{
32 if(cmdline.isset('?') || cmdline.isset("help"))
33 {
34 help();
35 return EX_OK;
36 }
37
39
40 #if 0
41 bool act_as_ld=
42 has_prefix(base_name, "ld") ||
43 has_prefix(base_name, "goto-ld") ||
44 has_prefix(base_name, "link") ||
45 has_prefix(base_name, "goto-link");
46 #endif
47
48 const auto default_verbosity =
50 const auto verbosity = messaget::eval_verbosity(
53
55 log.debug() << "ARM mode" << messaget::eom;
56
57 // model validation
58 compiler.validate_goto_model = cmdline.isset("validate-goto-model");
59
60 // get configuration
62
64 config.ansi_c.arch="arm";
65
66 // determine actions to be taken
67
68 if(cmdline.isset('E'))
70 else if(cmdline.isset('c') || cmdline.isset('S'))
72 else
74
75 if(cmdline.isset('U'))
76 config.ansi_c.undefines=cmdline.get_values('U');
77
78 if(cmdline.isset('L'))
79 compiler.library_paths=cmdline.get_values('L');
80 // Don't add the system paths!
81
82 // these take precedence over -I
83 if(cmdline.isset('J'))
84 {
85 const std::list<std::string> &values=
87
88 for(std::list<std::string>::const_iterator
89 it=values.begin();
90 it!=values.end();
91 it++)
92 config.ansi_c.preprocessor_options.push_back("-J"+*it);
93 }
94
95 if(cmdline.isset("preinclude="))
96 {
97 const std::list<std::string> &values=
98 cmdline.get_values("preinclude=");
99
100 for(std::list<std::string>::const_iterator
101 it=values.begin();
102 it!=values.end();
103 it++)
104 config.ansi_c.preprocessor_options.push_back("--preinclude="+*it);
105 }
106
107 // armcc's default is .o
108 compiler.object_file_extension =
109 cmdline.value_opt("default_extension=").value_or("o");
110
111 // note that ARM's default is "unsigned_chars",
112 // in contrast to gcc's default!
113 if(cmdline.isset("signed_chars"))
114 config.ansi_c.char_is_unsigned=false;
115 else
116 config.ansi_c.char_is_unsigned=true;
117
118 // ARM's default is 16 bits for wchar_t
119 if(cmdline.isset("wchar32"))
120 config.ansi_c.wchar_t_width=32;
121 else
122 config.ansi_c.wchar_t_width=16;
123
124 if(cmdline.isset('o'))
125 {
126 // given goto-armcc -o file1 -o file2, we output to file2, not file1
127 compiler.output_file_object=cmdline.get_values('o').back();
128 compiler.output_file_executable=cmdline.get_values('o').back();
129 }
130 else
131 {
132 compiler.output_file_object.clear();
133 compiler.output_file_executable="a.out";
134 }
135
136 if(verbosity > messaget::M_STATISTICS)
137 {
138 std::list<std::string>::iterator it;
139
140 std::cout << "Defines:\n";
141 for(it=config.ansi_c.defines.begin();
142 it!=config.ansi_c.defines.end();
143 it++)
144 {
145 std::cout << " " << (*it) << '\n';
146 }
147
148 std::cout << "Undefines:\n";
149 for(it=config.ansi_c.undefines.begin();
150 it!=config.ansi_c.undefines.end();
151 it++)
152 {
153 std::cout << " " << (*it) << '\n';
154 }
155
156 std::cout << "Preprocessor Options:\n";
157 for(it=config.ansi_c.preprocessor_options.begin();
158 it!=config.ansi_c.preprocessor_options.end();
159 it++)
160 {
161 std::cout << " " << (*it) << '\n';
162 }
163
164 std::cout << "Include Paths:\n";
165 for(it=config.ansi_c.include_paths.begin();
166 it!=config.ansi_c.include_paths.end();
167 it++)
168 {
169 std::cout << " " << (*it) << '\n';
170 }
171
172 std::cout << "Library Paths:\n";
173 for(it=compiler.library_paths.begin();
174 it!=compiler.library_paths.end();
175 it++)
176 {
177 std::cout << " " << (*it) << '\n';
178 }
179
180 std::cout << "Output file (object): "
181 << compiler.output_file_object << '\n';
182 std::cout << "Output file (executable): "
183 << compiler.output_file_executable << '\n';
184 }
185
186 // Parse input program, convert to goto program, write output
187 return compiler.doit() ? EX_USAGE : EX_OK;
188}
189
192{
193 std::cout << "goto-armcc understands the options "
194 << "of armcc plus the following.\n\n";
195}
configt config
Definition config.cpp:25
Base class for command line interpretation for CL.
virtual void clear()
Reset the abstract state.
Definition ai.h:265
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
Definition ai.h:562
gcc_message_handlert message_handler
Definition armcc_mode.h:37
int doit() final
does it.
armcc_cmdlinet & cmdline
Definition armcc_mode.h:36
void help_mode() final
display command line help
std::string get_value(char option) const
Definition cmdline.cpp:48
virtual bool isset(char option) const
Definition cmdline.cpp:30
std::optional< std::string > value_opt(char option) const
Definition cmdline.cpp:53
const std::list< std::string > & get_values(const std::string &option) const
Definition cmdline.cpp:119
@ PREPROCESS_ONLY
Definition compile.h:38
@ COMPILE_LINK_EXECUTABLE
Definition compile.h:43
@ COMPILE_ONLY
Definition compile.h:39
bool set(const cmdlinet &cmdline)
Definition config.cpp:863
struct configt::ansi_ct ansi_c
void print_warnings_as_errors(bool yes)
With yes set to true, prefix warnings with "error:" instead of "warning:".
const std::string base_name
void help()
display command line help
Class that provides messages with a built-in verbosity 'level'.
Definition message.h:154
static unsigned eval_verbosity(const std::string &user_input, const message_levelt default_verbosity, message_handlert &dest)
Parse a (user-)provided string as a verbosity level and set it as the verbosity of dest.
Definition message.cpp:105
@ M_STATISTICS
Definition message.h:170
@ M_ERROR
Definition message.h:169
@ M_WARNING
Definition message.h:169
static eomt eom
Definition message.h:289
Compile and link source and object files.
bool has_prefix(const std::string &s, const std::string &prefix)
Definition converter.cpp:13
double log(double x)
Definition math.c:2449