MimIR
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
insn.h
Go to the documentation of this file.
1#pragma once
2
3#include <mim/axm.h>
4#include <mim/lam.h>
5
7
8/// Machine facts about the instructions of the `arm` plugin, shared by `arm_isel.gen` and the backend.
10
11/// The latency in cycles of the instruction @p base, roughly as on recent cores.
12inline u32 latency(flags_t base) {
13 if (base == Annex::Base<mul> || base == Annex::Base<madd> || base == Annex::Base<fadd> || base == Annex::Base<fsub>
14 || base == Annex::Base<fmul>)
15 return 3;
16 if (base == Annex::Base<udiv> || base == Annex::Base<sdiv>) return 12;
17 if (base == Annex::Base<fdiv>) return 11;
18 if (base == Annex::Base<fsqrt>) return 14;
19 if (base == Annex::Base<load> || base == Annex::Base<fload>) return 4;
20 return 1;
21}
22
23/// The cost of the instruction @p app: its latency plus one, so of two equally fast covers the shorter wins.
24inline u32 cost(const App* app) { return latency(app->axm()->base()) + 1; }
25
26} // namespace mim::plug::arm::insn
const Axm * axm() const
Definition lam.h:257
flags_t base() const
Definition axm.h:62
Machine facts about the instructions of the arm plugin, shared by arm_isel.gen and the backend.
Definition insn.h:9
u32 latency(flags_t base)
The latency in cycles of the instruction base, roughly as on recent cores.
Definition insn.h:12
u32 cost(const App *app)
The cost of the instruction app: its latency plus one, so of two equally fast covers the shorter wins...
Definition insn.h:24
u64 flags_t
Definition types.h:39
uint32_t u32
Definition types.h:27
static constexpr flags_t Base
Definition plugin.h:276