-
Notifications
You must be signed in to change notification settings - Fork 571
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
i#2626 Add #fbits fixed-point handling to AArch64 codec #4860
Changes from 3 commits
288f7d3
20cbcf7
ec7820b
a6fd3b5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1557,6 +1557,35 @@ encode_opnd_cond(uint enc, int opcode, byte *pc, opnd_t opnd, OUT uint *enc_out) | |
return encode_opnd_int(12, 4, false, 0, 0, opnd, enc_out); | ||
} | ||
|
||
/* scale: scalar encoding of #fbits operand (number of bits after the decimal point for | ||
* fixed-point values) */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: Capitalize w/ punctuation for complete sentence style: prefer |
||
|
||
static inline bool | ||
decode_opnd_scale(uint enc, int opcode, byte *pc, OUT opnd_t *opnd) | ||
{ | ||
uint scale = extract_uint(enc, 10, 6); | ||
*opnd = opnd_create_immed_int(64 - scale, OPSZ_6b); | ||
return true; | ||
} | ||
|
||
static inline bool | ||
encode_opnd_scale(uint enc, int opcode, byte *pc, opnd_t opnd, OUT uint *enc_out) | ||
{ | ||
ptr_int_t fbits; | ||
|
||
if (!opnd_is_immed_int(opnd)) | ||
return false; | ||
|
||
fbits = opnd_get_immed_int(opnd); | ||
|
||
if (fbits < 1 || fbits > 64) | ||
return false; | ||
|
||
*enc_out = (64 - fbits) << 10; /* 'scale' bitfield in encoding */ | ||
|
||
return true; | ||
} | ||
|
||
/* fpimm8: immediate operand for SIMD fmov */ | ||
|
||
static inline bool | ||
|
@@ -2140,6 +2169,34 @@ encode_opnd_vindex_H(uint enc, int opcode, byte *pc, opnd_t opnd, OUT uint *enc_ | |
return true; | ||
} | ||
|
||
/* immhb: vector encoding of #fbits operand (number of bits after the decimal point for | ||
* fixed-point values) */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same style comments |
||
|
||
static inline bool | ||
decode_opnd_immhb(uint enc, int opcode, byte *pc, OUT opnd_t *opnd) | ||
{ | ||
uint immhb = extract_uint(enc, 16, 6); | ||
*opnd = opnd_create_immed_int(64 - immhb, OPSZ_6b); | ||
return true; | ||
} | ||
|
||
static inline bool | ||
encode_opnd_immhb(uint enc, int opcode, byte *pc, opnd_t opnd, OUT uint *enc_out) | ||
{ | ||
ptr_int_t fbits; | ||
|
||
if (!opnd_is_immed_int(opnd)) | ||
return false; | ||
|
||
fbits = opnd_get_immed_int(opnd); | ||
if (fbits < 1 || fbits > 64) | ||
return false; | ||
|
||
*enc_out = (64 - fbits) << 16; | ||
|
||
return true; | ||
} | ||
|
||
/* imm12: 12-bit immediate operand of ADD/SUB */ | ||
|
||
static inline bool | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,6 +96,7 @@ | |
-----------------xxxxx---------- q10 # Q register | ||
----------------xxx------------- ext # extend type | ||
----------------xxxx------------ cond # condition for CCMN, CCMP | ||
----------------xxxxxx---------- scale # encoding of #fbits value in scale field | ||
-------------xxx------xxxxx----- fpimm8 # floating-point immediate for vector fmov | ||
-------------xxxxxxxxxxxxxx----- sysops # immediate operands for SYS | ||
------------xxxxxxxxxxxxxxx----- sysreg # operand of MRS | ||
|
@@ -121,6 +122,7 @@ | |
----------?xxxxx--?-??---------- x16immvr # computes immed from 21, 13 and 11:10 | ||
----------?xxxxx???-??---------- x16immvs # computes immed from 21, 15:13 and 11:10 | ||
----------xx--------x----------- vindex_H # Index for vector with half elements (0-7) | ||
----------xxxxxx---------------- immhb # encoding of #fbits value in immh:immb fields | ||
----------xxxxxxxxxxxx---------- imm12 # immediate for ADD/SUB | ||
----------xxxxxxxxxxxxxxxxx----- mem12q # size is 16 bytes | ||
----------xxxxxxxxxxxxxxxxx----- prf12 # size is 0 bytes (prefetch variant of mem12) | ||
|
@@ -1158,20 +1160,23 @@ x101101011000000000101xxxxxxxxxx cls wx0 : wx5 | |
1001111000111000000000xxxxxxxxxx fcvtzs x0 : s5 | ||
0001111001111000000000xxxxxxxxxx fcvtzs w0 : d5 | ||
1001111001111000000000xxxxxxxxxx fcvtzs x0 : d5 | ||
0001111000111001000000xxxxxxxxxx fcvtzu w0 : s5 | ||
1001111000111001000000xxxxxxxxxx fcvtzu x0 : s5 | ||
0001111001111001000000xxxxxxxxxx fcvtzu w0 : d5 | ||
1001111001111001000000xxxxxxxxxx fcvtzu x0 : d5 | ||
x001111000111001000000xxxxxxxxxx fcvtzu wx0 : s5 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This patch folds the 4 |
||
x001111001111001000000xxxxxxxxxx fcvtzu wx0 : d5 | ||
x001111000011001xxxxxxxxxxxxxxxx fcvtzu wx0 : s5 scale | ||
x001111001011001xxxxxxxxxxxxxxxx fcvtzu wx0 : d5 scale | ||
|
||
# Floating-point convert (vector, integer) (vector single-precision and double-precision) | ||
0101111010100001101110xxxxxxxxxx fcvtzs s0 : s5 | ||
0101111011100001101110xxxxxxxxxx fcvtzs d0 : d5 | ||
0111111010100001101110xxxxxxxxxx fcvtzu s0 : s5 | ||
0111111011100001101110xxxxxxxxxx fcvtzu d0 : d5 | ||
0111111100xxxxxx111111xxxxxxxxxx fcvtzu s0 : s5 immhb | ||
0111111101xxxxxx111111xxxxxxxxxx fcvtzu d0 : d5 immhb | ||
|
||
# Floating-point convert (vector, integer) (scalar single-precision and double-precision) | ||
0x0011101x100001101110xxxxxxxxxx fcvtzs dq0 : dq5 sd_sz | ||
0x1011101x100001101110xxxxxxxxxx fcvtzu dq0 : dq5 sd_sz | ||
0x1011110xxxxxxx111111xxxxxxxxxx fcvtzu dq0 : dq5 sd_sz immhb | ||
|
||
# Floating-point data-processing (2 source) | ||
00011110xx1xxxxx000010xxxxxxxxxx fmul float_reg0 : float_reg5 float_reg16 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1759,6 +1759,19 @@ enum { | |
#define INSTR_CREATE_fcvtzu_vector(dc, Rd, Rm, width) \ | ||
instr_create_1dst_2src(dc, OP_fcvtzu, Rd, Rm, width) | ||
|
||
/** | ||
* Creates a FCVTZU vector floating-point to fixed-point convert instruction. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment as on Matt's PR: s/a/an/ for most common pronunciation. Ditto below. |
||
* \param dc The void * dcontext used to allocate memory for the #instr_t. | ||
* \param Rd The output register. | ||
* \param Rm The input register. | ||
* \param width The vector element width. Use either OPND_CREATE_SINGLE() or | ||
* OPND_CREATE_DOUBLE(). | ||
* \param fbits The number of bits after the binary point in the fixed-point | ||
* destination element. | ||
*/ | ||
#define INSTR_CREATE_fcvtzu_vector_fixed(dc, Rd, Rm, width, fbits) \ | ||
instr_create_1dst_3src(dc, OP_fcvtzu, Rd, Rm, width, fbits) | ||
|
||
/* -------- Floating-point data-processing (1 source) ------------------ */ | ||
|
||
/** | ||
|
@@ -1855,6 +1868,17 @@ enum { | |
#define INSTR_CREATE_fcvtzu_scalar(dc, Rd, Rm) \ | ||
instr_create_1dst_1src(dc, OP_fcvtzu, Rd, Rm) | ||
|
||
/** | ||
* Creates a FCVTZU scalar floating-point to fixed-point convert instruction. | ||
* \param dc The void * dcontext used to allocate memory for the #instr_t. | ||
* \param Rd Floating-point or integer output register. | ||
* \param Rm Floating-point input register. | ||
* \param fbits The number of bits after the binary point in the fixed-point | ||
* destination. | ||
*/ | ||
#define INSTR_CREATE_fcvtzu_scalar_fixed(dc, Rd, Rm, fbits) \ | ||
instr_create_1dst_2src(dc, OP_fcvtzu, Rd, Rm, fbits) | ||
|
||
/** | ||
* Creates a FRINTN floating point instruction. | ||
* \param dc The void * dcontext used to allocate memory for the instr_t. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Missing mini-description and colon after issue number prefix