From f72b16c3864a0072748b955dfa5e9126d998f08b Mon Sep 17 00:00:00 2001 From: Luc Van Oostenryck Date: Wed, 10 Jun 2020 18:09:33 +0200 Subject: builtin: add support for arch-specific builtins Now that a table is used for the declaration of builtin functions it's easy to support arch-specific builtins. The main objective is to not 'pollute' the main table with arch-specfic entries for uncommon architectures. Signed-off-by: Luc Van Oostenryck --- builtin.c | 4 ++++ target.h | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/builtin.c b/builtin.c index 0861928f..8a807613 100644 --- a/builtin.c +++ b/builtin.c @@ -391,6 +391,9 @@ static void declare_builtin(int stream, const struct builtin_fn *entry) static void declare_builtins(int stream, const struct builtin_fn tbl[]) { + if (!tbl) + return; + while (tbl->name) declare_builtin(stream, tbl++); } @@ -586,5 +589,6 @@ static const struct builtin_fn builtins_common[] = { void init_builtins(int stream) { declare_builtins(stream, builtins_common); + declare_builtins(stream, arch_target->builtins); init_linearized_builtins(stream); } diff --git a/target.h b/target.h index a89e21b6..1202c0be 100644 --- a/target.h +++ b/target.h @@ -54,6 +54,8 @@ extern int bits_in_enum; extern int enum_alignment; +struct builtin_fn; + struct target { enum machine mach; enum bitness bitness; @@ -71,6 +73,8 @@ struct target { const struct target *target_32bit; const struct target *target_64bit; + const struct builtin_fn *builtins; + void (*init)(const struct target *self); void (*predefine)(const struct target *self); }; -- cgit 1.2.3-korg