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
//! A template kept as text, and the holes in it that are filled once registers are known.
//!
//! An `asm` statement whose text is not read back into instructions is carried to the writer as
//! the text, with a hole wherever it names an operand. What goes in a hole is a register, an
//! address or a name, and none of those is known when the text is written down: the register is
//! the allocator's answer and the name is spelled the way the object format wants. The holes are
//! the same on every machine and so is filling them, which is why they are here rather than with
//! either machine's table. What each machine spells into a hole is its writer's business.
/// Where the address a kept template names goes in its text.
///
/// The address is the instruction's memory operand, and where it is depends on registers nothing
/// has chosen yet when the text is written down, so the text holds this in its place and the writer
/// puts the address there. The two bytes around it are ones no template can hold, since a string a
/// program wrote into an `asm` statement is text an assembler reads.
pub const TEMPLATE_MEM: &str = "\u{1}m\u{2}";
/// A name a kept template names, held the same way so the writer can spell it the way the object
/// format wants names spelled. See [`TEMPLATE_MEM`].
/// A register a kept template names, held the same way. What it says is the instruction's operand
/// at `at` and the width to spell it at, as the letter gcc's modifier for that width is. On x86-64
/// that is `b`, `w`, `k`, `q`, or `h` for the second byte, and on AArch64 it is `w` or `x`. The
/// register is only known once the allocator has run, which is after the text is written down. See
/// [`TEMPLATE_MEM`].
/// A kept template's text with its holes filled: the address by `mem`, each name by `name`, and
/// each register by `reg`, which is handed the operand and the width letter [`template_reg`] kept.