Alien-TinyCC
view release on metacpan or search on metacpan
src/tcc-doc.texi view on Meta::CPAN
If any code is generated which destroys the CPU flags, this value MUST be
put in a normal register.
@item VT_JMP
@itemx VT_JMPI
indicates that the value is the consequence of a conditional jump. For VT_JMP,
it is 1 if the jump is taken, 0 otherwise. For VT_JMPI it is inverted.
These values are used to compile the @code{||} and @code{&&} logical
operators.
If any code is generated, this value MUST be put in a normal
register. Otherwise, the generated code won't be executed if the jump is
taken.
@item VT_LVAL
is a flag indicating that the value is actually an lvalue (left value of
an assignment). It means that the value stored is actually a pointer to
the wanted value.
Understanding the use @code{VT_LVAL} is very important if you want to
understand how TCC works.
@item VT_LVAL_BYTE
@itemx VT_LVAL_SHORT
@itemx VT_LVAL_UNSIGNED
if the lvalue has an integer type, then these flags give its real
type. The type alone is not enough in case of cast optimisations.
@item VT_LLOCAL
is a saved lvalue on the stack. @code{VT_LLOCAL} should be eliminated
ASAP because its semantics are rather complicated.
@item VT_MUSTCAST
indicates that a cast to the value type must be performed if the value
is used (lazy casting).
@item VT_SYM
indicates that the symbol @code{SValue.sym} must be added to the constant.
@item VT_MUSTBOUND
@itemx VT_BOUNDED
are only used for optional bound checking.
@end table
@subsection Manipulating the value stack
@cindex value stack
@code{vsetc()} and @code{vset()} pushes a new value on the value
stack. If the previous @var{vtop} was stored in a very unsafe place(for
example in the CPU flags), then some code is generated to put the
previous @var{vtop} in a safe storage.
@code{vpop()} pops @var{vtop}. In some cases, it also generates cleanup
code (for example if stacked floating point registers are used as on
x86).
The @code{gv(rc)} function generates code to evaluate @var{vtop} (the
top value of the stack) into registers. @var{rc} selects in which
register class the value should be put. @code{gv()} is the @emph{most
important function} of the code generator.
@code{gv2()} is the same as @code{gv()} but for the top two stack
entries.
@subsection CPU dependent code generation
@cindex CPU dependent
See the @file{i386-gen.c} file to have an example.
@table @code
@item load()
must generate the code needed to load a stack value into a register.
@item store()
must generate the code needed to store a register into a stack value
lvalue.
@item gfunc_start()
@itemx gfunc_param()
@itemx gfunc_call()
should generate a function call
@item gfunc_prolog()
@itemx gfunc_epilog()
should generate a function prolog/epilog.
@item gen_opi(op)
must generate the binary integer operation @var{op} on the two top
entries of the stack which are guaranted to contain integer types.
The result value should be put on the stack.
@item gen_opf(op)
same as @code{gen_opi()} for floating point operations. The two top
entries of the stack are guaranted to contain floating point values of
same types.
@item gen_cvt_itof()
integer to floating point conversion.
@item gen_cvt_ftoi()
floating point to integer conversion.
@item gen_cvt_ftof()
floating point to floating point of different size conversion.
@item gen_bounded_ptr_add()
@item gen_bounded_ptr_deref()
are only used for bounds checking.
@end table
@section Optimizations done
@cindex optimizations
@cindex constant propagation
@cindex strength reduction
@cindex comparison operators
@cindex caching processor flags
( run in 0.503 second using v1.01-cache-2.11-cpan-ed4147ee29a )