public class InlineExpansion
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static int |
MODE_DEFAULT
Default mode for inlining, inlining will be performed inside main function
|
static int |
MODE_INLINE_PRAGMAS
Same as "MODE_INLINEIN_PRAGMAS" except that "inline" pragmas will also be honored
|
static int |
MODE_INLINEIN_PRAGMAS
Starting from main function inline the code which is inside "inlinein" pragmas
|
static int |
MODE_INSIDE_SELECTED_FUNCTIONS
Inlining will be performed inside the selected functions provided on command line via "functions" option
|
static int |
MODE_SELECTED_FUNCTIONS_INVOCATIONS
The selected functions provided on command line will be inlined wherever they are invoked
|
| Constructor and Description |
|---|
InlineExpansion()
default constructor
|
InlineExpansion(int mode) |
InlineExpansion(int mode,
java.util.ArrayList<java.lang.String> functions)
Creates an instance of the Inliner
|
| Modifier and Type | Method and Description |
|---|---|
java.util.ArrayList<java.lang.String> |
getCommandlineFunctions()
returns an array list of function names provided at the command line for MODE_INSIDE_SELECTED_FUNCTIONS and MODE_SELECTED_FUNCTIONS_INVOCATIONS modes
|
java.lang.String |
getLabelPrefix()
returns the prefix used in naming labels that replace labels in the inlined code
|
java.lang.String |
getLocalVarPrefix()
returns the prefix used in naming variables that replace local variables in the inlined code
|
int |
getMaxVarLength()
returns the maximum allowed length for the variable names that inlining introduces
|
int |
getMode()
tells the mode of the inliner, which is one of the MODE_XXX constants
|
java.lang.String |
getParamPrefix()
returns the prefix used in naming variables that replace parameters in the function to be inlined
|
java.lang.String |
getResultPrefix()
returns the prefix used in naming the variable that holds the return value of the function that has been inlined
|
void |
inline(Program program)
performs inlining in the given program according to the options that have been set before calling this function
Following are taken care of:
* Functions that result in recursion are not inlined
* Functions that use static external variables are not inlined
* Global variables used in the function to be inlined are handled by declaring them as extern
* Variable reshaping (array-dimensions) is handled
* Long function call chains (a->b->c->d->...) are handled as long as they do not result in a recursion
* Switches are provided for controlling variable names and their lengths
* Support for making log
* Comments with the inlined code
|
void |
inlineIn(CompoundStatement inlineIn)
inlines the function calls in the given compound statement, doesn't go deeper than that
i.e.
|
void |
inlineIn(Procedure proc)
inlines the function calls in the body of the given procedure, doesn't go deeper than that
i.e.
|
boolean |
isComplementFunctions()
tells if the complement functions option is on
|
boolean |
isDebugOption()
tells if the debug option is on
|
boolean |
isFullyQualifiedName()
tells if the inlining code uses verbose names for variables that it introuduces
|
boolean |
isHonorPragmas()
tells if the honor pragmas option is on
|
boolean |
isInlineFuncsWithStaticVars()
tells if the functions having static local variables will be inlined or not
|
boolean |
isInsideForOnly()
tells if the foronly option is on
|
boolean |
isLevel_1()
tells if the level_1 option is on
|
boolean |
isMakeLog()
tells if the log is being made
|
void |
setCommandlineFunctions(java.util.ArrayList<java.lang.String> functions)
sets the function names given on command line for MODE_INSIDE_SELECTED_FUNCTIONS and MODE_SELECTED_FUNCTIONS_INVOCATIONS modes
|
void |
setComplementFunctions(boolean complementFunctions)
sets the complement functions option, which when on, will consider all functions for inlining according to the provided mode,
except the ones given in the command line
|
void |
setDebugOption(boolean debug)
sets the debug option, which when on, will not result in deleting the unreachable functions after inlining
|
void |
setFullyQualifiedName(boolean verboseName)
sets the option to have verbose variable names
|
void |
setHonorPragmas(boolean honorPragmas)
sets the honor pragmas option
|
void |
setInlineFuncsWithStaticVars(boolean inline)
sets the option to inline functions that have static local variables
|
void |
setInsideForOnly(boolean insideForOnly)
sets the inside foronly option, which when on, will instruct the inliner to try to inline the function calls inside for loops only
|
void |
setLabelPrefix(java.lang.String labelPrefix)
sets the currently used prefix for new labels replacing old labels
|
void |
setLevel_1(boolean level_1)
sets the level_1 option, which when on, will result in 1-level inlining as opposed to recursive
|
void |
setLocalVarPrefix(java.lang.String localVarPrefix)
sets the currently used prefix for new variables replacing old local variables
|
void |
setMakeLog(boolean makeLog)
sets the make-log flag
|
void |
setMaxVarLength(int length)
sets the maximum length for the variables introduced by inlining
|
void |
setMode(int mode)
sets the mode for the inliner
|
void |
setParamPrefix(java.lang.String paramPrefix)
sets the currently used prefix for new variables replacing old function parameters
|
void |
setResultPrefix(java.lang.String resultPrefix)
sets the currently used prefix for new variables used to hold return value of the function that has been inlined
|
public static final int MODE_DEFAULT
public static final int MODE_INSIDE_SELECTED_FUNCTIONS
public static final int MODE_SELECTED_FUNCTIONS_INVOCATIONS
public static final int MODE_INLINEIN_PRAGMAS
public static final int MODE_INLINE_PRAGMAS
public InlineExpansion()
public InlineExpansion(int mode)
mode - - the mode for the inliner, should be one of the MODE_XXX constantspublic InlineExpansion(int mode,
java.util.ArrayList<java.lang.String> functions)
mode - - mode for the inliner, should be one of the MODE_XXX constantsfunctions - - ArrayList containing function names provided by the user on the command line
- it will be used by MODE_INSIDE_SELECTED_FUNCTIONS and MODE_SELECTED_FUNCTIONS_INVOCATIONS modespublic void setMakeLog(boolean makeLog)
makeLog - - new value for the currently used make-log optionpublic void setParamPrefix(java.lang.String paramPrefix)
paramPrefix - - the new prefixpublic void setResultPrefix(java.lang.String resultPrefix)
resultPrefix - - the new prefixpublic void setLocalVarPrefix(java.lang.String localVarPrefix)
localVarPrefix - - the new prefix for local variables in the inlined codepublic void setLabelPrefix(java.lang.String labelPrefix)
labelPrefix - - the new prefix for labels in the inlined codepublic void setMaxVarLength(int length)
length - - new length for variablespublic void setFullyQualifiedName(boolean verboseName)
verboseName - - the option to have verbose namespublic void setInlineFuncsWithStaticVars(boolean inline)
inline - - the option to inline such functionpublic void setMode(int mode)
mode - - the mode value, should be one of the MODE_XXX constantspublic void setCommandlineFunctions(java.util.ArrayList<java.lang.String> functions)
functions - - function names provided on the command linepublic void setDebugOption(boolean debug)
debug - - the boolean value for debug optionpublic void setHonorPragmas(boolean honorPragmas)
honorPragmas - - the boolean value for honor pragmas optionpublic void setLevel_1(boolean level_1)
level_1 - - the boolean value for level_1 optionpublic void setInsideForOnly(boolean insideForOnly)
insdeForOnly - - the boolean value for foronly optionpublic void setComplementFunctions(boolean complementFunctions)
complementFunctions - - the boolean value for complement functions optionpublic boolean isMakeLog()
public java.lang.String getParamPrefix()
public java.lang.String getLocalVarPrefix()
public java.lang.String getLabelPrefix()
public java.lang.String getResultPrefix()
public int getMaxVarLength()
public boolean isFullyQualifiedName()
public boolean isInlineFuncsWithStaticVars()
public int getMode()
public java.util.ArrayList<java.lang.String> getCommandlineFunctions()
public boolean isDebugOption()
public boolean isHonorPragmas()
public boolean isLevel_1()
public boolean isInsideForOnly()
public boolean isComplementFunctions()
public void inline(Program program)
program - - the programpublic void inlineIn(Procedure proc)
proc - - the procedure
Following are taken care of:
* Function calls that result in recursion are not inlined
* Functions that use static external variables are not inlined
* Global variables used in the function to be inlined are handled by declaring them as extern
* Variable reshaping (array-dimensions) is handled
* Switches are provided for controlling variable names and their lengths
* Support for making log
* Comments with the inlined codepublic void inlineIn(CompoundStatement inlineIn)
inlineIn - - the compound statement in which inlining is to be performed
Following are taken care of:
* Function calls that result in recursion are not inlined
* Functions that use static external variables are not inlined
* Global variables used in the function to be inlined are handled by declaring them as extern
* Variable reshaping (array-dimensions) is handled
* Switches are provided for controlling variable names and their lengths
* Support for making log
* Comments with the inlined code