Skip to content

Commit fc387e0

Browse files
authored
Add support sqrtps and sqrtpd (#10768)
Will pursue sqrtss and sqrtsd in a follow-up patch after the isle support needed there is understood.
1 parent 05ea71d commit fc387e0

File tree

5 files changed

+17
-10
lines changed

5 files changed

+17
-10
lines changed

cranelift/assembler-x64/meta/src/instructions.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ mod mul;
88
mod neg;
99
mod or;
1010
mod shift;
11+
mod sqrt;
1112
mod sub;
1213
mod xor;
1314

@@ -24,6 +25,7 @@ pub fn list() -> Vec<Inst> {
2425
all.extend(neg::list());
2526
all.extend(or::list());
2627
all.extend(shift::list());
28+
all.extend(sqrt::list());
2729
all.extend(sub::list());
2830
all.extend(xor::list());
2931
all
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
use crate::dsl::{Feature::*, Inst, Location::*};
2+
use crate::dsl::{align, fmt, inst, r, rex, w};
3+
4+
#[rustfmt::skip] // Keeps instructions on a single line.
5+
pub fn list() -> Vec<Inst> {
6+
vec![
7+
// Vector instructions.
8+
inst("sqrtpd", fmt("A", [w(xmm), r(align(xmm_m128))]), rex([0x66, 0x0F, 0x51]).r(), _64b | compat | sse2),
9+
inst("sqrtps", fmt("A", [w(xmm), r(align(xmm_m128))]), rex([0x0F, 0x51]).r(), _64b | compat | sse),
10+
]
11+
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4728,17 +4728,19 @@
47284728

47294729
;; Helper for creating `sqrtps` instructions.
47304730
(decl x64_sqrtps (XmmMem) Xmm)
4731-
(rule (x64_sqrtps x) (xmm_unary_rm_r (SseOpcode.Sqrtps) x))
47324731
(rule 1 (x64_sqrtps x)
47334732
(if-let true (use_avx))
47344733
(xmm_unary_rm_r_vex (AvxOpcode.Vsqrtps) x))
4734+
(rule 0 (x64_sqrtps x)
4735+
(x64_sqrtps_a x))
47354736

47364737
;; Helper for creating `sqrtpd` instructions.
47374738
(decl x64_sqrtpd (XmmMem) Xmm)
4738-
(rule (x64_sqrtpd x) (xmm_unary_rm_r (SseOpcode.Sqrtpd) x))
47394739
(rule 1 (x64_sqrtpd x)
47404740
(if-let true (use_avx))
47414741
(xmm_unary_rm_r_vex (AvxOpcode.Vsqrtpd) x))
4742+
(rule 0 (x64_sqrtpd x)
4743+
(x64_sqrtpd_a x))
47424744

47434745
;; Helper for creating `cvtss2sd` instructions.
47444746
;;

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,8 +1009,6 @@ pub enum SseOpcode {
10091009
Roundsd,
10101010
Rsqrtss,
10111011
Shufps,
1012-
Sqrtps,
1013-
Sqrtpd,
10141012
Sqrtss,
10151013
Sqrtsd,
10161014
Ucomiss,
@@ -1052,7 +1050,6 @@ impl SseOpcode {
10521050
| SseOpcode::Rcpss
10531051
| SseOpcode::Rsqrtss
10541052
| SseOpcode::Shufps
1055-
| SseOpcode::Sqrtps
10561053
| SseOpcode::Sqrtss
10571054
| SseOpcode::Ucomiss
10581055
| SseOpcode::Unpcklps
@@ -1105,7 +1102,6 @@ impl SseOpcode {
11051102
| SseOpcode::Punpckhwd
11061103
| SseOpcode::Punpcklbw
11071104
| SseOpcode::Punpcklwd
1108-
| SseOpcode::Sqrtpd
11091105
| SseOpcode::Sqrtsd
11101106
| SseOpcode::Ucomisd
11111107
| SseOpcode::Punpckldq
@@ -1313,8 +1309,6 @@ impl fmt::Debug for SseOpcode {
13131309
SseOpcode::Roundsd => "roundsd",
13141310
SseOpcode::Rsqrtss => "rsqrtss",
13151311
SseOpcode::Shufps => "shufps",
1316-
SseOpcode::Sqrtps => "sqrtps",
1317-
SseOpcode::Sqrtpd => "sqrtpd",
13181312
SseOpcode::Sqrtss => "sqrtss",
13191313
SseOpcode::Sqrtsd => "sqrtsd",
13201314
SseOpcode::Ucomiss => "ucomiss",

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1796,8 +1796,6 @@ pub(crate) fn emit(
17961796
SseOpcode::Pmovzxwd => (LegacyPrefixes::_66, 0x0F3833, 3),
17971797
SseOpcode::Pmovzxwq => (LegacyPrefixes::_66, 0x0F3834, 3),
17981798
SseOpcode::Pmovzxdq => (LegacyPrefixes::_66, 0x0F3835, 3),
1799-
SseOpcode::Sqrtps => (LegacyPrefixes::None, 0x0F51, 2),
1800-
SseOpcode::Sqrtpd => (LegacyPrefixes::_66, 0x0F51, 2),
18011799
SseOpcode::Movddup => (LegacyPrefixes::_F2, 0x0F12, 2),
18021800
_ => unimplemented!("Opcode {:?} not implemented", op),
18031801
};

0 commit comments

Comments
 (0)