• No se han encontrado resultados

Variable Aceptación de los padres frente a la discapacidad

We have designed a language for expressing specifications, which we call TRANS, that captures the features described in the previous section. The syntax of TRANS is shown in Figure 3.4. Note that op, literal and num are L0 elements from Figure 3.1. We

overload logical binders and use standard CTL binding rules. The @ operator binds more weakly than operators on node conditions.

Throughout this chapter we description the semantics of the TRANS language with respect toL0. The fundamental aspects of the language can be applied to many

other languages. The syntax of the side conditions can remain the same, for example shows how it possible to incorporate aliasing conditions into side conditions. It is nec-

essary to change the syntax of the pattern matching component of TRANS in order to pattern match a particular programming language or intermediate representation.

3.2.1 Introductory Example

The language is simple, yet can express many standard compiler optimizations, particu- larly with the introduction ofstrategiesin 3.3, which combine transformations to create more complex transformations. As an example of TRANS in use, the constant copy propagation transformation is written as:

replace n with x:=e[c] if

stmt(x:=e[v])∧←A−(¬def(v)U stmt(v:=c))@ n ∧ conlit(c)

The part of the transformation before the if statement is the actionand after it is called theside condition. The action describes what changes are to be made to the program, whilst the side condition describes the conditions under which the program is to be transformed. This transformation is described in more detail on page 45.

Information is shared between the two parts through metavariables which are variables in TRANS that bind to parts of the program’s abstract syntax. The metavari- ables in this specification aren,x,e,candv. Within the TRANS languagee[c]denotes an expression containingcas an operand.

The transformation’s meaning is dependent on the values that these variables represent. Informally, the meaning of a transformation is to perform the specified actions of the transformation using some valuation of the meta-variables such that the side condition is true.

This side condition can be more easily understood by splitting it into three distinct components. conlit(c) requires that the metavariable c can only bind to a

literal ::= metavar |num |exit|start|seq |branch expr-pattern ::= literal | expr-pattern op expr-pattern | expr-pattern[expr-pattern] pattern ::= if (expr-pattern) | metavar:= expr-pattern | skip | ret(expr-pattern)

node-condition ::= node-condition ∨node-condition

| node-condition ∧node-condition | ¬ node-condition | ∃ metavar. node-condition | [EX|AX |←−−EX|←−−AX][literal] (node-condition) | [E|A|←E−|←A−](node-condition U node-condition) | node(literal) | stmt(pattern)

side-condition ::= side-condition ∨side-condition

| side-condition ∧side-condition

| ¬ side-condition

| ∃ metavar. side-condition

| node-condition @literal

| pred (literal1,. . . ,literaln)

action ::= replaceliteral with pattern1;pattern2;. . . ;patternn

| remove edge (literal,literal,literal)

| add edge (literal,literal,edge-type)

| add edge (literal,literal,metavar)

| split edge (literal,literal,pattern)

transform ::= action1,. . . ,actionn if side-condition

| MATCH side-conditionIN transform

| APPLY ALLtransform

| transform transform

| transform THEN transform

constant literal value, for example1. stmt(x:=e[v])is a predicate that pattern matches statements, it only matches assignments. If it matches at a statement thenx is bound to lval of the assignment,eto the rval, andvto any value within the expressione. Note this might also be the whole ofe. ←A−(¬def(v)U stmt(v :=c)) @nmeans that the only definition ofv that reachesnis v:=c.

The actions in this case is very simple — to simply replace the node n with a new statement that it has constructed. The pattern syntax here is the same form as used by thestmtpredicate, but instead of matching existing statements in the program, it is used to reconstruct new statements.

3.2.2 Macros, syntactic sugar

Rewriting is an important tool in this framework. The traditional way to write conditional rewrites (where a node can be replaced by a sequence of nodes) is as follows:

literal:pattern =⇒ pattern1;pattern2;. . . ;patternn

This notation is supported in our framework as syntactic sugar and mapped into

areplaceaction. For example, the conditional rewrite:

n:p=⇒q1;q2;. . .;qm, A1, A2, . . . , Ak

if

wherep is the pattern to be matched to the statement atn, is an alternate syntax for the action: replace n with q1;q2;. . .;qm, A1, A2, . . . , Ak if stmt(p)@ n∧φ

A macro definition provides a way to name commonly used formulae. Macros are of the following general form

let p(−→x),φ

The expressionp(−→τ) in a formula represents the syntactic substitutionφ[−→τ /−→x], where each variable in −→x is replaced by the corresponding term in −→τ . This allows one to specify formulae that will be used in several different transformations. Free variables are used in some macros when all the uses of the variables have specific denotations, such as loop head or loop tail.

As examples, two macros which match nodes that are connected and strongly connected, respectively, tom can be written as: e.g.

let connected to(m),E(T rue U node(m))

let strongly connected to(m),E(T rue U node(m))∧←E−(T rue U node(m)) Macros support the definition of temporal operatorseventually (F) and forever

(G) in terms of untiloperators in the standard way:

let EF(φ),E(true U φ)

let AF(φ),A(true U φ)

let EG(φ),¬AF(¬φ)

Documento similar