public inbox for cgen@sourceware.org
 help / color / mirror / Atom feed
From: Greg McGary <greg@mcgary.org>
To: Doug Evans <dje@transmeta.com>
Cc: Ben Elliston <bje@redhat.com>,
	"Frank Ch. Eigler" <fche@redhat.com>,
	<cgen@sourceware.cygnus.com>
Subject: Re: sim's -DPROFILE=1 conflicts with CGEN's PROFILE attribute
Date: Wed, 15 Nov 2000 17:15:00 -0000	[thread overview]
Message-ID: <mslmuk3eey.fsf@mcgary.org> (raw)
In-Reply-To: <msofzg3eu2.fsf@mcgary.org>

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

  reply	other threads:[~2000-11-15 17:15 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-11-14 12:40 Greg McGary
2000-11-14 16:29 ` Ben Elliston
2000-11-14 17:18   ` Doug Evans
2000-11-15 11:56     ` Greg McGary
2000-11-15 12:06       ` Frank Ch. Eigler
2000-11-15 12:54         ` Greg McGary
2000-11-15 14:34           ` Doug Evans
2000-11-15 14:53           ` Frank Ch. Eigler
2000-11-15 15:28             ` Greg McGary
2000-11-20 11:17               ` Copyright assignment Frank Ch. Eigler
2000-11-15 15:32             ` sim's -DPROFILE=1 conflicts with CGEN's PROFILE attribute Ben Elliston
2000-11-15 15:35               ` Greg McGary
2000-11-15 16:03                 ` Doug Evans
2000-11-15 17:06                   ` Greg McGary
2000-11-15 17:15                     ` Greg McGary [this message]
2000-11-15 12:24       ` Doug Evans
2000-11-15 12:31     ` Frank Ch. Eigler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=mslmuk3eey.fsf@mcgary.org \
    --to=greg@mcgary.org \
    --cc=bje@redhat.com \
    --cc=cgen@sourceware.cygnus.com \
    --cc=dje@transmeta.com \
    --cc=fche@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).