Commit cb805c2d by Nick Clifton Committed by Nick Clifton

Add support for arm-pe and thumb-pe

From-SVN: r27871
parent 5e13e04f
Wed Jun 30 16:51:41 1999 Nick Clifton <nickc@cygnus.com>
* configure.in: Add arm-pe and thumb-pe targets.
* configure: Regenerate.
* thumb.c (arm_naked_function_p): New function: Determines if
a function is naked (has no gcc generated prologue/epilogue).
(is_called_in_ARM_mode): Return true if the func has the
interfacearm attribute.
(output_return): Do not generate a return for naked functions.
(thumb_function_prologue): Do not generate a prologue for
naked functions.
(thumb_expand_prologue): Do not generate a prologue for naked
functions.
(thumb_expand_epilogue): Do not generate an epilogue for naked
functions.
(arm_valid_machine_decl_attribute): New function, copied from
arm.c: Permit naked and interfacearm attributes.
* config/arm/pe.c: New file: Support code for arm-pe target.
* config/arm/pe.h: New file: Header file for arm-pe target.
* config/arm/tpe.h: New file: Header file for thumb-pe target.
* config/arm/t-thumb-pe: New file: Makefile fragment for
thumb-pe target.
1999-07-01 Mark Kettenis <kettenis@gnu.org>
* config/i386/gnu.h (CPP_SPEC): Define __PIC__ and __pic__ if
......
# Makefile fragment
# Copyright (c) 1998 Free Software Foundation
CROSS_LIBGCC1 = libgcc1-asm.a
LIB1ASMSRC = arm/lib1thumb.asm
LIB1ASMFUNCS = _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_tls _call_via_rX _interwork_call_via_rX
# These are really part of libgcc1, but this will cause them to be
# built correctly, so...
LIB2FUNCS_EXTRA = fp-bit.c dp-bit.c
fp-bit.c: $(srcdir)/config/fp-bit.c
echo '#define FLOAT' > fp-bit.c
echo '#ifndef __ARMEB__' >> fp-bit.c
echo '#define FLOAT_BIT_ORDER_MISMATCH' >> fp-bit.c
echo '#endif' >> fp-bit.c
cat $(srcdir)/config/fp-bit.c >> fp-bit.c
dp-bit.c: $(srcdir)/config/fp-bit.c
echo '#ifndef __ARMEB__' > dp-bit.c
echo '#define FLOAT_BIT_ORDER_MISMATCH' >> dp-bit.c
echo '#define FLOAT_WORD_ORDER_MISMATCH' >> dp-bit.c
echo '#endif' >> dp-bit.c
cat $(srcdir)/config/fp-bit.c >> dp-bit.c
# Rule to build Psion specific GCC functions.
pe.o: $(srcdir)/config/arm/pe.c
$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $(srcdir)/config/arm/pe.c
# Avoid building a duplicate set of libraries for the default endian-ness.
MULTILIB_OPTIONS = mthumb-interwork
MULTILIB_DIRNAMES = interwork
LIBGCC = stmp-multilib
INSTALL_LIBGCC = install-multilib
......@@ -398,6 +398,7 @@ thumb_reorg (first)
rtx first;
{
rtx insn;
for (insn = first; insn; insn = NEXT_INSN (insn))
{
if (broken_move (insn))
......@@ -540,6 +541,24 @@ thumb_reload_out_si (operands)
abort ();
}
#ifdef THUMB_PE
/* Return non-zero if FUNC is a naked function. */
static int
arm_naked_function_p (func)
tree func;
{
tree a;
if (TREE_CODE (func) != FUNCTION_DECL)
abort ();
a = lookup_attribute ("naked", DECL_MACHINE_ATTRIBUTES (func));
return a != NULL_TREE;
}
#endif
/* Return non-zero if FUNC must be entered in ARM mode. */
int
is_called_in_ARM_mode (func)
......@@ -552,7 +571,11 @@ is_called_in_ARM_mode (func)
if (TARGET_CALLEE_INTERWORKING && TREE_PUBLIC (func))
return TRUE;
#ifdef THUMB_PE
return lookup_attribute ("interfacearm", DECL_MACHINE_ATTRIBUTES (func)) != NULL_TREE;
#else
return FALSE;
#endif
}
......@@ -968,6 +991,12 @@ output_return ()
int regno;
int live_regs_mask = 0;
#ifdef THUMB_PE
/* If a function is naked, don't use the "return" insn. */
if (arm_naked_function_p (current_function_decl))
return "";
#endif
return_used_this_function = 1;
for (regno = 0; regno < 8; regno++)
......@@ -1026,9 +1055,15 @@ thumb_function_prologue (f, frame_size)
int store_arg_regs = 0;
int regno;
#ifdef THUMB_PE
if (arm_naked_function_p (current_function_decl))
return;
#endif
if (is_called_in_ARM_mode (current_function_decl))
{
char * name;
if (GET_CODE (DECL_RTL (current_function_decl)) != MEM)
abort();
if (GET_CODE (XEXP (DECL_RTL (current_function_decl), 0)) != SYMBOL_REF)
......@@ -1051,6 +1086,12 @@ thumb_function_prologue (f, frame_size)
#define STUB_NAME ".real_start_of"
asm_fprintf (f, "\t.code\t16\n");
#ifdef THUMB_PE
if (arm_dllexport_name_p (name))
name = ARM_STRIP_NAME_ENCODING (name);
#endif
asm_fprintf (f, "\t.globl %s%U%s\n", STUB_NAME, name);
asm_fprintf (f, "\t.thumb_func\n");
asm_fprintf (f, "%s%U%s:\n", STUB_NAME, name);
......@@ -1234,6 +1275,12 @@ thumb_expand_prologue ()
int regno;
int live_regs_mask;
#ifdef THUMB_PE
/* Naked functions don't have prologues. */
if (arm_naked_function_p (current_function_decl))
return;
#endif
if (amount)
{
live_regs_mask = 0;
......@@ -1297,6 +1344,12 @@ thumb_expand_epilogue ()
+ current_function_outgoing_args_size);
int regno;
#ifdef THUMB_PE
/* Naked functions don't have epilogues. */
if (arm_naked_function_p (current_function_decl))
return;
#endif
if (amount)
{
if (amount < 512)
......@@ -1991,3 +2044,37 @@ thumb_override_options ()
flag_pic = 0;
}
}
#ifdef THUMB_PE
/* Return nonzero if ATTR is a valid attribute for DECL.
ATTRIBUTES are any existing attributes and ARGS are the arguments
supplied with ATTR.
Supported attributes:
naked: don't output any prologue or epilogue code, the user is assumed
to do the right thing.
interfacearm: Always assume that this function will be entered in ARM
mode, not Thumb mode, and that the caller wishes to be returned to in
ARM mode. */
int
arm_valid_machine_decl_attribute (decl, attr, args)
tree decl;
tree attr;
tree args;
{
if (args != NULL_TREE)
return 0;
if (is_attribute_p ("naked", attr))
if (TREE_CODE (decl) == FUNCTION_DECL)
return 1;
if (is_attribute_p ("interfacearm", attr))
return TREE_CODE (decl) == FUNCTION_DECL;
return 0;
}
#endif /* THUMB_PE */
......@@ -3215,6 +3215,11 @@ for machine in $build $host $target; do
tm_file=arm/unknown-elf-oabi.h
tmake_file=arm/t-arm-elf
;;
arm-*-pe*)
tm_file=arm/pe.h
tmake_file=arm/t-pe
extra_objs=pe.o
;;
c1-convex-*) # Convex C1
target_cpu_default=1
use_collect2=yes
......@@ -5578,6 +5583,14 @@ for machine in $build $host $target; do
tmake_file=arm/t-thumb
thread_file='vxworks'
;;
thumb-*-pe)
tm_file=arm/tpe.h
out_file=arm/thumb.c
xm_file=arm/xm-thumb.h
md_file=arm/thumb.md
tmake_file=arm/t-pe-thumb
extra_objs=pe.o
;;
# This hasn't been upgraded to GCC 2.
# tron-*-*)
# cpu_type=gmicro
......
......@@ -788,6 +788,11 @@ changequote([,])dnl
tm_file=arm/unknown-elf-oabi.h
tmake_file=arm/t-arm-elf
;;
arm-*-pe*)
tm_file=arm/pe.h
tmake_file=arm/t-pe
extra_objs=pe.o
;;
c1-convex-*) # Convex C1
target_cpu_default=1
use_collect2=yes
......@@ -3275,6 +3280,14 @@ changequote([,])dnl
tmake_file=arm/t-thumb
thread_file='vxworks'
;;
thumb-*-pe)
tm_file=arm/tpe.h
out_file=arm/thumb.c
xm_file=arm/xm-thumb.h
md_file=arm/thumb.md
tmake_file=arm/t-pe-thumb
extra_objs=pe.o
;;
# This hasn't been upgraded to GCC 2.
# tron-*-*)
# cpu_type=gmicro
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment