logging: Optimize handling of simple and common log messages

Some compilers (e.g. riscv32) does not handle well complex macros
for logging. Generated code is bigger than expected (e.g. riscv32
code is almost twice bigger than cortex-m code). Use of logging can
lead to unexpected code increase.

To handle that an analysis of the zephyr code base was performed and
it shown that 75-80% of logs are simple strings with 0 arguments
(~45%), one 32 bit argument (~26%) or two 32 bit arguments (~6%).
Given that a set of dedicated macro were created which are applied
to those 3 cases which on 32 bit platform create very simple log
messages without padding or alignment needed.

Such dedicated macros save up to 40% of code (riscv32) and also
executes 30% faster (arm cortex and riscv32).

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
4 files changed