Parrot::OpsFile - Ops To C Code Generation
use Parrot::OpsFile;
Parrot::OpsFile takes one or more files of op functions and creates real C code for them.
Parrot::OpsFile
This class is used by tools/build/ops2c.pl, tools/build/ops2pm.pl and tools/build/pbc2c.pl.
For ops that have trivial bodies (such as just a call to some other function and a return statement), opcode functions are in the format:
return
inline op opname (args) :class,flags { ... body of function ... }
Note that currently the inline op type is ignored.
inline
Alternately, for opcode functions that have more internal complexity the format is:
op opname (args) :class,flags { ... body of function ... }
There may be more than one return.
In both cases the closing brace must be on its own line.
Op arguments are a comma-separated list of direction and type pairs.
Argument direction is one of:
in the argument passes a value into the op out the argument passes a value out of the op inout the argument passes a value into and out of the op inconst the argument passes a constant value into the op invar the argument passes a variable value into the op label an in argument containing a branch offset or address labelconst an invar argument containing a branch offset or address labelvar an inconst argument containing a branch offset or address
Argument direction is used to determine the life times of symbols and their related register allocations. When an argument is passed into an op a register is read from, when it's passed out of an op a register is written to.
Argument type is one of:
INT the argument is an integer NUM the argument is an numeric STR the argument is an string PMC the argument is an PMC KEY the argument is an aggregate PMC key INTKEY the argument is an aggregate PMC integer key
The size of the return offset is determined from the op function's signature.
The op classification and flags are optional hints which provide information about the op.
The classification of ops is intended to facilitate the selection of suitable ops for a Parrot safe mode, or for inclusion in miniparrot.
In the following macro descriptions, PC and PC' are the current and next position within the Parrot code.
PC
PC'
goto OFFSET(X)
Transforms to PC' = PC + X. This is used for branches.
PC' = PC + X
goto NEXT()
Transforms to PC' = PC + S, where S is the size of an op.
PC' = PC + S
S
goto ADDRESS(X)
Transforms to PC' = X. This is used for absolute jumps.
PC' = X
goto POP()
Transforms to PC' = <pop>. Pops the address off control stack.
PC' = <pop>
expr OFFSET(X)
Transforms to PC + X. This is used to give a relative address.
PC + X
expr NEXT()
Transforms to PC + S, the position of the next op.
PC + S
expr ADDRESS(X)
Transforms to X, an absolute address.
X
OP_SIZE
Transforms to S, the size of an op.
HALT()
Transforms to PC' = 0. Halts run loop, and resets the current position to the start of the Parrot code, without resuming.
PC' = 0
restart OFFSET(X)
Transforms to PC' = 0 and restarts at PC + X.
restart NEXT()
Transforms to PC' = 0 and restarts at PC + S.
$n
Transforms to the op function's nth argument. $0 is the opcode itself.
$0
Note that, for ease of parsing, if the argument to one of the above notations in a ops file contains parentheses, then double the enclosing parentheses and add a space around the argument, like so:
goto OFFSET(( (void*)interp->happy_place ))
new(@files)
Returns a new instance initialized by calling read_ops() on each of the specified op files.
read_ops()
read_ops($file,$nolines)
Reads in the specified .ops file, gathering information about the ops.
make_op($code, $type, $short_name, $body, $args, $argdirs, $line, $file, $labels, $flags, $nolines)
Returns a new Parrot::Op instance for the specified arguments.
Parrot::Op
expand_args(@args)
Given an argument list, returns a list of all the possible argument combinations.
ops()
Returns the Parrot::Op instances found in the file(s).
op($index)
Returns the op at $index.
$index
preamble()
preamble($trans)
Returns any lines found prior to first op definition.
If $trans (an Parrot::OpTrans subclass) is supplied then substitutions are made.
$trans
Parrot::OpTrans
version($major, $minor, $patch)
version($version)
version()
Sets/gets the version number.
major_version()
Returns the major version number.
minor_version()
Returns the minor version number.
patch_version()
Returns the patch version number.
push_op($op)
Adds $op to the end of the op list.
$op
To install SmartLink, copy and paste the appropriate command in to your terminal.
cpanm
cpanm SmartLink
CPAN shell
perl -MCPAN -e shell install SmartLink
For more information on module installation, please visit the detailed CPAN module installation guide.