From f02a5d0e98248b0a1302553e56de7e93f1c82c76 Mon Sep 17 00:00:00 2001 From: Bernd Schmidt Date: Tue, 12 Apr 2005 14:26:52 +0000 Subject: [PATCH] bfin.c (bfin_library_id_string): Remove. * config/bfin/bfin.c (bfin_library_id_string): Remove. (bfin_library_id): New variable. (bfin_expand_prologue): Use bfin_library_id and bfin_lib_id_given instead of bfin_library_id_string. (bfin_handle_option): New function. (override_options): Remove most code to deal with shared library IDs, just check they aren't used without -mid-shared-library. (TARGET_HANDLE_OPTION): Define. * config/bfin/bfin.h (TARGET_OPTIONS): Delete macro. * config/bfin/bfin.opt (mshared-library-id=): New. From-SVN: r98023 --- gcc/ChangeLog | 13 ++++++++++++ gcc/config/bfin/bfin.c | 45 ++++++++++++++++++++++++++-------------- gcc/config/bfin/bfin.h | 14 ------------- gcc/config/bfin/bfin.opt | 4 ++++ 4 files changed, 46 insertions(+), 30 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b52f8083f78..df41196fcb3 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,16 @@ +2005-04-12 Bernd Schmidt + + * config/bfin/bfin.c (bfin_library_id_string): Remove. + (bfin_library_id): New variable. + (bfin_expand_prologue): Use bfin_library_id and bfin_lib_id_given + instead of bfin_library_id_string. + (bfin_handle_option): New function. + (override_options): Remove most code to deal with shared library IDs, + just check they aren't used without -mid-shared-library. + (TARGET_HANDLE_OPTION): Define. + * config/bfin/bfin.h (TARGET_OPTIONS): Delete macro. + * config/bfin/bfin.opt (mshared-library-id=): New. + 2005-04-12 Kazu Hirata * tree-vect-transform.c: Fix comment typos. diff --git a/gcc/config/bfin/bfin.c b/gcc/config/bfin/bfin.c index 366c47d80ce..c4287a1f917 100644 --- a/gcc/config/bfin/bfin.c +++ b/gcc/config/bfin/bfin.c @@ -67,7 +67,8 @@ const char *byte_reg_names[] = BYTE_REGISTER_NAMES; static int arg_regs[] = FUNCTION_ARG_REGISTERS; -const char *bfin_library_id_string; +/* The value passed to -mshared-library-id=. */ +static int bfin_library_id; static void bfin_globalize_label (FILE *stream, const char *name) @@ -776,8 +777,8 @@ bfin_expand_prologue (void) { rtx addr; - if (bfin_library_id_string) - addr = plus_constant (pic_offset_table_rtx, atoi (bfin_library_id_string)); + if (bfin_lib_id_given) + addr = plus_constant (pic_offset_table_rtx, -4 - bfin_library_id * 4); else addr = gen_rtx_PLUS (Pmode, pic_offset_table_rtx, gen_rtx_UNSPEC (Pmode, gen_rtvec (1, const0_rtx), @@ -1711,6 +1712,26 @@ secondary_output_reload_class (enum reg_class class, enum machine_mode mode, return secondary_input_reload_class (class, mode, x); } +/* Implement TARGET_HANDLE_OPTION. */ + +static bool +bfin_handle_option (size_t code, const char *arg, int value) +{ + switch (code) + { + case OPT_mshared_library_id_: + if (value > MAX_LIBRARY_ID) + error ("-mshared-library-id=%s is not between 0 and %d", + arg, MAX_LIBRARY_ID); + else + bfin_library_id = value; + return true; + + default: + return true; + } +} + /* Implement the macro OVERRIDE_OPTIONS. */ void @@ -1720,19 +1741,8 @@ override_options (void) flag_omit_frame_pointer = 1; /* Library identification */ - if (bfin_library_id_string) - { - int id; - - if (! TARGET_ID_SHARED_LIBRARY) - error ("-mshared-library-id= specified without -mid-shared-library"); - id = atoi (bfin_library_id_string); - if (id < 0 || id > MAX_LIBRARY_ID) - error ("-mshared-library-id=%d is not between 0 and %d", id, MAX_LIBRARY_ID); - - /* From now on, bfin_library_id_string will contain the library offset. */ - asprintf ((char **)&bfin_library_id_string, "%d", (id * -4) - 4); - } + if (bfin_lib_id_given && ! TARGET_ID_SHARED_LIBRARY) + error ("-mshared-library-id= specified without -mid-shared-library"); if (TARGET_ID_SHARED_LIBRARY) /* ??? Provide a way to use a bigger GOT. */ @@ -2725,4 +2735,7 @@ bfin_output_mi_thunk (FILE *file ATTRIBUTE_UNUSED, #undef TARGET_VECTOR_MODE_SUPPORTED_P #define TARGET_VECTOR_MODE_SUPPORTED_P bfin_vector_mode_supported_p +#undef TARGET_HANDLE_OPTION +#define TARGET_HANDLE_OPTION bfin_handle_option + struct gcc_target targetm = TARGET_INITIALIZER; diff --git a/gcc/config/bfin/bfin.h b/gcc/config/bfin/bfin.h index f5304e0153b..512525afb81 100644 --- a/gcc/config/bfin/bfin.h +++ b/gcc/config/bfin/bfin.h @@ -50,20 +50,6 @@ extern int target_flags; #define TARGET_DEFAULT MASK_CSYNC -/* This macro is similar to `TARGET_SWITCHES' but defines names of - command options that have values. Its definition is an - initializer with a subgrouping for each command option. - - Each subgrouping contains a string constant, that defines the - fixed part of the option name, and the address of a variable. The - variable, type `char *', is set to the variable part of the given - option if the fixed part matches. The actual option name is made - by appending `-m' to the specified name. */ -#define TARGET_OPTIONS \ -{ { "shared-library-id=", &bfin_library_id_string, \ - "ID of shared library to build", 0} \ -} - /* Maximum number of library ids we permit */ #define MAX_LIBRARY_ID 255 diff --git a/gcc/config/bfin/bfin.opt b/gcc/config/bfin/bfin.opt index b09d4ddf177..8a07bc3187b 100644 --- a/gcc/config/bfin/bfin.opt +++ b/gcc/config/bfin/bfin.opt @@ -34,3 +34,7 @@ Avoid speculative loads by inserting CSYNC or equivalent mid-shared-library Target Report Mask(ID_SHARED_LIBRARY) Enabled ID based shared library + +mshared-library-id= +Target RejectNegative Joined UInteger Var(bfin_lib_id_given) +ID of shared library to build