Does anyone know a way of finding 64-bit divisions in an existing codebase? Possibly by introducing a compile error or warning for 64-bit division. (gcc or clang)?
Background is I would like to replace all 64-bit divisions in said code base with a custom function for example a/b
would be replaced by my64_div(a, b);
. To make it easier to port the code to ARM 32 bit platforms.
I guess I could cross-compile it for ARM 32 and look at the compilation errors. Is there a way to do this without cross-compilation?
Possibly a python script with a cparser library that could find 64-bit divisions? I have used PyCLibrary for a different task before but I don't see a way to use it for this purpose. Any hints are appreciated.
Edit: A little more background why I need this. There are 3 teams involved here.
Research team: they write their code without caring too much about 64-bit divisions.
My team: We integrate the research library in our code. And we make the final product. Which is delivered as source code.
Customer: Some of our customers will port this code to ARM 32-bit kernel. And they want to replace the 64-bit divisions with their own optimized functions.
Teams 1. and 2. use mostly 64 bit PCs to compile the code. It would be great to find 64-bit divisions at this stage, for one because they are expensive and we are trying to avoid them. So it would be great to have them flagged during nightly builds. Secondly, we want to make our customers' life easier. Meaning if we replace all 64-bit divisions by a custom function, they just need to replace function with another function. The rest of the source code can stay untouched.
The cross compilation and detecting __udivdi3 is certainly a possibility, and maybe the only option. But I was hoping there might be another solution out there.