MimIR
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
arm.h
Go to the documentation of this file.
1#pragma once
2
3#include <array>
4
7#include <mim/plug/mem/mem.h>
8
10
11namespace mim::plug::arm {
12
13using mach::encoding;
14
15constexpr size_t Num_Regs = Annex::num<reg>();
16constexpr size_t Num_Fpr = Annex::num<fpr>();
17
18/// AAPCS64: arguments in x0 … x7, result in x0.
19// clang-format off
24// clang-format on
25constexpr size_t Ret_Reg = encoding(reg::x0);
26constexpr 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.
34constexpr 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.
44constexpr size_t Ret_Fpr = encoding(fpr::d0);
45/// `d31` breaks a copy cycle, so allocation leaves it alone.
46constexpr size_t Fpr_Scratch = encoding(fpr::d31);
47/// AAPCS64: `d8`–`d15` are callee-saved.
48constexpr 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.
51template<class Sel>
52constexpr flags_t cc_to(cc c) {
53 return Annex::Base<Sel> | Annex::flags2sub(std::to_underlying(c));
54}
55
56} // namespace mim::plug::arm
The ARM Plugin
Definition arm.h:11
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
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
constexpr std::array< size_t, 8 > Fpr_Arg_Regs
AAPCS64: floating-point arguments in d0 … d7, result in d0.
Definition arm.h:40
constexpr bool Caller_Saved[Num_Regs]
Definition arm.h:26
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
constexpr size_t Ret_Reg
Definition arm.h:25
constexpr size_t Num_Regs
Definition arm.h:15
constexpr size_t Ret_Fpr
Definition arm.h:44
constexpr std::array< size_t, 8 > Arg_Regs
AAPCS64: arguments in x0 … x7, result in x0.
Definition arm.h:20
constexpr size_t Fpr_Scratch
d31 breaks a copy cycle, so allocation leaves it alone.
Definition arm.h:46
constexpr bool caller_saved_fpr(size_t r)
AAPCS64: d8–d15 are callee-saved.
Definition arm.h:48
constexpr size_t Num_Fpr
Definition arm.h:16
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
u64 flags_t
Definition types.h:39
static constexpr sub_t flags2sub(flags_t f)
Yields the sub part of the name as integer.
Definition plugin.h:262
static consteval size_t num()
Definition plugin.h:277
static constexpr flags_t Base
Definition plugin.h:276