This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Stack and Function parameters alignment
- From: Paul Brook <paul at codesourcery dot com>
- To: gcc at gcc dot gnu dot org
- Cc: "Petar Penchev" <ptr at melexis dot com>
- Date: Fri, 15 Apr 2005 13:53:33 +0100
- Subject: Re: Stack and Function parameters alignment
- Organization: CodeSourcery
- References: <opso9w540k8jxhtw@ptrlp.mlxbg.elex.be>
On Friday 15 April 2005 13:33, Petar Penchev wrote:
> Hello All,
> The CPU ,I am porting GCC to , has PUSH instruction for half-word (byte)
> and PUSH instruction for word as well.
> GCC is using them well, until I was told to add a command-line option
> which allows GCC to align on word.
> It has been done, however, there samoe problems. GCC generates following
> code:
>
> PUSH AL ; AL is 8-bit reister
> INC S ;?increment stack pointer
>
> This is correct code, but it is longer than
>
> PUSH A ; where A is 16 bit register<...>
Obviously this only works on little-endian targets.
<...>
> [(set (mem:QI (post_inc (reg:HI S_HREG)))
> (match_operand:QI 0 "general_operand" "b"))]
> "!TARGET_STACK_BYTE_ALLIGN"
> [
> (set (match_dup 1)
> (match_dup 0)
> )
> (set (mem:HI (post_inc (reg:HI S_HREG)))
> (match_dup 1)
> )
> ]
> "
> operands[1] = gen_rtx(REG, HImode, A_HREG);
> "
> )
A post_inc increments by the size of the memory access. A define_split is
supposed to replace one insn by multiple insns that do the same thing. You're
replacing a byte increment with a word increment.
You could try adding a define_peephole2 that turns push al; inc S into push a.
Paul