aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-06-10 18:09:33 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-06-12 21:41:32 +0200
commitf72b16c3864a0072748b955dfa5e9126d998f08b (patch)
tree73ee55ecb59349d626ccd9d89e7227bb0c1deae5
parentf8dc0b0fc2a06238700a4939fad1f76e748fdf12 (diff)
downloadsparse-f72b16c3864a0072748b955dfa5e9126d998f08b.tar.gz
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 <luc.vanoostenryck@gmail.com>
-rw-r--r--builtin.c4
-rw-r--r--target.h4
2 files changed, 8 insertions, 0 deletions
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);
};