public inbox for cgen@sourceware.org
 help / color / mirror / Atom feed
* Patch to add ifield number to cgen_operand (1/2)
@ 2001-01-23 10:17 Richard Sandiford
  2001-01-28 20:28 ` Ben Elliston
  0 siblings, 1 reply; 2+ messages in thread
From: Richard Sandiford @ 2001-01-23 10:17 UTC (permalink / raw)
  To: cgen

A few weeks ago I posted a bogus patch for reloc handling, which was
wisely ignored.  For what it's worth, the message was:

	http://sources.redhat.com/ml/cgen/2001-q1/msg00013.html

Part of the patch replaced the "start" and "length" fields of the
"cgen_operand" struct with the ifield number.  A comment in cgen.h
suggests that this change was already envisaged, so I decided to
update & resend that part. Please commit if OK.

(The patch affects include/, opcodes/ and cgen/.  I've done these
separately, hope that's OK.)

Richard

--

For INCLUDE/

2001-01-23  Richard Sandiford  <r.sandiford@redhat.com>

	* opcode/cgen.h (ifield_type): Define to a dummy value if CGEN_ARCH
	is not defined.
	(cgen_operand_type): Replace start and length fields with ifield
	member.
	(cgen_ifield_lookup_by_num): Declared.

Index: ./include/opcode/cgen.h
===================================================================
RCS file: /cvs/src/src/include/opcode/cgen.h,v
retrieving revision 1.8
diff -c -p -d -r1.8 cgen.h
*** ./include/opcode/cgen.h	2001/01/09 17:01:07	1.8
--- ./include/opcode/cgen.h	2001/01/23 18:10:36
*************** enum cgen_asm_type
*** 408,413 ****
--- 408,414 ----

  #ifndef CGEN_ARCH
  enum cgen_hw_type { CGEN_HW_MAX };
+ enum ifield_type { CGEN_IFLD_MAX };
  #endif

  /* List of hardware elements.  */
*************** typedef struct
*** 614,634 ****

    /* The hardware element associated with this operand.  */
    enum cgen_hw_type hw_type;
-
-   /* FIXME: We don't yet record ifield definitions, which we should.
-      When we do it might make sense to delete start/length (since they will
-      be duplicated in the ifield's definition) and replace them with a
-      pointer to the ifield entry.  */
-
-   /* Bit position.
-      This is just a hint, and may be unused in more complex operands.
-      May be unused for a modifier.  */
-   unsigned char start;

!   /* The number of bits in the operand.
!      This is just a hint, and may be unused in more complex operands.
!      May be unused for a modifier.  */
!   unsigned char length;

  #if 0 /* ??? Interesting idea but relocs tend to get too complicated,
  	 and ABI dependent, for simple table lookups to work.  */
--- 615,623 ----

    /* The hardware element associated with this operand.  */
    enum cgen_hw_type hw_type;

!   /* The field that the operand is stored in.  */
!   enum ifield_type ifield;

  #if 0 /* ??? Interesting idea but relocs tend to get too complicated,
  	 and ABI dependent, for simple table lookups to work.  */
*************** typedef struct cgen_ifld {
*** 814,819 ****
--- 803,812 ----
  /* Return value of attribute ATTR in IFLD.  */
  #define CGEN_IFLD_ATTR_VALUE(ifld, attr) \
  CGEN_ATTR_VALUE ((ifld), CGEN_IFLD_ATTRS (ifld), (attr))
+
+ extern const CGEN_IFLD * cgen_ifield_lookup_by_num
+      PARAMS ((CGEN_CPU_DESC, unsigned int));
+

  /* Instruction data.  */


For OPCODES/

2001-01-23  Richard Sandiford  <r.sandiford@redhat.com>

	* cgen-opc.c (cgen_ifield_lookup_by_num): Added.

Index: ./opcodes/cgen-opc.c
===================================================================
RCS file: /cvs/src/src/opcodes/cgen-opc.c,v
retrieving revision 1.5
diff -c -p -d -r1.5 cgen-opc.c
*** ./opcodes/cgen-opc.c	2001/01/02 16:34:07	1.5
--- ./opcodes/cgen-opc.c	2001/01/23 18:10:49
*************** cgen_hw_lookup_by_num (cd, hwnum)
*** 298,303 ****
--- 298,313 ----
    return NULL;
  }

+ /* Instruction fields.  */
+
+ const CGEN_IFLD *
+ cgen_ifield_lookup_by_num (cd, ifnum)
+      CGEN_CPU_DESC cd;
+      unsigned int ifnum;
+ {
+   return &cd->ifld_table[ifnum];
+ }
+
  /* Operand support.  */

  /* Lookup an operand by its name.

For CGEN/

2001-01-23  Richard Sandiford  <r.sandiford@redhat.com>

	* cgen/desc-cpu.scm (gen-operand-table): Replaced start and
	length fields with the instruction field number.
	* cgen/ifield.scm (ifld-enum): Enumerate f-nil as F_NIL
	(-ifield-parse): Add SIGNED attribute.
	* cgen/opcodes.scm (gen-insert): Remove special handling of
	SIGNED attribute following the change to ifld-enum.

Index: ./cgen/desc-cpu.scm
===================================================================
RCS file: /cvs/src/src/cgen/desc-cpu.scm,v
retrieving revision 1.5
diff -c -p -d -r1.5 desc-cpu.scm
*** ./cgen/desc-cpu.scm	2001/01/06 12:11:09	1.5
--- ./cgen/desc-cpu.scm	2001/01/23 17:54:46
*************** const CGEN_OPERAND @arch@_cgen_operand_t
*** 405,412 ****
      		   	         "\"" (obj:name op) "\", "
  			         (op-enum op) ", "
  			         (hw-enum (op:hw-name op)) ", "
! 			         (number->string (op:start op)) ", "
! 			         (number->string (op:length op)) ",\n"
  			         "    "
  			         (gen-obj-attr-defn 'operand op all-attrs
  				       	            num-non-bools gen-A-attr-mask)
--- 405,411 ----
      		   	         "\"" (obj:name op) "\", "
  			         (op-enum op) ", "
  			         (hw-enum (op:hw-name op)) ", "
! 				 (ifld-enum (op-ifield op)) ",\n"
  			         "    "
  			         (gen-obj-attr-defn 'operand op all-attrs
  				       	            num-non-bools gen-A-attr-mask)
Index: ./cgen/ifield.scm
===================================================================
RCS file: /cvs/src/src/cgen/ifield.scm,v
retrieving revision 1.3
diff -c -p -d -r1.3 ifield.scm
*** ./cgen/ifield.scm	2000/09/15 15:01:20	1.3
--- ./cgen/ifield.scm	2001/01/23 17:54:46
***************
*** 186,192 ****
    (string-upcase (string-append (if (or (null? prefix?) (car prefix?))
  				    "@ARCH@_"
  				    "")
! 				(gen-sym ifld)))
  )

  ; Return a boolean indicating if ifield F is an opcode field
--- 186,192 ----
    (string-upcase (string-append (if (or (null? prefix?) (car prefix?))
  				    "@ARCH@_"
  				    "")
! 				(if ifld (gen-sym ifld) "F_NIL")))
  )

  ; Return a boolean indicating if ifield F is an opcode field
***************
*** 520,526 ****
  		   (make <ifield>
  			 name
  			 (parse-comment comment errtxt)
! 			 atlist
  			 mode-obj
  			 bitrange
  			 (-ifld-parse-encode errtxt encode)
--- 520,528 ----
  		   (make <ifield>
  			 name
  			 (parse-comment comment errtxt)
! 			 (if (eq? (mode:class mode-obj) 'INT)
! 			     (atlist-cons (bool-attr-make 'SIGNED #t) atlist)
! 			     atlist)
  			 mode-obj
  			 bitrange
  			 (-ifld-parse-encode errtxt encode)
Index: ./cgen/opcodes.scm
===================================================================
RCS file: /cvs/src/src/cgen/opcodes.scm,v
retrieving revision 1.1.1.1
diff -c -p -d -r1.1.1.1 opcodes.scm
*** ./cgen/opcodes.scm	2000/07/28 04:11:52	1.1.1.1
--- ./cgen/opcodes.scm	2001/01/23 17:54:46
***************
*** 117,132 ****
        (if need-extra?
  	  "value"
  	  varname)
-       ", "
        ; We explicitly pass the attributes here rather than look them up
        ; to give the code more optimization opportunities.
!       ; ??? Maybe when fields are recorded in opc.c, stop doing this, and
!       ; pass a pointer to the recorded attributes instead.
!       (gen-bool-attrs (if (eq? (mode:class (ifld-mode self)) 'INT)
! 			  (atlist-cons (bool-attr-make 'SIGNED #t)
! 				       (obj-atlist self))
! 			  (obj-atlist self))
! 		      gen-attr-mask)
        ", " (number->string (ifld-word-offset self))
        ", " (number->string (ifld-start self #f))
        ", " (number->string (ifld-length self))
--- 117,126 ----
        (if need-extra?
  	  "value"
  	  varname)
        ; We explicitly pass the attributes here rather than look them up
        ; to give the code more optimization opportunities.
!       ; ??? Maybe we should pass a pointer to the recorded attributes instead.
!       ", " (gen-bool-attrs (obj-atlist self) gen-attr-mask)
        ", " (number->string (ifld-word-offset self))
        ", " (number->string (ifld-start self #f))
        ", " (number->string (ifld-length self))

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Patch to add ifield number to cgen_operand (1/2)
  2001-01-23 10:17 Patch to add ifield number to cgen_operand (1/2) Richard Sandiford
@ 2001-01-28 20:28 ` Ben Elliston
  0 siblings, 0 replies; 2+ messages in thread
From: Ben Elliston @ 2001-01-28 20:28 UTC (permalink / raw)
  To: Richard Sandiford; +Cc: cgen

Richard,

In cgen_ifield_lookup_by_num, how about testing the assertion that `ifnum'
is within range?

Ben

   ****************
   *** 298,303 ****
   --- 298,313 ----
       return NULL;
     }

   + /* Instruction fields.  */
   +
   + const CGEN_IFLD *
   + cgen_ifield_lookup_by_num (cd, ifnum)
   +      CGEN_CPU_DESC cd;
   +      unsigned int ifnum;
   + {
   +   return &cd->ifld_table[ifnum];
   + }
   +
     /* Operand support.  */

     /* Lookup an operand by its name.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-01-28 20:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-01-23 10:17 Patch to add ifield number to cgen_operand (1/2) Richard Sandiford
2001-01-28 20:28 ` Ben Elliston

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).