Name
tdftags — TDF tag fields
Synopsis
#include <tdf/exp.h>
#include <tdf/tag.h>
Description
An exp can occur in just one place in the tree, because of the backward pointers. Except for name_tag the general structure is that an exp has a son which is NULL
or its first argument exp. The next argument is the bro of the first, the next the bro of that etc. The last argument has the last field set and its bro is the head exp of the construction. In a name_tag the son contains the ident_tag which declares the identity or variable being used. case, env_offset and string are also special cases.
The pt field is used in goto and test-like constructions to hold the labst being jumped to. It is used in ident and name constructions to hold a list of uses of a declaration.
A name_tag or an exp with at pt to a labst MUST NOT be removed from the tree without the usage count being decreased. In the case of name_tag the exp must be removed from the pt-list which starts in the pt of the defining ident_tag. kill_exp does these operations. It also applies kill_exp recursively to all arguments.
For constructions not involving tags or labels, install_fns.c contains examples of ways of constructing exps which may be used during TDF transformations. However, at the time when the functions in install_fns.c are being used, tags and labels are represented by indexes into arrays. During TDF transformations this is no longer so. name_tag refers directly to the ident_tag of the appropriate declaration, and labels are represented by labst_tag exps. The form of a labst is explained below, but remember that the count of uses must be kept correctly up to date. The form of ident_tag and name_tag constructions are also explained below, as are the uses of some functions defined in me_fns.c to help in creating them.
The props field is zero except for those properties defined in <reader/exp.h>. Operations with ntests, rounding modes or error treatments have these represented in the props field. as in <reader/exp.h>.
An exp should normally have hold_refactor applied to it after being created.
Tag fields
abs_tag
: Represents integer abs construction-
son(e)
arg1 shape
sh(arg1) pt(e)
labst if error_jump, NULL
otherwise absbool_tag
: Represents comparison and conversion to boolean-
Only produced (by refactor.c) is HAS_SETCC is set.
son(e)
arg1 bro(arg1)
arg2 shape
a variety shape ntest
represented in props, qv pt(e)
NULL
no(e)
0 Delivers 1 in shape if arg1 ntest arg2, 0 otherwise.
addptr_tag
: Adds pointer and offset to produce pointer-
son(e)
arg1 (pointer) bro(arg1)
arg2 (offset) shape
pointer(al2(sh(arg2))) pt(e)
NULL
no(e)
0 alloca_tag
: Represents local_alloc construction-
son(e)
arg1 shape
pointer(x) no(e)
0 props(e)
0 pt(e)
NULL
and_tag
: represents and-
son(e)
a brother list of argument, all of the same shape. At least two arguments. After check any constants will have been combined into one, which will be the last exp. if there
a constant contribution. shape
shape of son(e). This may be changed in some installers by chvar_tag transformations in check - only if HAS_BYTEOPS
is set.no(e)
0 pt(e)
NULL
apply_tag
: Represents apply_proc construction-
son(e)
arg1 bro(son(e))
arg2 in the form of a brother list of zero or more exps. shape
result_shape. no(e)
0 pt(e)
NULL
Properties in the props field are defined in <reader/exp.h>
asm_tag
: Represents the ~asm group of token applications-
son(e)
arg shape
top no(e)
0 pt(e)
NULL
Properties in the props field are defined in <reader/exp.h>
ass_tag
: Represents assign construction-
son(e)
arg1 bro(son(e))
arg2 shape
top no(e)
0 pt(e)
NULL
assvol_tag
: Represents assign_to_volatile construction-
son(e)
arg1 bro(son(e))
arg2 shape
top no(e)
0 pt(e)
NULL
bfass_tag
andbfassvol_tag
: represent bitfield assignment opsbfcont_tag
andbfcontvol_tag
: represent bitfield contents ops-
These tags are removed by refactor.c and should not be seen elsewhere.
bitf_to_int_tag
: represents bitfield to int conversion son(e)arg1.-
shape
variety being converted to no(e)
0 pt(e)
NULL
case_tag
: Represents case construction-
son(e)
control bro(son(e))
a brother list of exps representing branches. Each element is zero-named exp with: pt is destination labst_tag. no is lower limit. if upper limit is equal to lower then son is NULL
else son is exp with no the upper limit. The elements of this list are arranged in increasing order of lower limit.shape
bottom if exhausive, top otherwise no(e)
0 pt(e)
NULL
chfl_tag
: represents change floating variety-
son(e)
arg1 shape
floating shape being converted to no(e)
0 pt(e)
NULL
chvar_tag
: represents change variety-
son(e)
arg1 shape
variety being converted to no(e)
0 pt(e)
NULL
clear_tag
: represents make_value-
son(e)
NULL
shape
shape of value required no(e)
0 pt(e)
NULL
component_tag
: represents component-
Always removed by refactor.c. Should not occur elsewhere.
compound_tag
: Represents the compound construction-
son(e)
arg2 in the form of a brother list of zero or more pairs. The first of each pair will be a val_tag with shape some offset. Its no field will be the offset in which to put the next item of the pair. shape
compound(arg1). pt(e)
NULL
no(e)
0 concatnof_tag
: represents concat nof-
son(e)
arg1 bro(arg1)
arg2. arg1 and arg2 will be nof(m, s) and nof(n, s) shape
nof(m + n, s) no(e)
0 pt(e)
NULL
cond_tag
: Represents conditional construction-
son(e)
first bro(son(e))
alt, which will be a labst_tag shape
LUB of first and alt pt(e)
NULL
no(e)
0 cont_tag
: represents contentscontvol_tag
: represents contents with volatile qualifier-
son(e)
arg1 (a pointer) shape
shape of value being extracted no(e)
0 pt(e)
NULL
Properties in the props field are defined in <reader/exp.h>
current_env_tag
: represents current env-
son(e)
NULL
shape
pointer(frame alignment) no(e)
0 pt(e)
NULL
diagnose_tag
: represents a diagnosing operation-
dno(e)
diag_info (qv.) son(e)
controlled exp. shape
sh(son(e)) pt(e)
NULL
div0_tag
div1_tag
div2_tag
: represent div0/1/2-
son(e)
arg1 bro(arg1)
arg2 shape
sh(arg1) unless changed by chvar_tag (HAS_BYTEOPS) no(e)
0 pt(e)
labst if error_jump, NULL
otherwiseRemember to increment labst count if used.
env_offset_tag
: represents env_offset-
son(e)
ident_tag referred to shape
offset from frame alignment. no(e)
0 pt(e)
NULL
fabs_tag
: represents floating abs-
son(e)
arg1 shape
sh(arg1) no(e)
0 pt(e)
labst if error_jump, NULL
otherwiseRemember to increment labst count if used.
fdiv_tag
: represents floating division-
son(e)
arg1 bro(arg1)
arg2 shape
sh(arg1) no(e)
0 pt(e)
labst if error_jump, NULL
otherwiseRemember to increment labst count if used.
field_tag
: represents selection from a compound shape-
son(e)
arg1 (value of shape compound) shape
shape of the component required no(e)
the offset (in bits) from the start of the compound to the required component. pt(e)
NULL
float_tag
: represents conversion from int to float-
son(e)
arg1 (int) shape
the floating shape required. no(e)
0 pt(e)
labst if error_jump, NULL
otherwiseRemember to increment labst count if used.
fmax_tag
fmin_tag
: represents floating maximum and minimum-
son(e)
arg1 bro(arg1)
arg2 shape
sh(arg1) no(e)
0 pt(e)
NULL
fminus_tag
: represents floating subtraction-
son(e)
arg1 bro(arg1)
arg2 shape
sh(arg1) no(e)
0 pt(e)
labst if error_jump, NULL
otherwiseRemember to increment labst count if used.
fmult_tag
: represents floating multiplication-
son(e)
a brother list of argument, all of the same shape. At least two arguments. After check any constants will have been combined into one, which will be the last exp. if there is a constant contribution. shape
shape of son(e) no(e)
0 pt(e)
labst if error_jump, NULL
otherwiseRemember to increment labst count if used.
fneg_tag
: represents floating negation-
son(e)
arg1 shape
sh(arg1) no(e)
0 pt(e)
labst if error_jump, NULL
otherwise.Remember to increment labst count if used.
fplus_tag
: represents floating addition-
son(e)
a brother list of argument, all of the same shape. At least two arguments. After check any constants will have been combined into one, which will be the last exp if there is a constant contribution. shape
shape of son(e) no(e)
0 pt(e)
labst if error_jump, NULL
otherwiseRemember to increment labst count if used.
fpower_tag
: represents floating power-
son(e)
arg1 bro(arg1)
arg2 shape
shape of son(e) no(e)
0 pt(e)
labst if error_jump, NULL
otherwiseRemember to increment labst count if used.
goto_tag
: Represents goto construction-
son(e)
NULL
shape
bottom pt(e)
destination labst_tag Create using me_l1, then set the pt field and increment the usage counter in the labst_tag.
goto_lv_tag
: Represents the goto_local_lv construction-
son(e)
local_lv value shape
bottom pt(e)
NULL
no(e)
0 hold_tag
: used as a dummy father at some times-
son(e)
exp being so held. ident_tag
: Represents identify and variable constructions-
For identify:
son(e)
definition bro(son(e))
body For variable:
son(e)
init bro(son(e))
body The shape of the result is the shape of body. The no(e) is a count of the number of uses. The pt(e) is the start of a chain of uses through name_tag's.
Properties in the props field are defined in <reader/exp.h>
Create an ident_tag using me_startid, add name_tag uses of it using me_obtain, complete the definition using me_complete_id.
ignorable_tag
: represents ignorable construction-
son(e)
exp being controlled shape
sh(son(e)) no(e)
0 pt(e)
NULL
imag_tag
: represents imaginary part-
son(e)
complex number shape
floating shape with same control parameters as the complex no(e)
0 pt(e)
NULL
int_to_bitf_tag
: represents integer to bitfield conversion-
son(e)
arg1 (int) shape
bitfield required no(e)
0 pt(e)
NULL
labst_tag
: Represents exps which are destination of jumps.-
Produced from alt of conditional, body of repeat and each place of labelled.
son(e)
a holder bro(son(e))
the destination exp shape
shape of bro(son(e)) pt(e)
NULL
Properties in the props field are defined in <reader/exp.h>
The holder (i.e. the son of the labst) can have any name_tag; its no field is the number of uses of the labst and its bro is the destination exp. No other field is defined.
last_local_tag
: represents last_local construction-
son(e)
NULL
shape
top pt(e)
pointer(x) no(e)
0 local_free_all_tag
: represents local_free_all construction-
son(e)
NULL
shape
top pt(e)
NULL
no(e)
0 local_free_tag
: Represents local_free construction-
son(e)
arg2 (pointer) bro(son(e))
arg1 (offset) shape
top pt(e)
NULL
no(e)
0 long_jump_tag
: Represents long_jump construction-
son(e)
arg1 bro(son(e))
arg2 shape
bottom pt(e)
NULL
no(e)
0 make_complex_tag
: represent make complex number-
son(e)
arg1 bro(arg1)
arg2 no(e)
0 pt(e)
NULL
make_lv_tag
: represents make label value-
son(e)
NULL
shape
lv pt(e)
labst no(e)
0 Remember to increment labst count.
max_tag
min_tag
: represent maximum and minimum integer ops-
son(e)
arg1 bro(arg1)
arg2 no(e)
0 pt(e)
NULL
minptr_tag
: Represents subtract_pointers construction-
son(e)
arg1 bro(son(e))
arg2 shape
offset(al1(arg2),al1(arg1)) pt(e)
NULL
no(e)
0 minus_tag
: represents subtraction-
This is replaced by addition of negation by refactor.c.
mod_tag
: Represents rem1 construction-
son(e)
arg1 bro(son(e))
arg2 shape
sh(arg1) pt(e)
labst if error_jump, NULL
otherwise.no(e)
0 movecont_tag
: Represents move_some construction-
son(e)
arg1 bro(son(e))
arg2 bro(bro(son(e)))
arg3 shape
top pt(e)
NULL
no(e)
0 Properties in the props field are defined in <reader/exp.h>
mult_tag
: represents integer multiplication-
son(e)
a brother list of argument, all of the same shape. At least two arguments. After check any constants will have been combined into one, which will be the last exp if there is a constant contribution. shape
shape of son(e) no(e)
0 pt(e)
labst if error_jump, NULL
otherwiseRemember to increment labst count if used.
name_tag
: Represents obtain_tag-
son(e)
declaration (an ident_tag). no(e)
offset in bits from the start of that declaration's value pt(e)
the next name_tag on the chain of uses of an ident_tag, which started in th pt field of the ident_tag, or NULL
if the end of the chain.Properties in the props field are defined in <reader/exp.h>
Remember to increment ident_tag count or use me_obtain from me_fns.c to create this.
ncopies_tag
: represents ncopies-
son(e)
value to be copied no(e)
n, the number of copies shape
nof(n, sh(son(e))) pt(e)
NULL
neg_tag
: Represents negate construction-
son(e)
arg1 shape
sh(arg1) no(e)
0 pt(e)
destination labst if ov_err is error_jump, otherwise NULL
nof_tag
: represents the make_nof construction-
son(e)
arg1 as a brother list of zero or more exps, each of the same shape (under eq_shape) shape
nof(n, shape of item) pt(e)
NULL
no(e)
0 not_tag
: Represents logical complement construction-
son(e)
arg1 shape
sh(arg1) no(e)
0 pt(e)
NULL
null_tag
: represent ptrNULL
and proc null-
son(e)
NULL
shape
pointer(approprite alignment) no(e)
0 pt(e)
NULL
offset_add_tag
: Represents offset_add construction-
son(e)
arg1 bro(son(e))
arg2 shape
offset(max(al1(arg1),al1(arg2)),al2(arg2)) pt(e)
NULL
no(e)
0 offset_div_tag
: Represents offset_div construction-
son(e)
arg1 bro(son(e))
arg2 shape
integer(v) pt(e)
NULL
no(e)
0 offset_div_by_int_tag
: Represents offset_div_by_int construction-
son(e)
arg1 bro(son(e))
arg2 shape
offset(x,x) pt(e)
NULL
no(e)
0 offset_max_tag
: Represents offset_max construction-
son(e)
arg1 bro(son(e))
arg2 shape
offset(max(al1(arg1),al1(arg2)),max(al2(arg1),al2(arg2))) pt(e)
NULL
no(e)
0 offset_mult_tag
: Represents offset_mult construction-
son(e)
arg1 bro(son(e))
arg2 shape
offset(x,x) pt(e)
NULL
no(e)
0 offset_negate_tag
: Represents offset_negate construction-
son(e)
arg1 shape
offset(x,x) pt(e)
NULL
no(e)
0 offset_pad_tag
: represents offset pad-
son(e)
arg1 (offset) shape
offset of required padded shape no(e)
0 pt(e)
NULL
offset_subtract_tag
: Represents offset_subtract construction-
son(e)
arg1 bro(son(e))
arg2 shape
offset(al2(arg1),al2(arg2)) pt(e)
NULL
no(e)
0 or_tag
: represents or-
son(e)
a brother list of argument, all of the same shape. At least two arguments. After check any constants will have been combined into one, which will be the last exp if there is a a constant contribution. shape
shape of son(e) no(e)
0 pt(e)
NULL
plus_tag
: represents the combination of plus and minus constructions-
son(e)
a brother list of argument, all of the same shape. At least two arguments. After check any constants will have been combined into one, which will be the last exp if there is a constant contribution. shape
shape of son(e) no(e)
0 pt(e)
destination labst if ov_err is error_jump, otherwise NULL
power_tag
: represents integer power-
son(e)
arg1 bro(arg1)
arg2 shape
sh(arg1) no(e)
0 pt(e)
labst if error_jump, NULL
otherwiseRemember to increment labst count if used.
proc_tag
: represents make_proc-
son(e)
body of procedure, starting with declarations (ident_tag) of parameters. shape
proc no(e)
0 pt(e)
shape of return Properties in the props field are defined in <reader/exp.h>
prof_tag
: represents profile exp-
son(e)
NULL
shape
top no(e)
expected number of times through this point pt(e)
NULL
real_tag
: represents a floating point constant-
son(e)
NULL
shape
a floating shape (not complex) no(e)
index of number in flptnos pt(e)
NULL
realpart_tag
: represents operation to take the real part of a complex-
son(e)
arg1 (complex) shape
floating derived from same controls as complex no(e)
0 pt(e)
NULL
reff_tag
: represents increment of a pointer by a constant offset-
son(e)
arg1 (pointer) shape
shape of resulting pointer no(e)
offset in bits pt(e)
NULL
rem0_tag
rem2_tag
: Represents rem0/2 construction-
son(e)
arg1 bro(son(e))
arg2 shape
sh(arg1) pt(e)
labst if error_jump, NULL
otherwiseno(e)
0 rep_tag
: represents repeat construction power/scan.c: * The arguments are effectively independent pieces of code * for these constructions. -
son(e)
start bro(son(e))
body, which will be a labst_tag shape
shape of body pt(e)
loop record of this repeat no(e)
0 Properties in the props field are defined in <reader/exp.h>
res_tag
: Represents the return construction-
son(e)
arg1 shape
bottom pt(e)
NULL
no(e)
0 rotl_tag
rotr_tag
: represent rotate left and right-
son(e)
arg1 (value to be rotated) bro(arg1)
arg2 (no of places) shape
sh(arg1) no(e)
0 pt(e)
NULL
round_tag
: represents round_with_mode construction-
son(e)
arg1 shape
integer(r) no(e)
0 pt(e)
destination labst if ov_err is error_jump, otherwise NULL
seq_tag
: Represents the sequence construction-
bro(son(e))
result. son(e) is statements in the form of a zero-named exp, with its son as the first statement, and the remaining statements chained through the bro fields. shape
the shape of result pt(e)
NULL
no(e)
0 Use new_exp_list to start and empty sequence, add_exp_list to add an exp. When all but the result exp have been added, use clear_exp_list on the list. Then create the sequence with f_sequence.
shl_tag
: Represents shift_left construction-
son(e)
arg1 bro(son(e))
arg2 shape
sh(arg1) no(e)
0 pt(e)
labst if error_jump, NULL
otherwise.Remember to increment labst count if used.
shr_tag
: Represents shift_right construction-
son(e)
arg1 bro(son(e))
arg2 shape
sh(arg1) no(e)
0 pt(e)
NULL
solve_tag
: Represents the labelled construction power/scan.c: * The arguments are effectively independent pieces of code * for these constructions. -
son(e)
starter bro(son(e))
the start of a brother list of one or more exps, which will be labst_tag's for each of the places shape
LUB of starter and each of the places pt(e)
loop record of this solve no(e)
0; Properties in the props field are defined in <reader/exp.h>
string_tag
: represents constant array of integers-
son(e)
NULL
shape
nof(n, s) nostr(e)
pointer to array of integers pt(e)
NULL
Properties in the props field are defined in <reader/exp.h>
subptr_tag
: represents subtract offset from pointer-
No longer used.
testbit_tag
: Introduced by check to replace test(nt, and(x, mask), 0) if tn is equal or not_equal.-
son(e)
x bro(son(e))
mask (not necessarily constant) shape
top no(e)
either between 0 and 100 inclusive, in which case the probability of continuing to the next construction (not jumping), or no(e) is 1000 in which case the probability of jumping is not known. pt(e)
destination labst_tag test_tag
: Represents floating_test, integer_test, local_lv_test offset_test, pointer_test, proc_test constructions.-
son(e)
arg1 bro(son(e))
arg2 shape
top no(e)
either between 0 and 100 inclusive, in which case the probability of continuing to the next construction (not jumping), or no(e) is 1000 in which case the probability of jumping is not known. pt(e)
destination labst_tag Create using me_q1 or me_q2 which will increment the usage counter in the labst_tag.
If a test_tag is removed from the tree it must be killed using kill_exp which will decrease the labst usage count AND kill the arguments. If the arguments must not be killed, the labst count must be decreased explicitly.
top_tag
: represents “do nothing” operation-
son(e)
NULL
shape
top no(e)
0 pt(e)
NULL
val_tag
: represents constant integers and offsets-
son(e)
NULL
shape
integer or offset shape pt(e)
NULL
no(e)
if shape is integer and !isbigval(e), no(e) is the number. if shape is integer and isbigval(e), no(e) is the index of a representation of the integer in flptnos. if shape is offset, no(e) the offset measured in bits. Properties in the props field are defined in <reader/exp.h>
general_proc_tag
-
son
(ident for caller-formal as in proc_tag) .... with body = (ident for callee_formal with def = formal_callee_tag) .... with body of proc props
procprops shape
proc pt(e)
shape of return. apply_general_tag
-
son
proc bro(son)
exp(tag = 0; props = procprops; no = number of otagexps; son = list of otagexps ie caller actuals) if tag is present in otagexp, then name(otagexp) = caller_tag son(otagexp) = actual and postlude will have ident with def = caller_name_tag and no(def) = no of corresponding caller_tag in the otagexp list, starting from 0 else otagexp is the actual exp bro(bro(son))
callees = (1) make_callee_list_tag with son list of exps and number = number in list (2) make_dynamic_callee_tag with son ptr and bro(son) size (3) same_callees_tag and props = procprops bro(bro(bro(son)))
postlude with tags identified as above tail_call_tag
-
son
proc bro(son)
(tag = 0; props = procprops; son = callees as above) untidy_return
-
son
result exp trap_tag
-
no()
error_code