Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

compiler cleanup

  • Loading branch information...
commit 804c3a5904f63d030bc16df928cc0c955cbfd2d4 1 parent e88d399
Marco Pensallorto authored
22 src/model/compilers/algebra.cc
View
@@ -135,7 +135,7 @@ void Compiler::algebraic_plus(const Expr_ptr expr)
carry = f_enc.base().LEQ(tmp); /* c >= 0x10 */
/* x[i] = (x[i] + y[i] + c) % base */
- PUSH(tmp.Modulus(f_enc.base()));
+ PUSH_ADD(tmp.Modulus(f_enc.base()));
}
}
@@ -196,7 +196,7 @@ void Compiler::algebraic_mul(const Expr_ptr expr)
}
// return i-th digit of result
- PUSH(res[ndx_i]);
+ PUSH_ADD(res[ndx_i]);
}
}
@@ -225,7 +225,7 @@ void Compiler::algebraic_and(const Expr_ptr expr)
/* x[i] & y[i] */
unsigned ndx = width - i - 1;
- PUSH(lhs[ndx].BWTimes(rhs[ndx]));
+ PUSH_ADD(lhs[ndx].BWTimes(rhs[ndx]));
}
}
@@ -242,7 +242,7 @@ void Compiler::algebraic_or(const Expr_ptr expr)
/* x[i] | y[i] */
unsigned ndx = width - i - 1;
- PUSH(lhs[ndx].BWOr(rhs[ndx]));
+ PUSH_ADD(lhs[ndx].BWOr(rhs[ndx]));
}
}
@@ -259,7 +259,7 @@ void Compiler::algebraic_xor(const Expr_ptr expr)
/* x[i] ^ y[i] */
unsigned ndx = width - i - 1;
- PUSH(lhs[ndx].BWXor(rhs[ndx]));
+ PUSH_ADD(lhs[ndx].BWXor(rhs[ndx]));
}
}
@@ -339,7 +339,7 @@ void Compiler::algebraic_lshift(const Expr_ptr expr)
/* push result (reversed) */
for (unsigned i = 0; i < width; ++ i) {
unsigned ndx = width - i - 1;
- PUSH( res[ndx]);
+ PUSH_ADD( res[ndx]);
}
}
@@ -396,7 +396,7 @@ void Compiler::algebraic_rshift(const Expr_ptr expr)
/* push result (reversed) */
for (unsigned i = 0; i < width; ++ i) {
unsigned ndx = width - i - 1;
- PUSH(res[ndx]);
+ PUSH_ADD(res[ndx]);
}
}
@@ -415,7 +415,7 @@ void Compiler::algebraic_equals(const Expr_ptr expr)
}
/* just one result */
- PUSH(optimize_and_chain(tmp, width));
+ PUSH_ADD(optimize_and_chain(tmp, width));
}
void Compiler::algebraic_not_equals(const Expr_ptr expr)
@@ -483,7 +483,7 @@ void Compiler::algebraic_lt(const Expr_ptr expr)
}
/* just one predult */
- PUSH(pred);
+ PUSH_ADD(pred);
}
void Compiler::algebraic_le(const Expr_ptr expr)
@@ -514,7 +514,7 @@ void Compiler::algebraic_le(const Expr_ptr expr)
}
/* just one result */
- PUSH(pred);
+ PUSH_ADD(pred);
}
void Compiler::algebraic_ite(const Expr_ptr expr)
@@ -529,6 +529,6 @@ void Compiler::algebraic_ite(const Expr_ptr expr)
/* (cond) ? x[i] : y[i] */
for (unsigned i = 0; i < width; ++ i) {
unsigned ndx = width - i - 1;
- PUSH(cnd.Ite(lhs[ndx], rhs[ndx]));
+ PUSH_ADD(cnd.Ite(lhs[ndx], rhs[ndx]));
}
}
12 src/model/compilers/boolean.cc
View
@@ -46,7 +46,7 @@ void Compiler::boolean_not(const Expr_ptr expr)
void Compiler::boolean_and(const Expr_ptr expr)
{
POP_TWO(rhs, lhs);
- PUSH(lhs.Times(rhs)); /* 0, 1 logic uses arithmetic product for AND */
+ PUSH_ADD(lhs.Times(rhs)); /* 0, 1 logic uses arithmetic product for AND */
f_type_stack.pop_back(); // consume one, leave the other
}
@@ -54,7 +54,7 @@ void Compiler::boolean_and(const Expr_ptr expr)
void Compiler::boolean_or(const Expr_ptr expr)
{
POP_TWO(rhs, lhs);
- PUSH(lhs.Or(rhs));
+ PUSH_ADD(lhs.Or(rhs));
f_type_stack.pop_back(); // consume one, leave the other
}
@@ -62,7 +62,7 @@ void Compiler::boolean_or(const Expr_ptr expr)
void Compiler::boolean_xor(const Expr_ptr expr)
{
POP_TWO(rhs, lhs);
- PUSH(lhs.Xor(rhs));
+ PUSH_ADD(lhs.Xor(rhs));
f_type_stack.pop_back(); // consume one, leave the other
}
@@ -70,7 +70,7 @@ void Compiler::boolean_xor(const Expr_ptr expr)
void Compiler::boolean_xnor(const Expr_ptr expr)
{
POP_TWO(rhs, lhs);
- PUSH(lhs.Xnor(rhs));
+ PUSH_ADD(lhs.Xnor(rhs));
f_type_stack.pop_back(); // consume one, leave the other
}
@@ -78,7 +78,7 @@ void Compiler::boolean_xnor(const Expr_ptr expr)
void Compiler::boolean_implies(const Expr_ptr expr)
{
POP_TWO(rhs, lhs);
- PUSH(lhs.Cmpl().Or(rhs));
+ PUSH_ADD(lhs.Cmpl().Or(rhs));
f_type_stack.pop_back(); // consume one, leave the other
}
@@ -93,7 +93,7 @@ void Compiler::boolean_ite(const Expr_ptr expr)
{
POP_TWO(rhs, lhs);
POP_ADD(cnd);
- PUSH(cnd.Ite(lhs, rhs));
+ PUSH_ADD(cnd.Ite(lhs, rhs));
// consume two operand types, leave the third
f_type_stack.pop_back();
2  src/model/compilers/compiler.hh
View
@@ -66,7 +66,7 @@ typedef pair<ENCMap::iterator, bool> ENCHit;
}
/* shortcut for pushing */
-#define PUSH(add) f_add_stack.push_back(add)
+#define PUSH_ADD(add) f_add_stack.push_back(add)
class Compiler : public SimpleWalker {
public:
6 src/model/compilers/enumerative.cc
View
@@ -40,7 +40,7 @@
void Compiler::enumerative_equals(const Expr_ptr expr)
{
POP_TWO(rhs, lhs);
- PUSH(lhs.Equals(rhs));
+ PUSH_ADD(lhs.Equals(rhs));
f_type_stack.pop_back(); // consume one, leave the other
}
@@ -48,7 +48,7 @@ void Compiler::enumerative_equals(const Expr_ptr expr)
void Compiler::enumerative_not_equals(const Expr_ptr expr)
{
POP_TWO(rhs, lhs);
- PUSH(lhs.Equals(rhs).Cmpl());
+ PUSH_ADD(lhs.Equals(rhs).Cmpl());
f_type_stack.pop_back(); // consume one, leave the other
}
@@ -57,7 +57,7 @@ void Compiler::enumerative_ite(const Expr_ptr expr)
{
POP_TWO(rhs, lhs);
POP_ADD(cnd);
- PUSH(cnd.Ite(lhs, rhs));
+ PUSH_ADD(cnd.Ite(lhs, rhs));
// consume all, push rhs type
Type_ptr type = f_type_stack.back();
40 src/model/compilers/integer.cc
View
@@ -40,19 +40,19 @@
void Compiler::integer_neg(const Expr_ptr expr)
{
POP_ADD(lhs);
- PUSH(lhs.Negate());
+ PUSH_ADD(lhs.Negate());
}
void Compiler::integer_not(const Expr_ptr expr)
{
POP_ADD(lhs);
- PUSH(lhs.BWCmpl());
+ PUSH_ADD(lhs.BWCmpl());
}
void Compiler::integer_plus(const Expr_ptr expr)
{
POP_TWO(rhs, lhs);
- PUSH(lhs.Plus(rhs));
+ PUSH_ADD(lhs.Plus(rhs));
f_type_stack.pop_back(); // consume one, leave the other
}
@@ -60,7 +60,7 @@ void Compiler::integer_plus(const Expr_ptr expr)
void Compiler::integer_sub(const Expr_ptr expr)
{
POP_TWO(rhs, lhs);
- PUSH(lhs.Minus(rhs));
+ PUSH_ADD(lhs.Minus(rhs));
f_type_stack.pop_back(); // consume one, leave the other
}
@@ -68,7 +68,7 @@ void Compiler::integer_sub(const Expr_ptr expr)
void Compiler::integer_mul(const Expr_ptr expr)
{
POP_TWO(rhs, lhs);
- PUSH(lhs.Times(rhs));
+ PUSH_ADD(lhs.Times(rhs));
f_type_stack.pop_back(); // consume one, leave the other
}
@@ -76,7 +76,7 @@ void Compiler::integer_mul(const Expr_ptr expr)
void Compiler::integer_div(const Expr_ptr expr)
{
POP_TWO(rhs, lhs);
- PUSH(lhs.Divide(rhs));
+ PUSH_ADD(lhs.Divide(rhs));
f_type_stack.pop_back(); // consume one, leave the other
}
@@ -84,7 +84,7 @@ void Compiler::integer_div(const Expr_ptr expr)
void Compiler::integer_mod(const Expr_ptr expr)
{
POP_TWO(rhs, lhs);
- PUSH(lhs.Modulus(rhs));
+ PUSH_ADD(lhs.Modulus(rhs));
f_type_stack.pop_back(); // consume one, leave the other
}
@@ -92,7 +92,7 @@ void Compiler::integer_mod(const Expr_ptr expr)
void Compiler::integer_and(const Expr_ptr expr)
{
POP_TWO(rhs, lhs);
- PUSH(lhs.BWTimes(rhs)); /* bitwise integer arithmetic */
+ PUSH_ADD(lhs.BWTimes(rhs)); /* bitwise integer arithmetic */
f_type_stack.pop_back(); // consume one, leave the other
}
@@ -100,7 +100,7 @@ void Compiler::integer_and(const Expr_ptr expr)
void Compiler::integer_or(const Expr_ptr expr)
{
POP_TWO(rhs, lhs);
- PUSH(lhs.BWOr(rhs)); /* bitwise integer arithmetic */
+ PUSH_ADD(lhs.BWOr(rhs)); /* bitwise integer arithmetic */
f_type_stack.pop_back(); // consume one, leave the other
}
@@ -108,7 +108,7 @@ void Compiler::integer_or(const Expr_ptr expr)
void Compiler::integer_xor(const Expr_ptr expr)
{
POP_TWO(rhs, lhs);
- PUSH(lhs.BWXor(rhs)); /* bitwise integer arithmetic */
+ PUSH_ADD(lhs.BWXor(rhs)); /* bitwise integer arithmetic */
f_type_stack.pop_back(); // consume one, leave the other
}
@@ -116,7 +116,7 @@ void Compiler::integer_xor(const Expr_ptr expr)
void Compiler::integer_xnor(const Expr_ptr expr)
{
POP_TWO(rhs, lhs);
- PUSH(lhs.BWXnor(rhs)); /* bitwise integer arithmetic */
+ PUSH_ADD(lhs.BWXnor(rhs)); /* bitwise integer arithmetic */
f_type_stack.pop_back(); // consume one, leave the other
}
@@ -124,7 +124,7 @@ void Compiler::integer_xnor(const Expr_ptr expr)
void Compiler::integer_implies(const Expr_ptr expr)
{
POP_TWO(rhs, lhs);
- PUSH(lhs.BWCmpl().BWOr(rhs)); /* bitwise integer arithmetic */
+ PUSH_ADD(lhs.BWCmpl().BWOr(rhs)); /* bitwise integer arithmetic */
f_type_stack.pop_back(); // consume one, leave the other
}
@@ -132,7 +132,7 @@ void Compiler::integer_implies(const Expr_ptr expr)
void Compiler::integer_lshift(const Expr_ptr expr)
{
POP_TWO(rhs, lhs);
- PUSH(lhs.LShift(rhs)); /* bitwise integer arithmetic */
+ PUSH_ADD(lhs.LShift(rhs)); /* bitwise integer arithmetic */
f_type_stack.pop_back(); // consume one, leave the other
}
@@ -140,7 +140,7 @@ void Compiler::integer_lshift(const Expr_ptr expr)
void Compiler::integer_rshift(const Expr_ptr expr)
{
POP_TWO(rhs, lhs);
- PUSH(lhs.RShift(rhs)); /* bitwise integer arithmetic */
+ PUSH_ADD(lhs.RShift(rhs)); /* bitwise integer arithmetic */
f_type_stack.pop_back(); // consume one, leave the other
}
@@ -148,7 +148,7 @@ void Compiler::integer_rshift(const Expr_ptr expr)
void Compiler::integer_equals(const Expr_ptr expr)
{
POP_TWO(rhs, lhs);
- PUSH(lhs.Equals(rhs));
+ PUSH_ADD(lhs.Equals(rhs));
f_type_stack.pop_back(); // consume one, leave the other
}
@@ -156,7 +156,7 @@ void Compiler::integer_equals(const Expr_ptr expr)
void Compiler::integer_not_equals(const Expr_ptr expr)
{
POP_TWO(rhs, lhs);
- PUSH(lhs.Equals(rhs).Cmpl());
+ PUSH_ADD(lhs.Equals(rhs).Cmpl());
f_type_stack.pop_back(); // consume one, leave the other
}
@@ -164,7 +164,7 @@ void Compiler::integer_not_equals(const Expr_ptr expr)
void Compiler::integer_gt(const Expr_ptr expr)
{
POP_TWO(rhs, lhs);
- PUSH(rhs.LT(lhs)); // simulate GT op
+ PUSH_ADD(rhs.LT(lhs)); // simulate GT op
f_type_stack.pop_back(); // consume one, leave the other
}
@@ -172,7 +172,7 @@ void Compiler::integer_gt(const Expr_ptr expr)
void Compiler::integer_ge(const Expr_ptr expr)
{
POP_TWO(rhs, lhs);
- PUSH(rhs.LEQ(lhs)); // simulate GEQ op
+ PUSH_ADD(rhs.LEQ(lhs)); // simulate GEQ op
f_type_stack.pop_back(); // consume one, leave the other
}
@@ -180,7 +180,7 @@ void Compiler::integer_ge(const Expr_ptr expr)
void Compiler::integer_lt(const Expr_ptr expr)
{
POP_TWO(rhs, lhs);
- PUSH(lhs.LT(rhs));
+ PUSH_ADD(lhs.LT(rhs));
f_type_stack.pop_back(); // consume one, leave the other
}
@@ -188,7 +188,7 @@ void Compiler::integer_lt(const Expr_ptr expr)
void Compiler::integer_le(const Expr_ptr expr)
{
POP_TWO(rhs, lhs);
- PUSH(lhs.LEQ(rhs));
+ PUSH_ADD(lhs.LEQ(rhs));
f_type_stack.pop_back(); // consume one, leave the other
}
6 src/model/compilers/internals.cc
View
@@ -44,7 +44,7 @@
f_add_stack.pop_back(); \
}
-#define PUSH_DDS(store, count) \
+#define PUSH_ADD_DDS(store, count) \
for (unsigned i = 0; i < (count); ++ i) { \
unsigned ndx = (count) - i - 1; \
f_add_stack.push_back((store) [ndx]); \
@@ -61,7 +61,7 @@
algebrize_operand((rhs), (width)); \
FETCH_DDS(tmp, (width)); \
algebrize_operand((lhs), (width)); \
- PUSH_DDS(tmp, (width)); \
+ PUSH_ADD_DDS(tmp, (width)); \
}
@@ -805,7 +805,7 @@ void Compiler::flush_operands()
{
for (ADDStack::reverse_iterator ri = f_tmp_stack.rbegin();
f_tmp_stack.rend() != ri; ++ ri) {
- PUSH(*ri);
+ PUSH_ADD(*ri);
}
f_tmp_stack.clear();
}
Please sign in to comment.
Something went wrong with that request. Please try again.