special-reg.ll
2.04 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
; RUN: llc < %s -mtriple=arm-none-eabi -mcpu=cortex-a8 2>&1 | FileCheck %s --check-prefix=ARM --check-prefix=ACORE
; RUN: llc < %s -mtriple=thumb-none-eabi -mcpu=cortex-m4 2>&1 | FileCheck %s --check-prefix=ARM --check-prefix=MCORE
define i32 @read_i32_encoded_register() nounwind {
entry:
; ARM-LABEL: read_i32_encoded_register:
; ARM: mrc p1, #2, r0, c3, c4, #5
%reg = call i32 @llvm.read_register.i32(metadata !0)
ret i32 %reg
}
define i64 @read_i64_encoded_register() nounwind {
entry:
; ARM-LABEL: read_i64_encoded_register:
; ARM: mrrc p1, #2, r0, r1, c3
%reg = call i64 @llvm.read_register.i64(metadata !1)
ret i64 %reg
}
define i32 @read_apsr() nounwind {
entry:
; ARM-LABEL: read_apsr:
; ARM: mrs r0, apsr
%reg = call i32 @llvm.read_register.i32(metadata !2)
ret i32 %reg
}
define i32 @read_fpscr() nounwind {
entry:
; ARM-LABEL: read_fpscr:
; ARM: vmrs r0, fpscr
%reg = call i32 @llvm.read_register.i32(metadata !3)
ret i32 %reg
}
define void @write_i32_encoded_register(i32 %x) nounwind {
entry:
; ARM-LABEL: write_i32_encoded_register:
; ARM: mcr p1, #2, r0, c3, c4, #5
call void @llvm.write_register.i32(metadata !0, i32 %x)
ret void
}
define void @write_i64_encoded_register(i64 %x) nounwind {
entry:
; ARM-LABEL: write_i64_encoded_register:
; ARM: mcrr p1, #2, r0, r1, c3
call void @llvm.write_register.i64(metadata !1, i64 %x)
ret void
}
define void @write_apsr(i32 %x) nounwind {
entry:
; ARM-LABEL: write_apsr:
; ACORE: msr APSR_nzcvq, r0
; MCORE: msr apsr_nzcvq, r0
call void @llvm.write_register.i32(metadata !4, i32 %x)
ret void
}
define void @write_fpscr(i32 %x) nounwind {
entry:
; ARM-LABEL: write_fpscr:
; ARM: vmsr fpscr, r0
call void @llvm.write_register.i32(metadata !3, i32 %x)
ret void
}
declare i32 @llvm.read_register.i32(metadata) nounwind
declare i64 @llvm.read_register.i64(metadata) nounwind
declare void @llvm.write_register.i32(metadata, i32) nounwind
declare void @llvm.write_register.i64(metadata, i64) nounwind
!0 = !{!"cp1:2:c3:c4:5"}
!1 = !{!"cp1:2:c3"}
!2 = !{!"apsr"}
!3 = !{!"fpscr"}
!4 = !{!"apsr_nzcvq"}