G'day all. On Thu, Apr 18, 2002 at 11:31:32PM -0400, Dan Sugalski wrote:
> Interesting. Could you give an example of how an op with metadata would look? Sure. Here's some of my experimenting with what is the right kind of metadata to attach. Brief glossary: - CANNOT_FALL_THROUGH means that the op will never goto NEXT(). - READS_STATE and AFFECTS_STATE refer to the state of the "world" (i.e. anything which isn't a register); the idea being that two ops which both read the state of the world can be swapped, but an op which READS_STATE and an op which AFFECTS_STATE cannot. (By conservative approximation, all PMC operations may affect state.) - BRANCH_TARGET_IS_* should be fairly self-explanatory, though this information is theoretically obtainable the same way that MAY_BRANCH is. (Though MAY_BRANCH is arguably metadata and could be subsumed by this mechanism.) For the future: - MAY_THROW_EXCEPTION - DEPRECATED - ALGEBRAIC_IDENTITY - DENOTATIONAL_SEMANTICS (ok, maybe not) Cheers, Andrew Bromage inline op ret() { goto POP(); } meta { CANNOT_FALL_THROUGH => 1 } inline op err(out INT) { $1 = errno; goto NEXT(); } meta { READS_STATE => 1 } inline op print(in INT) { printf(INTVAL_FMT, (INTVAL)$1); goto NEXT(); } meta { AFFECTS_STATE => 1 } inline op set(out NUM, in INT) { $1 = (FLOATVAL)$2; goto NEXT(); } inline op set(out NUM, in PMC) { $1 = $2->vtable->get_number(interpreter, $2); goto NEXT(); } meta { AFFECTS_STATE => 1 } inline op eq (in INT, in INT) { if ($1 == $2) { goto POP(); } goto NEXT(); } meta { BRANCH_TARGET_IS_POP => 1 } inline op eq(in INT, in INT, inconst INT) { if ($1 == $2) { goto OFFSET($3); } goto NEXT(); } meta { BRANCH_TARGET_IS_ARG => 3 }