carl  24.04
Computer ARithmetic Library
BVTermType.h
Go to the documentation of this file.
1 #pragma once
2 
4 
5 #include <iostream>
6 #include <type_traits>
7 
8 namespace carl {
9 
10  enum class BVTermType {
11  CONSTANT,
12  VARIABLE,
13  CONCAT, EXTRACT,
14  NOT,
15  NEG,
16  AND, OR, XOR, NAND, NOR, XNOR,
18  EQ,
21  EXT_U, EXT_S,
22  REPEAT
23  };
24 
25  inline auto typeId(BVTermType type) {
26  return static_cast<std::underlying_type<BVTermType>::type>(type);
27  }
28 
29  inline std::ostream& operator<<(std::ostream& os, BVTermType type) {
30  switch(type) {
31  case BVTermType::CONSTANT: return os << "CONSTANT";
32  case BVTermType::VARIABLE: return os << "VARIABLE";
33  case BVTermType::CONCAT: return os << "concat";
34  case BVTermType::EXTRACT: return os << "extract";
35  case BVTermType::NOT: return os << "bvnot";
36  case BVTermType::NEG: return os << "bvneg";
37  case BVTermType::AND: return os << "bvand";
38  case BVTermType::OR: return os << "bvor";
39  case BVTermType::XOR: return os << "bvxor";
40  case BVTermType::NAND: return os << "bvnand";
41  case BVTermType::NOR: return os << "bvnor";
42  case BVTermType::XNOR: return os << "bvxnor";
43  case BVTermType::ADD: return os << "bvadd";
44  case BVTermType::SUB: return os << "bvsub";
45  case BVTermType::MUL: return os << "bvmul";
46  case BVTermType::DIV_U: return os << "bvudiv";
47  case BVTermType::DIV_S: return os << "bvsdiv";
48  case BVTermType::MOD_U: return os << "bvurem";
49  case BVTermType::MOD_S1: return os << "bvsrem";
50  case BVTermType::MOD_S2: return os << "bvsmod";
51  case BVTermType::EQ: return os << "bvcomp";
52  case BVTermType::LSHIFT: return os << "bvshl";
53  case BVTermType::RSHIFT_LOGIC: return os << "bvlshr";
54  case BVTermType::RSHIFT_ARITH: return os << "bvashr";
55  case BVTermType::LROTATE: return os << "rotate_left";
56  case BVTermType::RROTATE: return os << "rotate_right";
57  case BVTermType::EXT_U: return os << "zero_extend";
58  case BVTermType::EXT_S: return os << "sign_extend";
59  case BVTermType::REPEAT: return os << "repeat";
60  default:
61  CARL_LOG_ERROR("carl.formula.bv", "Tried to print an unknown value for BVTermType: " << typeId(type));
62  return os << "unknown";
63  }
64  }
65 
66  inline bool typeIsUnary(BVTermType type) {
67  return (
68  type == BVTermType::NOT || type == BVTermType::NEG || type == BVTermType::LROTATE
69  || type == BVTermType::RROTATE || type == BVTermType::REPEAT || type == BVTermType::EXT_U
70  || type == BVTermType::EXT_S
71  );
72  }
73 
74  inline bool typeIsBinary(BVTermType type) {
75  return (
76  type == BVTermType::CONCAT || type == BVTermType::AND || type == BVTermType::OR
77  || type == BVTermType::XOR || type == BVTermType::NAND || type == BVTermType::NOR
78  || type == BVTermType::XNOR || type == BVTermType::ADD || type == BVTermType::SUB
79  || type == BVTermType::MUL || type == BVTermType::DIV_U || type == BVTermType::DIV_S
80  || type == BVTermType::MOD_U || type == BVTermType::MOD_S1 || type == BVTermType::MOD_S2
81  || type == BVTermType::EQ || type == BVTermType::LSHIFT || type == BVTermType::RSHIFT_LOGIC
82  || type == BVTermType::RSHIFT_ARITH
83  );
84  }
85 }
A small wrapper that configures logging for carl.
#define CARL_LOG_ERROR(channel, msg)
Definition: carl-logging.h:40
carl is the main namespace for the library.
bool typeIsUnary(BVTermType type)
Definition: BVTermType.h:66
BVTermType
Definition: BVTermType.h:10
bool typeIsBinary(BVTermType type)
Definition: BVTermType.h:74
std::ostream & operator<<(std::ostream &os, const BasicConstraint< Poly > &c)
Prints the given constraint on the given stream.
auto typeId(BVTermType type)
Definition: BVTermType.h:25