Skip to content

Commit 891c706

Browse files
Bhavana KilambiNingsheng Jian
Bhavana Kilambi
authored and
Ningsheng Jian
committed
8295276: AArch64: Add backend support for half float conversion intrinsics
Reviewed-by: ngasson, aph, njian
1 parent 3c09498 commit 891c706

File tree

4 files changed

+658
-624
lines changed

4 files changed

+658
-624
lines changed

src/hotspot/cpu/aarch64/aarch64.ad

+26
Original file line numberDiff line numberDiff line change
@@ -14577,6 +14577,32 @@ instruct convF2L_reg_reg(iRegLNoSp dst, vRegF src) %{
1457714577
ins_pipe(fp_f2l);
1457814578
%}
1457914579

14580+
instruct convF2HF_reg_reg(iRegINoSp dst, vRegF src, vRegF tmp) %{
14581+
match(Set dst (ConvF2HF src));
14582+
format %{ "fcvt $tmp, $src\t# convert single to half precision\n\t"
14583+
"smov $dst, $tmp\t# move result from $tmp to $dst"
14584+
%}
14585+
effect(TEMP tmp);
14586+
ins_encode %{
14587+
__ fcvtsh($tmp$$FloatRegister, $src$$FloatRegister);
14588+
__ smov($dst$$Register, $tmp$$FloatRegister, __ H, 0);
14589+
%}
14590+
ins_pipe(pipe_slow);
14591+
%}
14592+
14593+
instruct convHF2F_reg_reg(vRegF dst, iRegINoSp src, vRegF tmp) %{
14594+
match(Set dst (ConvHF2F src));
14595+
format %{ "mov $tmp, $src\t# move source from $src to $tmp\n\t"
14596+
"fcvt $dst, $tmp\t# convert half to single precision"
14597+
%}
14598+
effect(TEMP tmp);
14599+
ins_encode %{
14600+
__ mov($tmp$$FloatRegister, __ H, 0, $src$$Register);
14601+
__ fcvths($dst$$FloatRegister, $tmp$$FloatRegister);
14602+
%}
14603+
ins_pipe(pipe_slow);
14604+
%}
14605+
1458014606
instruct convI2F_reg_reg(vRegF dst, iRegIorL2I src) %{
1458114607
match(Set dst (ConvI2F src));
1458214608

src/hotspot/cpu/aarch64/assembler_aarch64.hpp

+19-17
Original file line numberDiff line numberDiff line change
@@ -1895,31 +1895,33 @@ void mvnw(Register Rd, Register Rm,
18951895
#undef INSN
18961896

18971897
// Floating-point data-processing (1 source)
1898-
void data_processing(unsigned op31, unsigned type, unsigned opcode,
1898+
void data_processing(unsigned type, unsigned opcode,
18991899
FloatRegister Vd, FloatRegister Vn) {
19001900
starti;
1901-
f(op31, 31, 29);
1901+
f(0b000, 31, 29);
19021902
f(0b11110, 28, 24);
19031903
f(type, 23, 22), f(1, 21), f(opcode, 20, 15), f(0b10000, 14, 10);
19041904
rf(Vn, 5), rf(Vd, 0);
19051905
}
19061906

1907-
#define INSN(NAME, op31, type, opcode) \
1907+
#define INSN(NAME, type, opcode) \
19081908
void NAME(FloatRegister Vd, FloatRegister Vn) { \
1909-
data_processing(op31, type, opcode, Vd, Vn); \
1910-
}
1911-
1912-
INSN(fmovs, 0b000, 0b00, 0b000000);
1913-
INSN(fabss, 0b000, 0b00, 0b000001);
1914-
INSN(fnegs, 0b000, 0b00, 0b000010);
1915-
INSN(fsqrts, 0b000, 0b00, 0b000011);
1916-
INSN(fcvts, 0b000, 0b00, 0b000101); // Single-precision to double-precision
1917-
1918-
INSN(fmovd, 0b000, 0b01, 0b000000);
1919-
INSN(fabsd, 0b000, 0b01, 0b000001);
1920-
INSN(fnegd, 0b000, 0b01, 0b000010);
1921-
INSN(fsqrtd, 0b000, 0b01, 0b000011);
1922-
INSN(fcvtd, 0b000, 0b01, 0b000100); // Double-precision to single-precision
1909+
data_processing(type, opcode, Vd, Vn); \
1910+
}
1911+
1912+
INSN(fmovs, 0b00, 0b000000);
1913+
INSN(fabss, 0b00, 0b000001);
1914+
INSN(fnegs, 0b00, 0b000010);
1915+
INSN(fsqrts, 0b00, 0b000011);
1916+
INSN(fcvts, 0b00, 0b000101); // Single-precision to double-precision
1917+
INSN(fcvths, 0b11, 0b000100); // Half-precision to single-precision
1918+
INSN(fcvtsh, 0b00, 0b000111); // Single-precision to half-precision
1919+
1920+
INSN(fmovd, 0b01, 0b000000);
1921+
INSN(fabsd, 0b01, 0b000001);
1922+
INSN(fnegd, 0b01, 0b000010);
1923+
INSN(fsqrtd, 0b01, 0b000011);
1924+
INSN(fcvtd, 0b01, 0b000100); // Double-precision to single-precision
19231925

19241926
private:
19251927
void _fcvt_narrow_extend(FloatRegister Vd, SIMD_Arrangement Ta,

test/hotspot/gtest/aarch64/aarch64-asmtest.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -957,7 +957,9 @@ def cstr(self):
957957
class FloatInstruction(Instruction):
958958

959959
def aname(self):
960-
if (self._name.endswith("s") | self._name.endswith("d")):
960+
if (self._name in ["fcvtsh", "fcvths"]):
961+
return self._name[:len(self._name)-2]
962+
elif (self._name.endswith("s") | self._name.endswith("d")):
961963
return self._name[:len(self._name)-1]
962964
else:
963965
return self._name
@@ -1012,6 +1014,8 @@ def __init__(self, args):
10121014
elif not self._isPredicated and (name in ["and", "eor", "orr", "bic"]):
10131015
self._width = RegVariant(3, 3)
10141016
self._bitwiseop = True
1017+
elif name == "revb":
1018+
self._width = RegVariant(1, 3)
10151019
else:
10161020
self._width = RegVariant(0, 3)
10171021

@@ -1458,7 +1462,7 @@ def generate(kind, names):
14581462

14591463
generate(TwoRegFloatOp,
14601464
[["fmovs", "ss"], ["fabss", "ss"], ["fnegs", "ss"], ["fsqrts", "ss"],
1461-
["fcvts", "ds"],
1465+
["fcvts", "ds"], ["fcvtsh", "hs"], ["fcvths", "sh"],
14621466
["fmovd", "dd"], ["fabsd", "dd"], ["fnegd", "dd"], ["fsqrtd", "dd"],
14631467
["fcvtd", "sd"],
14641468
])

0 commit comments

Comments
 (0)