diff options
author | Pekka Enberg <penberg@kernel.org> | 2012-01-14 12:49:12 +0200 |
---|---|---|
committer | Pekka Enberg <penberg@kernel.org> | 2012-01-14 12:49:25 +0200 |
commit | 0ab0e6fa38af8acb500e7c0e75b386a68ad4771a (patch) | |
tree | 9fa92bd82d574aa1c8572333e3faf7b2bdfe2aaf | |
parent | 8319a7fe0d1066aba4f101a58a384f45b2418c83 (diff) | |
download | jato-0ab0e6fa38af8acb500e7c0e75b386a68ad4771a.tar.gz |
x86-64: Simplify __emit_insn()
Signed-off-by: Pekka Enberg <penberg@kernel.org>
-rw-r--r-- | arch/x86/emit_64.c | 26 |
1 files changed, 7 insertions, 19 deletions
diff --git a/arch/x86/emit_64.c b/arch/x86/emit_64.c index 8f469aeb..67982bc5 100644 --- a/arch/x86/emit_64.c +++ b/arch/x86/emit_64.c @@ -63,15 +63,6 @@ #include <errno.h> #include <stdio.h> -typedef void (*emit_fn_t)(struct insn *insn, struct buffer *, struct basic_block *bb); - -struct emitter { - emit_fn_t emit_fn; -}; - -#define DECL_EMITTER(_insn_type, _fn) \ - [_insn_type] = { .emit_fn = _fn } - /* * Common code emitters */ @@ -1593,14 +1584,11 @@ void *emit_itable_resolver_stub(struct vm_class *vmc, } -static void do_emit_insn(struct emitter *emitter, struct buffer *buf, struct insn *insn, struct basic_block *bb) -{ - emit_fn_t fn = emitter->emit_fn; +typedef void (*emit_fn_t)(struct insn *insn, struct buffer *, struct basic_block *bb); - fn(insn, buf, bb); -} +#define DECL_EMITTER(_insn_type, _fn) [_insn_type] = _fn -static struct emitter emitters[] = { +static emit_fn_t emitters[] = { DECL_EMITTER(INSN_ADDSD_MEMDISP_XMM, insn_encode), DECL_EMITTER(INSN_ADDSD_XMM_XMM, insn_encode), DECL_EMITTER(INSN_ADDSS_XMM_XMM, insn_encode), @@ -1698,14 +1686,14 @@ static struct emitter emitters[] = { static void __emit_insn(struct buffer *buf, struct basic_block *bb, struct insn *insn) { - struct emitter *emitter; + emit_fn_t fn; - emitter = &emitters[insn->type]; + fn = emitters[insn->type]; - if (!emitter->emit_fn) + if (!fn) die("no emitter for instruction type %d", insn->type); - do_emit_insn(emitter, buf, insn, bb); + fn(insn, buf, bb); } void emit_insn(struct buffer *buf, struct basic_block *bb, struct insn *insn) |