Formatting changes to improve readability.

This commit is contained in:
Nick Clifton
1998-01-15 01:24:03 +00:00
parent bb3d9f43d3
commit b61df0261f
2 changed files with 97 additions and 55 deletions

View File

@ -1,3 +1,7 @@
Wed Jan 14 17:21:43 1998 Nick Clifton <nickc@cygnus.com>
* cgen.h: Formatting changes to improve readability.
Mon Jan 12 11:37:36 1998 Doug Evans <devans@seba.cygnus.com> Mon Jan 12 11:37:36 1998 Doug Evans <devans@seba.cygnus.com>
* cgen.h (*): Clean up pass over `struct foo' usage. * cgen.h (*): Clean up pass over `struct foo' usage.

View File

@ -60,7 +60,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#ifdef CGEN_INT_INSN #ifdef CGEN_INT_INSN
typedef unsigned int cgen_insn_t; typedef unsigned int cgen_insn_t;
#else #else
typedef char *cgen_insn_t; typedef char * cgen_insn_t;
#endif #endif
#ifdef __GNUC__ #ifdef __GNUC__
@ -71,7 +71,8 @@ typedef char *cgen_insn_t;
/* Perhaps we should just use bfd.h, but it's not clear /* Perhaps we should just use bfd.h, but it's not clear
one would want to require that yet. */ one would want to require that yet. */
enum cgen_endian { enum cgen_endian
{
CGEN_ENDIAN_UNKNOWN, CGEN_ENDIAN_UNKNOWN,
CGEN_ENDIAN_LITTLE, CGEN_ENDIAN_LITTLE,
CGEN_ENDIAN_BIG CGEN_ENDIAN_BIG
@ -81,7 +82,8 @@ enum cgen_endian {
Attributes are used to describe various random things. */ Attributes are used to describe various random things. */
/* Struct to record attribute information. */ /* Struct to record attribute information. */
typedef struct { typedef struct
{
unsigned char num_nonbools; unsigned char num_nonbools;
unsigned int bool; unsigned int bool;
unsigned int nonbool[1]; unsigned int nonbool[1];
@ -112,17 +114,19 @@ const struct { unsigned char num_nonbools; \
/* Attribute name/value tables. /* Attribute name/value tables.
These are used to assist parsing of descriptions at runtime. */ These are used to assist parsing of descriptions at runtime. */
typedef struct { typedef struct
const char *name; {
int value; const char * name;
int value;
} CGEN_ATTR_ENTRY; } CGEN_ATTR_ENTRY;
/* For each domain (fld,operand,insn), list of attributes. */ /* For each domain (fld,operand,insn), list of attributes. */
typedef struct { typedef struct
const char *name; {
const char * name;
/* NULL for boolean attributes. */ /* NULL for boolean attributes. */
const CGEN_ATTR_ENTRY *vals; const CGEN_ATTR_ENTRY * vals;
} CGEN_ATTR_TABLE; } CGEN_ATTR_TABLE;
/* Parse result (also extraction result). /* Parse result (also extraction result).
@ -234,7 +238,8 @@ extern cgen_print_fn * CGEN_SYM (print_handlers) [];
#define CGEN_MAX_INSN_ATTRS 1 #define CGEN_MAX_INSN_ATTRS 1
#endif #endif
struct cgen_base { struct cgen_base
{
/* Indices into the handler tables. /* Indices into the handler tables.
We could use pointers here instead, but in the case of the insn table, We could use pointers here instead, but in the case of the insn table,
90% of them would be identical and that's a lot of redundant data. 90% of them would be identical and that's a lot of redundant data.
@ -266,16 +271,21 @@ struct cgen_base {
The parsed value is stored in the bfd_vma *. */ The parsed value is stored in the bfd_vma *. */
/* Values for indicating what the caller wants. */ /* Values for indicating what the caller wants. */
enum cgen_parse_operand_type { enum cgen_parse_operand_type
CGEN_PARSE_OPERAND_INIT, CGEN_PARSE_OPERAND_INTEGER, {
CGEN_PARSE_OPERAND_INIT,
CGEN_PARSE_OPERAND_INTEGER,
CGEN_PARSE_OPERAND_ADDRESS CGEN_PARSE_OPERAND_ADDRESS
}; };
/* Values for indicating what was parsed. /* Values for indicating what was parsed.
??? Not too useful at present but in time. */ ??? Not too useful at present but in time. */
enum cgen_parse_operand_result { enum cgen_parse_operand_result
CGEN_PARSE_OPERAND_RESULT_NUMBER, CGEN_PARSE_OPERAND_RESULT_REGISTER, {
CGEN_PARSE_OPERAND_RESULT_QUEUED, CGEN_PARSE_OPERAND_RESULT_ERROR CGEN_PARSE_OPERAND_RESULT_NUMBER,
CGEN_PARSE_OPERAND_RESULT_REGISTER,
CGEN_PARSE_OPERAND_RESULT_QUEUED,
CGEN_PARSE_OPERAND_RESULT_ERROR
}; };
/* Don't require bfd.h unnecessarily. */ /* Don't require bfd.h unnecessarily. */
@ -320,22 +330,24 @@ void cgen_asm_finish_insn PARAMS ((const struct cgen_insn *, cgen_insn_t *,
/* Types of assembler elements. */ /* Types of assembler elements. */
enum cgen_asm_type { enum cgen_asm_type
{
CGEN_ASM_KEYWORD, CGEN_ASM_MAX CGEN_ASM_KEYWORD, CGEN_ASM_MAX
}; };
/* List of hardware elements. */ /* List of hardware elements. */
typedef struct cgen_hw_entry { typedef struct cgen_hw_entry
struct cgen_hw_entry *next; {
char *name; struct cgen_hw_entry * next;
enum cgen_asm_type asm_type; char * name;
PTR asm_data; enum cgen_asm_type asm_type;
PTR asm_data;
} CGEN_HW_ENTRY; } CGEN_HW_ENTRY;
extern CGEN_HW_ENTRY *CGEN_SYM (hw_list); extern CGEN_HW_ENTRY * CGEN_SYM (hw_list);
CGEN_HW_ENTRY *cgen_hw_lookup PARAMS ((const char *)); CGEN_HW_ENTRY * cgen_hw_lookup PARAMS ((const char *));
#ifndef CGEN_MAX_KEYWORD_ATTRS #ifndef CGEN_MAX_KEYWORD_ATTRS
#define CGEN_MAX_KEYWORD_ATTRS 1 #define CGEN_MAX_KEYWORD_ATTRS 1
@ -343,9 +355,10 @@ CGEN_HW_ENTRY *cgen_hw_lookup PARAMS ((const char *));
/* This struct is used to describe things like register names, etc. */ /* This struct is used to describe things like register names, etc. */
typedef struct cgen_keyword_entry { typedef struct cgen_keyword_entry
{
/* Name (as in register name). */ /* Name (as in register name). */
char *name; char * name;
/* Value (as in register number). /* Value (as in register number).
The value cannot be -1 as that is used to indicate "not found". The value cannot be -1 as that is used to indicate "not found".
@ -373,32 +386,42 @@ typedef struct cgen_keyword_entry {
This struct supports runtime entry of new values, and hashed lookups. */ This struct supports runtime entry of new values, and hashed lookups. */
typedef struct { typedef struct cgen_keyword
{
/* Pointer to initial [compiled in] values. */ /* Pointer to initial [compiled in] values. */
CGEN_KEYWORD_ENTRY *init_entries; CGEN_KEYWORD_ENTRY * init_entries;
/* Number of entries in `init_entries'. */ /* Number of entries in `init_entries'. */
unsigned int num_init_entries; unsigned int num_init_entries;
/* Hash table used for name lookup. */ /* Hash table used for name lookup. */
CGEN_KEYWORD_ENTRY **name_hash_table; CGEN_KEYWORD_ENTRY ** name_hash_table;
/* Hash table used for value lookup. */ /* Hash table used for value lookup. */
CGEN_KEYWORD_ENTRY **value_hash_table; CGEN_KEYWORD_ENTRY ** value_hash_table;
/* Number of entries in the hash_tables. */ /* Number of entries in the hash_tables. */
unsigned int hash_table_size; unsigned int hash_table_size;
/* Pointer to null keyword "" entry if present. */ /* Pointer to null keyword "" entry if present. */
const CGEN_KEYWORD_ENTRY *null_entry; const CGEN_KEYWORD_ENTRY * null_entry;
} CGEN_KEYWORD; } CGEN_KEYWORD;
/* Structure used for searching. */ /* Structure used for searching. */
typedef struct { typedef struct
{
/* Table being searched. */ /* Table being searched. */
const CGEN_KEYWORD *table; const CGEN_KEYWORD * table;
/* Specification of what is being searched for. */ /* Specification of what is being searched for. */
const char *spec; const char * spec;
/* Current index in hash table. */ /* Current index in hash table. */
unsigned int current_hash; unsigned int current_hash;
/* Current element in current hash chain. */ /* Current element in current hash chain. */
CGEN_KEYWORD_ENTRY *current_entry; CGEN_KEYWORD_ENTRY * current_entry;
} CGEN_KEYWORD_SEARCH; } CGEN_KEYWORD_SEARCH;
/* Lookup a keyword from its name. */ /* Lookup a keyword from its name. */
@ -441,9 +464,10 @@ const char * cgen_validate_unsigned_integer PARAMS ((unsigned long,
#define CGEN_MAX_OPERAND_ATTRS 1 #define CGEN_MAX_OPERAND_ATTRS 1
#endif #endif
typedef struct { typedef struct cgen_operand
{
/* Name as it appears in the syntax string. */ /* Name as it appears in the syntax string. */
char *name; char * name;
/* Bit position (msb of first byte = bit 0). /* Bit position (msb of first byte = bit 0).
This is just a hint, and may be unused in more complex operands. This is just a hint, and may be unused in more complex operands.
@ -497,7 +521,8 @@ enum cgen_operand_type;
#define CGEN_MAX_SYNTAX_BYTES 16 #define CGEN_MAX_SYNTAX_BYTES 16
#endif #endif
typedef struct { typedef struct
{
unsigned char syntax[CGEN_MAX_SYNTAX_BYTES]; unsigned char syntax[CGEN_MAX_SYNTAX_BYTES];
} CGEN_SYNTAX; } CGEN_SYNTAX;
@ -520,7 +545,8 @@ typedef struct {
This cuts down on the size of the opcode table as there are relatively few This cuts down on the size of the opcode table as there are relatively few
formats compared with the number of instructions. */ formats compared with the number of instructions. */
typedef struct { typedef struct
{
/* Length that MASK and VALUE have been calculated to /* Length that MASK and VALUE have been calculated to
[VALUE is recorded elsewhere]. [VALUE is recorded elsewhere].
Normally it is CGEN_BASE_INSN_BITSIZE. On [V]LIW architectures where Normally it is CGEN_BASE_INSN_BITSIZE. On [V]LIW architectures where
@ -540,37 +566,39 @@ typedef struct {
/* This struct defines each entry in the instruction table. */ /* This struct defines each entry in the instruction table. */
struct cgen_insn { struct cgen_insn
{
/* ??? Further table size reductions can be had by moving this element /* ??? Further table size reductions can be had by moving this element
either to the format table or to a separate table of its own. Not either to the format table or to a separate table of its own. Not
sure this is desirable yet. */ sure this is desirable yet. */
struct cgen_base base; struct cgen_base base;
/* Given a pointer to a cgen_insn struct, return a pointer to `base'. */ /* Given a pointer to a cgen_insn struct, return a pointer to `base'. */
#define CGEN_INSN_BASE(insn) (&(insn)->base) #define CGEN_INSN_BASE(insn) (&(insn)->base)
/* Name of entry (that distinguishes it from all other entries). /* Name of entry (that distinguishes it from all other entries).
This is used, for example, in simulator profiling results. */ This is used, for example, in simulator profiling results. */
/* ??? If mnemonics have operands, try to print full mnemonic. */ /* ??? If mnemonics have operands, try to print full mnemonic. */
const char *name; const char * name;
#define CGEN_INSN_NAME(insn) ((insn)->name) #define CGEN_INSN_NAME(insn) ((insn)->name)
/* Mnemonic. This is used when parsing and printing the insn. /* Mnemonic. This is used when parsing and printing the insn.
In the case of insns that have operands on the mnemonics, this is In the case of insns that have operands on the mnemonics, this is
only the constant part. E.g. for conditional execution of an `add' insn, only the constant part. E.g. for conditional execution of an `add' insn,
where the full mnemonic is addeq, addne, etc., this is only "add". */ where the full mnemonic is addeq, addne, etc., this is only "add". */
const char *mnemonic; const char * mnemonic;
#define CGEN_INSN_MNEMONIC(insn) ((insn)->mnemonic) #define CGEN_INSN_MNEMONIC(insn) ((insn)->mnemonic)
/* Syntax string. /* Syntax string.
For now this only points to CGEN_SYNTAX elements, but it can point For now this only points to CGEN_SYNTAX elements, but it can point
to other things (e.g. something different for macros?). */ to other things (e.g. something different for macros?). */
const CGEN_SYNTAX *syntax; const CGEN_SYNTAX * syntax;
#define CGEN_INSN_SYNTAX(insn) ((CGEN_SYNTAX *) (insn)->syntax) #define CGEN_INSN_SYNTAX(insn) ((CGEN_SYNTAX *) (insn)->syntax)
/* Format entry. /* Format entry.
For now this only points to CGEN_FORMAT elements, but it can point For now this only points to CGEN_FORMAT elements, but it can point
to other things (e.g. something different for macros?). */ to other things (e.g. something different for macros?). */
const CGEN_FORMAT *format; const CGEN_FORMAT * format;
#define CGEN_INSN_MASK_BITSIZE(insn) (((CGEN_FORMAT *) (insn)->format)->mask_length) #define CGEN_INSN_MASK_BITSIZE(insn) (((CGEN_FORMAT *) (insn)->format)->mask_length)
#define CGEN_INSN_BITSIZE(insn) (((CGEN_FORMAT *) (insn)->format)->length) #define CGEN_INSN_BITSIZE(insn) (((CGEN_FORMAT *) (insn)->format)->length)
@ -594,28 +622,37 @@ CGEN_ATTR_VALUE (insn, CGEN_INSN_ATTRS (insn), attr)
/* Instruction lists. /* Instruction lists.
This is used for adding new entries and for creating the hash lists. */ This is used for adding new entries and for creating the hash lists. */
typedef struct cgen_insn_list { typedef struct cgen_insn_list
struct cgen_insn_list *next; {
const CGEN_INSN *insn; struct cgen_insn_list * next;
const CGEN_INSN * insn;
} CGEN_INSN_LIST; } CGEN_INSN_LIST;
/* The table of instructions. */ /* The table of instructions. */
typedef struct { typedef struct
{
/* Pointer to initial [compiled in] entries. */ /* Pointer to initial [compiled in] entries. */
const CGEN_INSN *init_entries; const CGEN_INSN * init_entries;
/* Size of an entry (since the attribute member is variable sized). */ /* Size of an entry (since the attribute member is variable sized). */
unsigned int entry_size; unsigned int entry_size;
/* Number of entries in `init_entries', including trailing NULL entry. */ /* Number of entries in `init_entries', including trailing NULL entry. */
unsigned int num_init_entries; unsigned int num_init_entries;
/* Values added at runtime. */ /* Values added at runtime. */
CGEN_INSN_LIST *new_entries; CGEN_INSN_LIST * new_entries;
/* Assembler hash function. */ /* Assembler hash function. */
unsigned int (*asm_hash) PARAMS ((const char *)); unsigned int (* asm_hash) PARAMS ((const char *));
/* Number of entries in assembler hash table. */ /* Number of entries in assembler hash table. */
unsigned int asm_hash_table_size; unsigned int asm_hash_table_size;
/* Disassembler hash function. */ /* Disassembler hash function. */
unsigned int (*dis_hash) PARAMS ((const char *, unsigned long)); unsigned int (* dis_hash) PARAMS ((const char *, unsigned long));
/* Number of entries in disassembler hash table. */ /* Number of entries in disassembler hash table. */
unsigned int dis_hash_table_size; unsigned int dis_hash_table_size;
} CGEN_INSN_TABLE; } CGEN_INSN_TABLE;
@ -673,10 +710,11 @@ CGEN_INSN_LIST * cgen_dis_lookup_insn PARAMS ((const char *, unsigned long));
/* Top level structures and functions. */ /* Top level structures and functions. */
typedef struct { typedef struct
CGEN_HW_ENTRY *hw_list; {
/*CGEN_OPERAND_TABLE *operand_table; - FIXME:wip */ CGEN_HW_ENTRY * hw_list;
CGEN_INSN_TABLE *insn_table; /*CGEN_OPERAND_TABLE * operand_table; - FIXME:wip */
CGEN_INSN_TABLE * insn_table;
} CGEN_OPCODE_DATA; } CGEN_OPCODE_DATA;
/* Each CPU has one of these. */ /* Each CPU has one of these. */