From 43be05f54315b889662bb4f8c085cce301a03862 Mon Sep 17 00:00:00 2001 From: Tom de Vries Date: Wed, 19 Dec 2018 10:16:41 +0000 Subject: [PATCH] [nvptx] Use TARGET_SET_CURRENT_FUNCTION Implement TARGET_SET_CURRENT_FUNCTION for nvptx. This gives us a place to add initialization or reset actions that need to be executed on a per-function basis. Build and reg-tested on x86_64 with nvptx accelerator. 2018-12-19 Tom de Vries * config/nvptx/nvptx.c (nvptx_previous_fndecl): Declare. (nvptx_set_current_function): New function. (TARGET_SET_CURRENT_FUNCTION): Define. From-SVN: r267256 --- gcc/ChangeLog | 6 ++++++ gcc/config/nvptx/nvptx.c | 14 ++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 524ad19..82f381a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2018-12-19 Tom de Vries + + * config/nvptx/nvptx.c (nvptx_previous_fndecl): Declare. + (nvptx_set_current_function): New function. + (TARGET_SET_CURRENT_FUNCTION): Define. + 2018-12-19 Shaokun Zhang * config/aarch64/aarch64-cores.def (tsv110): Fix architecture. This diff --git a/gcc/config/nvptx/nvptx.c b/gcc/config/nvptx/nvptx.c index 74ca0f5..9f834d3 100644 --- a/gcc/config/nvptx/nvptx.c +++ b/gcc/config/nvptx/nvptx.c @@ -5980,6 +5980,17 @@ nvptx_can_change_mode_class (machine_mode, machine_mode, reg_class_t) return false; } +static GTY(()) tree nvptx_previous_fndecl; + +static void +nvptx_set_current_function (tree fndecl) +{ + if (!fndecl || fndecl == nvptx_previous_fndecl) + return; + + nvptx_previous_fndecl = fndecl; +} + #undef TARGET_OPTION_OVERRIDE #define TARGET_OPTION_OVERRIDE nvptx_option_override @@ -6116,6 +6127,9 @@ nvptx_can_change_mode_class (machine_mode, machine_mode, reg_class_t) #undef TARGET_HAVE_SPECULATION_SAFE_VALUE #define TARGET_HAVE_SPECULATION_SAFE_VALUE speculation_safe_value_not_needed +#undef TARGET_SET_CURRENT_FUNCTION +#define TARGET_SET_CURRENT_FUNCTION nvptx_set_current_function + struct gcc_target targetm = TARGET_INITIALIZER; #include "gt-nvptx.h" -- 2.7.4