tmk_keyboard/tmk_core/common
Purdea Andrei 061e662345 tmk_core/common/timer.h: Improve code generation for TIMER_DIFF* macros
Because of integer promotion the compiler is having a hard time generating
efficient code to calculate TIMER_DIFF* macros in some situations.
In the below example, the return value is "int", and this is causing the
trouble.

Example C code:

int __attribute__ ((noinline)) test(uint8_t current_timer, uint8_t start_timer)
{
    return TIMER_DIFF_8(current_timer, start_timer);
}

BEFORE: (with -Os)

00004c40 <test>:
    4c40:       28 2f           mov     r18, r24
    4c42:       30 e0           ldi     r19, 0x00       ; 0
    4c44:       46 2f           mov     r20, r22
    4c46:       50 e0           ldi     r21, 0x00       ; 0
    4c48:       86 17           cp      r24, r22
    4c4a:       20 f0           brcs    .+8             ; 0x4c54 <test+0x14>
    4c4c:       c9 01           movw    r24, r18
    4c4e:       84 1b           sub     r24, r20
    4c50:       95 0b           sbc     r25, r21
    4c52:       08 95           ret
    4c54:       c9 01           movw    r24, r18
    4c56:       84 1b           sub     r24, r20
    4c58:       95 0b           sbc     r25, r21
    4c5a:       93 95           inc     r25
    4c5c:       08 95           ret

AFTER: (with -Os)

00004c40 <test>:
    4c40:       86 1b           sub     r24, r22
    4c42:       90 e0           ldi     r25, 0x00       ; 0
    4c44:       08 95           ret

