[AVR] Expand 8/16-bit multiplication to libcalls on MCUs that don't have hardware MUL
authorDylan McKay <me@dylanmckay.io>
Fri, 18 Jan 2019 06:10:41 +0000 (06:10 +0000)
committerDylan McKay <me@dylanmckay.io>
Fri, 18 Jan 2019 06:10:41 +0000 (06:10 +0000)
commit7203e00b5e4e83117524242df372c293b0952d60
treeca9dcb23c7032a23e6706cbbe0c4effb0c948b52
parentf47bef661ec171a5de35816365c05738be7159cd
[AVR] Expand 8/16-bit multiplication to libcalls on MCUs that don't have hardware MUL

This change modifies the LLVM ISel lowering settings so that
8-bit/16-bit multiplication is expanded to calls into the compiler
runtime library if the MCU being targeted does not support
multiplication in hardware.

Before this, MUL instructions would be generated on CPUs like the
ATtiny85, triggering a CPU reset due to an illegal instruction at
runtime.

First raised in https://github.com/avr-rust/rust/issues/124.

llvm-svn: 351523
llvm/lib/Target/AVR/AVRISelLowering.cpp
llvm/lib/Target/AVR/AVRISelLowering.h
llvm/lib/Target/AVR/AVRSubtarget.cpp
llvm/lib/Target/AVR/AVRSubtarget.h
llvm/test/CodeGen/AVR/hardware-mul.ll [moved from llvm/test/CodeGen/AVR/mul.ll with 90% similarity]
llvm/test/CodeGen/AVR/smul-with-overflow.ll
llvm/test/CodeGen/AVR/software-mul.ll [new file with mode: 0644]
llvm/test/CodeGen/AVR/umul-with-overflow.ll