[fpc-devel] [Suggestion] Enumeration range-check intrinsic

Sven Barth pascaldragon at googlemail.com
Tue Jul 9 07:41:42 CEST 2019


Am 08.07.2019 um 02:52 schrieb J. Gareth Moreton:
> On an extra note, the assembly language produced is not yet optimal, 
> so it may end up that an x86-specific implementation will be 
> beneficial.  TIsNode contains a virtual method named 
> "DoVariableEnumCheck" that would allow such an extension, coupled with 
> returning "nil" that would defer code generation to 
> "pass_generate_code" (allowing this, but not overriding 
> "pass_generate_code", will trigger an internal error, because the 'is' 
> node normally never allows it to be called).  Nevertheless, even if 
> that is a no-go, it's making me a little excited to see if I can find 
> new peephole optimisations to implement.  But until my old x86_64 
> overhaul is accepted, rejected or reworked (at least to make it 
> successfully merge), I can't really make any new additions yet.
Some non-technical remarks regarding code formatting (I know the 
compiler does currently not use a consistent style, but there is one 
that is considered the de facto one (I should find the time to write 
that down in the Wiki some time -.-) and new code should be added 
following this):
- no spaces between operators and symbols, both in assignments and 
expressions as well as parameter declarations
- local variables are written in lower case with the declarations as 
"name1,name2,name3 : type"
- types are written in lower case
- method names are lower case with '_' as separator between words (so 
your DoVariableEnumCheck would become do_variable_enum_check)

And one very important technical remark:
*No* "as" (or "is") inside the compiler. Use hard casts as you already 
checked for the def type

Regards,
Sven


More information about the fpc-devel mailing list