Skip to content
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#4393 Revert new AArch64 codec patch (PR5453) #5553

Merged
merged 3 commits into from
Jul 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 2 additions & 23 deletions core/ir/aarch64/codec.c
Original file line number Diff line number Diff line change
Expand Up @@ -5055,25 +5055,6 @@ encode_opnds_tbz(byte *pc, instr_t *instr, uint enc, decode_info_t *di)
return ENCFAIL;
}

/* Function(s) used by new codec. */

/* Halfword and short element size. This is the same as encode_opnd_hs_sz()
* except that the shift of the size value to place it in the correct part of
* the encoding is not done here. That placement is instruction specific and so
* is done by each instruction's enc_*() function. In general the positioning
* of operand encodings in instruction encodings should be done by each
* instruction's encoding function, rather than an operand's encoding function.
*/
static inline bool
get_el_hs_sz(OUT uint *elsz_out, opnd_t opnd)
{
ptr_int_t val = opnd_get_immed_int(opnd);
if (val < 1 || val > 2)
return false;
*elsz_out = val;
return true;
}

/******************************************************************************/

/* Include automatically generated decoder and encoder files. Decode and encode
Expand All @@ -5086,13 +5067,11 @@ get_el_hs_sz(OUT uint *elsz_out, opnd_t opnd)
#include "opnd_encode_funcs.h"
#include "decode_gen_sve.h"
#include "decode_gen_v82.h"
#include "decode_v81.h"
#include "decode_gen_v81.h" /* Redirects decoding to decode_v81.h */
#include "decode_gen_v81.h"
#include "decode_gen_v80.h"
#include "encode_gen_sve.h"
#include "encode_gen_v82.h"
#include "encode_v81.h"
#include "encode_gen_v81.h" /* Redirects encoding to encode_v81.h */
#include "encode_gen_v81.h"
#include "encode_gen_v80.h"

/******************************************************************************/
Expand Down
24 changes: 0 additions & 24 deletions core/ir/aarch64/codec.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,32 +51,8 @@ decode_common(dcontext_t *dcontext, byte *pc, byte *orig_pc, instr_t *instr);
uint
encode_common(byte *pc, instr_t *i, decode_info_t *di);

/* Types and macros used by new codec. */

/* Bit extraction macro used extensively by automatically generated decoder and
* encoder functions.
*/
#define BITS(_enc, bitmax, bitmin) \
((((uint32)(_enc)) >> (bitmin)) & \
(uint32)((1ULL << ((bitmax) - (bitmin) + 1)) - 1ULL))

/* Decoding is based on a key/value mapping (decode_map) where the key
* (enc_bits) is a unique set of up to 32 bits representing an instruction
* which is decoded by a function (decode_fn).
*/
typedef bool(decode_func_ptr)(dcontext_t *dcontext, uint enc, instr_t *instr);

typedef struct dmap {
uint32 enc_bits;
decode_func_ptr *decode_fn;
} decode_map;

/* Encoding function call-and-check macro used extensively by automatically
* generated encoder switch/case clauses.
*/
#define ENCODE_IF_MATCH(ENCODE_FUNCTION) \
enc = ENCODE_FUNCTION(instr); \
if (enc != ENCFAIL) \
return enc;

#endif /* CODEC_H */
38 changes: 8 additions & 30 deletions core/ir/aarch64/codec.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,6 @@ def generate_opndset_decoders(opndsettab, opndtab):
FALLTHROUGH.values()]
c += ['\n']
for name in sorted(opndsettab):
# Ignore dummy codec_*.txt entries. This suppresses generation of this
# decoder function for instructions handled by the new decoder.
if name == 'gen_00000000_00000000':
return '\n'
opnd_set = opndsettab[name]
(dsts, srcs) = (opnd_set.dsts, opnd_set.srcs)
c += ['/* %s <- %s */' % (opnd_set.dsts, opnd_set.srcs)]
Expand Down Expand Up @@ -259,17 +255,10 @@ def indent_append(text):
c = ['static bool',
'decoder_' + curr_isa + '(uint enc, dcontext_t *dc, byte *pc, instr_t *instr)',
'{']
if curr_isa != 'v81':
gen(c, patterns, 1)
for opcode in FALLTHROUGH.values():
c += [' %s' % opcode.decode_clause]
c += [' %s' % opcode.decode_function]
else:
# This calls a decode function for v8.1 instructions which uses a new
# method of decoding.
c += [' return decode_v81(enc, dc, pc, instr);']
c.append('}')
return '\n'.join(c) + '\n'
gen(c, patterns, 1)
for opcode in FALLTHROUGH.values():
c += [' %s' % opcode.decode_clause]
c += [' %s' % opcode.decode_function]
# Call the next version of the decoder if defined.
if next_isa != '':
c.append(' return decoder_' + next_isa + '(enc, dc, pc, instr);')
Expand Down Expand Up @@ -308,10 +297,6 @@ def make_enc(n, reordered, f, opndtab):
def generate_opndset_encoders(opndsettab, opndtab):
c = []
for name in sorted(opndsettab):
# Ignore dummy codec_*.txt entries. This suppresses generation of this
# encoder function for instructions handled by the new encoder.
if name == 'gen_00000000_00000000':
return '\n'
os = opndsettab[name]
(fixed, dsts, srcs, enc_order) = (os.fixed, os.dsts, os.srcs, os.enc_order)
c += ['/* %s <- %s */' % (os.dsts, os.srcs)]
Expand Down Expand Up @@ -360,17 +345,10 @@ def generate_encoder(patterns, opndsettab, opndtab, curr_isa, next_isa):
case[mn].append(p)
c += ['static uint',
'encoder_' + curr_isa + '(byte *pc, instr_t *instr, decode_info_t *di)',
'{']
# This calls an encode function for v8.1 instructions which uses a new
# method of encoding.
if curr_isa == 'v81':
c += [' return encode_v81(pc, instr, di);']
c.append('}')
return '\n'.join(c) + '\n'
else:
c += [' uint enc;',
' (void)enc;',
' switch (instr->opcode) {']
'{',
' uint enc;',
' (void)enc;',
' switch (instr->opcode) {']

def reorder_key(t):
b, m, mn, f = t
Expand Down
Loading