* Target dependent frag fields (proposed change)
@ 1997-11-04 5:56 Ian Dall
0 siblings, 0 replies; 2+ messages in thread
From: Ian Dall @ 1997-11-04 5:56 UTC (permalink / raw)
To: gas2
Following the comments in as.h, I decided to have a look at making the
fields needed for the ns32k configurable.
This turned out to not be very hard. Basically the problem is that you
would want targ-*.h to define TC_FRAG_TYPE (like TC_FIX_TYPE for the
fix structure), but the targ-*.h use the frag structure quite a bit so
it has to be defined before the targ-*.h.
The solution to to have an incomplete definition
struct frag;
before including the targ-*.h and defer a complete definition until
afterwards.
I don't have the resources to test this for all targets, but it works
for the ns32k and looks safe for other targets.
Ian
ChangeLog Entry:
Wed Nov 5 00:00:20 1997 Ian Dall <Ian.Dall@dsto.defence.gov.au>
* as.h: Move struct frag definition to after targ-*.h is
included. Leave incomplete definition at old place. (struct frag):
Add TC_FRAG_TYPE analagously to TC_FIX_TYPE.
* config/tc-ns32k.h (TC_FRAG_TYPE): Define to contain ns32k target
dependent frag fields. (frag_opcode_frag, frag_opcode_offset,
frag_bsr): change to reflect TC_FRAG_TYPE definition.
Patch:
diff -rc ../gas-build/gas/as.h ./gas/as.h
*** ../gas-build/gas/as.h Wed Oct 29 22:57:20 1997
--- ./gas/as.h Tue Nov 4 22:45:52 1997
***************
*** 395,472 ****
typedef addressT relax_addressT;
\f
! /* frags.c */
!
! /*
! * A code fragment (frag) is some known number of chars, followed by some
! * unknown number of chars. Typically the unknown number of chars is an
! * instruction address whose size is yet unknown. We always know the greatest
! * possible size the unknown number of chars may become, and reserve that
! * much room at the end of the frag.
! * Once created, frags do not change address during assembly.
! * We chain the frags in (a) forward-linked list(s). The object-file address
! * of the 1st char of a frag is generally not known until after relax().
! * Many things at assembly time describe an address by {object-file-address
! * of a particular frag}+offset.
!
! BUG: it may be smarter to have a single pointer off to various different
! notes for different frag kinds. See how code pans
! */
!
typedef struct frag fragS;
- struct frag
- {
- /* Object file address. */
- addressT fr_address;
- /* Chain forward; ascending address order. Rooted in frch_root. */
- struct frag *fr_next;
-
- /* (Fixed) number of chars we know we have. May be 0. */
- offsetT fr_fix;
- /* (Variable) number of chars after above. May be 0. */
- offsetT fr_var;
- /* For variable-length tail. */
- struct symbol *fr_symbol;
- /* For variable-length tail. */
- offsetT fr_offset;
- /* Points to opcode low addr byte, for relaxation. */
- char *fr_opcode;
-
- #ifndef NO_LISTING
- struct list_info_struct *line;
- #endif
-
- /* What state is my tail in? */
- relax_stateT fr_type;
- relax_substateT fr_subtype;
-
- union {
- /* These are needed only on the NS32K machines. But since we don't
- include targ-cpu.h until after this structure has been defined,
- we can't really conditionalize it. This code should be
- rearranged a bit to make that possible. */
- struct {
- fragS *fr_opcode_fragP;
- unsigned int fr_opcode_offset;
- char fr_bsr;
- } fr_ns32k;
- #ifdef USING_CGEN
- /* Don't include this unless using CGEN to keep frag size down. */
- struct {
- const struct cgen_insn *insn;
- unsigned char opindex, opinfo;
- } cgen;
- #endif
- } fr_targ;
-
- /* Where the frag was created, or where it became a variant frag. */
- char *fr_file;
- unsigned int fr_line;
-
- /* Data begins here. */
- char fr_literal[1];
- };
#define SIZEOF_STRUCT_FRAG \
((char *)zero_address_frag.fr_literal-(char *)&zero_address_frag)
--- 395,404 ----
typedef addressT relax_addressT;
\f
! struct frag; /* Complete definition after target
! dependent includes */
typedef struct frag fragS;
#define SIZEOF_STRUCT_FRAG \
((char *)zero_address_frag.fr_literal-(char *)&zero_address_frag)
***************
*** 656,661 ****
--- 588,660 ----
/* this one starts the chain of target dependant headers */
#include "targ-env.h"
+
+ /* frags.c */
+
+ /*
+ * A code fragment (frag) is some known number of chars, followed by some
+ * unknown number of chars. Typically the unknown number of chars is an
+ * instruction address whose size is yet unknown. We always know the greatest
+ * possible size the unknown number of chars may become, and reserve that
+ * much room at the end of the frag.
+ * Once created, frags do not change address during assembly.
+ * We chain the frags in (a) forward-linked list(s). The object-file address
+ * of the 1st char of a frag is generally not known until after relax().
+ * Many things at assembly time describe an address by {object-file-address
+ * of a particular frag}+offset.
+
+ BUG: it may be smarter to have a single pointer off to various different
+ notes for different frag kinds. See how code pans
+ */
+
+ struct frag
+ {
+ /* Object file address. */
+ addressT fr_address;
+ /* Chain forward; ascending address order. Rooted in frch_root. */
+ struct frag *fr_next;
+
+ /* (Fixed) number of chars we know we have. May be 0. */
+ offsetT fr_fix;
+ /* (Variable) number of chars after above. May be 0. */
+ offsetT fr_var;
+ /* For variable-length tail. */
+ struct symbol *fr_symbol;
+ /* For variable-length tail. */
+ offsetT fr_offset;
+ /* Points to opcode low addr byte, for relaxation. */
+ char *fr_opcode;
+
+ #ifndef NO_LISTING
+ struct list_info_struct *line;
+ #endif
+
+ /* What state is my tail in? */
+ relax_stateT fr_type;
+ relax_substateT fr_subtype;
+
+ #ifdef TC_FRAG_TYPE
+ TC_FRAG_TYPE tc_frag_data;
+ #endif
+
+ #ifdef USING_CGEN
+ /* Don't include this unless using CGEN to keep frag size down.
+ Change tc file to use TC_FRAG_TYPE */
+ union {
+ struct {
+ const struct cgen_insn *insn;
+ unsigned char opindex, opinfo;
+ } cgen;
+ } fr_targ;
+ #endif
+
+ /* Where the frag was created, or where it became a variant frag. */
+ char *fr_file;
+ unsigned int fr_line;
+
+ /* Data begins here. */
+ char fr_literal[1];
+ };
#include "struc-symbol.h"
#include "write.h"
diff -rc ../gas-build/gas/config/tc-ns32k.h ./gas/config/tc-ns32k.h
*** ../gas-build/gas/config/tc-ns32k.h Wed Oct 29 22:57:23 1997
--- ./gas/config/tc-ns32k.h Mon Nov 3 23:30:53 1997
***************
*** 102,128 ****
#define TC_FIX_DATA_PRINT(FILE, TC_FIX) \
! do \
! { \
! fprintf((FILE), "\nopcode_frag=%p operand offset=%d, \
! bsr=%d" , (TC_FIX).opcode_fragP, (TC_FIX).opcode_offset, \
! (TC_FIX).bsr); \
! } \
! while(0)
#define TC_FRAG_INIT(X) \
! do \
! { \
! frag_opcode_frag(X) = NULL; \
! frag_opcode_offset(X) = 0; \
! frag_bsr(X) = 0; \
! } \
! while(0)
/* Accessor macros for things which may move around */
! #define frag_opcode_frag(X) (X)->fr_targ.fr_ns32k.fr_opcode_fragP
! #define frag_opcode_offset(X) (X)->fr_targ.fr_ns32k.fr_opcode_offset
! #define frag_bsr(X) (X)->fr_targ.fr_ns32k.fr_bsr
#define TC_FIX_TYPE \
struct \
--- 102,135 ----
#define TC_FIX_DATA_PRINT(FILE, TC_FIX) \
! do \
! { \
! fprintf((FILE), "\nopcode_frag=%p operand offset=%d, bsr=%d", \
! (TC_FIX).opcode_fragP, (TC_FIX).opcode_offset, (TC_FIX).bsr); \
! } \
! while(0)
#define TC_FRAG_INIT(X) \
! do \
! { \
! frag_opcode_frag(X) = NULL; \
! frag_opcode_offset(X) = 0; \
! frag_bsr(X) = 0; \
! } \
! while(0)
!
! #define TC_FRAG_TYPE \
! struct { \
! fragS *fr_opcode_fragP; \
! unsigned int fr_opcode_offset; \
! char fr_bsr; \
! }
!
/* Accessor macros for things which may move around */
! #define frag_opcode_frag(X) (X)->tc_frag_data.fr_opcode_fragP
! #define frag_opcode_offset(X) (X)->tc_frag_data.fr_opcode_offset
! #define frag_bsr(X) (X)->tc_frag_data.fr_bsr
#define TC_FIX_TYPE \
struct \
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Target dependent frag fields (proposed change)
[not found] <199711041355.AAA14448.cygnus.gas2@sibyl.chez-dall.org.au>
@ 1997-11-05 13:21 ` Doug Evans
0 siblings, 0 replies; 2+ messages in thread
From: Doug Evans @ 1997-11-05 13:21 UTC (permalink / raw)
To: gas2
Ian.Dall@dsto.defence.gov.au (Ian Dall) writes:
> Following the comments in as.h, I decided to have a look at making the
> fields needed for the ns32k configurable.
>
> This turned out to not be very hard. Basically the problem is that you
> would want targ-*.h to define TC_FRAG_TYPE (like TC_FIX_TYPE for the
> fix structure), but the targ-*.h use the frag structure quite a bit so
> it has to be defined before the targ-*.h.
I checked in something along these lines and will be in the
next snapshot.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1997-11-05 13:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-11-04 5:56 Target dependent frag fields (proposed change) Ian Dall
[not found] <199711041355.AAA14448.cygnus.gas2@sibyl.chez-dall.org.au>
1997-11-05 13:21 ` Doug Evans
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).