Program Listing for File ExtractFunctionArguments.h#
↰ Return to documentation for file (src/midend/programTransformation/extractFunctionArgumentsNormalization/ExtractFunctionArguments.h)
#pragma once
// DQ (10/5/2014): This is more strict now that we include rose_config.h in the sage3basic.h.
// #include "rose.h"
#include "sage3basic.h"
#include "functionEvaluationOrderTraversal.h"
//class FunctionCallInfo;
class ExtractFunctionArguments
{
public:
void NormalizeTree(SgNode* tree, bool doUnsafeNormalization = false);
// returns a vector of newly introduced temporaries
std::vector<SgVariableDeclaration*> GetTemporariesIntroduced();
/*
IsNormalized: Given a subtree, returns true if every argument of every function call is a trivial arguemnt.
*/
bool IsNormalized(SgNode* tree);
/*
IsNormalizable: Given a subtree, returns true if every argument of every function call is a either trivial arguemnt or
is present in a SAFE place from where lifting is possible.
*/
bool IsNormalizable(SgNode* tree);
private:
std::vector<SgVariableDeclaration*> temporariesIntroduced;
std::pair< std::vector<FunctionCallInfo>, std::vector<FunctionCallInfo> > functionCalls;
bool FunctionArgumentNeedsNormalization(SgExpression* argument);
bool FunctionArgsNeedNormalization(SgExprListExp* functionArgs);
bool SubtreeNeedsNormalization(SgNode* top);
void RewriteFunctionCallArguments(const FunctionCallInfo& functionCallInfo);
void InsertStatement(SgStatement* newStatement, SgStatement* location, const FunctionCallInfo& insertionMode);
bool FunctionArgumentCanBeNormalized(SgExpression* argument);
/* Given the expression which is the argument to a function call, returns true if that
expression is trivial. Trivial expressions are those which are simple variable references or constants.
*/
bool IsFunctionArgumentTrivial(SgExpression* argument);
/* Given a vector of function call sites returns true if every argument of every function call is a trivial expression
(IsFunctionArgumentTrivial). Such functions don't need to be normalized.
*/
bool AreAllFunctionCallsTrivial(std::vector<FunctionCallInfo> functions);
/* Given a vector of function call sites, returns true if every argument
at every function call site is either trivial (IsFunctionArgumentTrivial) or can be normalized (FunctionArgumentCanBeNormalized).
*/
bool AreAllFunctionCallsNormalizable(std::vector<FunctionCallInfo> functions);
};