ESBMC
Efficient SMT-based Context-Bounded Model Checker
Loading...
Searching...
No Matches
c_builtins.h
Go to the documentation of this file.
1#pragma once
2
3#include <string_view>
4#include <util/base/prefix.h>
5
9constexpr int esbmc_object_size_whole = 4;
10
24
35inline bit_scan_endt bit_scan_builtin(std::string_view symname)
36{
37 constexpr std::string_view prefix = "c:@F@__builtin_";
38 if (!has_prefix(symname, prefix))
40 symname.remove_prefix(prefix.size());
41
43 std::size_t stem = 3;
44 if (has_prefix(symname, "clz"))
46 else if (has_prefix(symname, "ctz"))
48 else if (has_prefix(symname, "ffs"))
50 else if (has_prefix(symname, "clrsb"))
51 {
53 stem = 5;
54 }
55 else
57 symname.remove_prefix(stem);
58
59 for (const std::string_view width : {"", "l", "ll"})
60 if (symname == width)
61 return end;
62
63 // Only clz/ctz have the 16-bit and type-generic spellings.
66
67 for (const std::string_view width : {"s", "g"})
68 if (symname == width)
69 return end;
71}
constexpr int esbmc_object_size_whole
An __ESBMC_builtin_object_size type outside GCC's 0..3: the size of the whole object,...
Definition c_builtins.h:9
bit_scan_endt bit_scan_builtin(std::string_view symname)
Recognise the __builtin_clz*‍/__builtin_ctz* family from a symbol name such as "c:@F@__builtin_clzll"...
Definition c_builtins.h:35
bit_scan_endt
Which bit of the operand a __builtin_clz*‍/ctz*‍/ffs*‍/clrsb* call reports.
Definition c_builtins.h:13
@ none
Definition c_builtins.h:14
@ leading
Definition c_builtins.h:15
@ redundant_sign
clrsb: the leading bits equal to the sign bit, less the sign bit itself; defined for every operand.
Definition c_builtins.h:22
@ trailing
Definition c_builtins.h:16
@ first_set
ffs: the one-based index of the least-significant set bit, and 0 for a zero operand – defined there,...
Definition c_builtins.h:19
bool has_prefix(std::string_view s, std::string_view prefix)
Definition prefix.h:6