MimIR
0.6-dev
MimIR is my Intermediate Representation
Toggle main menu visibility
Loading...
Searching...
No Matches
arm.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <array>
4
5
#include <
mim/plug/core/core.h
>
6
#include <
mim/plug/mach/mach.h
>
7
#include <
mim/plug/mem/mem.h
>
8
9
#include "
mim/plug/arm/autogen.h
"
10
11
namespace
mim::plug::arm
{
12
13
using
mach::encoding
;
14
15
constexpr
size_t
Num_Regs
=
Annex::num<reg>
();
16
constexpr
size_t
Num_Fpr
=
Annex::num<fpr>
();
17
18
/// AAPCS64: arguments in x0 … x7, result in x0.
19
// clang-format off
20
constexpr
std::array<size_t, 8>
Arg_Regs
= {
21
encoding
(
reg::x0
),
encoding
(
reg::x1
),
encoding
(
reg::x2
),
encoding
(
reg::x3
),
22
encoding
(
reg::x4
),
encoding
(
reg::x5
),
encoding
(
reg::x6
),
encoding
(
reg::x7
),
23
};
24
// clang-format on
25
constexpr
size_t
Ret_Reg
=
encoding
(
reg::x0
);
26
constexpr
bool
Caller_Saved
[
Num_Regs
] = {
27
true
,
true
,
true
,
true
,
true
,
true
,
true
,
true
,
// x0 - x7
28
true
,
true
,
true
,
true
,
true
,
true
,
true
,
true
,
// x8 - x15
29
false
,
false
,
false
,
// x16 - x18: scratch, reserved
30
false
,
false
,
false
,
false
,
false
,
false
,
false
,
false
,
false
,
false
,
// x19 - x28: callee-saved
31
false
,
false
,
// x29 fp, x30 lr
32
};
33
/// `x16`/`x17`/`x18` are the scratch and platform registers, `x29`/`x30` the frame pointer and link register.
34
constexpr
bool
reserved
(
size_t
r) {
35
return
r ==
encoding
(
reg::x16
) || r ==
encoding
(
reg::x17
) || r ==
encoding
(
reg::x18
) || r ==
encoding
(
reg::x29
)
36
|| r ==
encoding
(
reg::x30
);
37
}
38
39
/// AAPCS64: floating-point arguments in d0 … d7, result in d0.
40
constexpr
std::array<size_t, 8>
Fpr_Arg_Regs
= {
41
encoding
(
fpr::d0
),
encoding
(
fpr::d1
),
encoding
(
fpr::d2
),
encoding
(
fpr::d3
),
42
encoding
(
fpr::d4
),
encoding
(
fpr::d5
),
encoding
(
fpr::d6
),
encoding
(
fpr::d7
),
43
};
44
constexpr
size_t
Ret_Fpr
=
encoding
(
fpr::d0
);
45
/// `d31` breaks a copy cycle, so allocation leaves it alone.
46
constexpr
size_t
Fpr_Scratch
=
encoding
(
fpr::d31
);
47
/// AAPCS64: `d8`–`d15` are callee-saved.
48
constexpr
bool
caller_saved_fpr
(
size_t
r) {
return
r <
encoding
(
fpr::d8
) || r >
encoding
(
fpr::d15
); }
49
50
/// The instance of the select family @p Sel (`csel` or `fcsel`) that selects on @p c.
51
template
<
class
Sel>
52
constexpr
flags_t
cc_to
(
cc
c) {
53
return
Annex::Base<Sel>
|
Annex::flags2sub
(std::to_underlying(c));
54
}
55
56
}
// namespace mim::plug::arm
autogen.h
core.h
mach.h
mem.h
mim::plug::arm
The ARM Plugin
Definition
arm.h:11
mim::plug::arm::reserved
constexpr bool reserved(size_t r)
x16/x17/x18 are the scratch and platform registers, x29/x30 the frame pointer and link register.
Definition
arm.h:34
mim::plug::arm::cc_to
constexpr flags_t cc_to(cc c)
The instance of the select family Sel (csel or fcsel) that selects on c.
Definition
arm.h:52
mim::plug::arm::Fpr_Arg_Regs
constexpr std::array< size_t, 8 > Fpr_Arg_Regs
AAPCS64: floating-point arguments in d0 … d7, result in d0.
Definition
arm.h:40
mim::plug::arm::Caller_Saved
constexpr bool Caller_Saved[Num_Regs]
Definition
arm.h:26
mim::plug::arm::encoding
constexpr size_t encoding(Reg r)
The hardware encoding of the register r of a backend's module reg, whose subtags are in encoding orde...
Definition
mach.h:15
mim::plug::arm::fpr::d0
@ d0
Definition
autogen.h:53
mim::plug::arm::fpr::d6
@ d6
Definition
autogen.h:59
mim::plug::arm::fpr::d8
@ d8
Definition
autogen.h:61
mim::plug::arm::fpr::d1
@ d1
Definition
autogen.h:54
mim::plug::arm::fpr::d4
@ d4
Definition
autogen.h:57
mim::plug::arm::fpr::d2
@ d2
Definition
autogen.h:55
mim::plug::arm::fpr::d5
@ d5
Definition
autogen.h:58
mim::plug::arm::fpr::d3
@ d3
Definition
autogen.h:56
mim::plug::arm::fpr::d31
@ d31
Definition
autogen.h:84
mim::plug::arm::fpr::d7
@ d7
Definition
autogen.h:60
mim::plug::arm::fpr::d15
@ d15
Definition
autogen.h:68
mim::plug::arm::reg::x3
@ x3
Definition
autogen.h:18
mim::plug::arm::reg::x7
@ x7
Definition
autogen.h:22
mim::plug::arm::reg::x16
@ x16
Definition
autogen.h:31
mim::plug::arm::reg::x1
@ x1
Definition
autogen.h:16
mim::plug::arm::reg::x29
@ x29
Definition
autogen.h:44
mim::plug::arm::reg::x2
@ x2
Definition
autogen.h:17
mim::plug::arm::reg::x6
@ x6
Definition
autogen.h:21
mim::plug::arm::reg::x18
@ x18
Definition
autogen.h:33
mim::plug::arm::reg::x4
@ x4
Definition
autogen.h:19
mim::plug::arm::reg::x17
@ x17
Definition
autogen.h:32
mim::plug::arm::reg::x30
@ x30
Definition
autogen.h:45
mim::plug::arm::reg::x0
@ x0
Definition
autogen.h:15
mim::plug::arm::reg::x5
@ x5
Definition
autogen.h:20
mim::plug::arm::Ret_Reg
constexpr size_t Ret_Reg
Definition
arm.h:25
mim::plug::arm::Num_Regs
constexpr size_t Num_Regs
Definition
arm.h:15
mim::plug::arm::Ret_Fpr
constexpr size_t Ret_Fpr
Definition
arm.h:44
mim::plug::arm::Arg_Regs
constexpr std::array< size_t, 8 > Arg_Regs
AAPCS64: arguments in x0 … x7, result in x0.
Definition
arm.h:20
mim::plug::arm::Fpr_Scratch
constexpr size_t Fpr_Scratch
d31 breaks a copy cycle, so allocation leaves it alone.
Definition
arm.h:46
mim::plug::arm::caller_saved_fpr
constexpr bool caller_saved_fpr(size_t r)
AAPCS64: d8–d15 are callee-saved.
Definition
arm.h:48
mim::plug::arm::cc
cc
Definition
autogen.h:272
mim::plug::arm::Num_Fpr
constexpr size_t Num_Fpr
Definition
arm.h:16
mim::plug::mach::encoding
constexpr size_t encoding(Reg r)
The hardware encoding of the register r of a backend's module reg, whose subtags are in encoding orde...
Definition
mach.h:15
mim::flags_t
u64 flags_t
Definition
types.h:39
mim::Annex::flags2sub
static constexpr sub_t flags2sub(flags_t f)
Yields the sub part of the name as integer.
Definition
plugin.h:262
mim::Annex::num
static consteval size_t num()
Definition
plugin.h:277
mim::Annex::Base
static constexpr flags_t Base
Definition
plugin.h:276
include
mim
plug
arm
arm.h
Generated by
1.18.0