本文整理汇总了C++中SgProject::get_frontendConstantFolding方法的典型用法代码示例。如果您正苦于以下问题:C++ SgProject::get_frontendConstantFolding方法的具体用法?C++ SgProject::get_frontendConstantFolding怎么用?C++ SgProject::get_frontendConstantFolding使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SgProject
的用法示例。
在下文中一共展示了SgProject::get_frontendConstantFolding方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: resetConstantFoldedValues
//! This removes the original expression tree from value expressions where it has been constant folded by EDG.
void resetConstantFoldedValues( SgNode* node )
{
// This is the initial default, it will be changed later to be an optional behavior.
// Note that all unparsing will use the original expression tree and is verified to generate
// correct for all of the regression tests in C and C++. The original expression trees are
// saved in ROSE as part of supporting source to source work. One could conclude that the
// original expression tree should always of never used as part of analysis, but not both
// the constant folded value AND the original expression tree.
// This is a temporary option, if false then we pass all tests and are consistent with historical configurations
// of the ROSE AST, but it is inconsistent so we want to fix that (because it causes control flow problems).
#if 1
// DQ (11/5/2012): Original value
bool makeASTConstantFoldingExpressionConsistant = true;
#else
// DQ (11/5/2012): An experimental value while I play with the original expression trees.
bool makeASTConstantFoldingExpressionConsistant = false;
#endif
#if 1
// This should be turned on except for internal testing.
ROSE_ASSERT(makeASTConstantFoldingExpressionConsistant == true);
#else
printf ("WARNING: INTERNAL TESTING MODE: In resetConstantFoldedValues() \n");
ROSE_ASSERT(makeASTConstantFoldingExpressionConsistant == false);
#endif
// This will become an input option in the near future. Once they can be supported through all of the test codes.
// The default is to use the original expression trees and replace the saved constant folded values in the AST.
// Note that having both can lead to some confusion (e.g. in the control flow graph and analysis, so we select one
// (no constant folded values) and make it an option to have the other (using constant folded values)). Note also
// This this is EDG's definition of constant folding which is fairly aggressive.
bool makeASTConstantFoldingExpressionConsistant_useOriginalExpressionTrees = true;
// Constant folding is optional and can be specified as an optional parameter to "frontend()" function.
// If set it sets a flag in the SgProject IR node.
SgProject* project = isSgProject(node);
if (project != NULL)
{
// Read the optional setting for constant folding in the frontend (only applied to C/C++ when using EDG).
makeASTConstantFoldingExpressionConsistant_useOriginalExpressionTrees = (project->get_frontendConstantFolding() == false);
}
// ROSE_ASSERT(project != NULL);
// printf ("project->get_frontendConstantFolding() = %s \n",(project->get_frontendConstantFolding() == true) ? "true" : "false");
#if 0
// SgProject* project = isSgProject(node);
// Output an optional graph of the AST (the whole graph, of bounded complexity, when active)
const int MAX_NUMBER_OF_IR_NODES_TO_GRAPH_FOR_WHOLE_GRAPH = 8000;
ROSE_ASSERT(project != NULL);
if (project != NULL)
{
printf ("OUTPUT A GRAPH BEFORE CONSTANT FOLDING \n");
generateAstGraph(project,MAX_NUMBER_OF_IR_NODES_TO_GRAPH_FOR_WHOLE_GRAPH,"_before_constantfolding");
}
#endif
// printf ("In resetConstantFoldedValues(): makeASTConstantFoldingExpressionConsistant = %s \n",makeASTConstantFoldingExpressionConsistant ? "true" : "false");
if (makeASTConstantFoldingExpressionConsistant == true)
{
// printf ("In resetConstantFoldedValues(): makeASTConstantFoldingExpressionConsistant_useOriginalExpressionTrees = %s \n",makeASTConstantFoldingExpressionConsistant_useOriginalExpressionTrees ? "true" : "false");
if (makeASTConstantFoldingExpressionConsistant_useOriginalExpressionTrees == true)
{
// We want this to be the default for ROSE, since it matches what is output by the unparser and thus what
// is required to pass all of the tests codes.
// DQ (9/17/2011): This case fails dozens of test codes!
// However, this case fails lot of tests codes due to the verification of all OriginalExpressionTree pointer
// to be NULL and the name qualification tests (which fail as a result of the transformations to eliminate the
// constant folded expressions and instead use the original expression trees).
// printf ("WARNING: Testing current default to replace constant folded value with the original expression tree (future default setting for ROSE). \n");
// This replaces the constant folded value with the saved original expression tree (default).
// This fails for test2011_113.C since we don't handle expressions in array types that contain
// original expression trees. The reason is that original expression tree is not used to replace
// the constant folded value and then (because of recent changes to the AST traversal) the variables
// in the array types index expression is not processed for name qualification.
// We need to either:
// 1) uniformly define the how constants are replaced (everywhere) with their original expressions, or
// 2) fix the name qualification to look into the original expression trees explicitly.
// or both.
// Note: If we fix #1 then we will not have to worry about #2, also I think that #1 defines a consistent
// AST, where as #2 pushes the name qualification to simple work on the non-consistent AST.
removeConstantFoldedValue(node);
}
else
{
// DQ (9/17/2011): This case fails only 2 test codes. Where the constant folded expression is unparsed but
// does not generate the correct code. This may be a separate issue to investigate after we get the original
// expression trees to be used (and the constant folding overridden; the other face below).
// DQ (9/18/2011): Leave this warning message in place for now (we will likely remove it later).
printf ("WARNING: Current default is to reset constant folding by removing the original expression tree. \n");
// This removes the original expression tree leaving the constant folded values (optional; not the default).
// This fails for test2006_112.C (fails to compile unparsed code because the original expression is correct
//.........这里部分代码省略.........