forked from jancarlsson/snarkfront
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEnumOps.cpp
50 lines (38 loc) · 1.15 KB
/
EnumOps.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "EnumOps.hpp"
using namespace std;
namespace snarkfront {
////////////////////////////////////////////////////////////////////////////////
// number of operator input arguments
//
#define DEFN_OPARGC(E, R) template <> size_t opArgc<E>(const E op) { return R; }
DEFN_OPARGC(LogicalOps, LogicalOps::CMPLMNT == op ? 1 : 2)
DEFN_OPARGC(ScalarOps, 2)
DEFN_OPARGC(BitwiseOps, BitwiseOps::CMPLMNT == op ? 1 : 2)
DEFN_OPARGC(EqualityCmp, 2)
DEFN_OPARGC(ScalarCmp, 2)
#undef DEFN_OPARGC
////////////////////////////////////////////////////////////////////////////////
// returns true for shift and rotate
//
bool isPermute(const BitwiseOps op) {
switch (op) {
case (BitwiseOps::SHL) :
case (BitwiseOps::SHR) :
case (BitwiseOps::ROTL) :
case (BitwiseOps::ROTR) :
return true;
default:
return false;
}
}
////////////////////////////////////////////////////////////////////////////////
// EQ --> SAME
// NEQ --> XOR
//
LogicalOps eqToLogical(const EqualityCmp op) {
switch (op) {
case (EqualityCmp::EQ) : return LogicalOps::SAME;
case (EqualityCmp::NEQ) : return LogicalOps::XOR;
}
}
} // namespace snarkfront