OSDN Git Service

[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)
commita3db7ac3457f887631d1e8f4d244cdd20d93cbe1
treef79ab6e607ae1a29f5d8028dae57d8ebc91aa53e
parentabe6bc1296a96938e277aa2f8ac99f9685a3d79e
[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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@351523 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/AVR/AVRISelLowering.cpp
lib/Target/AVR/AVRISelLowering.h
lib/Target/AVR/AVRSubtarget.cpp
lib/Target/AVR/AVRSubtarget.h
test/CodeGen/AVR/hardware-mul.ll [moved from test/CodeGen/AVR/mul.ll with 90% similarity]
test/CodeGen/AVR/smul-with-overflow.ll
test/CodeGen/AVR/software-mul.ll [new file with mode: 0644]
test/CodeGen/AVR/umul-with-overflow.ll