setTflCFunctionEntryParameters
Set specified parameters for function entry in code replacement table
Description
Examples
Specify Parameters for Function Entry
This example shows how to use the
setTflCFunctionEntryParameters
function to set specified
parameters for a code replacement function entry for
sqrt
.
fcn_entry = RTW.TflCFunctionEntry; fcn_entry.setTflCFunctionEntryParameters( ... 'Key', 'sqrt', ... 'Priority', 100, ... 'ImplementationName', 'sqrt', ... 'ImplementationHeaderFile', '<math.h>' );
Input Arguments
hEntry
— Handle to a code replacement function entry
handle
The hEntry
is a handle to a code replacement
function entry previously returned by
or hEntry
=
RTW.TflCFunctionEntry
, where
hEntry
=
MyCustomFunctionEntry
is a
class derived from MyCustomFunctionEntry
RTW.TflCFunctionEntry
.
Example: fcn_entry
varargin
— Name-value pairs of arguments for function entry
name-value pairs
Example: 'Key','sqrt'
Name-Value Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN
, where Name
is
the argument name and Value
is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Before R2021a, use commas to separate each name and value, and enclose
Name
in quotes.
Example: 'Key','sqrt'
AcceptExprInput
— Selects whether implementation function accepts expression inputs
true
| false
The AcceptExprInput
value flags the code
generator that the implementation function described by this entry
accepts expression inputs. The default value is true
if ImplType
equals FCN_IMPL_FUNCT
and false
if ImplType
equals
FCN_IMPL_MACRO
.
If the value is true
, expression inputs are
integrated into the generated code in a form similar to this
form:
rtY.Out1 = mySin(rtU.In1 + rtU.In2);
If the value is false
, a temporary variable is
generated for the expression input:
real_T rtb_Sum; rtb_Sum = rtU.In1 + rtU.In2; rtY.Out1 = mySin(rtb_Sum);
Example: 'AcceptExprInput',true
AdditionalHeaderFiles
— Specifies additional header files for table entry
{}
(default) | array of character vectors | string array
The AdditionalHeaderFiles
value specifies
additional header files for a code replacement table entry. The vectors
can include tokens. For example, in the token
$mytoken$
, mytoken
is a
variable defined as a character vector or string scalar in the
MATLAB® workspace or as a MATLAB function in the search path that returns a character
vector.
Example: 'AdditionalHeaderFiles',{}
AdditionalIncludePaths
— Specifies additional include paths for table entry
{}
(default) | array of character vectors | string array
The AdditionalIncludePaths
value specifies
the full path of additional include paths for a code replacement entry.
The character vectors or string array can include tokens. For example,
in the token $mytoken$
, mytoken
is
a variable defined as a character vector or string scalar in the
MATLAB workspace or as a MATLAB function in the search path that returns a character
vector.
Example: 'AdditionalIncludePaths',{}
AdditionalLinkObjs
— Specifies additional link objects for table entry
{}
(default) | array of character vectors | string array
The AdditionalLinkObjs
value specifies
additional link objects for a code replacement table entry. The
character vectors or string array can include tokens. For example, in
the token $mytoken$
, mytoken
is a
variable defined as a character vector or string scalar in the
MATLAB workspace or as a MATLAB function in the search path that returns a character
vector.
Example: 'AdditionalLinkObjs',{}
AdditionalLinkObjsPaths
— Specifying additional link object paths for table entry
{}
(default) | array of character vectors | string array
The AdditionalLinkObjsPaths
value specifies
the full path of additional link object paths for a code replacement
entry. The character vectors or string array can include tokens. For
example, in the token $mytoken$
,
mytoken
is a variable defined as a character
vector or string scalar in the MATLAB workspace or as a MATLAB function in the search path that returns a character
vector. The default is {}
.
Example: 'AdditionalLinkObjsPaths',{}
AdditionalSourceFiles
— Specifies additional source files for table entry
{}
(default) | array of character vectors | string array
The AdditionalSourceFiles
value specifies
additional source files for a code replacement table entry. The
character vectors or string array can include tokens. For example, in
the token $mytoken$
, mytoken
is a
variable defined as a character vector or string scalar in the
MATLAB workspace or as a MATLAB function in the search path that returns a character
vector.
Example: 'AdditionalSourceFiles',{}
AdditionalSourcePaths
— Specifies additional source paths for table entry
{}
(default) | array of character vectors | string array
The AdditionalSourcePaths
value specifies
the full path of additional source paths for a code replacement entry.
The character vectors or string array can include tokens. For example,
in the token $mytoken$
, mytoken
is
a variable defined as a character vector or string scalar in the
MATLAB workspace or as a MATLAB function in the search path that returns a character
vector.
Example: 'AdditionalSourcePaths',{}
AdditionalCompileFlags
— Specifies additional compiler flags for table entry
{}
(default) | array of character vectors | string array
The AdditionalCompileFlags
value specifies
additional flags required to compile the source files defined for a code
replacement table entry. The default is {}
.
Example: 'AdditionalCompileFlags',{}
AdditionalLinkFlags
— Specifies additional linker flags for table entry
{}
(default) | array of character vectors | string array
The AdditionalLinkFlags
value specifies
additional flags required to link the compiled files for a code
replacement table entry.
Example: 'AdditionalLinkFlags',{}
ArrayLayout
— Specifies layout of array storage for table entry
'COLUMN_MAJOR'
(default) | 'ROW_MAJOR'
| 'COLUMN_AND_ROW'
The ArrayLayout
value specifies the order
of array elements in memory supported by the replacement implementation.
By default, the replacement implementation supports column-major data
layout. For ROW-MAJOR
, the replacement implementation
supports row-major data layout. For COLUMN_AND_ROW
,
the replacement implementation supports column-major and row-major data
layouts.
Example: 'ArrayLayout','ROW_MAJOR'
EntryInfoAlgorithm
— Specifies computation or approximation method to match for table entry
'RTW_DEFAULT'
| 'RTW_NEWTON_RAPHSON'
| 'RTW_CORDIC'
| 'RTW_LOOKUP'
| 'RTW_UNSPECIFIED'
The EntryInfoAlgorithm
value specifies a
computation or approximation method, configured for the specified math
function, that must be matched in order for function replacement to
occur. Code replacement libraries support function replacement based on
computation or approximation method for the math functions
rSqrt
, sin
,
cos
, sincos
, and
atan2
. The valid arguments for each supported
function are listed in the table.
Function | Argument | Meaning |
---|---|---|
|
|
Match the default computation method,
|
|
Match the | |
|
Match a computation method | |
|
|
Match the |
| Match the | |
| Match the default approximation method,
| |
| Match an approximation method |
Example: 'EntryInfoAlgorithm','RTW_DEFAULT'
GenCallback
— Specifies callback that follows code generation
''
(default) | 'RTW.copyFileToBuildDir'
The GenCallback
specifies a callback that
follows code generation. If you specify
'RTW.copyFileToBuildDir'
, and if this function
entry is matched and used, the code generator calls function
RTW.copyFileToBuildDir
after code generation.
This callback function copies additional header, source, or object files
that you have specified for this function entry to the build
folder.
Example: 'GenCallback',''
ImplementationHeaderFile
— Specifies the name of the header file that declares the implementation function
''
(default) | character vector | string scalar
The ImplementationHeaderFile
value
specifies the name of the header file that declares the implementation
function, for example, '<math.h>'
. The
character vector or string scalar can include tokens. For example, in
the token $mytoken$
, mytoken
is a
variable defined as a character vector or string scalar in the
MATLAB workspace or as a MATLAB function in the search path that returns a character
vector.
Example: 'ImplementationHeaderFile',''
ImplementationHeaderPath
— Specifies path to implementation header file
''
(default) | character vector | string scalar
The ImplementationHeaderPath
value
specifies the full path to the implementation header file. The character
vector or string scalar can include tokens. For example, in the token
$mytoken$
, mytoken
is a
variable defined as a character vector or string scalar in the
MATLAB workspace or as a MATLAB function in the search path that returns a character
vector.
Example: 'ImplementationHeaderPath',''
ImplementationName
— Specifies name of implementation function
''
(default) | character vector | string scalar
The ImplementationName
value specifies the
name of the implementation function, for example,
'sqrt'
, which can match or differ from the
Key
name.
Example: 'ImplementationName',''
ImplementationSourceFile
— Specifies name of implementation source file
''
(default) | character vector | string scalar
The ImplementationSourceFile
value
specifies the name of the implementation source file. The character
vector or string scalar can include tokens. For example, in the token
$mytoken$
, mytoken
is a
variable defined as a character vector or string scalar in the
MATLAB workspace or as a MATLAB function in the search path that returns a character
vector.
Example: 'ImplementationSourceFile',''
ImplementationSourcePath
— Specifies path to implementation source file
''
(default) | character vector | string scalar
The ImplementationSourcePath
value
specifies the full path to the implementation source file. The character
vector or string scalar can include tokens. For example, in the token
$mytoken$
, mytoken
is a
variable defined as a character vector or string scalar in the
MATLAB workspace or as a MATLAB function in the search path that returns a character
vector.
Example: 'ImplementationSourcePath',''
ImplType
— Specifies the type of entry
'FCN_IMPL_FUNCT'
(default) | 'FCN_IMPL_MACRO'
Use FCN_IMPL_FUNCT
for function or
FCN_IMPL_MACRO
for macro.
Example: 'ImplType','FCN_IMPL_FUNCT'
Key
— Specifies name of function to replace
character vector | string scalar
The Key value specifies the name of the function to replace. The name must match a function name listed in Code You Can Replace from MATLAB Code or Code You Can Replace From Simulink Models.
Example: 'Key','sqrt'
Priority
— Specifies the search priority for function entry
100
(default) | integer 0..100
The Priority
value specifies the search
priority for the function entry, relative to other entries of the same
function name and conceptual argument list within this table. Highest
priority is 0, and lowest priority is 100. If the table provides two
implementations for a function, the implementation with the higher
priority shadows the one with the lower priority.
Example: 'Priority',100
RoundingModes
— Specifying rounding modes supported by implementation function
'RTW_ROUND_UNSPECIFIED'
(default) | 'RTW_ROUND_FLOOR'
| 'RTW_ROUND_CEILING'
| 'RTW_ROUND_ZERO'
| 'RTW_ROUND_NEAREST'
| 'RTW_ROUND_NEAREST_ML'
| 'RTW_ROUND_SIMPLEST'
| 'RTW_ROUND_CONV'
| array of character vectors | string array
The RoundingModes
value specifies one or
more rounding modes supported by the implementation function.
Example: 'RoundingModes',{'RTW_ROUND_UNSPECIFIED'}
SaturationMode
— Specifying saturation mode supported by implementation function
'RTW_SATURATE_UNSPECIFIED'
(default) | 'RTW_SATURATE_ON_OVERFLOW'
| 'RTW_WRAP_ON_OVERFLOW'
The SaturationMode
value specifies the
saturation mode supported by the implementation function.
Example: 'SaturationMode','RTW_SATURATE_UNSPECIFIED'
SideEffects
— Specifies whether to attempt to optimize away the implementation function
false
(default) | true
The SideEffects
value flags the code
generator not to optimize away the implementation function described by this
entry. This parameter applies to implementation functions that return
void
but are not to be optimized away, such as a
memcpy
implementation or an implementation function
that accesses global memory values. For those implementation functions only,
you must include this parameter and specify the value
true
.
Example: 'SideEffects',false
StoreFcnReturnInLocalVar
— Specifies whether to store the implementation function regardless expression folding settings
false
(default) | true
The StoreFcnReturnInLocalVar
value flags
the code generator that the return value of the implementation function
described by this entry must be stored in a local variable regardless of
other expression folding settings. If the value is
false
, other expression folding settings
determine whether the return value is folded. Storing function returns
in a local variable can increase the clarity of generated code. This
example shows code generated with expression folding:
void sw_step(void) { if (ssub(sadd(sw_U.In1, sw_U.In2), sw_U.In3) <= smul(ssub(sw_U.In4, sw_U.In5),sw_U.In6)) { sw_Y.Out1 = sw_U.In7; } else { sw_Y.Out1 = sw_U.In8; } }
With StoreFcnReturnInLocalVar
set to
true
, the generated code is potentially easier to
understand and debug:
void sw_step(void) { real32_T rtb_Switch; real32_T hoistedExpr; ...... rtb_Switch = sadd(sw_U.In1, sw_U.In2); rtb_Switch = ssub(rtb_Switch, sw_U.In3); hoistedExpr = ssub(sw_U.In4, sw_U.In5); hoistedExpr = smul(hoistedExpr, sw_U.In6); if (rtb_Switch <= hoistedExpr) { sw_Y.Out1 = sw_U.In7; } else { sw_Y.Out1 = sw_U.In8; } }
Example: 'StoreFcnReturnInLocalVar',false
Version History
Introduced in R2007b
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)