-
Notifications
You must be signed in to change notification settings - Fork 12k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
------------------------------------------------------------------------ r351523 | dylanmckay | 2019-01-17 22:10:41 -0800 (Thu, 17 Jan 2019) | 12 lines [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 avr-rust/rust-legacy-fork#124. ------------------------------------------------------------------------ llvm-svn: 361551
- Loading branch information
Showing
8 changed files
with
70 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
llvm/test/CodeGen/AVR/mul.ll → llvm/test/CodeGen/AVR/hardware-mul.ll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
; RUN: llc -mattr=avr6,-mul < %s -march=avr | FileCheck %s | ||
; RUN: llc -mcpu=attiny85 < %s -march=avr | FileCheck %s | ||
; RUN: llc -mcpu=ata5272 < %s -march=avr | FileCheck %s | ||
; RUN: llc -mcpu=attiny861a < %s -march=avr | FileCheck %s | ||
; RUN: llc -mcpu=at90usb82 < %s -march=avr | FileCheck %s | ||
|
||
; Tests lowering of multiplication to compiler support routines. | ||
|
||
; CHECK-LABEL: mul8: | ||
define i8 @mul8(i8 %a, i8 %b) { | ||
; CHECK: mov r25, r24 | ||
; CHECK: mov r24, r22 | ||
; CHECK: mov r22, r25 | ||
; CHECK: call __mulqi3 | ||
%mul = mul i8 %b, %a | ||
ret i8 %mul | ||
} | ||
|
||
; CHECK-LABEL: mul16: | ||
define i16 @mul16(i16 %a, i16 %b) { | ||
; CHECK: movw r18, r24 | ||
; CHECK: movw r24, r22 | ||
; CHECK: movw r22, r18 | ||
; CHECK: call __mulhi3 | ||
%mul = mul nsw i16 %b, %a | ||
ret i16 %mul | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters