Open64 (mfef90, whirl2f, and IR tools)
TAG: version-openad; SVN changeset: 916
|
00001 /* 00002 00003 Copyright (C) 2000, 2001 Silicon Graphics, Inc. All Rights Reserved. 00004 00005 This program is free software; you can redistribute it and/or modify it 00006 under the terms of version 2.1 of the GNU Lesser General Public License 00007 as published by the Free Software Foundation. 00008 00009 This program is distributed in the hope that it would be useful, but 00010 WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00012 00013 Further, this software is distributed without any warranty that it is 00014 free of the rightful claim of any third person regarding infringement 00015 or the like. Any license provided herein, whether implied or 00016 otherwise, applies only to this software file. Patent licenses, if 00017 any, provided herein do not apply to combinations of this program with 00018 other software, or any other product whatsoever. 00019 00020 You should have received a copy of the GNU Lesser General Public 00021 License along with this program; if not, write the Free Software 00022 Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, 00023 USA. 00024 00025 Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pky, 00026 Mountain View, CA 94043, or: 00027 00028 http://www.sgi.com 00029 00030 For further information regarding this notice, see: 00031 00032 http://oss.sgi.com/projects/GenInfo/NoticeExplan 00033 00034 */ 00035 00036 00037 #include "stdio.h" 00038 #include "cmplrs/host.h" 00039 #include "comargs.h" 00040 00041 extern int32 num_father_args, num_son_args; 00042 extern uint32 father_addr[], father_len[]; 00043 extern uint32 son_addr[], son_len[]; 00044 extern void s_abort(void); 00045 extern int32 set_arg_arr(uint32 **,uint32 *,uint32 *); 00046 00047 void set_args(uint32 *addr_arg1, uint32 *addr_arg2 ) 00048 { 00049 if (addr_arg1) 00050 num_father_args = set_arg_arr((uint32 **) addr_arg1, father_addr, 00051 father_len); 00052 if (addr_arg2) 00053 num_son_args = set_arg_arr((uint32 **) addr_arg2,son_addr,son_len); 00054 comargs__[0] = 0; 00055 } 00056 00057 int32 00058 set_arg_arr(uint32 **iaddr,uint32 *result_addr,uint32 *result_len) 00059 { 00060 int32 nargs = *(unsigned char *) iaddr; 00061 int32 i; 00062 uint32 charmask; 00063 uint32 *sp, *fp; 00064 00065 sp = *iaddr; 00066 /* recreate the first byte of the stack pointer */ 00067 *(char *)&sp = ((unsigned long)&sp) >> 24; 00068 /* the stack pointer cannot be smaller than the address of local variables 00069 in this function unless there has been a cross over at the 24-bit boundary 00070 E.g: when 'sp' is suposed to be 7f000000 and &sp is at 7effff00 therefore 00071 recreating the stack pointer value using &sp will result in 7e000000 */ 00072 if (sp < (unsigned *)&sp) 00073 (*(char *)&sp)++; 00074 fp = sp; 00075 for (i = 0; i < nargs; i++) 00076 *result_addr++ = *sp++; 00077 if (fp != *((unsigned **)*sp)) { 00078 printf("Function is not declared as varargs %x %x\n", fp, *((unsigned **)*sp)); 00079 s_abort(); 00080 } 00081 charmask = *((unsigned*)*(++sp)); 00082 if (charmask!=0) 00083 for (i=0; i<nargs; i++) { 00084 *result_len++ = (charmask&1) ? *++sp : 0; 00085 charmask >>= 1; 00086 } 00087 else 00088 for (i=0; i<nargs; i++) *result_len++ = 0; 00089 return (nargs); 00090 }