Home | History | Annotate | Download | only in gen
      1 /*
      2  * CDDL HEADER START
      3  *
      4  * The contents of this file are subject to the terms of the
      5  * Common Development and Distribution License (the "License").
      6  * You may not use this file except in compliance with the License.
      7  *
      8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
      9  * or http://www.opensolaris.org/os/licensing.
     10  * See the License for the specific language governing permissions
     11  * and limitations under the License.
     12  *
     13  * When distributing Covered Code, include this CDDL HEADER in each
     14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
     15  * If applicable, add the following below this CDDL HEADER, with the
     16  * fields enclosed by brackets "[]" replaced with your own identifying
     17  * information: Portions Copyright [yyyy] [name of copyright owner]
     18  *
     19  * CDDL HEADER END
     20  */
     21 /*
     22  * Copyright (c) 1998, by Sun Microsystems, Inc.
     23  * All rights reserved.
     24  */
     25 
     26 	.file	"alloca.s"
     27 
     28 #include <sys/asm_linkage.h>
     29 #include <sys/stack.h>
     30 
     31 	!
     32 	! o0: # bytes of space to allocate, already rounded to 0 mod 8
     33 	! o1: %sp-relative offset of tmp area
     34 	! o2: %sp-relative offset of end of tmp area
     35 	!
     36 	! we want to bump %sp by the requested size
     37 	! then copy the tmp area to its new home
     38 	! this is necessary as we could theoretically
     39 	! be in the middle of a complicated expression.
     40 	!
     41 	ENTRY(__builtin_alloca)
     42 	add	%sp, STACK_BIAS, %g1	! save current sp + STACK_BIAS
     43 	sub	%sp, %o0, %sp		! bump to new value
     44 	add	%sp, STACK_BIAS, %g5
     45 	! copy loop: should do nothing gracefully
     46 	b	2f
     47 	subcc	%o2, %o1, %o5		! number of bytes to move
     48 1:
     49 	ldx	[%g1 + %o1], %o4	! load from old temp area
     50 	stx	%o4, [%g5 + %o1]	! store to new temp area
     51 	add	%o1, 8, %o1
     52 2:	bg,pt	%xcc, 1b
     53 	subcc	%o5, 8, %o5
     54 	! now return new %sp + end-of-temp
     55 	add	%sp, %o2, %o0
     56 	retl
     57 	add	%o0, STACK_BIAS, %o0
     58 	SET_SIZE(__builtin_alloca)
     59