Skip to content

Commit

Permalink
modified command line option "--strict-const-arrays" to satisfy TI's …
Browse files Browse the repository at this point in the history
…compiler

This forces array members to be initialized with constants only.
  • Loading branch information
Xuejun Yang committed Jun 17, 2011
1 parent 8e95972 commit d1ae3b2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/RandomProgramGenerator.cpp
Expand Up @@ -254,7 +254,7 @@ static void print_advanced_help()
// other options
cout << " --math-notmp: make csmith generate code for safe_math_macros_notmp." << endl << endl;

cout << " --strict-const-arrays: restrict const array elements to integer constants." << endl << endl;
cout << " --strict-const-arrays: restrict array elements to constants." << endl << endl;

cout << " --partial-expand <assignment[,for[,block[,if-else[,invoke[,return]]]]]: ";
cout <<"partial-expand controls which what kind of statements should be generated first. ";
Expand Down
2 changes: 0 additions & 2 deletions src/StatementArrayOp.cpp
Expand Up @@ -119,8 +119,6 @@ StatementArrayOp::make_random_array_init(CGContext &cg_context)
// JYTODO: initialize only field(s) of array members if they are of type struct
Block* b = cg_context.get_current_block()->random_parent_block();
Expression* init = VariableSelector::make_init_value(Effect::READ, cg_context, av->type, &av->qfer, b);
if (CGOptions::strict_const_arrays())
assert(av->type->eType != ePointer);
assert(init->visit_facts(fm->global_facts, cg_context));
StatementArrayOp* sa = new StatementArrayOp(cg_context.get_current_block(), av, cvs, inits, incrs, init);
Lhs lhs(*av);
Expand Down
27 changes: 11 additions & 16 deletions src/VariableSelector.cpp
Expand Up @@ -489,24 +489,19 @@ VariableSelector::create_and_initialize(Effect::Access access, const CGContext &
{
const Expression* init = NULL;
Variable* var = NULL;

if (t->eType == ePointer && CGOptions::strict_const_arrays()) {
init = make_init_value(access, cg_context, t, qfer, blk);
ERROR_GUARD(NULL);
var = new_variable(name, t, init, qfer);
}
else {
init = make_init_value(access, cg_context, t, qfer, blk);
if (rnd_flipcoin(NewArrayVariableProb)) {
ERROR_GUARD(NULL);
var = create_array_and_itemize(blk, name, cg_context, t, init, qfer);

if (rnd_flipcoin(NewArrayVariableProb)) {
if (CGOptions::strict_const_arrays()) {
init = Constant::make_random(t);
} else {
init = make_init_value(access, cg_context, t, qfer, blk);
}
else {
ERROR_GUARD(NULL);
var = new_variable(name, t, init, qfer);
}
var = create_array_and_itemize(blk, name, cg_context, t, init, qfer);
}
ERROR_GUARD(NULL);
else {
init = make_init_value(access, cg_context, t, qfer, blk);
var = new_variable(name, t, init, qfer);
}
assert(var);
return var;
}
Expand Down

0 comments on commit d1ae3b2

Please sign in to comment.