div.ll
2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
; RUN: llc -mattr=mul,movw < %s -march=avr | FileCheck %s
; Unsigned 8-bit division
define i8 @udiv8(i8 %a, i8 %b) {
; CHECK-LABEL: div8:
; CHECK: call __udivmodqi4
; CHECK-NEXT: ret
%quotient = udiv i8 %a, %b
ret i8 %quotient
}
; Signed 8-bit division
define i8 @sdiv8(i8 %a, i8 %b) {
; CHECK-LABEL: sdiv8:
; CHECK: call __divmodqi4
; CHECK-NEXT: ret
%quotient = sdiv i8 %a, %b
ret i8 %quotient
}
; Unsigned 16-bit division
define i16 @udiv16(i16 %a, i16 %b) {
; CHECK-LABEL: udiv16:
; CHECK: call __udivmodhi4
; CHECK-NEXT: movw r24, r22
; CHECK-NEXT: ret
%quot = udiv i16 %a, %b
ret i16 %quot
}
; Signed 16-bit division
define i16 @sdiv16(i16 %a, i16 %b) {
; CHECK-LABEL: sdiv16:
; CHECK: call __divmodhi4
; CHECK-NEXT: movw r24, r22
; CHECK-NEXT: ret
%quot = sdiv i16 %a, %b
ret i16 %quot
}
; Unsigned 32-bit division
define i32 @udiv32(i32 %a, i32 %b) {
; CHECK-LABEL: udiv32:
; CHECK: call __udivmodsi4
; CHECK-NEXT: movw r22, r18
; CHECK-NEXT: movw r24, r20
; CHECK-NEXT: ret
%quot = udiv i32 %a, %b
ret i32 %quot
}
; Signed 32-bit division
define i32 @sdiv32(i32 %a, i32 %b) {
; CHECK-LABEL: sdiv32:
; CHECK: call __divmodsi4
; CHECK-NEXT: movw r22, r18
; CHECK-NEXT: movw r24, r20
; CHECK-NEXT: ret
%quot = sdiv i32 %a, %b
ret i32 %quot
}
; Unsigned 64-bit division
define i64 @udiv64(i64 %a, i64 %b) {
; CHECK-LABEL: udiv64:
; CHECK: call __udivmoddi4
; CHECK-NEXT: ldd r18, Y+1
; CHECK-NEXT: ldd r19, Y+2
; CHECK-NEXT: ldd r20, Y+3
; CHECK-NEXT: ldd r21, Y+4
; CHECK-NEXT: ldd r22, Y+5
; CHECK-NEXT: ldd r23, Y+6
; CHECK-NEXT: ldd r24, Y+7
; CHECK-NEXT: ldd r25, Y+8
; CHECK: ret
%quot = udiv i64 %a, %b
ret i64 %quot
}
; Signed 64-bit division
define i64 @sdiv64(i64 %a, i64 %b) {
; CHECK-LABEL: sdiv64:
; CHECK: call __divmoddi4
; CHECK-NEXT: ldd r18, Y+1
; CHECK-NEXT: ldd r19, Y+2
; CHECK-NEXT: ldd r20, Y+3
; CHECK-NEXT: ldd r21, Y+4
; CHECK-NEXT: ldd r22, Y+5
; CHECK-NEXT: ldd r23, Y+6
; CHECK-NEXT: ldd r24, Y+7
; CHECK-NEXT: ldd r25, Y+8
; CHECK: ret
%quot = sdiv i64 %a, %b
ret i64 %quot
}
; Unsigned 128-bit division
define i128 @udiv128(i128 %a, i128 %b) {
; CHECK-LABEL: udiv128:
; CHECK: call __udivmodti4
; CHECK: ret
%quot = udiv i128 %a, %b
ret i128 %quot
}
; Signed 128-bit division
define i128 @sdiv128(i128 %a, i128 %b) {
; CHECK-LABEL: sdiv128:
; CHECK: call __divmodti4
; CHECK: ret
%quot = sdiv i128 %a, %b
ret i128 %quot
}