00001 /* M32C Pragma support 00002 Copyright (C) 2004 Free Software Foundation, Inc. 00003 Contributed by Red Hat, Inc. 00004 00005 This file is part of GCC. 00006 00007 GCC is free software; you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License as published by 00009 the Free Software Foundation; either version 2, or (at your option) 00010 any later version. 00011 00012 GCC is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with GCC; see the file COPYING. If not, write to 00019 the Free Software Foundation, 51 Franklin Street, Fifth Floor, 00020 Boston, MA 02110-1301, USA. */ 00021 00022 #include <stdio.h> 00023 #include "config.h" 00024 #include "system.h" 00025 #include "coretypes.h" 00026 #include "tm.h" 00027 #include "tree.h" 00028 #include "rtl.h" 00029 #include "toplev.h" 00030 #include "c-pragma.h" 00031 #include "cpplib.h" 00032 #include "hard-reg-set.h" 00033 #include "output.h" 00034 #include "m32c-protos.h" 00035 #include "function.h" 00036 #define MAX_RECOG_OPERANDS 10 00037 #include "reload.h" 00038 #include "target.h" 00039 00040 /* Implements the "GCC memregs" pragma. This pragma takes only an 00041 integer, and is semantically identical to the -memregs= command 00042 line option. The only catch is, the programmer should only use 00043 this pragma at the beginning of the file (preferably, in some 00044 project-wide header) to avoid ABI changes related to changing the 00045 list of available "registers". */ 00046 static void 00047 m32c_pragma_memregs (cpp_reader * reader ATTRIBUTE_UNUSED) 00048 { 00049 /* on off */ 00050 tree val; 00051 enum cpp_ttype type; 00052 HOST_WIDE_INT i; 00053 static char new_number[3]; 00054 00055 type = pragma_lex (&val); 00056 if (type == CPP_NUMBER) 00057 { 00058 if (host_integerp (val, 1)) 00059 { 00060 i = tree_low_cst (val, 1); 00061 00062 type = pragma_lex (&val); 00063 if (type != CPP_EOF) 00064 warning (0, "junk at end of #pragma GCC memregs [0..16]"); 00065 00066 if (0 <= i && i <= 16) 00067 { 00068 if (!ok_to_change_target_memregs) 00069 { 00070 warning (0, 00071 "#pragma GCC memregs must precede any function decls"); 00072 return; 00073 } 00074 new_number[0] = (i / 10) + '0'; 00075 new_number[1] = (i % 10) + '0'; 00076 new_number[2] = 0; 00077 target_memregs = new_number; 00078 m32c_conditional_register_usage (); 00079 } 00080 else 00081 { 00082 warning (0, "#pragma GCC memregs takes a number [0..16]"); 00083 } 00084 00085 return; 00086 } 00087 } 00088 00089 error ("#pragma GCC memregs takes a number [0..16]"); 00090 } 00091 00092 /* Implements REGISTER_TARGET_PRAGMAS. */ 00093 void 00094 m32c_register_pragmas (void) 00095 { 00096 c_register_pragma ("GCC", "memregs", m32c_pragma_memregs); 00097 }
1.5.6