Message ID | 152819516132.30857.1700667353240369481.stgit@pasha-ThinkPad-T60 (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On 05.06.2018 12:39, Pavel Dovgalyuk wrote: > From: Pavel Dovgalyuk <pavel.dovgaluk@gmail.com> > > This patch adds functions and headers for adding the helpers from > the modules other than the target translators. > > Signed-off-by: Pavel Dovgalyuk <Pavel.Dovgaluk@ispras.ru> > --- > include/exec/helper-register.h | 53 ++++++++++++++++++++++++++++++++++++++++ > tcg/tcg.c | 12 +++++++++ > tcg/tcg.h | 3 ++ > 3 files changed, 68 insertions(+) > create mode 100644 include/exec/helper-register.h > > diff --git a/include/exec/helper-register.h b/include/exec/helper-register.h > new file mode 100644 > index 0000000..aeface9 > --- /dev/null > +++ b/include/exec/helper-register.h > @@ -0,0 +1,53 @@ > +#ifndef HELPER_REGISTER_H > +#define HELPER_REGISTER_H > + > +#include "exec/helper-head.h" > + > +/* Need one more level of indirection before stringification > + to get all the macros expanded first. */ > +#define str(s) #s Could you use tostring() from include/qemu/compiler.h instead? Thomas
> From: Thomas Huth [mailto:thuth@redhat.com] > On 05.06.2018 12:39, Pavel Dovgalyuk wrote: > > From: Pavel Dovgalyuk <pavel.dovgaluk@gmail.com> > > > > This patch adds functions and headers for adding the helpers from > > the modules other than the target translators. > > > > Signed-off-by: Pavel Dovgalyuk <Pavel.Dovgaluk@ispras.ru> > > --- > > include/exec/helper-register.h | 53 ++++++++++++++++++++++++++++++++++++++++ > > tcg/tcg.c | 12 +++++++++ > > tcg/tcg.h | 3 ++ > > 3 files changed, 68 insertions(+) > > create mode 100644 include/exec/helper-register.h > > > > diff --git a/include/exec/helper-register.h b/include/exec/helper-register.h > > new file mode 100644 > > index 0000000..aeface9 > > --- /dev/null > > +++ b/include/exec/helper-register.h > > @@ -0,0 +1,53 @@ > > +#ifndef HELPER_REGISTER_H > > +#define HELPER_REGISTER_H > > + > > +#include "exec/helper-head.h" > > + > > +/* Need one more level of indirection before stringification > > + to get all the macros expanded first. */ > > +#define str(s) #s > > Could you use tostring() from include/qemu/compiler.h instead? Thanks, fixed. BTW, this was a copy-paste from helper-tcg.h Pavel Dovgalyuk
Pavel Dovgalyuk <Pavel.Dovgaluk@ispras.ru> writes: > From: Pavel Dovgalyuk <pavel.dovgaluk@gmail.com> > > This patch adds functions and headers for adding the helpers from > the modules other than the target translators. > > Signed-off-by: Pavel Dovgalyuk <Pavel.Dovgaluk@ispras.ru> > --- > include/exec/helper-register.h | 53 ++++++++++++++++++++++++++++++++++++++++ > tcg/tcg.c | 12 +++++++++ > tcg/tcg.h | 3 ++ > 3 files changed, 68 insertions(+) > create mode 100644 include/exec/helper-register.h > > diff --git a/include/exec/helper-register.h b/include/exec/helper-register.h > new file mode 100644 > index 0000000..aeface9 > --- /dev/null > +++ b/include/exec/helper-register.h > @@ -0,0 +1,53 @@ > +#ifndef HELPER_REGISTER_H > +#define HELPER_REGISTER_H > + > +#include "exec/helper-head.h" > + > +/* Need one more level of indirection before stringification > + to get all the macros expanded first. */ > +#define str(s) #s > + > +#define DEF_HELPER_FLAGS_0(NAME, FLAGS, ret) \ > + tcg_register_helper(HELPER(NAME), str(NAME), FLAGS, dh_sizemask(ret, 0)); > + > +#define DEF_HELPER_FLAGS_1(NAME, FLAGS, ret, t1) \ > + tcg_register_helper(HELPER(NAME), str(NAME), FLAGS, \ > + dh_sizemask(ret, 0) | dh_sizemask(t1, 1)); > + > +#define DEF_HELPER_FLAGS_2(NAME, FLAGS, ret, t1, t2) \ > + tcg_register_helper(HELPER(NAME), str(NAME), FLAGS, \ > + dh_sizemask(ret, 0) | dh_sizemask(t1, 1) | dh_sizemask(t2, 2)); > + > +#define DEF_HELPER_FLAGS_3(NAME, FLAGS, ret, t1, t2, t3) \ > + tcg_register_helper(HELPER(NAME), str(NAME), FLAGS, \ > + dh_sizemask(ret, 0) | dh_sizemask(t1, 1) | dh_sizemask(t2, 2) \ > + | dh_sizemask(t3, 3)); > + > +#define DEF_HELPER_FLAGS_4(NAME, FLAGS, ret, t1, t2, t3, t4) \ > + tcg_register_helper(HELPER(NAME), str(NAME), FLAGS, \ > + dh_sizemask(ret, 0) | dh_sizemask(t1, 1) | dh_sizemask(t2, 2) \ > + | dh_sizemask(t3, 3) | dh_sizemask(t4, 4)); > + > +#define DEF_HELPER_FLAGS_5(NAME, FLAGS, ret, t1, t2, t3, t4, t5) \ > + tcg_register_helper(HELPER(NAME), str(NAME), FLAGS, \ > + dh_sizemask(ret, 0) | dh_sizemask(t1, 1) | dh_sizemask(t2, 2) \ > + | dh_sizemask(t3, 3) | dh_sizemask(t4, 4) | dh_sizemask(t5, 5)); > + > +#define DEF_HELPER_FLAGS_6(NAME, FLAGS, ret, t1, t2, t3, t4, t5, t6) \ > + tcg_register_helper(HELPER(NAME), str(NAME), FLAGS, \ > + dh_sizemask(ret, 0) | dh_sizemask(t1, 1) | dh_sizemask(t2, 2) \ > + | dh_sizemask(t3, 3) | dh_sizemask(t4, 4) | dh_sizemask(t5, 5) \ > + | dh_sizemask(t6, 6)); > + > +#include "helper.h" > + > +#undef str > +#undef DEF_HELPER_FLAGS_0 > +#undef DEF_HELPER_FLAGS_1 > +#undef DEF_HELPER_FLAGS_2 > +#undef DEF_HELPER_FLAGS_3 > +#undef DEF_HELPER_FLAGS_4 > +#undef DEF_HELPER_FLAGS_5 > +#undef DEF_HELPER_FLAGS_6 > + > +#endif /* HELPER_REGISTER_H */ > diff --git a/tcg/tcg.c b/tcg/tcg.c > index 6eeebe0..8191381 100644 > --- a/tcg/tcg.c > +++ b/tcg/tcg.c > @@ -1623,6 +1623,18 @@ static inline const char *tcg_find_helper(TCGContext *s, uintptr_t val) > return ret; > } > > +void tcg_register_helper(void *func, const char *name, > + unsigned flags, unsigned sizemask) > +{ > + TCGHelperInfo *info = g_new0(TCGHelperInfo, 1); > + info->func = func; > + info->name = name; > + info->flags = flags; > + info->sizemask = sizemask; > + > + g_hash_table_insert(helper_table, func, info); > +} > + > static const char * const cond_name[] = > { > [TCG_COND_NEVER] = "never", > diff --git a/tcg/tcg.h b/tcg/tcg.h > index 08f8bbf..7a4b750 100644 > --- a/tcg/tcg.h > +++ b/tcg/tcg.h > @@ -890,6 +890,9 @@ void tcg_register_thread(void); > void tcg_prologue_init(TCGContext *s); > void tcg_func_start(TCGContext *s); > A small comment might be worthwhile here, maybe something like: /** * tcg_register_helper * * Used by the helper-register.h machinery to register non-core helpers * from plugins. Built-in helpers are installed via all_helpers[] */ > +void tcg_register_helper(void *func, const char *name, > + unsigned flags, unsigned sizemask); > + > int tcg_gen_code(TCGContext *s, TranslationBlock *tb); > > void tcg_set_frame(TCGContext *s, TCGReg reg, intptr_t start, intptr_t size); -- Alex Bennée
diff --git a/include/exec/helper-register.h b/include/exec/helper-register.h new file mode 100644 index 0000000..aeface9 --- /dev/null +++ b/include/exec/helper-register.h @@ -0,0 +1,53 @@ +#ifndef HELPER_REGISTER_H +#define HELPER_REGISTER_H + +#include "exec/helper-head.h" + +/* Need one more level of indirection before stringification + to get all the macros expanded first. */ +#define str(s) #s + +#define DEF_HELPER_FLAGS_0(NAME, FLAGS, ret) \ + tcg_register_helper(HELPER(NAME), str(NAME), FLAGS, dh_sizemask(ret, 0)); + +#define DEF_HELPER_FLAGS_1(NAME, FLAGS, ret, t1) \ + tcg_register_helper(HELPER(NAME), str(NAME), FLAGS, \ + dh_sizemask(ret, 0) | dh_sizemask(t1, 1)); + +#define DEF_HELPER_FLAGS_2(NAME, FLAGS, ret, t1, t2) \ + tcg_register_helper(HELPER(NAME), str(NAME), FLAGS, \ + dh_sizemask(ret, 0) | dh_sizemask(t1, 1) | dh_sizemask(t2, 2)); + +#define DEF_HELPER_FLAGS_3(NAME, FLAGS, ret, t1, t2, t3) \ + tcg_register_helper(HELPER(NAME), str(NAME), FLAGS, \ + dh_sizemask(ret, 0) | dh_sizemask(t1, 1) | dh_sizemask(t2, 2) \ + | dh_sizemask(t3, 3)); + +#define DEF_HELPER_FLAGS_4(NAME, FLAGS, ret, t1, t2, t3, t4) \ + tcg_register_helper(HELPER(NAME), str(NAME), FLAGS, \ + dh_sizemask(ret, 0) | dh_sizemask(t1, 1) | dh_sizemask(t2, 2) \ + | dh_sizemask(t3, 3) | dh_sizemask(t4, 4)); + +#define DEF_HELPER_FLAGS_5(NAME, FLAGS, ret, t1, t2, t3, t4, t5) \ + tcg_register_helper(HELPER(NAME), str(NAME), FLAGS, \ + dh_sizemask(ret, 0) | dh_sizemask(t1, 1) | dh_sizemask(t2, 2) \ + | dh_sizemask(t3, 3) | dh_sizemask(t4, 4) | dh_sizemask(t5, 5)); + +#define DEF_HELPER_FLAGS_6(NAME, FLAGS, ret, t1, t2, t3, t4, t5, t6) \ + tcg_register_helper(HELPER(NAME), str(NAME), FLAGS, \ + dh_sizemask(ret, 0) | dh_sizemask(t1, 1) | dh_sizemask(t2, 2) \ + | dh_sizemask(t3, 3) | dh_sizemask(t4, 4) | dh_sizemask(t5, 5) \ + | dh_sizemask(t6, 6)); + +#include "helper.h" + +#undef str +#undef DEF_HELPER_FLAGS_0 +#undef DEF_HELPER_FLAGS_1 +#undef DEF_HELPER_FLAGS_2 +#undef DEF_HELPER_FLAGS_3 +#undef DEF_HELPER_FLAGS_4 +#undef DEF_HELPER_FLAGS_5 +#undef DEF_HELPER_FLAGS_6 + +#endif /* HELPER_REGISTER_H */ diff --git a/tcg/tcg.c b/tcg/tcg.c index 6eeebe0..8191381 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1623,6 +1623,18 @@ static inline const char *tcg_find_helper(TCGContext *s, uintptr_t val) return ret; } +void tcg_register_helper(void *func, const char *name, + unsigned flags, unsigned sizemask) +{ + TCGHelperInfo *info = g_new0(TCGHelperInfo, 1); + info->func = func; + info->name = name; + info->flags = flags; + info->sizemask = sizemask; + + g_hash_table_insert(helper_table, func, info); +} + static const char * const cond_name[] = { [TCG_COND_NEVER] = "never", diff --git a/tcg/tcg.h b/tcg/tcg.h index 08f8bbf..7a4b750 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -890,6 +890,9 @@ void tcg_register_thread(void); void tcg_prologue_init(TCGContext *s); void tcg_func_start(TCGContext *s); +void tcg_register_helper(void *func, const char *name, + unsigned flags, unsigned sizemask); + int tcg_gen_code(TCGContext *s, TranslationBlock *tb); void tcg_set_frame(TCGContext *s, TCGReg reg, intptr_t start, intptr_t size);