From: thorpej Date: Tue, 1 Oct 2002 20:16:04 +0000 (+0000) Subject: 2002-10-01 Matt Thomas X-Git-Url: http://git.sourceforge.jp/view?p=pf3gnuchains%2Fgcc-fork.git;a=commitdiff_plain;h=83accbc0d8c7414cba0520ed917f6ba1819af322 2002-10-01 Matt Thomas Jason Thorpe * config.gcc (vax-*-netbsdelf*): Enable configuration. * config/elfos.h (PCC_BITFIELD_TYPE_MATTERS): Define only if not already defined. * config/vax/elf.h: New file. * config/vax/netbsd-elf.h: New file. * config/vax/vax.c: Include "debug.h". (vax_output_function_prologue): Add dwarf2 support. Use MAIN_NAME_P when checking for VMS_TARGET stack adjust. * config/vax/vax.h (CONST_OK_FOR_LETTER_P): Add cases for 'J' [0..63], 'K' [-128..127], 'L' [-32768..32767], 'M' [0..255], 'N' [0..65535], and, 'O' [-63..-1]. (VAX_ISTREAM_SYNC): Remove. (INITIALIZE_TRAMPOLINE): Use gen_sync_istream. (JUMP_TABLES_IN_TEXT_SECTION): Define. (ASM_OUTPUT_REG_POP): Use reg_names for the stack pointer. (ASM_OUTPUT_ADDR_VEC_ELT): Use ASM_GENERATE_INTERNAL_LABEL and assemble_name. (ASM_OUTPUT_ADDR_DIFF_ELT): Likewise. (PRINT_OPERAND_PUNCT_VALID_P): Accept '|'. (PRINT_OPERAND): Output REGISTER_PREFIX for '|'. (INCOMING_RETURN_ADDR_RTX): Define. * config/vax/vax.md (VUNSPEC_BLOCKAGE) (VUNSPEC_SYNC_ISTREAM): Define. (blockage): Use VUNSPEC_BLOCKAGE. (sync_istream): New insn. 2002-10-01 Richard Henderson * config/vax/vax.md (call_pop, *call_pop, call_value_pop) (*call_value_pop, call, call_value): Add dwarf2 EH support. (*call): New insn. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@57702 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 600b7ea4a6e..d1a6dda3a38 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,38 @@ +2002-10-01 Matt Thomas + Jason Thorpe + + * config.gcc (vax-*-netbsdelf*): Enable configuration. + * config/elfos.h (PCC_BITFIELD_TYPE_MATTERS): Define only + if not already defined. + * config/vax/elf.h: New file. + * config/vax/netbsd-elf.h: New file. + * config/vax/vax.c: Include "debug.h". + (vax_output_function_prologue): Add dwarf2 support. Use + MAIN_NAME_P when checking for VMS_TARGET stack adjust. + * config/vax/vax.h (CONST_OK_FOR_LETTER_P): Add cases for + 'J' [0..63], 'K' [-128..127], 'L' [-32768..32767], + 'M' [0..255], 'N' [0..65535], and, 'O' [-63..-1]. + (VAX_ISTREAM_SYNC): Remove. + (INITIALIZE_TRAMPOLINE): Use gen_sync_istream. + (JUMP_TABLES_IN_TEXT_SECTION): Define. + (ASM_OUTPUT_REG_POP): Use reg_names for the stack pointer. + (ASM_OUTPUT_ADDR_VEC_ELT): Use ASM_GENERATE_INTERNAL_LABEL + and assemble_name. + (ASM_OUTPUT_ADDR_DIFF_ELT): Likewise. + (PRINT_OPERAND_PUNCT_VALID_P): Accept '|'. + (PRINT_OPERAND): Output REGISTER_PREFIX for '|'. + (INCOMING_RETURN_ADDR_RTX): Define. + * config/vax/vax.md (VUNSPEC_BLOCKAGE) + (VUNSPEC_SYNC_ISTREAM): Define. + (blockage): Use VUNSPEC_BLOCKAGE. + (sync_istream): New insn. + +2002-10-01 Richard Henderson + + * config/vax/vax.md (call_pop, *call_pop, call_value_pop) + (*call_value_pop, call, call_value): Add dwarf2 EH support. + (*call): New insn. + 2002-10-01 Nathan Sidwell PR c/8083 diff --git a/gcc/config.gcc b/gcc/config.gcc index 1ab0f6d4cef..961dee16332 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -2609,7 +2609,8 @@ vax-*-sysv*) # VAXen running system V xm_defines=POSIX ;; vax-*-netbsdelf*) - echo "GCC does not yet support the ${machine} target"; exit 1 + tm_file="${tm_file} elfos.h netbsd.h netbsd-elf.h vax/elf.h vax/netbsd-elf.h" + float_format=vax ;; vax-*-netbsd*) tm_file="${tm_file} netbsd.h netbsd-aout.h vax/netbsd.h" diff --git a/gcc/config/elfos.h b/gcc/config/elfos.h index 0eaf3a39d0c..1900e9aeb0e 100644 --- a/gcc/config/elfos.h +++ b/gcc/config/elfos.h @@ -48,7 +48,9 @@ Boston, MA 02111-1307, USA. */ /* Writing `int' for a bit-field forces int alignment for the structure. */ +#ifndef PCC_BITFIELD_TYPE_MATTERS #define PCC_BITFIELD_TYPE_MATTERS 1 +#endif /* Implicit library calls should use memcpy, not bcopy, etc. */ diff --git a/gcc/config/vax/elf.h b/gcc/config/vax/elf.h new file mode 100644 index 00000000000..2f1a37566cd --- /dev/null +++ b/gcc/config/vax/elf.h @@ -0,0 +1,97 @@ +/* Target definitions for GNU compiler for VAX using ELF + Copyright (C) 2002 Free Software Foundation, Inc. + Contributed by Matt Thomas (matt@3am-software.com) + +This file is part of GNU CC. + +GNU CC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#undef REGISTER_PREFIX +#undef REGISTER_NAMES +#define REGISTER_PREFIX "%" +#define REGISTER_NAMES \ +{"%r0", "%r1", "%r2", "%r3", "%r4", "%r5", "%r6", "%r7", \ + "%r8", "%r9", "%r10", "%r11", "%ap", "%fp", "%sp", "%pc"} + +#undef SIZE_TYPE +#define SIZE_TYPE "long unsigned int" + +#undef PTRDIFF_TYPE +#define PTRDIFF_TYPE "long int" + +/* Profiling routine. */ +#undef FUNCTION_PROFILER +#define FUNCTION_PROFILER(FILE, LABELNO) \ + fprintf (FILE, "\tmovab .LP%d,%sr0\n\tjsb __mcount+2\n", (LABELNO), \ + REGISTER_PREFIX) + +/* Let's be re-entrant. */ +#undef PCC_STATIC_STRUCT_RETURN + +/* Make sure .stabs for a function are always the same section. */ +#define DBX_OUTPUT_FUNCTION_END(file,decl) function_section(decl) + +/* Before the prologue, the top of the frame is below the argument + count pushed by the CALLS and before the start of the saved registers. */ +#define INCOMING_FRAME_SP_OFFSET 0 + +/* We use R2-R5 (call-clobbered) registers for exceptions. */ +#define EH_RETURN_DATA_REGNO(N) ((N) < 4 ? (N) + 2 : INVALID_REGNUM) + +/* Place the top of the stack for the DWARF2 EH stackadj value. */ +#define EH_RETURN_STACKADJ_RTX \ + gen_rtx_MEM (SImode, \ + plus_constant (gen_rtx_REG (Pmode, FRAME_POINTER_REGNUM), \ + -4)) + +/* Simple store the return handler into the call frame. */ +#define EH_RETURN_HANDLER_RTX \ + gen_rtx_MEM (Pmode, \ + plus_constant (gen_rtx_REG (Pmode, FRAME_POINTER_REGNUM), \ + 16)) + + +/* Reserve the top of the stack for exception handler stackadj value. */ +#undef STARTING_FRAME_OFFSET +#define STARTING_FRAME_OFFSET -4 + +/* The VAX wants no space between the case instruction and the jump table. */ +#undef ASM_OUTPUT_BEFORE_CASE_LABEL +#define ASM_OUTPUT_BEFORE_CASE_LABEL(FILE, PREFIX, NUM, TABLE) + +/* Get the udiv/urem calls out of the user's namespace. */ +#undef UDIVSI3_LIBCALL +#define UDIVSI3_LIBCALL "*__udiv" +#undef UMODSI3_LIBCALL +#define UMODSI3_LIBCALL "*__urem" + +#undef OVERRIDE_OPTIONS +#define OVERRIDE_OPTIONS \ + do \ + { \ + /* Do generic VAX overrides. */ \ + override_options (); \ + \ + /* Turn off function CSE if we're \ + doing PIC. */ \ + if (flag_pic) flag_no_function_cse = 1; \ + } \ + while (0) + +/* VAX ELF is always gas; override the generic VAX ASM_SPEC. */ + +#undef ASM_SPEC +#define ASM_SPEC "" diff --git a/gcc/config/vax/netbsd-elf.h b/gcc/config/vax/netbsd-elf.h new file mode 100644 index 00000000000..e28d1a15743 --- /dev/null +++ b/gcc/config/vax/netbsd-elf.h @@ -0,0 +1,61 @@ +/* Definitions of target machine for GNU compiler, + for NetBSD/vax ELF systems. + Copyright (C) 2002 Free Software Foundation, Inc. + +This file is part of GNU CC. + +GNU CC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + + +/* Names to predefine in the preprocessor for this target OS. */ +#undef TARGET_OS_CPP_BUILTINS +#define TARGET_OS_CPP_BUILTINS() \ + do \ + { \ + NETBSD_OS_CPP_BUILTINS_ELF(); \ + } \ + while (0) + +#undef CPP_SPEC +#define CPP_SPEC NETBSD_CPP_SPEC + +#define NETBSD_ENTRY_POINT "__start" + +#undef LINK_SPEC +#if 1 +/* FIXME: We must link all executables statically until PIC support + is added to the compiler. */ +#define LINK_SPEC \ + "%{assert*} %{R*} %{rpath*} \ + %{shared:%eThe -shared option is not currently supported for VAX ELF.} \ + %{!shared: \ + -dc -dp \ + %{!nostdlib: \ + %{!r*: \ + %{!e*:-e %(netbsd_entry_point)}}} \ + %{!static:-static} \ + %{static:-static}}" +#else +#define LINK_SPEC NETBSD_LINK_SPEC_ELF +#endif + +#define EXTRA_SPECS \ + { "netbsd_entry_point", NETBSD_ENTRY_POINT }, + +/* We use gas, not the UNIX assembler. */ +#undef TARGET_DEFAULT +#define TARGET_DEFAULT 0 + +#undef ASM_FINAL_SPEC diff --git a/gcc/config/vax/vax.c b/gcc/config/vax/vax.c index 1a83eba2ff8..f8b0a0d3343 100644 --- a/gcc/config/vax/vax.c +++ b/gcc/config/vax/vax.c @@ -34,6 +34,7 @@ Boston, MA 02111-1307, USA. */ #include "recog.h" #include "expr.h" #include "flags.h" +#include "debug.h" #include "tm_p.h" #include "target.h" #include "target-def.h" @@ -101,40 +102,31 @@ vax_output_function_prologue (file, size) fprintf (file, "\t.word 0x%x\n", mask); - if (VMS_TARGET) + if (dwarf2out_do_frame ()) { - /* - * This works for both gcc and g++. It first checks to see if - * the current routine is "main", which will only happen for - * GCC, and add the jsb if it is. If is not the case then try - * and see if __MAIN_NAME is part of current_function_name, - * which will only happen if we are running g++, and add the jsb - * if it is. In gcc there should never be a paren in the - * function name, and in g++ there is always a "(" in the - * function name, thus there should never be any confusion. - * - * Adjusting the stack pointer by 4 before calling C$MAIN_ARGS - * is required when linking with the VMS POSIX version of the C - * run-time library; using `subl2 $4,r0' is adequate but we use - * `clrl -(sp)' instead. The extra 4 bytes could be removed - * after the call because STARTING_FRAME_OFFSET's setting of -4 - * will end up adding them right back again, but don't bother. - */ - - const char *p = current_function_name; - int is_main = strcmp ("main", p) == 0; -# define __MAIN_NAME " main(" - - while (!is_main && *p != '\0') - { - if (*p == *__MAIN_NAME - && strncmp (p, __MAIN_NAME, sizeof __MAIN_NAME - sizeof "") == 0) - is_main = 1; - else - p++; - } + const char *label = dwarf2out_cfi_label (); + int offset = 0; + + for (regno = FIRST_PSEUDO_REGISTER-1; regno >= 0; --regno) + if (regs_ever_live[regno] && !call_used_regs[regno]) + dwarf2out_reg_save (label, regno, offset -= 4); - if (is_main) + dwarf2out_reg_save (label, PC_REGNUM, offset -= 4); + dwarf2out_reg_save (label, FRAME_POINTER_REGNUM, offset -= 4); + dwarf2out_reg_save (label, ARG_POINTER_REGNUM, offset -= 4); + dwarf2out_def_cfa (label, FRAME_POINTER_REGNUM, -(offset - 4)); + } + + if (VMS_TARGET) + { + /* Adjusting the stack pointer by 4 before calling C$MAIN_ARGS + is required when linking with the VMS POSIX version of the C + run-time library; using `subl2 $4,r0' is adequate but we use + `clrl -(sp)' instead. The extra 4 bytes could be removed + after the call because STARTING_FRAME_OFFSET's setting of -4 + will end up adding them right back again, but don't bother. */ + + if (MAIN_NAME_P (DECL_NAME (current_function_decl))) fprintf (file, "\tclrl -(%ssp)\n\tjsb _C$MAIN_ARGS\n", REGISTER_PREFIX); } diff --git a/gcc/config/vax/vax.md b/gcc/config/vax/vax.md index 56e18a06391..1a163ad7763 100644 --- a/gcc/config/vax/vax.md +++ b/gcc/config/vax/vax.md @@ -28,6 +28,15 @@ ;;- cpp macro #define NOTICE_UPDATE_CC in file tm.h handles condition code ;;- updates for most instructions. +;; UNSPEC_VOLATILE usage: + +(define_constants + [(VUNSPEC_BLOCKAGE 0) ; `blockage' insn to prevent scheduling across an + ; insn in the code. + (VUNSPEC_SYNC_ISTREAM 1) ; sequence of insns to sync the I-stream + ] +) + ;; We don't want to allow a constant operand for test insns because ;; (set (cc0) (const_int foo)) has no mode information. Such insns will ;; be folded while optimizing anyway. @@ -1798,11 +1807,6 @@ "" "decl %0\;jgequ %l1") -;; Note that operand 1 is total size of args, in bytes, -;; and what the call insn wants is the number of words. -;; It is used in the call instruction as a byte, but in the addl2 as -;; a word. Since the only time we actually use it in the call instruction -;; is when it is a constant, SImode (for addl2) is the proper mode. (define_expand "call_pop" [(parallel [(call (match_operand:QI 0 "memory_operand" "") (match_operand:SI 1 "const_int_operand" "")) @@ -1810,12 +1814,15 @@ (plus:SI (reg:SI 14) (match_operand:SI 3 "immediate_operand" "")))])] "" - " { - if (INTVAL (operands[1]) > 255 * 4) + if (INTVAL (operands[3]) > 255 * 4 || INTVAL (operands[3]) % 4) abort (); - operands[1] = GEN_INT ((INTVAL (operands[1]) + 3)/ 4); -}") + + /* Operand 1 is the number of bytes to be popped by DW_CFA_GNU_args_size + during EH unwinding. We must include the argument count pushed by + the calls instruction. */ + operands[1] = GEN_INT (INTVAL (operands[3]) + 4); +}) (define_insn "*call_pop" [(call (match_operand:QI 0 "memory_operand" "m") @@ -1823,7 +1830,10 @@ (set (reg:SI 14) (plus:SI (reg:SI 14) (match_operand:SI 2 "immediate_operand" "i")))] "" - "calls %1,%0") +{ + operands[1] = GEN_INT ((INTVAL (operands[1]) - 4) / 4); + return "calls %1,%0"; +}) (define_expand "call_value_pop" [(parallel [(set (match_operand 0 "" "") @@ -1833,12 +1843,15 @@ (plus:SI (reg:SI 14) (match_operand:SI 4 "immediate_operand" "")))])] "" - " { - if (INTVAL (operands[2]) > 255 * 4) - abort (); - operands[2] = GEN_INT ((INTVAL (operands[2]) + 3)/ 4); -}") + if (INTVAL (operands[4]) > 255 * 4 || INTVAL (operands[4]) % 4) + abort (); + + /* Operand 2 is the number of bytes to be popped by DW_CFA_GNU_args_size + during EH unwinding. We must include the argument count pushed by + the calls instruction. */ + operands[2] = GEN_INT (INTVAL (operands[4]) + 4); +}) (define_insn "*call_value_pop" [(set (match_operand 0 "" "") @@ -1847,20 +1860,47 @@ (set (reg:SI 14) (plus:SI (reg:SI 14) (match_operand:SI 3 "immediate_operand" "i")))] "" - "calls %2,%1") + "* +{ + operands[2] = GEN_INT ((INTVAL (operands[2]) - 4) / 4); + return \"calls %2,%1\"; +}") + +(define_expand "call" + [(call (match_operand:QI 0 "memory_operand" "") + (match_operand:SI 1 "const_int_operand" ""))] + "" + " +{ + /* Operand 1 is the number of bytes to be popped by DW_CFA_GNU_args_size + during EH unwinding. We must include the argument count pushed by + the calls instruction. */ + operands[1] = GEN_INT (INTVAL (operands[1]) + 4); +}") -;; Define another set of these for the case of functions with no operands. -;; These will allow the optimizers to do a slightly better job. -(define_insn "call" - [(call (match_operand:QI 0 "memory_operand" "m") - (const_int 0))] +(define_insn "*call" + [(call (match_operand:QI 0 "memory_operand" "m") + (match_operand:SI 1 "const_int_operand" ""))] "" "calls $0,%0") -(define_insn "call_value" +(define_expand "call_value" + [(set (match_operand 0 "" "") + (call (match_operand:QI 1 "memory_operand" "") + (match_operand:SI 2 "const_int_operand" "")))] + "" + " +{ + /* Operand 2 is the number of bytes to be popped by DW_CFA_GNU_args_size + during EH unwinding. We must include the argument count pushed by + the calls instruction. */ + operands[2] = GEN_INT (INTVAL (operands[2]) + 4); +}") + +(define_insn "*call_value" [(set (match_operand 0 "" "") (call (match_operand:QI 1 "memory_operand" "m") - (const_int 0)))] + (match_operand:SI 2 "const_int_operand" "")))] "" "calls $0,%1") @@ -1897,7 +1937,7 @@ ;; all of memory. This blocks insns from being moved across this point. (define_insn "blockage" - [(unspec_volatile [(const_int 0)] 0)] + [(unspec_volatile [(const_int 0)] VUNSPEC_BLOCKAGE)] "" "") @@ -2121,3 +2161,9 @@ = GEN_INT (INTVAL (operands[3]) & ~((1 << INTVAL (operands[2])) - 1)); return \"rotl %2,%1,%0\;bicl2 %N3,%0\"; }") + +;; Instruction sequence to sync the VAX instruction stream. +(define_insn "sync_istream" + [(unspec_volatile [(const_int 0)] VUNSPEC_SYNC_ISTREAM)] + "" + "movpsl -(%|sp)\;pushal 1(%|pc)\;rei")