| 1 |
/* PRU target specific pragmas |
| 2 |
Copyright (C) 2015-2025 Free Software Foundation, Inc. |
| 3 |
Contributed by Dimitar Dimitrov <[email protected]> |
| 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 *) |
| 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 %wd is not valid", i); |
| 62 |
else if (pru_ctable[i].valid && pru_ctable[i].base != base) |
| 63 |
error ("redefinition of %<CTABLE_ENTRY %wd%>", i); |
| 64 |
else |
| 65 |
{ |
| 66 |
if (base & 0xff) |
| 67 |
warning (0, "%<CTABLE_ENTRY%> base address is not " |
| 68 |
"a multiple of 256"); |
| 69 |
pru_ctable[i].base = base; |
| 70 |
pru_ctable[i].valid = true; |
| 71 |
} |
| 72 |
return; |
| 73 |
} |
| 74 |
} |
| 75 |
error ("malformed %<#pragma CTABLE_ENTRY%> variable address"); |
| 76 |
} |
| 77 |
|
| 78 |
/* Implements REGISTER_TARGET_PRAGMAS. */ |
| 79 |
void |
| 80 |
pru_register_pragmas (void) |
| 81 |
{ |
| 82 |
c_register_pragma (NULL, "ctable_entry", pru_pragma_ctable_entry); |
| 83 |
c_register_pragma (NULL, "CTABLE_ENTRY", pru_pragma_ctable_entry); |
| 84 |
|
| 85 |
c_register_addr_space ("__regio_symbol", ADDR_SPACE_REGIO); |
| 86 |
} |