Skip to content

Commit 6392f56

Browse files
authored
x64: remove AluRM (#10494)
This `Inst` form was used for read-modify-write instructions during lowering, but these have been replaced by the new assembler.
1 parent 44e4919 commit 6392f56

File tree

5 files changed

+0
-321
lines changed

5 files changed

+0
-321
lines changed

cranelift/codegen/src/isa/x64/inst.isle

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,6 @@
2020
(src2 GprMemImm)
2121
(dst WritableGpr))
2222

23-
;; Integer arithmetic read-modify-write on memory.
24-
(AluRM (size OperandSize) ;; 1, 2, 4 or 8
25-
(op AluRmiROpcode)
26-
(src1_dst SyntheticAmode)
27-
(src2 Gpr)
28-
(lock bool))
29-
3023
;; Integer arithmetic binary op that relies on the VEX prefix.
3124
;; NOTE: we don't currently support emitting VEX instructions with memory
3225
;; arguments, so `src2` is artificially constrained to be a Gpr.
@@ -5032,12 +5025,6 @@
50325025
(if-let true (use_avx))
50335026
(xmm_rmir_vex (AvxOpcode.Vpcmpgtq) x y))
50345027

5035-
;; Helpers for read-modify-write ALU form (AluRM).
5036-
(decl alu_rm (Type AluRmiROpcode Amode Gpr) SideEffectNoResult)
5037-
(rule (alu_rm ty opcode src1_dst src2)
5038-
(let ((size OperandSize (operand_size_of_type_32_64 ty)))
5039-
(SideEffectNoResult.Inst (MInst.AluRM size opcode src1_dst src2 false))))
5040-
50415028
(decl x64_add_mem (Type Amode Gpr) SideEffectNoResult)
50425029
(spec (x64_add_mem ty addr val)
50435030
(provide (= result (store_effect

cranelift/codegen/src/isa/x64/inst/emit.rs

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -250,47 +250,6 @@ pub(crate) fn emit(
250250
);
251251
}
252252

253-
Inst::AluRM {
254-
size,
255-
src1_dst,
256-
src2,
257-
op,
258-
lock,
259-
} => {
260-
let src2 = src2.to_reg();
261-
let src1_dst = src1_dst.finalize(state.frame_layout(), sink).clone();
262-
263-
let opcode = match op {
264-
AluRmiROpcode::Add => 0x01,
265-
AluRmiROpcode::Sub => 0x29,
266-
AluRmiROpcode::And => 0x21,
267-
AluRmiROpcode::Or => 0x09,
268-
AluRmiROpcode::Xor => 0x31,
269-
_ => panic!("Unsupported read-modify-write ALU opcode"),
270-
};
271-
272-
let prefix = match (size, lock) {
273-
(OperandSize::Size16, false) => LegacyPrefixes::_66,
274-
(OperandSize::Size16, true) => LegacyPrefixes::_66F0,
275-
(_, false) => LegacyPrefixes::None,
276-
(_, true) => LegacyPrefixes::_F0,
277-
};
278-
let opcode = if *size == OperandSize::Size8 {
279-
opcode - 1
280-
} else {
281-
opcode
282-
};
283-
284-
let mut rex = RexFlags::from(*size);
285-
if *size == OperandSize::Size8 {
286-
debug_assert!(src2.is_real());
287-
rex.always_emit_if_8bit_needed(src2);
288-
}
289-
290-
let enc_g = int_reg_enc(src2);
291-
emit_std_enc_mem(sink, prefix, opcode, 1, enc_g, &src1_dst, rex, 0);
292-
}
293-
294253
Inst::AluRmRVex {
295254
size,
296255
op,

cranelift/codegen/src/isa/x64/inst/emit_tests.rs

Lines changed: 0 additions & 237 deletions
Original file line numberDiff line numberDiff line change
@@ -1629,243 +1629,6 @@ fn test_x64_emit() {
16291629
"sbbq %r15, 99(%rdi), %r15",
16301630
));
16311631

1632-
// ========================================================
1633-
// AluRM
1634-
1635-
insns.push((
1636-
Inst::AluRM {
1637-
size: OperandSize::Size32,
1638-
op: AluRmiROpcode::Add,
1639-
src1_dst: Amode::imm_reg(99, rdi).into(),
1640-
src2: Gpr::unwrap_new(r12),
1641-
lock: false,
1642-
},
1643-
"44016763",
1644-
"addl %r12d, 99(%rdi)",
1645-
));
1646-
1647-
insns.push((
1648-
Inst::AluRM {
1649-
size: OperandSize::Size64,
1650-
op: AluRmiROpcode::Add,
1651-
src1_dst: Amode::imm_reg_reg_shift(0, Gpr::unwrap_new(rbp), Gpr::unwrap_new(rax), 3)
1652-
.into(),
1653-
src2: Gpr::unwrap_new(rax),
1654-
lock: false,
1655-
},
1656-
"480144C500",
1657-
"addq %rax, 0(%rbp,%rax,8)",
1658-
));
1659-
1660-
insns.push((
1661-
Inst::AluRM {
1662-
size: OperandSize::Size32,
1663-
op: AluRmiROpcode::Sub,
1664-
src1_dst: Amode::imm_reg(0, rsp).into(),
1665-
src2: Gpr::unwrap_new(rcx),
1666-
lock: false,
1667-
},
1668-
"290C24",
1669-
"subl %ecx, 0(%rsp)",
1670-
));
1671-
1672-
insns.push((
1673-
Inst::AluRM {
1674-
size: OperandSize::Size64,
1675-
op: AluRmiROpcode::Sub,
1676-
src1_dst: Amode::imm_reg(0, rbp).into(),
1677-
src2: Gpr::unwrap_new(rax),
1678-
lock: false,
1679-
},
1680-
"48294500",
1681-
"subq %rax, 0(%rbp)",
1682-
));
1683-
1684-
insns.push((
1685-
Inst::AluRM {
1686-
size: OperandSize::Size32,
1687-
op: AluRmiROpcode::And,
1688-
src1_dst: Amode::imm_reg(0, rsp).into(),
1689-
src2: Gpr::unwrap_new(rcx),
1690-
lock: false,
1691-
},
1692-
"210C24",
1693-
"andl %ecx, 0(%rsp)",
1694-
));
1695-
1696-
insns.push((
1697-
Inst::AluRM {
1698-
size: OperandSize::Size64,
1699-
op: AluRmiROpcode::And,
1700-
src1_dst: Amode::imm_reg(0, rbp).into(),
1701-
src2: Gpr::unwrap_new(rax),
1702-
lock: false,
1703-
},
1704-
"48214500",
1705-
"andq %rax, 0(%rbp)",
1706-
));
1707-
1708-
insns.push((
1709-
Inst::AluRM {
1710-
size: OperandSize::Size32,
1711-
op: AluRmiROpcode::Or,
1712-
src1_dst: Amode::imm_reg(0, rsp).into(),
1713-
src2: Gpr::unwrap_new(rcx),
1714-
lock: false,
1715-
},
1716-
"090C24",
1717-
"orl %ecx, 0(%rsp)",
1718-
));
1719-
1720-
insns.push((
1721-
Inst::AluRM {
1722-
size: OperandSize::Size64,
1723-
op: AluRmiROpcode::Or,
1724-
src1_dst: Amode::imm_reg(0, rbp).into(),
1725-
src2: Gpr::unwrap_new(rax),
1726-
lock: false,
1727-
},
1728-
"48094500",
1729-
"orq %rax, 0(%rbp)",
1730-
));
1731-
1732-
insns.push((
1733-
Inst::AluRM {
1734-
size: OperandSize::Size32,
1735-
op: AluRmiROpcode::Xor,
1736-
src1_dst: Amode::imm_reg(0, rsp).into(),
1737-
src2: Gpr::unwrap_new(rcx),
1738-
lock: false,
1739-
},
1740-
"310C24",
1741-
"xorl %ecx, 0(%rsp)",
1742-
));
1743-
1744-
insns.push((
1745-
Inst::AluRM {
1746-
size: OperandSize::Size64,
1747-
op: AluRmiROpcode::Xor,
1748-
src1_dst: Amode::imm_reg(0, rbp).into(),
1749-
src2: Gpr::unwrap_new(rax),
1750-
lock: false,
1751-
},
1752-
"48314500",
1753-
"xorq %rax, 0(%rbp)",
1754-
));
1755-
1756-
insns.push((
1757-
Inst::AluRM {
1758-
size: OperandSize::Size16,
1759-
op: AluRmiROpcode::Add,
1760-
src1_dst: Amode::imm_reg(0, rbp).into(),
1761-
src2: Gpr::unwrap_new(rax),
1762-
lock: false,
1763-
},
1764-
"66014500",
1765-
"addw %ax, 0(%rbp)",
1766-
));
1767-
insns.push((
1768-
Inst::AluRM {
1769-
size: OperandSize::Size16,
1770-
op: AluRmiROpcode::Sub,
1771-
src1_dst: Amode::imm_reg(0, rbp).into(),
1772-
src2: Gpr::unwrap_new(r12),
1773-
lock: false,
1774-
},
1775-
"6644296500",
1776-
"subw %r12w, 0(%rbp)",
1777-
));
1778-
1779-
insns.push((
1780-
Inst::AluRM {
1781-
size: OperandSize::Size8,
1782-
op: AluRmiROpcode::Add,
1783-
src1_dst: Amode::imm_reg(0, rbp).into(),
1784-
src2: Gpr::unwrap_new(rax),
1785-
lock: false,
1786-
},
1787-
"004500",
1788-
"addb %al, 0(%rbp)",
1789-
));
1790-
insns.push((
1791-
Inst::AluRM {
1792-
size: OperandSize::Size8,
1793-
op: AluRmiROpcode::Sub,
1794-
src1_dst: Amode::imm_reg(0, rbp).into(),
1795-
src2: Gpr::unwrap_new(rbp),
1796-
lock: false,
1797-
},
1798-
"40286D00",
1799-
"subb %bpl, 0(%rbp)",
1800-
));
1801-
insns.push((
1802-
Inst::AluRM {
1803-
size: OperandSize::Size8,
1804-
op: AluRmiROpcode::Xor,
1805-
src1_dst: Amode::imm_reg(0, rbp).into(),
1806-
src2: Gpr::unwrap_new(r10),
1807-
lock: false,
1808-
},
1809-
"44305500",
1810-
"xorb %r10b, 0(%rbp)",
1811-
));
1812-
insns.push((
1813-
Inst::AluRM {
1814-
size: OperandSize::Size8,
1815-
op: AluRmiROpcode::And,
1816-
src1_dst: Amode::imm_reg(0, rbp).into(),
1817-
src2: Gpr::unwrap_new(r15),
1818-
lock: false,
1819-
},
1820-
"44207D00",
1821-
"andb %r15b, 0(%rbp)",
1822-
));
1823-
1824-
insns.push((
1825-
Inst::AluRM {
1826-
size: OperandSize::Size64,
1827-
op: AluRmiROpcode::And,
1828-
src1_dst: Amode::imm_reg(0, rdx).into(),
1829-
src2: Gpr::unwrap_new(rax),
1830-
lock: true,
1831-
},
1832-
"F0482102",
1833-
"lock andq %rax, 0(%rdx)",
1834-
));
1835-
insns.push((
1836-
Inst::AluRM {
1837-
size: OperandSize::Size32,
1838-
op: AluRmiROpcode::Or,
1839-
src1_dst: Amode::imm_reg(0, rdx).into(),
1840-
src2: Gpr::unwrap_new(rax),
1841-
lock: true,
1842-
},
1843-
"F00902",
1844-
"lock orl %eax, 0(%rdx)",
1845-
));
1846-
insns.push((
1847-
Inst::AluRM {
1848-
size: OperandSize::Size16,
1849-
op: AluRmiROpcode::Xor,
1850-
src1_dst: Amode::imm_reg(0, rdx).into(),
1851-
src2: Gpr::unwrap_new(rax),
1852-
lock: true,
1853-
},
1854-
"66F03102",
1855-
"lock xorw %ax, 0(%rdx)",
1856-
));
1857-
insns.push((
1858-
Inst::AluRM {
1859-
size: OperandSize::Size8,
1860-
op: AluRmiROpcode::Add,
1861-
src1_dst: Amode::imm_reg(0, r9).into(),
1862-
src2: Gpr::unwrap_new(rax),
1863-
lock: true,
1864-
},
1865-
"F0410001",
1866-
"lock addb %al, 0(%r9)",
1867-
));
1868-
18691632
// ========================================================
18701633
// UnaryRmR
18711634

cranelift/codegen/src/isa/x64/inst/mod.rs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ impl Inst {
7474
// These instructions are part of SSE2, which is a basic requirement in Cranelift, and
7575
// don't have to be checked.
7676
Inst::AluRmiR { .. }
77-
| Inst::AluRM { .. }
7877
| Inst::AtomicRmwSeq { .. }
7978
| Inst::Bswap { .. }
8079
| Inst::CallKnown { .. }
@@ -713,20 +712,6 @@ impl PrettyPrint for Inst {
713712
let op = ljustify2(op.to_string(), suffix_lqb(*size));
714713
format!("{op} {dst}, {dst}, {dst}")
715714
}
716-
Inst::AluRM {
717-
size,
718-
op,
719-
src1_dst,
720-
src2,
721-
lock,
722-
} => {
723-
let size_bytes = size.to_bytes();
724-
let src2 = pretty_print_reg(src2.to_reg(), size_bytes);
725-
let src1_dst = src1_dst.pretty_print(size_bytes);
726-
let op = ljustify2(op.to_string(), suffix_bwlq(*size));
727-
let prefix = if *lock { "lock " } else { "" };
728-
format!("{prefix}{op} {src2}, {src1_dst}")
729-
}
730715
Inst::AluRmRVex {
731716
size,
732717
op,
@@ -2012,10 +1997,6 @@ fn x64_get_operands(inst: &mut Inst, collector: &mut impl OperandVisitor) {
20121997
src2.get_operands(collector);
20131998
}
20141999
Inst::AluConstOp { dst, .. } => collector.reg_def(dst),
2015-
Inst::AluRM { src1_dst, src2, .. } => {
2016-
collector.reg_use(src2);
2017-
src1_dst.get_operands(collector);
2018-
}
20192000
Inst::AluRmRVex {
20202001
src1, src2, dst, ..
20212002
} => {

cranelift/codegen/src/isa/x64/pcc.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -158,17 +158,6 @@ pub(crate) fn check(
158158
}
159159
},
160160

161-
Inst::AluRM {
162-
size,
163-
op: _,
164-
ref src1_dst,
165-
src2: _,
166-
lock: _,
167-
} => {
168-
check_load(ctx, None, src1_dst, vcode, size.to_type(), 64)?;
169-
check_store(ctx, None, src1_dst, vcode, size.to_type())
170-
}
171-
172161
Inst::AluRmRVex {
173162
size,
174163
ref src2,

0 commit comments

Comments
 (0)