next up previous contents
Next: 4.6 An example with Up: 4 The classifier Previous: 4.4 Chunk level

4.5 Literal level and argument level

Syntax:

 
literal_classification    		 ::= 		 (usrlit (functor arglist_classification) literal_descr)

lispcall_classification ::= (lispcall_type (lisp-builtin arglist_classification)

lispcall_descr)

builtin ::= unknown tex2html_wrap_inline2907 is_primitive tex2html_wrap_inline2907 (refl-Xreg lhs_term)

arglist_classification ::= {term_classification}*

term_classification ::= constant_classification tex2html_wrap_inline2907 variable_classification

tex2html_wrap_inline2907 structure_classification

is_primitive ::= (is lhs_term rhs_term)

lhs_term ::= constant_classification tex2html_wrap_inline2907 variable_classification

rhs_term ::= term_classification

constant_classification ::= constant_name

variable_classification ::= (variable local_var_descr)

structure_classification ::= `(functor arglist_classification)

tex2html_wrap_inline2907 (inst (functor arglist_classification))

local_var_descr ::= (occurrence saveness var_class)

literal_descr ::= (arity env_size arg_seq)

lispcall_descr ::= (arity env_size arg_seq)

Description:

term_classification
A term is a denotative literal. The inst_op (```'' or ``inst'') indicates that a literal is a denotative (sometimes called passive) one.
local_var_descr
A variable is locally described (with respect to all its occurrences in the clauses) by the local_var_descr. It is a list of three elements (occurrence saveness var_class). The occurrence can be first, nonfirst, or reuse. While the meaning of first and nonfirst is intuitively clear, reuse means that the classifier has assigned a register to more than one temporary variable. If a variable occurs first it gets the information reuse (instead of first) when the register was assigned to another temporary variable before in the same chunk. This is more an information for the user than for the code generator. Because of the different possible references of a variable, we describe the different reference states by the information saveness. The saveness is distinguished into global (a reference to the heap), safe (a reference to a caller environment or to the heap), and unsafe (a possible reference to the local environment). The information var_class tells the code generator whether the variable is temp or perm.
literal_descr
The arity gives the number of arguments in the literal.
env_size
denotes how many permanent variables have to survive the call to the literal. The Y-register assignment in the permvar_list has been done in a way that the env_size is as small as possible.
arg_seq
is a list that tells the code generator in which order the argument positions have to be represented by GWAM instructions. It is possible that some arguments need no instructions. A missing argument position in arg-seq indicates such a case.

Example:

Prolog-like source:
foo(alpha,beta).
foo(T,gamma) :- bar(T,P) !& bar(P,Q).
.  .  .
Lisp-like source:
(hn (foo alpha beta))
(ft (foo _t gamma) (bar _t _p) ! (bar _p _q))
.  .  .

Classified Clauses:

(db (proc foo/2 2 (indexing ...)
       (rel0
             (cut-info nil)
             (perm) (temp)
             (chunk
                    ((usrlit (foo alpha beta)
                             (2 0 (1 2)))) ; The literal foo has 2
                                      ; arguments. The env_size is 0.
                                      ; Use the order given in
                                      ; arg_seq (1st: alpha, 2nd:
                                      ; beta.
                    nil))             ; No chunk description needed
       (fun*eva
             (cut-info general)
             (perm (_p (1 nil (2 1))))
             (temp (_t (1 (1) (1))) (_q (2 nil (2))))
             (chunk
                    ((usrlit (foo (_t (first safe temp)); _t occurs
                                      ; first and is safe because
                                      ; it has a reference to the
                                  gamma); caller's environment
                             (2 1 (2))); _t needs no instruction
                                       ; since it stays first arg
                     (usrlit (bar (_t (nonfirst safe temp))
                                  (_p (first unsafe perm)))
                                      ; _p is potentially unsafe
                             (2 1 (2)))); As above!
                                      ; No instruction for _t
                    (2 ((_p (2)))) )
             (chunk ((cutlit (cut) (0 1 nil))) (0 nil))
             (chunk
                    ((usrlit (bar (_p (nonfirst unsafe perm))
                                  (_q (first unsafe temp)))
                     (2 0 (1 2))))
                    (2 ((_p (1)))))))
    .  .  .)

Remark:
The WAM-instruction meaning of the Classified Clauses is described in paragraph 5, where an introduction to the code generator is given. The code generator takes as input the Classified Clauses for RELFUN and produces the GWAM code. Therefore, in paragraph 5 you can find more detailed information on how the added annotations are used for code generation.


next up previous contents
Next: 4.6 An example with Up: 4 The classifier Previous: 4.4 Chunk level

Harold Boley (boley@informatik.uni-kl.de)