This is the mail archive of the cgen@sources.redhat.com mailing list for the CGEN project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: INSN_MAX


>>>>> "Ben" == Ben Elliston <bje@redhat.com> writes:

  Ben> The cgen_insn_type enumeration in @arch@-opc.h suffers from the fact
  Ben> that the final enumerator is called @ARCH@_INSN_MAX.  This makes it
  Ben> impossible to name an instruction `max'.

Having thought about this some more, I decided to eliminate this enum
value altogether, since it is only used by the MAX_INSNS macro.  This
is cleaner, since it doesn't pollute the real instruction list.  Okay
to commit?  It has been tested.

2001-03-20  Ben Elliston  <bje@redhat.com>

	* opc-itab.scm (-gen-insn-enum): Do not append a dummy `max'
	instruction onto the instruction list. Define MAX_INSNS to be the
	value of the last instruction enum plus one.

--- opc-itab.scm	2000/11/20 19:03:16	1.20
+++ opc-itab.scm	2001/03/20 07:51:48
@@ -292,17 +292,18 @@
 
 (define (-gen-insn-enum)
   (logit 2 "Generating instruction enum ...\n")
-  (string-list
-   (gen-enum-decl 'cgen_insn_type "@arch@ instruction types"
-		  "@ARCH@_INSN_"
-		  (cons '(invalid)
-			(append (gen-obj-list-enums (non-multi-insns (current-insn-list)))
-				'((max)))))
-   "/* Index of `invalid' insn place holder.  */\n"
-   "#define CGEN_INSN_INVALID @ARCH@_INSN_INVALID\n\n"
-   "/* Total number of insns in table.  */\n"
-   "#define MAX_INSNS ((int) @ARCH@_INSN_MAX)\n\n"
+  (let ((insns (gen-obj-list-enums (non-multi-insns (current-insn-list)))))
+    (string-list
+     (gen-enum-decl 'cgen_insn_type "@arch@ instruction types"
+		    "@ARCH@_INSN_"
+		    (cons '(invalid) insns))
+     "/* Index of `invalid' insn place holder.  */\n"
+     "#define CGEN_INSN_INVALID @ARCH@_INSN_INVALID\n\n"
+     "/* Total number of insns in table.  */\n"
+     "#define MAX_INSNS ((int) @ARCH@_INSN_"
+     (string-upcase (gen-c-symbol (caar (list-take -1 insns))))) " + 1)\n\n"
    )
+  )
 )
 
 ; Return a reference to the format table entry of INSN.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]