[Patch / Refactor] Reference helper function
Original Reporter info from Mantis: CuriousKit @CuriousKit
-
Reporter name: J. Gareth Moreton
Original Reporter info from Mantis: CuriousKit @CuriousKit
- Reporter name: J. Gareth Moreton
Description:
This patch introduces a new function for the peephole optimizer named "reference_is_local". It replaces multiple conditional checks such as:
...
(taicpu(p).oper[0]^.ref^.relsymbol = nil) and
(taicpu(p).oper[0]^.ref^.segment = NR_NO) and
(taicpu(p).oper[0]^.ref^.symbol = nil) and
...
and replaces it with a single function:
reference_is_local(taicpu(p).oper[0]^.ref^)
The idea being that it reduces maintenance costs by ensuring that a check isn't missed and simplifying large conditional blocks in the peephole optimizer.
Steps to reproduce:
Apply patch and confirm that compiled code (e.g. the RTL) does not change.
Additional information:
Though "reference_is_local" is marked as inline, the compiler doesn't seem to like it being compiled this way and builds it as a regular function. This isn't a major concern though.
The function is designed to be cross-platform, but currently it is only utilised by the x86 peephole optimizer. It should be compatible with other platforms though.
The patch also contains an implementation for a pass-through "debug_str" function that's designed to help the compiler strip out literals in debug messages when making a release build. This isn't used anywhere yet, but if accepted, will be used in the near-future.
I had some difficulty deciding a name for the helper function; alternative names were "reference_is_regular" and "reference_is_relative". If anyone has a name that's better than "reference_is_local", feel free to change it.
Mantis conversion info:
- Mantis ID: 38595
- OS: Microsoft Windows
- OS Build: 10 Home
- Build: r48887
- Platform: Cross-platform
- Version: 3.3.1