Skip to content

Commit 9e57074

Browse files
authored
add FCCMP and FCCMPE instructions (dlang#22538)
1 parent 079547e commit 9e57074

File tree

2 files changed

+51
-3
lines changed

2 files changed

+51
-3
lines changed

compiler/src/dmd/backend/arm/disasmarm.d

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2209,6 +2209,7 @@ void disassemble(uint c) @trusted
22092209
p3 = (Rm == 0 && (opcode2 & 8)) ? "#0.0" : fregString(rbuf[4..8],"sd h"[ftype],Rm);
22102210
}
22112211
}
2212+
else
22122213

22132214
// Floating-point immediate http://www.scs.stanford.edu/~zyedidia/arm64/encodingindex.html#floatimm
22142215
if (field(ins,31,24) == 0x1E && field(ins,21,21) == 1 && field(ins,12,10) == 4)
@@ -2226,7 +2227,33 @@ void disassemble(uint c) @trusted
22262227
}
22272228
else
22282229

2229-
// Floating-point conditional compare
2230+
// Floating-point conditional compare https://www.scs.stanford.edu/~zyedidia/arm64/encodingindex.html#floatccmp
2231+
if (field(ins, 30, 30) == 0 && field(ins, 28, 24) == 0x1E && field(ins,21,21) == 1 && field(ins, 11, 10) == 1)
2232+
{
2233+
url = "floatccmp";
2234+
2235+
uint M = field(ins,31,31);
2236+
uint S = field(ins,29,29);
2237+
uint ftype = field(ins,23,22);
2238+
uint Rm = field(ins,20,16);
2239+
uint cond = field(ins,15,12);
2240+
uint Rn = field(ins, 9, 5);
2241+
uint op = field(ins, 4, 4);
2242+
uint nzcv = field(ins, 3, 0);
2243+
2244+
if (M == 0 && S == 0)
2245+
{
2246+
// fccmp d5,d5,#0,vs
2247+
url = op ? "fccmpe_float" : "fccmp_float";
2248+
p1 = op ? "fccmpe" : "fccmp";
2249+
p2 = fregString(rbuf[0..4],"sd h"[ftype],Rn);
2250+
p3 = fregString(rbuf[0..4],"sd h"[ftype],Rm);
2251+
uint n = snprintf(buf.ptr, cast(uint)buf.length,"#0x%x", nzcv);
2252+
p4 = buf[0 .. n];
2253+
p5 = condstring[cond];
2254+
}
2255+
}
2256+
else
22302257

22312258
// Floating-point data-processing (2 source) https://www.scs.stanford.edu/~zyedidia/arm64/encodingindex.html#floatdp2
22322259
if (field(ins, 30, 30) == 0 && field(ins, 28, 24) == 0x1E && field(ins,21,21) == 1 && field(ins, 11, 10) == 2)
@@ -3216,8 +3243,10 @@ unittest
32163243
unittest
32173244
{
32183245
int line64 = __LINE__;
3219-
string[96] cases64 = // 64 bit code gen
3246+
string[98] cases64 = // 64 bit code gen
32203247
[
3248+
"1E 65 64 A0 fccmp d5,d5,#0x0,vs",
3249+
"1E 65 64 B0 fccmpe d5,d5,#0x0,vs",
32213250
"79 C0 47 AB ldrsh w11,[x29,#0x22]",
32223251
"F8 1F 03 A8 stur x8,[x29,#-0x10]",
32233252
"B8 00 04 62 str w2,[x3],#0",

compiler/src/dmd/backend/arm/instr.d

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -946,8 +946,27 @@ struct INSTR
946946
*/
947947
static uint fmov_float_imm(uint ftype, uint imm8, reg_t Vd) { return (0x1E << 24) | (ftype << 22) | (1 << 21) | (imm8 << 13) | (4 << 10) | (Vd & 31); }
948948

949-
/* Floating-point condistional compare
949+
/* Floating-point conditional compare https://www.scs.stanford.edu/~zyedidia/arm64/encodingindex.html#floatccmp
950950
*/
951+
static uint floatccmp(uint ftype, reg_t Vm, uint cond, reg_t Vn, uint op, uint nzcv)
952+
{
953+
assert(Vm >= 32 && Vn >= 32);
954+
return (0x1E << 24) | (ftype << 22) | (1 << 21) | ((Vm & 31) << 16) | (cond << 12) | (1 << 10) | ((Vn & 31) << 5) | (op << 4) | nzcv;
955+
}
956+
957+
/* FCCMP Vn,Vm,#nzcv,cond https://www.scs.stanford.edu/~zyedidia/arm64/fccmp_float.html
958+
*/
959+
static uint fccmp_float(uint ftype, reg_t Vm, uint cond, reg_t Vn, uint nzcv)
960+
{
961+
return floatccmp(ftype, Vm, cond, Vn, 0, nzcv);
962+
}
963+
964+
/* FCCMPE Vn,Vm,#nzcv,cond https://www.scs.stanford.edu/~zyedidia/arm64/fccmpe_float.html
965+
*/
966+
static uint fccmpe_float(uint ftype, reg_t Vm, uint cond, reg_t Vn, uint nzcv)
967+
{
968+
return floatccmp(ftype, Vm, cond, Vn, 1, nzcv);
969+
}
951970

952971
/* Floating-point data-processing (2 source) https://www.scs.stanford.edu/~zyedidia/arm64/encodingindex.html#floatdp2
953972
*/

0 commit comments

Comments
 (0)