This is the mail archive of the
cgen@sources.redhat.com
mailing list for the CGEN project.
Re: sim's -DPROFILE=1 conflicts with CGEN's PROFILE attribute
Greg McGary <greg@mcgary.org> writes:
> Index: utils-cgen.scm
This part of the diff I just posted was stale.
Here's a diff of the diffs:
@@ -283,11 +284,11 @@
+ (string-append
+ "\
+#if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
-+"
++#define "
+ head (string-map (lambda (elm) (string-append "##" elm)) args)
+ "
+#else
-+"
++#define "
+ head (string-map (lambda (elm) (string-append "/**/" elm)) args)
+ "
+#endif
Here's the whole thing again:
Index: utils-cgen.scm
===================================================================
RCS file: /cvs/src/src/cgen/utils-cgen.scm,v
retrieving revision 1.2
diff -u -p -r1.2 utils-cgen.scm
--- utils-cgen.scm 2000/10/13 11:21:57 1.2
+++ utils-cgen.scm 2000/11/16 01:14:19
@@ -636,3 +636,26 @@ Mark an entry as being sanitized.
*UNSPECIFIED*
)
+
+; Return a pair of definitions for a C macro that concatenates its
+; argument symbols. The definitions are conditional on ANSI C
+; semantics: one contains ANSI concat operators (##), and the other
+; uses the empty-comment trick (/**/). We must do this, rather than
+; use CONCATn(...) as defined in include/symcat.h, in order to avoid
+; spuriously expanding our macro's args.
+
+(define (gen-define-with-symcat head . args)
+ (string-append
+ "\
+#if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
+#define "
+ head (string-map (lambda (elm) (string-append "##" elm)) args)
+ "
+#else
+#define "
+ head (string-map (lambda (elm) (string-append "/**/" elm)) args)
+ "
+#endif
+"
+ )
+)
Index: desc-cpu.scm
===================================================================
RCS file: /cvs/src/src/cgen/desc-cpu.scm,v
retrieving revision 1.2
diff -u -p -r1.2 desc-cpu.scm
--- desc-cpu.scm 2000/10/02 19:13:53 1.2
+++ desc-cpu.scm 2000/11/16 01:14:11
@@ -132,11 +132,12 @@ static const CGEN_MACH @arch@_cgen_mach_
(all-attrs (current-ifld-attr-list))
(num-non-bools (attr-count-non-bools all-attrs)))
(string-list
- "\
+ "
/* The instruction field table. */
-
-#define A(a) (1 << CONCAT2 (CGEN_IFLD_,a))
+"
+ (gen-define-with-symcat "A(a) (1 << CGEN_IFLD_" "a)")
+ "
const CGEN_IFLD @arch@_cgen_ifld_table[] =
{
"
@@ -248,11 +249,11 @@ const CGEN_IFLD @arch@_cgen_ifld_table[]
(string-list-map gen-defn (current-kw-list))
(string-list-map -gen-hw-defn (current-hw-list))
"
-
/* The hardware table. */
-#define A(a) (1 << CONCAT2 (CGEN_HW_,a))
-
+"
+ (gen-define-with-symcat "A(a) (1 << CGEN_HW_" "a)")
+ "
const CGEN_HW_ENTRY @arch@_cgen_hw_table[] =
{
"
@@ -294,8 +295,8 @@ const CGEN_HW_ENTRY @arch@_cgen_hw_table
(string-list
"#define CGEN_ARCH @arch@\n\n"
"/* Given symbol S, return @arch@_cgen_<S>. */\n"
- "#define CGEN_SYM(s) CONCAT3 (@arch@,_cgen_,s)\n\n"
- "/* Selected cpu families. */\n"
+ (gen-define-with-symcat "CGEN_SYM(s) @arch@" "_cgen_" "s")
+ "\n\n/* Selected cpu families. */\n"
; FIXME: Move to sim's arch.h.
(string-map (lambda (cpu)
(gen-obj-sanitize cpu
@@ -381,12 +382,13 @@ const CGEN_HW_ENTRY @arch@_cgen_hw_table
(let* ((all-attrs (current-op-attr-list))
(num-non-bools (attr-count-non-bools all-attrs)))
(string-list
- "\
+ "
/* The operand table. */
-
-#define A(a) (1 << CONCAT2 (CGEN_OPERAND_,a))
-#define OPERAND(op) CONCAT2 (@ARCH@_OPERAND_,op)
+"
+ (gen-define-with-symcat "A(a) (1 << CGEN_OPERAND_" "a)")
+ (gen-define-with-symcat "OPERAND(op) @ARCH@_OPERAND_" "op")
+"
const CGEN_OPERAND @arch@_cgen_operand_table[] =
{
"
@@ -477,12 +479,13 @@ const CGEN_OPERAND @arch@_cgen_operand_t
(let* ((all-attrs (current-insn-attr-list))
(num-non-bools (attr-count-non-bools all-attrs)))
(string-write
- "\
-#define A(a) (1 << CONCAT2 (CGEN_INSN_,a))
-#define OP(field) CGEN_SYNTAX_MAKE_FIELD (OPERAND (field))
-
+ "
/* The instruction table. */
+#define OP(field) CGEN_SYNTAX_MAKE_FIELD (OPERAND (field))
+"
+ (gen-define-with-symcat "A(a) (1 << CGEN_INSN_" "a)")
+"
static const CGEN_IBASE @arch@_cgen_insn_table[MAX_INSNS] =
{
/* Special null first entry.
@@ -499,9 +502,8 @@ static const CGEN_IBASE @arch@_cgen_insn
"\
};
-#undef A
-#undef MNEM
#undef OP
+#undef A
"
)
Index: opc-itab.scm
===================================================================
RCS file: /cvs/src/src/cgen/opc-itab.scm,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 opc-itab.scm
--- opc-itab.scm 2000/07/28 04:11:52 1.1.1.1
+++ opc-itab.scm 2000/11/16 01:14:14
@@ -214,7 +214,7 @@
(define (-gen-ifmt-table)
(string-write
"/* Instruction formats. */\n\n"
- "#define F(f) & @arch@_cgen_ifld_table[CONCAT2 (@ARCH@_,f)]\n\n"
+ (gen-define-with-symcat "F(f) & @arch@_cgen_ifld_table[@ARCH@_" "f]\n\n")
(string-list-map -gen-ifmt-table-1 (current-ifmt-list))
"#undef F\n\n"
)
@@ -350,10 +350,10 @@
(let* ((all-attrs (current-insn-attr-list))
(num-non-bools (attr-count-non-bools all-attrs)))
(string-write
+ (gen-define-with-symcat "A(a) (1 << CGEN_INSN_" "a)")
+ (gen-define-with-symcat "OPERAND(op) @ARCH@_OPERAND_" "op")
"\
-#define A(a) (1 << CONCAT2 (CGEN_INSN_,a))
#define MNEM CGEN_SYNTAX_MNEMONIC /* syntax value for mnemonic */
-#define OPERAND(op) CONCAT2 (@ARCH@_OPERAND_,op)
#define OP(field) CGEN_SYNTAX_MAKE_FIELD (OPERAND (field))
/* The instruction table. */
@@ -376,8 +376,8 @@ static const CGEN_OPCODE @arch@_cgen_ins
};
#undef A
-#undef MNEM
#undef OPERAND
+#undef MNEM
#undef OP
"
@@ -549,7 +549,7 @@ static unsigned int dis_hash_insn PARAMS
(num-non-bools (attr-count-non-bools all-attrs)))
(string-write
"/* Formats for ALIAS macro-insns. */\n\n"
- "#define F(f) & @arch@_cgen_ifld_table[CONCAT2 (@ARCH@_,f)]\n\n"
+ (gen-define-with-symcat "F(f) & @arch@_cgen_ifld_table[@ARCH@_" "f]\n\n")
(lambda ()
(string-write-map -gen-ifmt-table-1
(map insn-ifmt (find (lambda (minsn)
@@ -568,10 +568,10 @@ static unsigned int dis_hash_insn PARAMS
(minsn-expansions minsn))
" { 0, 0 }\n};\n\n")))
minsn-list))
+ (gen-define-with-symcat "A(a) (1 << CGEN_INSN_" "a)")
+ (gen-define-with-symcat "OPERAND(op) @ARCH@_OPERAND_" "op")
"\
-#define A(a) (1 << CONCAT2 (CGEN_INSN_,a))
#define MNEM CGEN_SYNTAX_MNEMONIC /* syntax value for mnemonic */
-#define OPERAND(op) CONCAT2 (@ARCH@_OPERAND_,op)
#define OP(field) CGEN_SYNTAX_MAKE_FIELD (OPERAND (field))
/* The macro instruction table. */
@@ -606,8 +606,8 @@ static const CGEN_OPCODE @arch@_cgen_mac
};
#undef A
-#undef MNEM
#undef OPERAND
+#undef MNEM
#undef OP
\n"
))
Index: opc-opinst.scm
===================================================================
RCS file: /cvs/src/src/cgen/opc-opinst.scm,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 opc-opinst.scm
--- opc-opinst.scm 2000/07/28 04:11:52 1.1.1.1
+++ opc-opinst.scm 2000/11/16 01:14:14
@@ -62,20 +62,22 @@
"\
/* Operand references. */
+"
+ (gen-define-with-symcat "OP_ENT(op) @ARCH@_OPERAND_" "op")
+"\
#define INPUT CGEN_OPINST_INPUT
#define OUTPUT CGEN_OPINST_OUTPUT
#define END CGEN_OPINST_END
#define COND_REF CGEN_OPINST_COND_REF
-#define OP_ENT(op) CONCAT2 (@ARCH@_OPERAND_,op)
"
(lambda () (string-write-map -gen-operand-instance-table (current-sfmt-list)))
"\
+#undef OP_ENT
#undef INPUT
#undef OUTPUT
#undef END
#undef COND_REF
-#undef OP_ENT
"
)
Index: sim-cpu.scm
===================================================================
RCS file: /cvs/src/src/cgen/sim-cpu.scm,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 sim-cpu.scm
--- sim-cpu.scm 2000/07/28 04:11:52 1.1.1.1
+++ sim-cpu.scm 2000/11/16 01:14:18
@@ -1001,9 +1001,10 @@ void
#include \"cgen-ops.h\"
#undef GET_ATTR
-#define GET_ATTR(cpu, num, attr) \
-CGEN_ATTR_VALUE (NULL, abuf->idesc->attrs, CGEN_INSN_##attr)
-
+"
+ (gen-define-with-symcat "GET_ATTR(cpu, num, attr) \
+CGEN_ATTR_VALUE (NULL, abuf->idesc->attrs, CGEN_INSN_" "attr)")
+"
/* This is used so that we can compile two copies of the semantic code,
one with full feature support and one without that runs fast(er).
FAST_P, when desired, is defined on the command line, -DFAST_P=1. */
@@ -1112,9 +1113,10 @@ CGEN_ATTR_VALUE (NULL, abuf->idesc->attr
#endif
#undef GET_ATTR
-#define GET_ATTR(cpu, num, attr) \
-CGEN_ATTR_VALUE (NULL, abuf->idesc->attrs, CGEN_INSN_##attr)
-
+"
+ (gen-define-with-symcat "GET_ATTR(cpu, num, attr) \
+CGEN_ATTR_VALUE (NULL, abuf->idesc->attrs, CGEN_INSN_" "attr)")
+"
{
#if WITH_SCACHE_PBB