1 /* PRU target specific pragmas 2 Copyright (C) 2015-2020 Free Software Foundation, Inc. 3 Contributed by Dimitar Dimitrov <dimitar@dinux.eu> 4 5 This file is part of GCC. 6 7 GCC is free software; you can redistribute it and/or modify it 8 under the terms of the GNU General Public License as published 9 by the Free Software Foundation; either version 3, or (at your 10 option) any later version. 11 12 GCC is distributed in the hope that it will be useful, but WITHOUT 13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 15 License for more details. 16 17 You should have received a copy of the GNU General Public License 18 along with GCC; see the file COPYING3. If not see 19 <http://www.gnu.org/licenses/>. */ 20 21 #define IN_TARGET_CODE 1 22 23 #include "config.h" 24 #include "system.h" 25 #include "coretypes.h" 26 #include "tm.h" 27 #include "alias.h" 28 #include "symtab.h" 29 #include "tree.h" 30 #include "c-family/c-pragma.h" 31 #include "c-family/c-common.h" 32 #include "diagnostic-core.h" 33 #include "cpplib.h" 34 #include "pru-protos.h" 35 36 37 /* Implements the "pragma CTABLE_ENTRY" pragma. This pragma takes a 38 CTABLE index and an address, and instructs the compiler that 39 LBCO/SBCO can be used on that base address. 40 41 WARNING: Only immediate constant addresses are currently supported. */ 42 static void 43 pru_pragma_ctable_entry (cpp_reader * reader ATTRIBUTE_UNUSED) 44 { 45 tree ctable_index, base_addr; 46 enum cpp_ttype type; 47 48 type = pragma_lex (&ctable_index); 49 if (type == CPP_NUMBER && tree_fits_uhwi_p (ctable_index)) 50 { 51 type = pragma_lex (&base_addr); 52 if (type == CPP_NUMBER && tree_fits_uhwi_p (base_addr)) 53 { 54 unsigned HOST_WIDE_INT i = tree_to_uhwi (ctable_index); 55 unsigned HOST_WIDE_INT base = tree_to_uhwi (base_addr); 56 57 type = pragma_lex (&base_addr); 58 if (type != CPP_EOF) 59 error ("junk at end of %<#pragma CTABLE_ENTRY%>"); 60 else if (i >= ARRAY_SIZE (pru_ctable)) 61 error ("%<CTABLE_ENTRY%> index %" HOST_WIDE_INT_PRINT "d" 62 " is not valid", i); 63 else if (pru_ctable[i].valid && pru_ctable[i].base != base) 64 error ("redefinition of %<CTABLE_ENTRY " 65 "%" HOST_WIDE_INT_PRINT "d%>", i); 66 else 67 { 68 if (base & 0xff) 69 warning (0, "%<CTABLE_ENTRY%> base address is not " 70 "a multiple of 256"); 71 pru_ctable[i].base = base; 72 pru_ctable[i].valid = true; 73 } 74 return; 75 } 76 } 77 error ("malformed %<#pragma CTABLE_ENTRY%> variable address"); 78 } 79 80 /* Implements REGISTER_TARGET_PRAGMAS. */ 81 void 82 pru_register_pragmas (void) 83 { 84 c_register_pragma (NULL, "ctable_entry", pru_pragma_ctable_entry); 85 c_register_pragma (NULL, "CTABLE_ENTRY", pru_pragma_ctable_entry); 86 } 87