Commit b08de47e by Michael Meissner

Add better support for passing args in registers; Add loop/jump/function…

Add better support for passing args in registers; Add loop/jump/function alignment overrides; add decrement_and_branch until 0

From-SVN: r9647
parent b5f89788
......@@ -82,15 +82,15 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
For the 486, align to 16-byte boundary for sake of cache. */
#undef ASM_OUTPUT_ALIGN_CODE
#define ASM_OUTPUT_ALIGN_CODE(FILE) \
fprintf ((FILE), "\t.align %d,0x90\n", \
TARGET_486 ? 4 : 2); /* Use log of 16 or log of 4 as arg. */
#define ASM_OUTPUT_ALIGN_CODE(FILE) \
fprintf ((FILE), "\t.align %d,0x90\n", 1 << i386_align_jumps)
/* Align start of loop at 4-byte boundary. */
#undef ASM_OUTPUT_LOOP_ALIGN
#define ASM_OUTPUT_LOOP_ALIGN(FILE) \
fprintf ((FILE), "\t.align 2,0x90\n"); /* Use log of 4 as arg. */
fprintf ((FILE), "\t.align %d,0x90\n", 1 << i386_align_loops)
/* A C statement or statements which output an assembler instruction
opcode to the stdio stream STREAM. The macro-operand PTR is a
......
......@@ -9,60 +9,6 @@
#include "i386/gas.h"
/* Value is the number of bytes of arguments automatically
popped when returning from a subroutine call.
FUNDECL is the declaration node of the function (as a tree),
FUNTYPE is the data type of the function (as a tree),
or for a library call it is an identifier node for the subroutine name.
SIZE is the number of bytes of arguments passed on the stack.
This only happens if the function declaration has the STDCALL attribute and
the number of arguments is not variable */
#undef RETURN_POPS_ARGS
#define RETURN_POPS_ARGS(FUNDECL,FUNTYPE,SIZE) \
( \
TREE_CODE (FUNTYPE) == IDENTIFIER_NODE \
? \
0 \
: \
( \
((FUNDECL && (TREE_CODE_CLASS (TREE_CODE (FUNDECL)) == 'd') \
? \
lookup_attribute ("stdcall", \
DECL_MACHINE_ATTRIBUTES (FUNDECL)) != NULL_TREE \
: 0 \
) \
) \
&& \
( \
TYPE_ARG_TYPES (FUNTYPE) == 0 \
|| \
TREE_VALUE (tree_last (TYPE_ARG_TYPES (FUNTYPE))) \
== void_type_node \
) \
) \
? \
(SIZE) \
: \
(aggregate_value_p (TREE_TYPE (FUNTYPE))) \
? \
GET_MODE_SIZE (Pmode) \
: \
0 \
)
/* Value is 1 if the declaration has either of the attributes: CDECL or
STDCALL and 0 otherwise */
#define VALID_MACHINE_DECL_ATTRIBUTE(DECL, ATTR, NAME, ARGS) \
(((TREE_CODE(DECL) == FUNCTION_DECL) \
|| (TREE_CODE(DECL) == FIELD_DECL) \
|| (TREE_CODE(DECL) == TYPE_DECL)) \
&& (is_attribute_p ("stdcall", (NAME)) \
|| is_attribute_p ("cdecl", (NAME))) \
&& (ARGS) == NULL)
#ifdef CPP_PREDEFINES
#undef CPP_PREDEFINES
#endif
......
......@@ -38,6 +38,8 @@
;; 'B' Print the opcode suffix for an 8-bit integer opcode.
;; 'S' Print the opcode suffix for a 32-bit float opcode.
;; 'Q' Print the opcode suffix for a 64-bit float opcode.
;; 'T' Print the opcode suffix for an 80-bit extended real XFmode float opcode.
;; 'J' Print the appropriate jump operand.
;; 'b' Print the QImode name of the register for the indicated operand.
;; %b0 would print %al if operands[0] is reg 0.
......@@ -45,7 +47,6 @@
;; 'k' Likewise, print the SImode name of the register.
;; 'h' Print the QImode name for a "high" register, either ah, bh, ch or dh.
;; 'y' Print "st(0)" instead of "st" as a register.
;; 'T' Print the opcode suffix for an 80-bit extended real XFmode float opcode.
;; UNSPEC usage:
;; 0 This is a `scas' operation. The mode of the UNSPEC is always SImode.
......@@ -4908,6 +4909,73 @@
return AS1 (jmp,%*%0);
}")
(define_expand "decrement_and_branch_until_zero"
[(parallel [(set (pc)
(if_then_else (ge (plus:SI (match_operand:SI 0 "general_operand" "")
(const_int -1))
(const_int 0))
(label_ref (match_operand 1 "" ""))
(pc)))
(set (match_dup 0)
(plus:SI (match_dup 0)
(const_int -1)))])]
""
"")
(define_insn ""
[(set (pc)
(if_then_else (match_operator 0 "comparison_operator"
[(plus:SI (match_operand:SI 1 "general_operand" "+r,m")
(match_operand:SI 2 "general_operand" "rmi,ri"))
(const_int 0)])
(label_ref (match_operand 3 "" ""))
(pc)))
(set (match_dup 1)
(plus:SI (match_dup 1)
(match_dup 2)))]
""
"*
{
CC_STATUS_INIT;
if (operands[2] == constm1_rtx)
output_asm_insn (AS1 (dec%L1,%1), operands);
else if (operands[1] == const1_rtx)
output_asm_insn (AS1 (inc%L1,%1), operands);
else
output_asm_insn (AS2 (add%L1,%2,%1), operands);
return AS1 (%J0,%l3);
}")
(define_insn ""
[(set (pc)
(if_then_else (match_operator 0 "comparison_operator"
[(minus:SI (match_operand:SI 1 "general_operand" "+r,m")
(match_operand:SI 2 "general_operand" "rmi,ri"))
(const_int 0)])
(label_ref (match_operand 3 "" ""))
(pc)))
(set (match_dup 1)
(minus:SI (match_dup 1)
(match_dup 2)))]
""
"*
{
CC_STATUS_INIT;
if (operands[2] == const1_rtx)
output_asm_insn (AS1 (dec%L1,%1), operands);
else if (operands[1] == constm1_rtx)
output_asm_insn (AS1 (inc%L1,%1), operands);
else
output_asm_insn (AS2 (sub%L1,%2,%1), operands);
return AS1 (%J0,%l3);
}")
;; Implement switch statements when generating PIC code. Switches are
;; implemented by `tablejump' when not using -fpic.
......
......@@ -411,7 +411,7 @@ while (0)
#undef ASM_OUTPUT_ALIGN_CODE
#define ASM_OUTPUT_ALIGN_CODE(STREAM) \
fprintf (STREAM, "\t.align\t%d\n", \
(TARGET_486 && TARGET_LARGE_ALIGN) ? 4 : 2)
(!TARGET_LARGE_ALIGN && i386_align_jumps > 2) ? 2 : i386_align_jumps)
/* A C expression to output text to align the location counter in the
way that is desirable at the beginning of a loop.
......@@ -422,7 +422,7 @@ while (0)
#undef ASM_OUTPUT_LOOP_ALIGN
#define ASM_OUTPUT_LOOP_ALIGN(STREAM) \
fprintf (STREAM, "\t.align\t2\n")
fprintf (STREAM, "\t.align\t%d\n", i386_align_loops)
/* A C statement to output to the stdio stream STREAM an assembler
command to advance the location counter to a multiple of 2 to the
......
......@@ -48,13 +48,13 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#undef ASM_OUTPUT_ALIGN_CODE
#define ASM_OUTPUT_ALIGN_CODE(FILE) \
fprintf ((FILE), "\t.align %d,0x90\n", \
TARGET_486 ? 16 : 4); /* Use log of 16 or log of 4 as arg. */
1 << i386_align_jumps)
/* Align start of loop at 4-byte boundary. */
#undef ASM_OUTPUT_LOOP_ALIGN
#define ASM_OUTPUT_LOOP_ALIGN(FILE) \
fprintf ((FILE), "\t.align 4,0x90\n");
fprintf ((FILE), "\t.align %d,0x90\n", 1 << i386_align_loops);
/* Additional overrides needed for dbx-in-coff gas, mostly taken from pbb.h */
......
......@@ -23,49 +23,6 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "i386/gas.h"
/* Value is the number of bytes of arguments automatically
popped when returning from a subroutine call.
FUNDECL is the declaration node of the function (as a tree),
FUNTYPE is the data type of the function (as a tree),
or for a library call it is an identifier node for the subroutine name.
SIZE is the number of bytes of arguments passed on the stack.
This only happens if the function declaration has the STDCALL attribute and
the number of arguments is not variable */
#undef RETURN_POPS_ARGS
#define RETURN_POPS_ARGS(FUNDECL,FUNTYPE,SIZE) \
( \
TREE_CODE (FUNTYPE) == IDENTIFIER_NODE \
? \
0 \
: \
( \
((FUNDECL && (TREE_CODE_CLASS (TREE_CODE (FUNDECL)) == 'd') \
? \
lookup_attribute ("stdcall", \
DECL_MACHINE_ATTRIBUTES (FUNDECL)) != NULL_TREE \
: 0 \
) \
) \
&& \
( \
TYPE_ARG_TYPES (FUNTYPE) == 0 \
|| \
TREE_VALUE (tree_last (TYPE_ARG_TYPES (FUNTYPE))) \
== void_type_node \
) \
) \
? \
(SIZE) \
: \
(aggregate_value_p (TREE_TYPE (FUNTYPE))) \
? \
GET_MODE_SIZE (Pmode) \
: \
0 \
)
#ifdef CPP_PREDEFINES
#undef CPP_PREDEFINES
#endif
......@@ -157,24 +114,13 @@ do \
} \
if (TREE_CODE (DECL) == FUNCTION_DECL) \
if (lookup_attribute ("stdcall", \
DECL_MACHINE_ATTRIBUTES (DECL))) \
TYPE_ATTRIBUTES (TREE_TYPE (DECL)))) \
XEXP (DECL_RTL (DECL), 0) = \
gen_rtx (SYMBOL_REF, Pmode, gen_stdcall_suffix (DECL)); \
} \
while (0)
#endif
/* Value is 1 if the declaration has either of the attributes: CDECL or
STDCALL and 0 otherwise */
#define VALID_MACHINE_DECL_ATTRIBUTE(DECL, ATTR, NAME, ARGS) \
(((TREE_CODE(DECL) == FUNCTION_DECL) \
|| (TREE_CODE(DECL) == FIELD_DECL) \
|| (TREE_CODE(DECL) == TYPE_DECL)) \
&& (is_attribute_p ("stdcall", (NAME)) \
|| is_attribute_p ("cdecl", (NAME))) \
&& (ARGS) == NULL)
/* The global __fltused is necessary to cause the printf/scanf routines
for outputting/inputting floating point numbers to be loaded. Since this
is kind of hard to detect, we just do it all the time. */
......
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