ESBMC
Efficient SMT-based Context-Bounded Model Checker
Loading...
Searching...
No Matches
run_builtin.cpp File Reference
#include <cassert>
#include <goto-symex/engine/goto_symex.h>
#include <string>
#include <util/arith/arith_tools.h>
#include <util/lang/c_builtins.h>
#include <util/lang/c_types.h>
#include <util/expr/expr_util.h>
#include <irep2/irep2.h>
#include <util/message/message.h>
#include <util/irep/migrate.h>
#include <util/base/prefix.h>
#include <util/irep/std_types.h>
#include <algorithm>
Include dependency graph for run_builtin.cpp:

Functions

static bool ends_with (std::string const &value, std::string const &ending)
static expr2tc build_bit_scan (const code_function_call2t &func_call, bit_scan_endt end)
 Value of a __builtin_clz*‍/ctz*‍/ffs*‍/clrsb* call.
static expr2tc build_rotate (const code_function_call2t &func_call, bool left)
 Value of a __builtin_rotateleft{8,16,32,64}/__builtin_rotateright* call.
static expr2tc build_bitreverse (const code_function_call2t &func_call)
 Value of a __builtin_bitreverse{8,16,32,64} call: swap adjacent bits, then 2-bit groups, then 4-bit groups, doubling until the halves are swapped.
static expr2tc build_bit_builtin (const code_function_call2t &func_call, const std::string &symname)
 Value of a bit-counting, rotating or bit-reversing builtin call, or nil if symname is not one.
static bool is_constant_operand (const expr2tc &op)
static expr2tc overflow_operation (const code_function_call2t &func_call, const std::string &symname)
 The operation of a __builtin_{s,u}{add,sub,mul}*_overflow call.

Function Documentation

◆ build_bit_builtin()

expr2tc build_bit_builtin ( const code_function_call2t & func_call,
const std::string & symname )
static

Value of a bit-counting, rotating or bit-reversing builtin call, or nil if symname is not one.

◆ build_bit_scan()

expr2tc build_bit_scan ( const code_function_call2t & func_call,
bit_scan_endt end )
static

Value of a __builtin_clz*‍/ctz*‍/ffs*‍/clrsb* call.

One encoding covers every spelling: the operand type fixes the bit width, and the directions differ only in which way the smear shifts. Zero is undefined for every form but the two-argument clzg/ctzg, ffs and clrsb; the optional UB assertion is added in goto-check (–clz-zero-check), with the other UB checks. See #4606, #6925, #183.

◆ build_bitreverse()

expr2tc build_bitreverse ( const code_function_call2t & func_call)
static

Value of a __builtin_bitreverse{8,16,32,64} call: swap adjacent bits, then 2-bit groups, then 4-bit groups, doubling until the halves are swapped.

◆ build_rotate()

expr2tc build_rotate ( const code_function_call2t & func_call,
bool left )
static

Value of a __builtin_rotateleft{8,16,32,64}/__builtin_rotateright* call.

The distance is taken modulo the width, and so is its complement, so a zero distance gives (x << 0) | (x >> 0) == x rather than a full-width shift.

◆ ends_with()

bool ends_with ( std::string const & value,
std::string const & ending )
inlinestatic

◆ is_constant_operand()

bool is_constant_operand ( const expr2tc & op)
static

◆ overflow_operation()

expr2tc overflow_operation ( const code_function_call2t & func_call,
const std::string & symname )
static

The operation of a __builtin_{s,u}{add,sub,mul}*_overflow call.