Note: the example is showing -Os but improvements can be seen at all optimization levels,
including -O0. We never use -O0, but I tested it to make sure that no extra code is
generated in that case.
2020-04-01 07:46:18 +03:00
..
avr core: Fix bootloader for 128KB flash 2019-12-04 15:09:36 +09:00
chibios make some change to complie stm32_f103_onekey with new version of Chibios (#583) 2018-11-07 08:08:08 +09:00
mbed Merge commit 'a074364c3731d66b56d988c8a6c960a83ea0e0a1' as 'tmk_core' 2015-04-10 01:32:04 +09:00
action.c core: Add AC_BTLD to actionmap and unimap 2019-09-17 20:55:35 +09:00
action.h core: Add utility type_code() in aciton.h #528 2018-01-28 16:17:20 +09:00
action_code.h core: Add AC_BTLD to actionmap and unimap 2019-09-17 20:55:35 +09:00
action_layer.c core: Fix out-of-bounds access by TICK event #487 2017-10-22 03:43:04 +09:00
action_layer.h core: Fix for build option NO_ACTION_LAYER 2017-09-14 12:58:06 +09:00
action_macro.c core: Fix variable initialize 2016-01-15 16:26:01 +09:00
action_macro.h core: Add utility macros in action_macro.h (#532) 2018-01-29 08:10:35 +09:00
action_tapping.c core: Fix for stuck key problem #441 2017-05-30 15:25:26 +09:00
action_tapping.h Merge commit 'a074364c3731d66b56d988c8a6c960a83ea0e0a1' as 'tmk_core' 2015-04-10 01:32:04 +09:00
action_util.c core: Fix for disabling NKRO in Boot protocol 2015-09-20 14:34:13 +09:00
action_util.h Merge commit 'a074364c3731d66b56d988c8a6c960a83ea0e0a1' as 'tmk_core' 2015-04-10 01:32:04 +09:00
actionmap.c core: Add unimap support 2016-08-29 13:54:44 +09:00
actionmap.h core: Add short name for keycode KP_00 and KP_000 2019-11-12 15:38:31 +09:00
backlight.c Merge commit 'a074364c3731d66b56d988c8a6c960a83ea0e0a1' as 'tmk_core' 2015-04-10 01:32:04 +09:00
backlight.h Merge commit 'a074364c3731d66b56d988c8a6c960a83ea0e0a1' as 'tmk_core' 2015-04-10 01:32:04 +09:00
bootloader.h Merge commit 'a074364c3731d66b56d988c8a6c960a83ea0e0a1' as 'tmk_core' 2015-04-10 01:32:04 +09:00
bootmagic.c Merge commit '71381457fa1311dfa0b58ba882a96db740640871' 2016-04-21 14:37:16 +09:00
bootmagic.h core: Actionmap support 2016-03-03 16:18:19 +09:00
command.c lufa: Print TMK version to console 2019-05-29 23:42:56 +09:00
command.h Fix header guard in tmk_core/common/command.h (#581) 2018-10-31 09:34:01 +09:00
debug.c Merge commit 'a074364c3731d66b56d988c8a6c960a83ea0e0a1' as 'tmk_core' 2015-04-10 01:32:04 +09:00
debug.h Merge commit '657d9f23fe47fb88cf221adb23095082f191ba6a' 2016-02-17 08:18:03 +09:00
eeconfig.h Merge commit 'a074364c3731d66b56d988c8a6c960a83ea0e0a1' as 'tmk_core' 2015-04-10 01:32:04 +09:00
hook.c core: Add hook_process_action() 2019-05-29 23:57:51 +09:00
hook.h core: Add hook_process_action() 2019-05-29 23:57:51 +09:00
host.c Merge commit '22b6e15a179031afb7c3534cf7b109b0668b602c' 2016-12-10 10:29:51 +09:00
host.h Merge commit '22b6e15a179031afb7c3534cf7b109b0668b602c' 2016-12-10 10:29:51 +09:00
host_driver.h Merge commit 'a074364c3731d66b56d988c8a6c960a83ea0e0a1' as 'tmk_core' 2015-04-10 01:32:04 +09:00
keyboard.c core: Typo (mantrix -> matrix) 2018-01-26 16:53:27 +09:00
keyboard.h Add keyboard_setup() and matrix_setup() 2015-05-19 00:39:43 +09:00
keycode.h core: Add short name for keycode KP_00 and KP_000 2019-11-12 15:38:31 +09:00
keymap.c core: Add AC_BTLD to actionmap and unimap 2019-09-17 20:55:35 +09:00
keymap.h Move declaration of keymap_config. 2015-10-12 09:46:48 +01:00
led.h usb_usb: Support locking key indicator LED 2015-07-15 15:13:15 +09:00
matrix.c core: Change matrix_init and matrix_print 2016-10-08 13:13:48 +09:00
matrix.h core: Change matrix_init and matrix_print 2016-10-08 13:13:48 +09:00
mousekey.c Merge commit 'a074364c3731d66b56d988c8a6c960a83ea0e0a1' as 'tmk_core' 2015-04-10 01:32:04 +09:00
mousekey.h Merge commit 'a074364c3731d66b56d988c8a6c960a83ea0e0a1' as 'tmk_core' 2015-04-10 01:32:04 +09:00
nodebug.h Workaround for compiler warnings when console disabled. 2015-12-03 09:05:09 +00:00
print.c Add ChibiOS support (USB stack + support files). 2015-09-07 21:57:04 +01:00
print.h Merge commit '657d9f23fe47fb88cf221adb23095082f191ba6a' 2016-02-17 08:18:03 +09:00
progmem.h Modularity and gcc warnings fixes. 2015-09-07 21:33:06 +01:00
report.h core:adb_usb: Add Extended Mouse Protocol support #274 2019-06-23 15:04:35 +09:00
ringbuf.h core: Add ring buffer file 2018-09-23 12:36:18 +09:00
sendchar.h Merge commit 'a074364c3731d66b56d988c8a6c960a83ea0e0a1' as 'tmk_core' 2015-04-10 01:32:04 +09:00
sendchar_null.c Merge commit 'a074364c3731d66b56d988c8a6c960a83ea0e0a1' as 'tmk_core' 2015-04-10 01:32:04 +09:00
sendchar_uart.c Merge commit 'a074364c3731d66b56d988c8a6c960a83ea0e0a1' as 'tmk_core' 2015-04-10 01:32:04 +09:00
sleep_led.h core: Fix sleep_led 2016-10-12 14:35:53 +09:00
suspend.h core: Add hook_usb_startup_wait_loop 2019-05-29 14:50:56 +09:00
timer.h tmk_core/common/timer.h: Improve code generation for TIMER_DIFF* macros 2020-04-01 07:46:18 +03:00
uart.h Merge commit 'a074364c3731d66b56d988c8a6c960a83ea0e0a1' as 'tmk_core' 2015-04-10 01:32:04 +09:00
unimap.c core: Fix unimap translation range 2020-02-03 12:47:01 +09:00
unimap.h core: Fix typo 2017-04-11 15:54:35 +09:00
util.c Merge commit 'a074364c3731d66b56d988c8a6c960a83ea0e0a1' as 'tmk_core' 2015-04-10 01:32:04 +09:00
util.h usb_usb: Add multiple keyboard support 2016-06-21 13:49:06 +09:00
wait.h Add ChibiOS support (USB stack + support files). 2015-09-07 21:57:04 +01:00