GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/theory/bv/slicer.cpp Lines: 1 32 3.1 %
Date: 2021-08-14 Branches: 2 64 3.1 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Liana Hadarean, Aina Niemetz
4
 *
5
 * This file is part of the cvc5 project.
6
 *
7
 * Copyright (c) 2009-2021 by the authors listed in the file AUTHORS
8
 * in the top-level source directory and their institutional affiliations.
9
 * All rights reserved.  See the file COPYING in the top-level source
10
 * directory for licensing information.
11
 * ****************************************************************************
12
 *
13
 * Bitvector theory.
14
 */
15
#include "theory/bv/slicer.h"
16
17
#include <sstream>
18
19
#include "theory/bv/theory_bv_utils.h"
20
#include "theory/rewriter.h"
21
22
using namespace std;
23
24
namespace cvc5 {
25
namespace theory {
26
namespace bv {
27
28
/**
29
 * Base
30
 *
31
 */
32
Base::Base(uint32_t size)
33
  : d_size(size),
34
    d_repr(size/32 + (size % 32 == 0? 0 : 1), 0)
35
{
36
  Assert(d_size > 0);
37
}
38
39
void Base::sliceAt(Index index)
40
{
41
  Index vector_index = index / 32;
42
  if (vector_index == d_repr.size())
43
    return;
44
45
  Index int_index = index % 32;
46
  uint32_t bit_mask = 1u << int_index;
47
  d_repr[vector_index] = d_repr[vector_index] | bit_mask;
48
}
49
50
bool Base::isCutPoint (Index index) const
51
{
52
  // there is an implicit cut point at the end and begining of the bv
53
  if (index == d_size || index == 0)
54
    return true;
55
56
  Index vector_index = index / 32;
57
  Assert(vector_index < d_size);
58
  Index int_index = index % 32;
59
  uint32_t bit_mask = 1u << int_index;
60
61
  return (bit_mask & d_repr[vector_index]) != 0;
62
}
63
64
std::string Base::debugPrint() const {
65
  std::ostringstream os;
66
  os << "[";
67
  bool first = true;
68
  for (int i = d_size - 1; i >= 0; --i) {
69
    if (isCutPoint(i)) {
70
      if (first)
71
        first = false;
72
      else
73
        os <<"| ";
74
75
      os << i ;
76
    }
77
  }
78
  os << "]";
79
  return os.str();
80
}
81
82
83
}  // namespace bv
84
}  // namespace theory
85
29340
}  // namespace cvc5