-
Notifications
You must be signed in to change notification settings - Fork 0
Instruction Set
Each instruction can take several forms, indicated in each section below detailing the function of each instruction. $<dest> refers to a variable called where <> indicates where a custom name/value should be inserted. The use of square brackets [] means it is optional, so [$] would mean that a parameter can be a variable or a constant value.
A simple summation example, it iterates over an array of items and returns the integer sum of them.
get $size $t1 size
cpy $i 0
cpy $sum 0
:loop
get $x $t1 $i
add $sum $sum $x
inc $i
jlt :loop $i $size
ret $sum
Add two numeric NIDs together and put result into dest, or add one value to dest.
add $<dest> [$]<a> [$]<b>
add $<dest> [$]<value>
Subtract two numeric NIDs (b from a) and put result into dest.
sub $<dest> [$]<a> [$]<b>
sub $<dest> [$]<value>
div $<dest> [$]<a> [$]<b>
div $<dest> [$]<value>
mul $<dest> [$]<a> [$]<b>
mul $<dest> [$]<value>
Shift value left by n bits and put into dest.
shl $<dest> [$]<value> [$]<n>
shl $<dest> [$]<n>
Shift value right by n bits and put into dest.
shr $<dest> [$]<value> [$]<n>
shr $<dest> [$]<n>
and $<dest> [$]<a> [$]<b>
and $<dest> [$]<value>
or $<dest> [$]<a> [$]<b>
or $<dest> [$]<value>
xor $<dest> [$]<a> [$]<b>
xor $<dest> [$]<value>
neg $<dest> [$]<value>
neg $<dest>
inc $<value>
dec $<value>
Sets value to null.
clr $<value>
Convert value to an integer and put into dest.
int $<dest> [$]<value>
int $<dest>
Convert value to a float and put into dest.
flt $<dest> [$]<value>
flt $<dest>
Copy a value from source into dest.
cpy $<dest> [$]<source>
const <NAME> <value>
Return value.
ret [$]<value>
jmp :<label>
jeq :<label> [$]<a> [$]<b>
jne :<label> [$]<a> [$]<b>
jle :<label> [$]<a> [$]<b>
jge :<label> [$]<a> [$]<b>
jlt :<label> [$]<a> [$]<b>
jgt :<label> [$]<a> [$]<b>
Read a single value from the t1 t2 HARC into dest.
get $<dest> [$]<t1> [$]<t2>
Define the HARC t1 t2 as value. The value may be a constant or definition.
def [$]<t1> [$]<t2> [$]<value>
Add a dependency where a1 a2 depends upon b1 b2.
dep [$]<a1> [$]<a2> [$]<b1> [$]<b2>
Create a new NID in dest which matches the kind NID.
new $<dest> [$]<kind>
new $<dest>
Delete the HARC t1 t2.
del [$]<t1> [$]<t2>
Follow a path through the graph, starting at element and putting the result into dest. Elements may be repeated any number of times and are separated by dots. The pathd form also adds dependencies to the HARC whose definition this corresponds to ($t1 and $t2).
path $<dest> [$]<element>[.]*
pathd $<dest> [$]<element>[.]*
sclone
dclone
jisa :<label> [$]<value> [$]<pattern>
jisnt :<label> [$]<value> [$]<pattern>