os << endl;
break;
case BVSX:
+ case BVZX:
os << kind << "(";
c[0].PL_Print1(os,indentation,letize);
os << ",";
case BVSX:
//in BVSX(n[0],len), the length of the BVSX term must be
//greater than the length of n[0]
- if(n[0].GetValueWidth() >= n.GetValueWidth()) {
+ if(n[0].GetValueWidth() > n.GetValueWidth()) {
FatalError("BVTypeCheck: BVSX(t,bvsx_len) : length of 't' must be <= bvsx_len\n",n);
}
break;
+
+ case BVZX:
+ //in BVZX(n[0],len), the length of the BVZX term must be
+ //greater than the length of n[0]
+ if(n[0].GetValueWidth() > n.GetValueWidth()) {
+ FatalError("BVTypeCheck: BVZX(t,bvzx_len) : length of 't' must be <= bvzx_len\n",n);
+ }
+ break;
+
default:
for(ASTVec::iterator it=v.begin(),itend=v.end();it!=itend;it++)
if(BITVECTOR_TYPE != it->GetType()) {
SBVREM 2 2 Term
SBVMOD 2 2 Term
BVSX 1 1 Term
+BVZX 1 1 Term
BOOLVEC 0 - Term
# Formula OR term, depending on context
break;
}
}
+
+ case BVZX: {
+ // Fill the high-order bits with as many zeroes as needed.
+ // Arg 0 is expression to be sign extended.
+ const ASTNode& arg = term[0];
+ unsigned long result_width = term.GetValueWidth();
+ unsigned long arg_width = arg.GetValueWidth();
+
+ //FIXME Uses a temporary const ASTNode reference
+ const ASTNode& bbarg = BBTerm(arg);
+ ASTVec tmp_res(result_width);
+
+ //FIXME Should these be gotten from result?
+ ASTVec::const_iterator bb_it = bbarg.begin();
+ ASTVec::iterator res_it = tmp_res.begin();
+ ASTVec::iterator res_ext = res_it+arg_width; // first bit of extended part
+ ASTVec::iterator res_end = tmp_res.end();
+ // copy LSBs directly from bbvec
+ for( ; res_it < res_ext; (res_it++, bb_it++)) {
+ *res_it = *bb_it;
+ }
+ // repeat zero to fill up rest of result.
+ for( ; res_it < res_end; (res_it++)) {
+ *res_it = ASTFalse;
+ }
+
+ // Temporary debugging code
+ // cout << "Zero extending:" << endl
+ // << " Vec ";
+ // lpvec( bbarg.GetChildren() );
+ // cout << " Extended to ";
+ // cout << result;
+ // cout << endl;
+
+ result = CreateNode(BOOLVEC, tmp_res);
+
+ break;
+ }
+
+
+
+
case BVEXTRACT: {
// bitblast the child, then extract the relevant bits.
// Note: This could be optimized by not bitblasting the bits
}
break;
}
+
+ case BVZX: {
+ output = CONSTANTBV::BitVector_Create(inputwidth,true);
+ unsigned t0_width = t[0].GetValueWidth();
+ if(inputwidth == t0_width) {
+ CONSTANTBV::BitVector_Copy(output, tmp0);
+ OutputNode = CreateBVConst(output, outputwidth);
+ }
+ else {
+ CONSTANTBV::BitVector_Interval_Copy(output, tmp0, 0, 0, t0_width);
+ OutputNode = CreateBVConst(output, outputwidth);
+ }
+ break;
+ }
+
+
case BVAND: {
output = CONSTANTBV::BitVector_Create(inputwidth,true);
CONSTANTBV::Set_Intersection(output,tmp0,tmp1);
"bvsub" { return BVSUB_TOK;}
"bvnot" { return BVNOT_TOK;}
"bvmul" { return BVMULT_TOK;}
-"bvdiv" { return BVDIV_TOK;}
+"bvudiv" { return BVDIV_TOK;}
"bvsdiv" { return SBVDIV_TOK;}
"bvurem" { return BVMOD_TOK;}
"bvsrem" { return SBVREM_TOK;}
"bvsle" { return BVSLE_TOK;}
"bvsge" { return BVSGE_TOK;}
+"zero_extend" { return BVZX_TOK;}
"sign_extend" { return BVSX_TOK;}
"boolextract" { return BOOLEXTRACT_TOK;}
"boolbv" { return BOOL_TO_BV_TOK;}
%token BVSLE_TOK
%token BVSGE_TOK
%token BVSX_TOK
+%token BVZX_TOK
%token BOOLEXTRACT_TOK
%token BOOL_TO_BV_TOK
%token BVEXTRACT_TOK
$$ = n;
delete $5;
}
+| BVZX_TOK LBRACKET_TOK NUMERAL_TOK RBRACKET_TOK an_term
+ {
+ BEEV::globalBeevMgr_for_parser->BVTypeCheck(*$5);
+ unsigned w = $5->GetValueWidth() + $3;
+ BEEV::ASTNode width = BEEV::globalBeevMgr_for_parser->CreateBVConst(32,w);
+ BEEV::ASTNode *n = new BEEV::ASTNode(BEEV::globalBeevMgr_for_parser->CreateTerm(BEEV::BVZX,w,*$5,width));
+ BEEV::globalBeevMgr_for_parser->BVTypeCheck(*n);
+ $$ = n;
+ delete $5;
+ }
+
;
sort_symb:
}
break;
}
+
+ case BVZX:
+ {
+ output = CreateTerm(BVZX,inputValueWidth,SimplifyTerm(inputterm[0]),inputterm[1]);
+ }
+ break;
+
+
case BVSX:{
//a0 is the expr which is being sign extended
ASTNode a0 = SimplifyTerm(inputterm[0]);