]> granicus.if.org Git - re2c/commit
Optimized pointer arithmetics generated with '-C, --contexts'.
authorUlya Trofimovich <skvadrik@gmail.com>
Tue, 29 Mar 2016 14:16:01 +0000 (15:16 +0100)
committerUlya Trofimovich <skvadrik@gmail.com>
Tue, 29 Mar 2016 14:16:01 +0000 (15:16 +0100)
commit7aac1ad2d440c47ea458e6da20f2a83d95f3b08e
tree519775f075fdeec44df28806a4ddea2e326e6c54
parentf506af77bb7d9d68fcddecf28878ae80cc68a90f
Optimized pointer arithmetics generated with '-C, --contexts'.

If default input API is used and fixed-length context is based on
the rightmost context (that is, YYCURSOR), then the following expression
(that calculates pointer corresponding to the given context):
    (YYCTXMARKER + ((YYCURSOR - YYCTXMARKER) - yyctx))
can be optimized to:
    (YYCURSOR - yyctx)

Note: unfortunately, as of GCC < 7.0, expressions like:
    (YYCURSOR - 3) - (YYCURSOR - 5)
trigger warning:
    warning: integer overflow in expression [-Woverflow]
See this GCC bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61240
re2c/src/codegen/emit_action.cc
re2c/src/codegen/input_api.cc
re2c/src/codegen/input_api.h
re2c/test/contexts/fix2.i--contexts.c
re2c/test/contexts/fix2_trail.i--contexts--input(custom).c
re2c/test/contexts/fix2_trail.i--contexts.c
re2c/test/contexts/fix4.i--contexts.c