2 * Copyright(c) 2019-2021 Qualcomm Innovation Center, Inc. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, see <http://www.gnu.org/licenses/>.
19 * This program generates the semantics file that is processed by
20 * the do_qemu.py script. We use the C preporcessor to manipulate the
21 * files imported from the Hexagon architecture library.
25 #define STRINGIZE(X) #X
27 int main(int argc
, char *argv
[])
32 fprintf(stderr
, "Usage: gen_semantics ouptputfile\n");
35 outfile
= fopen(argv
[1], "w");
36 if (outfile
== NULL
) {
37 fprintf(stderr
, "Cannot open %s for writing\n", argv
[1]);
42 * Process the instruction definitions
43 * Scalar core instructions have the following form
44 * Q6INSN(A2_add,"Rd32=add(Rs32,Rt32)",ATTRIBS(),
45 * "Add 32-bit registers",
48 #define Q6INSN(TAG, BEH, ATTRIBS, DESCR, SEM) \
50 fprintf(outfile, "SEMANTICS( \\\n" \
53 " \"\"\"%s\"\"\" \\\n" \
55 #TAG, STRINGIZE(BEH), STRINGIZE(SEM)); \
56 fprintf(outfile, "ATTRIBUTES( \\\n" \
60 #TAG, STRINGIZE(ATTRIBS)); \
62 #include "imported/allidefs.def"
66 * Process the macro definitions
67 * Macros definitions have the following form
70 * predlog_read(thread,0),
73 * The important part here is the attributes. Whenever an instruction
74 * invokes a macro, we add the macro's attributes to the instruction.
76 #define DEF_MACRO(MNAME, BEH, ATTRS) \
77 fprintf(outfile, "MACROATTRIB( \\\n" \
79 " \"\"\"%s\"\"\", \\\n" \
82 #MNAME, STRINGIZE(BEH), STRINGIZE(ATTRS));
83 #include "imported/macros.def"