MimIR
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
target.h
Go to the documentation of this file.
1#pragma once
2
4
5#include "mim/plug/arm/arm.h"
6
7namespace mim::plug::arm {
8
9/// The machine facts of the AArch64 backend; the ABI is AAPCS64.
10class Target : public mach::Target {
11public:
13 : mach::Target("arm", Plugin_Id) {}
14
15 bool is_flags(const Def* def) const final { return Axm::isa<mach::Flags>(def->type()) || Axm::isa<cc>(def); }
16 bool is_sched_cc(const App* app) const final {
18 }
19 /// The hardware encoding pairs each condition code with its negation in bit 0.
20 size_t negate_cc(size_t c) const final { return c ^ 1; }
22
23 bool is_mem_insn(const App* app) const final {
25 || Axm::isa<fstore>(app);
26 }
27
28 size_t num_regs(Class cls) const final { return cls == Gpr ? Num_Regs : cls == Fpr ? Num_Fpr : 0; }
29 bool reserved(Class cls, size_t r) const final { return cls == Fpr ? r == Fpr_Scratch : arm::reserved(r); }
30 bool caller_saved(Class cls, size_t r) const final {
31 return cls == Gpr ? Caller_Saved[r] : arm::caller_saved_fpr(r);
32 }
33 size_t num_arg_regs(Class cls) const final {
34 return cls == Gpr ? Arg_Regs.size() : cls == Fpr ? Fpr_Arg_Regs.size() : 0;
35 }
36 size_t arg_reg(Class cls, size_t i) const final { return cls == Gpr ? Arg_Regs[i] : Fpr_Arg_Regs[i]; }
37 size_t ret_reg(Class cls) const final { return cls == Gpr ? Ret_Reg : Ret_Fpr; }
38
39 bool is_removable(const App* insn) const final {
41 }
42};
43
44} // namespace mim::plug::arm
static auto isa(const Def *def)
Definition axm.h:112
Base class for all Defs.
Definition def.h:285
bool is_sched_cc(const App *app) const final
Is app the sched of the backend's cc?
Definition target.h:16
size_t ret_reg(Class cls) const final
Definition target.h:37
bool is_removable(const App *insn) const final
May insn go if nothing uses its results, e.g.
Definition target.h:39
bool caller_saved(Class cls, size_t r) const final
Definition target.h:30
bool is_mem_insn(const App *app) const final
Is app an instruction that takes the mem.M 0 it continues as its first argument?
Definition target.h:23
bool reserved(Class cls, size_t r) const final
Is r never available to register allocation?
Definition target.h:29
size_t num_arg_regs(Class cls) const final
Definition target.h:33
size_t arg_reg(Class cls, size_t i) const final
The register of the i-th argument of class cls.
Definition target.h:36
size_t num_regs(Class cls) const final
Definition target.h:28
bool is_flags(const Def *def) const final
Definition target.h:15
size_t negate_cc(size_t c) const final
The hardware encoding pairs each condition code with its negation in bit 0.
Definition target.h:20
The machine facts of a native backend that the phases of mach need.
Definition target.h:45
Class
The register classes; Stack values live in a spill slot and are unbounded.
Definition target.h:48
Class cls(const Def *def) const
Definition target.h:105
static const Def * sched_insn(const App *app)
Definition target.h:204
virtual bool is_removable(const App *insn) const
May insn go if nothing uses its results, e.g.
Definition target.h:125
virtual bool is_mem_insn(const App *app) const
Is app an instruction that takes the mem.M 0 it continues as its first argument?
Definition target.h:122
Machine facts about the instructions of the arm plugin, shared by arm_isel.gen and the backend.
Definition insn.h:9
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 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 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
The mach Plugin
Definition asm.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