rucc_mir/inst.rs
1//! What one machine instruction is, and what an operand is.
2//!
3//! Design: `spec/10-backend.md` section 10.1.
4//!
5//! An instruction is an opcode, a run of operands, the three things an opcode may carry besides
6//! its operands, which are an immediate, a memory addressing mode and a symbol, and one set of
7//! flags. Twenty-eight bytes, all of it either a small number or an index into a table the
8//! function owns, so walking a function is walking one dense array and nothing in it is
9//! separately freed.
10//!
11//! An operand is a register, the class it is drawn from, whether the instruction reads or
12//! writes it, and any constraint on where it may live. That is what the allocator reads and it
13//! is all the allocator reads, which is the point: the opcode is a name to everything except
14//! the encoder, and the allocator never has to know what any particular target's instructions
15//! mean.
16//!
17//! # Where the other pieces are
18//!
19//! [`Role`] and [`Constraint`] are in `rucc-target`, and this crate re-exports them. A target
20//! says what its instructions do to their operands before there is any machine IR to say it in,
21//! and both the selector that builds the IR and the encoder that reads it need the answer, so
22//! the two of them live below both.
23//!
24//! Successors are on the block rather than on the terminator, in the order the terminator's own
25//! arms run. That is regalloc2's arrangement, which `spec/10-backend.md` section 10.4 says the
26//! allocator interface follows, and it keeps a branch's arguments out of the operand vector
27//! where they would otherwise be uses the allocator has to be told to treat differently.
28//!
29//! The source location is a parallel array in the function, reached by [`crate::Func::span`],
30//! for the same reason `rucc-ir` puts it there: it is read when a diagnostic is being made and
31//! at no other time, so it does not belong on the row that every pass walks.
32
33use std::fmt;
34
35use rucc_base::{Idx, IdxRange, Symbol};
36use rucc_target::{Constraint, PhysReg, RegClass, Role, Segment};
37
38/// One instruction, in the function that owns it.
39pub type Inst = Idx<InstData>;
40/// One basic block, in the function that owns it.
41pub type Block = Idx<BlockData>;
42/// A run of operands, which is what an instruction's operand vector is.
43pub type OperandList = IdxRange<Operand>;
44/// One immediate, in the function's immediate table.
45pub type ImmRef = Idx<Imm>;
46/// One addressing mode, in the function's table of them.
47pub type MemRef = Idx<Amode>;
48
49/// Which instruction this is.
50///
51/// A name rather than a variant of an enum. `spec/10-backend.md` section 10.8 says no pipeline
52/// crate holds target-specific code, and an enum of every x86-64 opcode in the crate every
53/// target's MIR passes through is exactly that. The opcodes a target has are data: they come out
54/// of its rule set, which is what the selector was compiled from, and this crate never asks what
55/// one of them means. The encoder does, against the same description the rules were written
56/// against.
57#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
58pub struct Opcode(Symbol);
59
60impl Opcode {
61 /// The opcode of that name.
62 #[must_use]
63 pub const fn new(name: Symbol) -> Self {
64 Self(name)
65 }
66
67 /// Its name, which needs the interner it was made with to read.
68 #[must_use]
69 pub const fn name(self) -> Symbol {
70 self.0
71 }
72}
73
74/// A register, either one the allocator has still to place or one it has placed.
75///
76/// The two are one type and four bytes because every operand holds one and because a pass that
77/// runs both before and after allocation should not be two passes. Which of the two it is, is
78/// the top bit, so a virtual register is its own number and nothing has to be masked to compare
79/// two of them.
80#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
81pub struct Reg(u32);
82
83impl Reg {
84 /// The bit that says the rest is a physical register rather than a virtual one.
85 const PHYSICAL: u32 = 1 << 31;
86
87 /// The virtual register with that number.
88 ///
89 /// # Panics
90 ///
91 /// Panics if the number is two billion or more, which no function reaches.
92 #[must_use]
93 pub const fn virtual_reg(number: u32) -> Self {
94 assert!(number < Self::PHYSICAL, "a function with two billion virtual registers");
95 Self(number)
96 }
97
98 /// The physical register, once one has been chosen.
99 #[must_use]
100 pub const fn physical(reg: PhysReg) -> Self {
101 Self(Self::PHYSICAL | reg.number() as u32)
102 }
103
104 /// Whether the allocator has still to place it.
105 #[must_use]
106 pub const fn is_virtual(self) -> bool {
107 self.0 & Self::PHYSICAL == 0
108 }
109
110 /// Its number as a virtual register, or `None` once it is a physical one.
111 #[must_use]
112 pub const fn number(self) -> Option<u32> {
113 if self.is_virtual() { Some(self.0) } else { None }
114 }
115
116 /// The physical register it is, or `None` while it is still virtual.
117 ///
118 /// Which class the register is in is on the operand rather than here, because an operand
119 /// carries its class already and a second copy of it is a thing that can disagree.
120 #[must_use]
121 pub const fn phys(self) -> Option<PhysReg> {
122 if self.is_virtual() { None } else { Some(PhysReg::new((self.0 & 0xff) as u8)) }
123 }
124}
125
126/// One operand of one instruction.
127#[derive(Debug, Clone, Copy, PartialEq, Eq)]
128pub struct Operand {
129 /// The register, virtual until the allocator has run.
130 pub reg: Reg,
131 /// The class it is drawn from.
132 pub class: RegClass,
133 /// Whether the instruction reads it or writes it.
134 pub role: Role,
135 /// Where it is allowed to live.
136 pub constraint: Constraint,
137}
138
139impl Operand {
140 /// An operand the instruction reads.
141 #[must_use]
142 pub const fn read(reg: Reg, class: RegClass) -> Self {
143 Self { reg, class, role: Role::Use, constraint: Constraint::Reg }
144 }
145
146 /// An operand the instruction writes as it finishes.
147 #[must_use]
148 pub const fn write(reg: Reg, class: RegClass) -> Self {
149 Self { reg, class, role: Role::Def, constraint: Constraint::Reg }
150 }
151
152 /// An operand the instruction writes before it has finished reading.
153 #[must_use]
154 pub const fn write_early(reg: Reg, class: RegClass) -> Self {
155 Self { reg, class, role: Role::EarlyDef, constraint: Constraint::Reg }
156 }
157
158 /// The same operand, constrained.
159 #[must_use]
160 pub const fn with(mut self, constraint: Constraint) -> Self {
161 self.constraint = constraint;
162 self
163 }
164}
165
166/// One immediate.
167///
168/// Signed and sixty-four bits, which every immediate field of every target we have is narrower
169/// than. What fits in the field the encoder is about to write is the encoder's question, and it
170/// is one it can only answer per opcode, so nothing here tries to.
171#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
172pub struct Imm(pub i64);
173
174/// What the four bytes beside a symbol in an address hold.
175///
176/// Three different numbers written in the same place, and nothing about the instruction says which
177/// one it is: `movq sym(%rip)`, `movq sym@GOTPCREL(%rip)` and `movq sym@GOTTPOFF(%rip)` are the
178/// same opcode with the same operands, and the only thing that tells them apart is the relocation
179/// the assembler leaves behind. So the difference has to be carried here, beside the symbol, rather
180/// than being read back out of the shape of the address.
181#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
182pub enum Reach {
183 /// The distance to the symbol itself, which is the ordinary case. `R_X86_64_PC32`.
184 #[default]
185 Itself,
186 /// The distance to the slot of the global offset table holding the symbol's address, which is
187 /// a load rather than an arithmetic. See [`Mem::got`].
188 Table,
189 /// The distance to the slot of the global offset table holding the symbol's offset inside a
190 /// thread's own block of storage. See [`Mem::thread`].
191 Thread,
192}
193
194/// A memory addressing mode, as the instruction holds it.
195///
196/// The registers are the indices of the operands holding them rather than the registers
197/// themselves, because an address register is a register the allocator has to see and rewrite,
198/// and the only thing it looks at is the operand vector. [`Mem`] is the same thing written the
199/// way a caller writes it, and [`crate::InstBuilder::mem`] turns one into the other.
200#[derive(Debug, Clone, Copy, PartialEq, Eq)]
201pub struct Amode {
202 /// The operand holding the base register.
203 pub base: Option<u8>,
204 /// The operand holding the index register.
205 pub index: Option<u8>,
206 /// What the index is multiplied by, which is 1 when there is no index.
207 pub scale: u8,
208 /// The constant added to the address.
209 pub disp: i32,
210 /// The symbol the address is relative to, for an access to a global.
211 pub symbol: Option<Symbol>,
212 /// The block of this function the address is of, for the address of a label. See
213 /// [`Mem::block`].
214 pub block: Option<Block>,
215 /// What the four bytes beside the symbol hold, when there is a symbol. See [`Reach`].
216 pub reach: Reach,
217 /// Which storage the address is counted from, when it is not the flat one. See [`Segment`].
218 pub segment: Option<Segment>,
219}
220
221impl Amode {
222 /// The addressing mode naming no register and no symbol, at offset zero.
223 pub const NOTHING: Self = Self {
224 base: None,
225 index: None,
226 scale: 1,
227 disp: 0,
228 symbol: None,
229 block: None,
230 reach: Reach::Itself,
231 segment: None,
232 };
233}
234
235/// A memory addressing mode as a caller writes one down.
236///
237/// The difference from [`Amode`] is that the registers are here rather than in the operand
238/// vector, which is what [`crate::InstBuilder::mem`] fixes. Keeping the two apart is what lets
239/// the operand indices in an [`Amode`] be an invariant of the builder rather than something
240/// every caller has to get right.
241#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
242pub struct Mem {
243 /// The base register, which the instruction reads.
244 pub base: Option<Operand>,
245 /// The index register, which the instruction reads.
246 pub index: Option<Operand>,
247 /// What the index is multiplied by.
248 pub scale: u8,
249 /// The constant added to the address.
250 pub disp: i32,
251 /// The symbol the address is relative to.
252 pub symbol: Option<Symbol>,
253 /// The block of this function the address is of. See [`Mem::block`].
254 pub block: Option<Block>,
255 /// What the four bytes beside the symbol hold, when there is a symbol. See [`Reach`].
256 pub reach: Reach,
257 /// Which storage the address is counted from, when it is not the flat one. See [`Segment`].
258 pub segment: Option<Segment>,
259}
260
261impl Mem {
262 /// The address in that register.
263 #[must_use]
264 pub const fn at(base: Operand) -> Self {
265 Self {
266 base: Some(base),
267 index: None,
268 scale: 1,
269 disp: 0,
270 symbol: None,
271 block: None,
272 reach: Reach::Itself,
273 segment: None,
274 }
275 }
276
277 /// The address of that symbol.
278 #[must_use]
279 pub const fn of(symbol: Symbol) -> Self {
280 Self {
281 base: None,
282 index: None,
283 scale: 1,
284 disp: 0,
285 symbol: Some(symbol),
286 block: None,
287 reach: Reach::Itself,
288 segment: None,
289 }
290 }
291
292 /// The address of that block of this function, which is what GNU's `&&label` is.
293 ///
294 /// A block rather than a symbol because the block it names is in this same function and has no
295 /// name outside it. What the assembler is given is the local label the block already carries,
296 /// which is a name the object file need not keep, and what the object writer is given is
297 /// nothing at all: the distance is between two places in one section and both of them are
298 /// known once the blocks have been laid out, so it is filled in here rather than left to a
299 /// linker the way the distance to a global is.
300 #[must_use]
301 pub const fn block(block: Block) -> Self {
302 Self {
303 base: None,
304 index: None,
305 scale: 1,
306 disp: 0,
307 symbol: None,
308 block: Some(block),
309 reach: Reach::Itself,
310 segment: None,
311 }
312 }
313
314 /// That many bytes into a thread's own block of words, which names no register at all.
315 ///
316 /// The whole address is the constant, because where the block is is something only the machine
317 /// knows: the segment register is what holds it and nothing loads one. See [`Segment`].
318 #[must_use]
319 pub const fn in_segment(segment: Segment, disp: i32) -> Self {
320 Self {
321 base: None,
322 index: None,
323 scale: 1,
324 disp,
325 symbol: None,
326 block: None,
327 reach: Reach::Itself,
328 segment: Some(segment),
329 }
330 }
331
332 /// The slot of the global offset table holding that symbol's address.
333 ///
334 /// Not the same thing as [`Self::of`] and not an optimization of it. `sym(%rip)` is the
335 /// address worked out from where the instruction is, which is only the right address when the
336 /// symbol is in this same object, and the linker refuses it in a position independent
337 /// executable when the symbol may turn out to be in a shared library. `sym@GOTPCREL(%rip)` is
338 /// a slot the linker fills in with the one address everybody agrees on, so it is a load rather
339 /// than an arithmetic, and whatever reads it gets an address rather than a place.
340 ///
341 /// The linker relaxes it back into the arithmetic when the symbol turns out to be in this
342 /// program after all, which is why nothing is lost by asking for it.
343 #[must_use]
344 pub const fn got(symbol: Symbol) -> Self {
345 Self { reach: Reach::Table, ..Self::of(symbol) }
346 }
347
348 /// The slot of the global offset table holding that symbol's offset inside a thread's block.
349 ///
350 /// A thread-local variable has no one address, since every thread has a copy of it, so there is
351 /// nothing for [`Self::of`] to be the distance to and a linker refuses one aimed at such a
352 /// symbol. What every copy does share is where it sits inside the block a thread gets, and that
353 /// offset is the number this slot holds: add it to the address of the running thread's block,
354 /// which the machine keeps in `%fs`, and the result is this thread's copy.
355 ///
356 /// The offset is a slot rather than a constant because how big the blocks in front of this
357 /// object's are is only known once the program is linked together, and in a shared library only
358 /// once it is loaded. The linker writes the constant into the instruction instead when it is
359 /// making an executable, where it does know, so this costs nothing in the case that is common.
360 #[must_use]
361 pub const fn thread(symbol: Symbol) -> Self {
362 Self { reach: Reach::Thread, ..Self::of(symbol) }
363 }
364
365 /// The same address with an index register scaled by that much.
366 #[must_use]
367 pub const fn indexed(mut self, index: Operand, scale: u8) -> Self {
368 self.index = Some(index);
369 self.scale = scale;
370 self
371 }
372
373 /// The same address, that many bytes along.
374 #[must_use]
375 pub const fn plus(mut self, disp: i32) -> Self {
376 self.disp = disp;
377 self
378 }
379}
380
381/// How often something happens, next to once for every time the function is entered.
382///
383/// Ten thousand is once, which is the scale the block frequencies in `rucc_opt` are worked out
384/// in. The numbers here are those carried down rather than worked out again: by the time the
385/// blocks are laid out the loops the frequency came from are branches and there is nothing left
386/// to work one out from.
387///
388/// Nothing keeps these in step with the graph afterwards. A pass that makes a block says how
389/// often the block runs, and a pass that does not is one whose new blocks run as often as the
390/// function does, which is what [`Weight::ONCE`] is and is the only answer available to something
391/// that was never told. They are a layout heuristic, nothing reads them for anything a wrong
392/// answer could make incorrect, and the worst a stale one costs is a jump where a fall-through
393/// would have done.
394#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
395pub struct Weight(u64);
396
397impl Weight {
398 /// The scale: how many parts one run of the function is divided into.
399 ///
400 /// Ten thousand rather than one, because a block inside three conditionals runs a fraction of
401 /// a time per call and a fraction is not an integer. It is the same scale `rucc_opt` uses,
402 /// which is what makes carrying a frequency down here a copy rather than a conversion.
403 pub const SCALE: u64 = 10_000;
404
405 /// Once for every time the function is entered.
406 pub const ONCE: Self = Self(Self::SCALE);
407
408 /// Never.
409 pub const NEVER: Self = Self(0);
410
411 /// That many parts of [`Weight::SCALE`].
412 #[must_use]
413 pub const fn parts(parts: u64) -> Self {
414 Self(parts)
415 }
416
417 /// How many parts of [`Weight::SCALE`] it is.
418 #[must_use]
419 pub const fn raw(self) -> u64 {
420 self.0
421 }
422
423 /// What fraction of `whole` this is, in parts of [`Weight::SCALE`].
424 ///
425 /// A whole of nothing answers nothing, since a block that never runs has no arm that is taken
426 /// more often than any other and the question has no answer rather than an arbitrary one.
427 #[must_use]
428 pub const fn out_of(self, whole: Self) -> u64 {
429 if whole.0 == 0 {
430 return 0;
431 }
432 // Saturating rather than wrapping, for the same reason a frequency saturates: a nest of
433 // loops multiplies, and a number that wrapped would read as cold where it is hottest.
434 match self.0.checked_mul(Self::SCALE) {
435 Some(scaled) => scaled / whole.0,
436 None => (self.0 / whole.0).saturating_mul(Self::SCALE),
437 }
438 }
439}
440
441impl Default for Weight {
442 /// Once, which is what a block nobody worked a number out for runs as often as.
443 fn default() -> Self {
444 Self::ONCE
445 }
446}
447
448/// One arm of a terminator: where it goes, and what it takes with it.
449///
450/// The arguments are the values the target block's parameters arrive as, so this is the edge on
451/// which a phi would otherwise sit. After allocation the parameters are physical registers and
452/// these arguments have become the moves that write them, which is the point at which MIR stops
453/// being in SSA form.
454#[derive(Debug, Clone, PartialEq, Eq)]
455pub struct BlockCall {
456 /// The block it goes to.
457 pub block: Block,
458 /// What its parameters arrive as, one for one.
459 pub args: Vec<Reg>,
460 /// How often the edge is taken, next to how often the function is entered. See [`Weight`].
461 pub weight: Weight,
462}
463
464impl BlockCall {
465 /// A jump to that block carrying nothing.
466 #[must_use]
467 pub const fn to(block: Block) -> Self {
468 Self { block, args: Vec::new(), weight: Weight::ONCE }
469 }
470
471 /// A jump to that block carrying those registers.
472 #[must_use]
473 pub fn with(block: Block, args: Vec<Reg>) -> Self {
474 Self { block, args, weight: Weight::ONCE }
475 }
476
477 /// The same arm, taken that often.
478 #[must_use]
479 pub fn taken(mut self, weight: Weight) -> Self {
480 self.weight = weight;
481 self
482 }
483}
484
485/// One parameter of a block: the register the value arrives in, and its class.
486#[derive(Debug, Clone, Copy, PartialEq, Eq)]
487pub struct Param {
488 /// What the value arrives as, virtual until the allocator has run.
489 pub reg: Reg,
490 /// The class it is drawn from.
491 pub class: RegClass,
492}
493
494/// What is true of an instruction besides what its operands say.
495///
496/// One flag, and a set rather than a `bool` because the thing it is the first of is a class: a
497/// fact the front end knew about an access, which selection has to carry down because no pass
498/// below can work it out again. A second `bool` on the row every pass walks is how a struct
499/// turns into a bag, and a second bit here is free.
500///
501/// Empty on every instruction the machine writes for itself, which is most of them. A prologue,
502/// a spill, a jump and the move the allocator writes to put a value where the machine wants it
503/// were all asked for by this compiler rather than by the program, so there is nothing the
504/// program said about them to carry.
505#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
506pub struct Flags(u8);
507
508impl Flags {
509 /// Nothing besides what the operands say.
510 pub const NONE: Self = Self(0);
511
512 /// The access happens exactly once, and is never moved or merged with another.
513 ///
514 /// `rucc_ir::Flags::VOLATILE` on the load or the store this instruction was selected from.
515 /// Every pass above selection reads that flag, and until it was carried down here the
516 /// instruction that reached the machine level passes was the same instruction whether the
517 /// program had written `volatile` or not, so a pass that merges two accesses merged these
518 /// as well. See [`InstData::flags`] and tamnd/rucc#1302.
519 pub const VOLATILE: Self = Self(1);
520
521 /// Both of them at once.
522 #[must_use]
523 pub const fn with(self, other: Self) -> Self {
524 Self(self.0 | other.0)
525 }
526
527 /// Whether every flag in the other one is in this one. True of [`Self::NONE`] always, since
528 /// there is nothing in it to be missing.
529 #[must_use]
530 pub const fn contains(self, other: Self) -> bool {
531 self.0 & other.0 == other.0
532 }
533
534 /// Whether nothing is set.
535 #[must_use]
536 pub const fn is_empty(self) -> bool {
537 self.0 == 0
538 }
539}
540
541impl fmt::Display for Flags {
542 /// Each flag with a space in front of it, so that it reads as written after the opcode and
543 /// prints as nothing at all when there is nothing set. The same arrangement `rucc_ir` uses
544 /// for the flags an IR instruction carries.
545 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
546 if self.contains(Self::VOLATILE) {
547 f.write_str(" volatile")?;
548 }
549 Ok(())
550 }
551}
552
553/// One instruction.
554#[derive(Debug, Clone, Copy, PartialEq, Eq)]
555pub struct InstData {
556 /// Which instruction this is.
557 pub opcode: Opcode,
558 /// Its operands, defs first and then uses, with the registers a memory operand names last.
559 /// The order is what the printer and the parser agree on, and [`crate::InstBuilder`] is
560 /// what keeps it.
561 pub operands: OperandList,
562 /// Its immediate, if it has one.
563 pub imm: Option<ImmRef>,
564 /// Its memory operand, if it has one.
565 pub mem: Option<MemRef>,
566 /// The symbol it names, which is the callee of a direct call and the target of a direct
567 /// jump to another function.
568 pub symbol: Option<Symbol>,
569 /// What the program said about it that its operands do not. See [`Flags`].
570 pub flags: Flags,
571}
572
573impl InstData {
574 /// An instruction with that opcode and nothing else.
575 #[must_use]
576 pub const fn new(opcode: Opcode) -> Self {
577 Self {
578 opcode,
579 operands: OperandList::EMPTY,
580 imm: None,
581 mem: None,
582 symbol: None,
583 flags: Flags::NONE,
584 }
585 }
586}
587
588/// Where an instruction sits: which block it is in, and what is either side of it.
589#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
590pub(crate) struct InstLayout {
591 pub(crate) block: Option<Block>,
592 pub(crate) prev: Option<Inst>,
593 pub(crate) next: Option<Inst>,
594}
595
596/// One block: what arrives in it, what is in it, and where it goes.
597#[derive(Debug, Clone, Default, PartialEq, Eq)]
598pub struct BlockData {
599 /// The values that arrive in it, which are the function's arguments in the entry block.
600 pub params: Vec<Param>,
601 /// Where its terminator goes, in the order the terminator's arms run.
602 pub succs: Vec<BlockCall>,
603 /// How often the block runs, next to how often the function is entered. See [`Weight`].
604 pub weight: Weight,
605 pub(crate) first_inst: Option<Inst>,
606 pub(crate) last_inst: Option<Inst>,
607 pub(crate) prev: Option<Block>,
608 pub(crate) next: Option<Block>,
609}
610
611#[cfg(test)]
612mod tests {
613 use super::*;
614
615 #[test]
616 fn an_instruction_is_the_size_the_design_says() {
617 assert_eq!(size_of::<InstData>(), 28);
618 assert_eq!(size_of::<Operand>(), 8);
619 }
620
621 #[test]
622 fn a_virtual_register_is_its_own_number() {
623 let reg = Reg::virtual_reg(7);
624 assert!(reg.is_virtual());
625 assert_eq!(reg.number(), Some(7));
626 assert_eq!(reg.phys(), None);
627 }
628
629 #[test]
630 fn a_physical_register_is_not_a_virtual_one_of_the_same_number() {
631 let reg = Reg::physical(PhysReg::new(7));
632 assert!(!reg.is_virtual());
633 assert_eq!(reg.number(), None);
634 assert_eq!(reg.phys(), Some(PhysReg::new(7)));
635 assert_ne!(reg, Reg::virtual_reg(7));
636 }
637
638 #[test]
639 fn an_operand_keeps_what_it_was_constrained_to() {
640 let class = RegClass::new(0);
641 let plain = Operand::write(Reg::virtual_reg(1), class);
642 assert_eq!(plain.role, Role::Def);
643 assert_eq!(plain.constraint, Constraint::Reg);
644 let tied = plain.with(Constraint::Reuse(1));
645 assert_eq!(tied.constraint, Constraint::Reuse(1));
646 assert_eq!(tied.reg, plain.reg);
647 assert!(tied.role.is_def());
648 assert!(!Operand::read(Reg::virtual_reg(1), class).role.is_def());
649 }
650}