There are port-specific directories, such as device/lib/z80 for port-specific code.
Unfortunately, the mcs51 port doesn't seem to honor this directory structure, cluttering files in device/lib with lots of #ifdefs and mcs51-specific code. Most of the time there are just some mcs51-specific variants of an individual function, followed by a generic version. This makes the runtime library harder to read, understand, maintain and extend.
All (or at least most, some two lines #ifdefed somewhere don't matter) of the mcs51-specific code should be moved to the respective port-specific directories.