186 defines.push_back(
"__LITTLE_ENDIAN__");
219 defines.push_back(
"__x86_64__");
221 defines.push_back(
"__amd64__");
225 defines.push_back(
"__LITTLE_ENDIAN__");
247 if(subarch==
"powerpc")
252 if(subarch==
"ppc64le")
265 defines.push_back(
"__powerpc");
266 defines.push_back(
"__powerpc__");
267 defines.push_back(
"__POWERPC__");
271 defines.push_back(
"__BIG_ENDIAN__");
273 if(subarch!=
"powerpc")
275 defines.push_back(
"__powerpc64");
276 defines.push_back(
"__powerpc64__");
277 defines.push_back(
"__PPC64__");
278 defines.push_back(
"__ppc64__");
279 if(subarch==
"ppc64le")
281 defines.push_back(
"_CALL_ELF=2");
282 defines.push_back(
"__LITTLE_ENDIAN__");
286 defines.push_back(
"_CALL_ELF=1");
287 defines.push_back(
"__BIG_ENDIAN__");
330 defines.push_back(
"__aarch64__");
334 defines.push_back(
"__ARM_PCS_VFP");
338 if(subarch ==
"arm64")
367 defines.push_back(
"__alpha__");
389 if(subarch==
"mipsel" ||
391 subarch==
"mipsn32el" ||
403 if(subarch==
"mipsel" ||
404 subarch==
"mipsn32el" ||
419 "_MIPS_SZPTR="+std::to_string(
config.ansi_c.pointer_width));
508 defines.push_back(
"__s390x__");
530 if(subarch==
"sparc64")
548 defines.push_back(
"__sparc__");
549 if(subarch==
"sparc64")
550 defines.push_back(
"__arch64__");
616 defines.push_back(
"__ILP32__");
618 defines.push_back(
"__x86_64__");
619 defines.push_back(
"__amd64__");
740 defines.push_back(
"__loongarch__");
771 defines.push_back(
"__EMSCRIPTEN__");
791#if defined(__APPLE__)
794#elif defined(__FreeBSD__) || defined(__OpenBSD__)
825 ansi_c.NULL_is_zero=
false;
826 ansi_c.arch_is_x86_family =
false;
827 ansi_c.set_argument_evaluation_order();
829 if(
sizeof(
long int)==8)
834 else if(arch==
"alpha")
835 ansi_c.set_arch_spec_alpha();
836 else if(arch==
"arm64" ||
840 ansi_c.set_arch_spec_arm(arch);
841 else if(arch==
"mips64el" ||
847 ansi_c.set_arch_spec_mips(arch);
848 else if(arch==
"powerpc" ||
851 ansi_c.set_arch_spec_power(arch);
852 else if(arch ==
"riscv64")
853 ansi_c.set_arch_spec_riscv64();
854 else if(arch==
"sparc" ||
856 ansi_c.set_arch_spec_sparc(arch);
857 else if(arch==
"ia64")
858 ansi_c.set_arch_spec_ia64();
859 else if(arch==
"s390x")
860 ansi_c.set_arch_spec_s390x();
861 else if(arch==
"s390")
862 ansi_c.set_arch_spec_s390();
864 ansi_c.set_arch_spec_x32();
865 else if(arch==
"v850")
866 ansi_c.set_arch_spec_v850();
867 else if(arch==
"hppa")
868 ansi_c.set_arch_spec_hppa();
870 ansi_c.set_arch_spec_sh4();
871 else if(arch==
"x86_64")
872 ansi_c.set_arch_spec_x86_64();
873 else if(arch==
"i386")
874 ansi_c.set_arch_spec_i386();
875 else if(arch ==
"loongarch64")
876 ansi_c.set_arch_spec_loongarch64();
877 else if(arch ==
"emscripten")
878 ansi_c.set_arch_spec_emscripten();
883 ansi_c.set_arch_spec_i386();
896 const std::string &argument,
897 const std::size_t pointer_width)
899 const auto throw_for_reason = [&](
const std::string &reason) {
901 "Value of \"" + argument +
"\" given for object-bits is " + reason +
902 ". object-bits must be positive and less than the pointer width (" +
903 std::to_string(pointer_width) +
") ",
908 throw_for_reason(
"not a valid unsigned integer");
909 if(*object_bits == 0 || *object_bits >= pointer_width)
910 throw_for_reason(
"out of range");
924 ansi_c.single_precision_constant=
false;
925 ansi_c.allow_anonymous_struct_embedding =
false;
926 ansi_c.for_has_scope=
true;
927 ansi_c.ts_18661_3_Floatn_types=
false;
928 ansi_c.__float128_is_keyword =
false;
929 ansi_c.float16_type =
false;
938 ansi_c.NULL_is_zero=
reinterpret_cast<size_t>(
nullptr)==0;
947 if(cmdline.
isset(
"function"))
950 if(cmdline.
isset(
'D'))
953 if(cmdline.
isset(
'I'))
956 if(cmdline.
isset(
"classpath"))
962 else if(cmdline.
isset(
"cp"))
971 const char *CLASSPATH=getenv(
"CLASSPATH");
972 if(CLASSPATH!=
nullptr)
978 if(cmdline.
isset(
"main-class"))
981 if(cmdline.
isset(
"include"))
993 if(cmdline.
isset(
"i386-linux"))
998 else if(cmdline.
isset(
"i386-win32") ||
999 cmdline.
isset(
"win32"))
1004 else if(cmdline.
isset(
"winx64"))
1009 else if(cmdline.
isset(
"i386-macos"))
1014 else if(cmdline.
isset(
"ppc-macos"))
1020 if(cmdline.
isset(
"arch"))
1025 if(cmdline.
isset(
"os"))
1037 if(cmdline.
isset(
"gcc"))
1046 ansi_c.defines.push_back(
"__CYGWIN__");
1050 ansi_c.defines.push_back(
"__int64=long long");
1062#elif defined(__FreeBSD__) || defined(__OpenBSD__)
1073 else if(os==
"macos")
1082 ansi_c.__float128_is_keyword =
true;
1083 ansi_c.float16_type =
true;
1087 else if(os ==
"linux" || os ==
"solaris" || os ==
"netbsd" || os ==
"hurd")
1094 else if(os ==
"freebsd" || os ==
"openbsd")
1103 ansi_c.__float128_is_keyword =
true;
1104 ansi_c.float16_type =
true;
1118 ansi_c.gcc__float128_type =
true;
1130 ansi_c.wchar_t_width=2*8;
1131 ansi_c.wchar_t_is_unsigned=
true;
1135 if(arch ==
"x86_64" && cmdline.
isset(
"gcc"))
1136 ansi_c.long_double_width=16*8;
1138 ansi_c.long_double_width=8*8;
1140 else if(os ==
"macos" && arch ==
"arm64")
1144 ansi_c.char_is_unsigned =
false;
1145 ansi_c.long_double_width = 8 * 8;
1149 (arch ==
"powerpc" || arch ==
"ppc64" || arch ==
"ppc64le"))
1157 if(arch == this_arch && os == this_os)
1158 ansi_c.long_double_width =
sizeof(
long double) * CHAR_BIT;
1159 else if(arch ==
"ppc64le")
1160 ansi_c.long_double_width = 16 * 8;
1162 ansi_c.long_double_width = 8 * 8;
1167 if(arch==this_arch && os==this_os)
1170 ansi_c.int_width ==
sizeof(
int) * CHAR_BIT,
1171 "int width shall be equal to the system int width");
1173 ansi_c.long_int_width ==
sizeof(
long) * CHAR_BIT,
1174 "long int width shall be equal to the system long int width");
1176 ansi_c.bool_width ==
sizeof(
bool) * CHAR_BIT,
1177 "bool width shall be equal to the system bool width");
1179 ansi_c.char_width ==
sizeof(
char) * CHAR_BIT,
1180 "char width shall be equal to the system char width");
1182 ansi_c.short_int_width ==
sizeof(
short) * CHAR_BIT,
1183 "short int width shall be equal to the system short int width");
1185 ansi_c.long_long_int_width ==
sizeof(
long long) * CHAR_BIT,
1186 "long long int width shall be equal to the system long long int width");
1188 ansi_c.pointer_width ==
sizeof(
void *) * CHAR_BIT,
1189 "pointer width shall be equal to the system pointer width");
1191 ansi_c.single_width ==
sizeof(
float) * CHAR_BIT,
1192 "float width shall be equal to the system float width");
1194 ansi_c.double_width ==
sizeof(
double) * CHAR_BIT,
1195 "double width shall be equal to the system double width");
1197 ansi_c.char_is_unsigned ==
1198 (
static_cast<char>((1 << CHAR_BIT) - 1) == (1 << CHAR_BIT) - 1),
1199 "char_is_unsigned flag shall indicate system char unsignedness");
1204 ansi_c.long_double_width ==
sizeof(
long double) * CHAR_BIT,
1205 "long double width shall be equal to the system long double width");
1211 if(cmdline.
isset(
"16"))
1214 if(cmdline.
isset(
"32"))
1217 if(cmdline.
isset(
"64"))
1220 if(cmdline.
isset(
"LP64"))
1223 if(cmdline.
isset(
"ILP64"))
1226 if(cmdline.
isset(
"LLP64"))
1229 if(cmdline.
isset(
"ILP32"))
1232 if(cmdline.
isset(
"LP32"))
1235 if(cmdline.
isset(
"string-abstraction"))
1236 ansi_c.string_abstraction=
true;
1238 ansi_c.string_abstraction=
false;
1240 if(cmdline.
isset(
"dfcc-debug-lib"))
1241 ansi_c.dfcc_debug_lib =
true;
1243 ansi_c.dfcc_debug_lib =
false;
1245 if(cmdline.
isset(
"dfcc-simple-invalid-pointer-model"))
1246 ansi_c.simple_invalid_pointer_model =
true;
1248 ansi_c.simple_invalid_pointer_model =
false;
1250 if(cmdline.
isset(
"no-library"))
1253 if(cmdline.
isset(
"little-endian"))
1256 if(cmdline.
isset(
"big-endian"))
1259 if(cmdline.
isset(
"little-endian") &&
1260 cmdline.
isset(
"big-endian"))
1263 if(cmdline.
isset(
"unsigned-char"))
1264 ansi_c.char_is_unsigned=
true;
1266 if(cmdline.
isset(
"round-to-even") ||
1267 cmdline.
isset(
"round-to-nearest"))
1270 if(cmdline.
isset(
"round-to-plus-inf"))
1273 if(cmdline.
isset(
"round-to-minus-inf"))
1276 if(cmdline.
isset(
"round-to-zero"))
1279 if(cmdline.
isset(
"object-bits"))
1285 if(cmdline.
isset(
"malloc-fail-assert") && cmdline.
isset(
"malloc-fail-null"))
1288 "at most one malloc failure mode is acceptable",
"--malloc-fail-null"};
1290 if(cmdline.
isset(
"malloc-fail-null"))
1291 ansi_c.malloc_failure_mode =
ansi_c.malloc_failure_mode_return_null;
1292 if(cmdline.
isset(
"malloc-fail-assert"))
1293 ansi_c.malloc_failure_mode =
ansi_c.malloc_failure_mode_assert_then_assume;
1295 if(cmdline.
isset(
"malloc-may-fail"))
1297 ansi_c.malloc_may_fail =
true;
1299 if(cmdline.
isset(
"no-malloc-may-fail"))
1301 ansi_c.malloc_may_fail =
false;
1305 if(cmdline.
isset(
"c89"))
1308 if(cmdline.
isset(
"c99"))
1311 if(cmdline.
isset(
"c11"))
1314 if(cmdline.
isset(
"c17"))
1317 if(cmdline.
isset(
"c23"))
1320 if(cmdline.
isset(
"cpp98"))
1323 if(cmdline.
isset(
"cpp03"))
1326 if(cmdline.
isset(
"cpp11"))
1344 const auto pointer_bits_2log =
1346 if(
ansi_c.pointer_width - pointer_bits_2log - 1 <=
ansi_c.int_width)
1349 power(2,
config.ansi_c.int_width - pointer_bits_2log - 1);
1376 else if(
os==
"macos")
1386 const std::string &what)
1391 const bool not_found = ns.
lookup(
id, symbol);
1397 tmp.
id() == ID_address_of &&
1401 "symbol table configuration entry '" +
id2string(
id) +
1402 "' must be a string constant");
1409 const std::string &what)
1414 const bool not_found = ns.
lookup(
id, symbol);
1422 "symbol table configuration entry '" +
id2string(
id) +
1423 "' must be a constant");
1430 "symbol table configuration entry '" +
id2string(
id) +
1431 "' must be convertible to mp_integer");
1495 "argument_evaluation_order") !=
1498 ansi_c.argument_evaluation_order =
1522 const symbolt &entry_point_symbol=*maybe_symbol;
1524 if(entry_point_symbol.
mode==ID_java)
1526 else if(entry_point_symbol.
mode==ID_C)
1528 else if(entry_point_symbol.
mode==ID_cpp)
1532 "object_bits should fit into pointer width");
1538 return "Running with "+std::to_string(
bv_encoding.object_bits)+
1542 (
bv_encoding.is_object_bits_default ?
"default" :
"user-specified")+
1554 this_arch =
"alpha";
1555 #elif defined(__armel__)
1556 this_arch =
"armel";
1557 #elif defined(__aarch64__)
1558 this_arch =
"arm64";
1559 #elif defined(__arm__)
1560 #ifdef __ARM_PCS_VFP
1561 this_arch =
"armhf";
1565 #elif defined(_MIPSEL)
1566 #if _MIPS_SIM==_ABIO32
1567 this_arch =
"mipsel";
1568 #elif _MIPS_SIM==_ABIN32
1569 this_arch =
"mipsn32el";
1571 this_arch =
"mips64el";
1573 #elif defined(__mips__)
1574 #if _MIPS_SIM==_ABIO32
1576 #elif _MIPS_SIM==_ABIN32
1577 this_arch =
"mipsn32";
1579 this_arch =
"mips64";
1581 #elif defined(__powerpc__)
1582 #if defined(__ppc64__) || defined(__PPC64__) || \
1583 defined(__powerpc64__) || defined(__POWERPC64__)
1584 #ifdef __LITTLE_ENDIAN__
1585 this_arch =
"ppc64le";
1587 this_arch =
"ppc64";
1590 this_arch =
"powerpc";
1592 #elif defined(__riscv)
1593 this_arch =
"riscv64";
1594 #elif defined(__sparc__)
1596 this_arch =
"sparc64";
1598 this_arch =
"sparc";
1600 #elif defined(__ia64__)
1602 #elif defined(__s390x__)
1603 this_arch =
"s390x";
1604 #elif defined(__s390__)
1606 #elif defined(__x86_64__)
1610 this_arch =
"x86_64";
1612 #elif defined(__i386__)
1614 #elif defined(_WIN64)
1615 this_arch =
"x86_64";
1616 #elif defined(_WIN32)
1618 #elif defined(__hppa__)
1620 #elif defined(__sh__)
1622 #elif defined(__loongarch__)
1623 this_arch =
"loongarch64";
1624 #elif defined(__EMSCRIPTEN__)
1625 this_arch =
"emscripten";
1628 this_arch =
"unknown";
1640 const char cp_separator =
';';
1642 const char cp_separator =
':';
1645 std::vector<std::string> class_path =
1647 java.classpath.insert(
1648 java.classpath.end(), class_path.begin(), class_path.end());
1662 this_os =
"openbsd";
1672 this_os =
"emscripten";
1701 const auto bits_for_positive_offset = offset_bits - 1;
std::string get_value(char option) const
virtual bool isset(char option) const
const std::list< std::string > & get_values(const std::string &option) const
Globally accessible architectural configuration.
void set_object_bits_from_symbol_table(const symbol_table_baset &)
Sets the number of bits used for object addresses.
void set_arch(const irep_idt &)
struct configt::bv_encodingt bv_encoding
bool set(const cmdlinet &cmdline)
std::string object_bits_info()
void set_classpath(const std::string &cp)
mp_integer max_malloc_size() const
The maximum allocation size is determined by the number of bits that are left in the pointer of width...
void set_from_symbol_table(const symbol_table_baset &)
static irep_idt this_architecture()
std::optional< std::string > main
struct configt::javat java
static irep_idt this_operating_system()
struct configt::ansi_ct ansi_c
Base class for all expressions.
bool is_constant() const
Return whether the expression is a constant.
Thrown when users pass incorrect command line arguments, for example passing no files to analysis or ...
const irep_idt & get(const irep_idt &name) const
const irep_idt & id() const
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
bool lookup(const irep_idt &name, const symbolt *&symbol) const override
See documentation for namespace_baset::lookup().
The symbol table base class interface.
const symbolt * lookup(const irep_idt &name) const
Find a symbol in the symbol table for read-only access.
const symbolst & symbols
Read-only field, used to look up symbols given their names.
exprt value
Initial value of symbol.
irep_idt mode
Language mode.
configt::bv_encodingt parse_object_bits_encoding(const std::string &argument, const std::size_t pointer_width)
Parses the object_bits argument from the command line arguments.
static unsigned unsigned_from_ns(const namespacet &ns, const std::string &what)
static irep_idt string_from_ns(const namespacet &ns, const std::string &what)
const std::string & id2string(const irep_idt &d)
API to expression classes for Pointers.
const address_of_exprt & to_address_of_expr(const exprt &expr)
Cast an exprt to an address_of_exprt.
bool simplify(exprt &expr, const namespacet &ns)
#define UNREACHABLE
This should be used to mark dead code.
#define DATA_INVARIANT(CONDITION, REASON)
This condition should be used to document that assumptions that are made on goto_functions,...
#define PRECONDITION(CONDITION)
#define INVARIANT(CONDITION, REASON)
This macro uses the wrapper function 'invariant_violated_string'.
const index_exprt & to_index_expr(const exprt &expr)
Cast an exprt to an index_exprt.
const constant_exprt & to_constant_expr(const exprt &expr)
Cast an exprt to a constant_exprt.
std::optional< T > string2optional(std::string_view str, int base=10)
Convert a string to an integer, given the base of the representation, works with signed and unsigned ...
void split_string(std::string_view s, char delim, std::vector< std::string > &result, bool strip, bool remove_empty)
std::size_t long_double_width
void set_arch_spec_riscv64()
void set_arch_spec_loongarch64()
void set_ILP32()
int=32, long=32, pointer=32
void set_arch_spec_v850()
Sets up the widths of variables for the Renesas V850.
argument_evaluation_ordert argument_evaluation_order
argument_evaluation_ordert
void set_arch_spec_hppa()
static std::string os_to_string(ost)
std::size_t pointer_width
void set_ILP64()
int=64, long=64, pointer=64
void set_arch_spec_sparc(const irep_idt &subarch)
static ost string_to_os(const std::string &)
std::list< std::string > defines
void set_argument_evaluation_order()
Sets the architectural parameter recording the order in which compilers evaluate the arguments of a f...
void set_LLP64()
int=32, long=32, pointer=64
void set_arch_spec_arm(const irep_idt &subarch)
std::size_t wchar_t_width
@ malloc_failure_mode_none
static c_standardt default_c_standard()
void set_arch_spec_alpha()
void set_arch_spec_power(const irep_idt &subarch)
void set_arch_spec_s390()
void set_LP64()
int=32, long=64, pointer=64
void set_arch_spec_x86_64()
void set_LP32()
int=16, long=32, pointer=32
std::size_t memory_operand_size
std::size_t long_long_int_width
void set_arch_spec_s390x()
std::size_t long_int_width
void set_arch_spec_mips(const irep_idt &subarch)
void set_arch_spec_i386()
std::size_t short_int_width
void set_arch_spec_ia64()
void set_arch_spec_emscripten()
bool is_object_bits_default
static cpp_standardt default_cpp_standard()