diff options
author | Alexandre Oliva <oliva@adacore.com> | 2023-12-20 04:59:00 -0300 |
---|---|---|
committer | Alexandre Oliva <oliva@gnu.org> | 2023-12-20 04:59:00 -0300 |
commit | 438bf6ade4b089d592ec481086cde664a1ea1f3d (patch) | |
tree | 3f03c661faef97a27b1f5dd5bbb0f291b18cd9d5 /gcc/builtins.cc | |
parent | 6c22779dfb09f9691c2893c5cabfe35187e1b9f6 (diff) | |
download | gcc-438bf6ade4b089d592ec481086cde664a1ea1f3d.zip gcc-438bf6ade4b089d592ec481086cde664a1ea1f3d.tar.gz gcc-438bf6ade4b089d592ec481086cde664a1ea1f3d.tar.bz2 |
untyped calls: use wrapper class type for implicit plus_one
Instead of get and set macros to apply a delta, use a single macro
that resorts to a temporary wrapper class to apply it.
for gcc/ChangeLog
* builtins.cc (delta_type): New template class.
(set_apply_args_size, get_apply_args_size): Replace with...
(saved_apply_args_size): ... this.
(set_apply_result_size, get_apply_result_size): Replace with...
(saved_apply_result_size): ... this.
(apply_args_size, apply_result_size): Adjust.
Diffstat (limited to 'gcc/builtins.cc')
-rw-r--r-- | gcc/builtins.cc | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/gcc/builtins.cc b/gcc/builtins.cc index 7c2732a..23cc6b6 100644 --- a/gcc/builtins.cc +++ b/gcc/builtins.cc @@ -1403,16 +1403,24 @@ get_memory_rtx (tree exp, tree len) /* Built-in functions to perform an untyped call and return. */ -#define set_apply_args_size(x) \ - (this_target_builtins->x_apply_args_size_plus_one = 1 + (x)) -#define get_apply_args_size() \ - (this_target_builtins->x_apply_args_size_plus_one - 1) +/* Wrapper that implicitly applies a delta when getting or setting the + enclosed value. */ +template <typename T> +class delta_type +{ + T &value; T const delta; +public: + delta_type (T &val, T dlt) : value (val), delta (dlt) {} + operator T () const { return value + delta; } + T operator = (T val) const { value = val - delta; return val; } +}; + +#define saved_apply_args_size \ + (delta_type<int> (this_target_builtins->x_apply_args_size_plus_one, -1)) #define apply_args_mode \ (this_target_builtins->x_apply_args_mode) -#define set_apply_result_size(x) \ - (this_target_builtins->x_apply_result_size_plus_one = 1 + (x)) -#define get_apply_result_size() \ - (this_target_builtins->x_apply_result_size_plus_one - 1) +#define saved_apply_result_size \ + (delta_type<int> (this_target_builtins->x_apply_result_size_plus_one, -1)) #define apply_result_mode \ (this_target_builtins->x_apply_result_mode) @@ -1422,7 +1430,7 @@ get_memory_rtx (tree exp, tree len) static int apply_args_size (void) { - int size = get_apply_args_size (); + int size = saved_apply_args_size; int align; unsigned int regno; @@ -1456,7 +1464,7 @@ apply_args_size (void) else apply_args_mode[regno] = as_a <fixed_size_mode> (VOIDmode); - set_apply_args_size (size); + saved_apply_args_size = size; } return size; } @@ -1467,7 +1475,7 @@ apply_args_size (void) static int apply_result_size (void) { - int size = get_apply_result_size (); + int size = saved_apply_result_size; int align, regno; /* The values computed by this function never change. */ @@ -1500,7 +1508,7 @@ apply_result_size (void) size = APPLY_RESULT_SIZE; #endif - set_apply_result_size (size); + saved_apply_result_size = size; } return size; } |