⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cgen.h

📁 这个是LINUX下的GDB调度工具的源码
💻 H
📖 第 1 页 / 共 4 页
字号:
enum cgen_parse_operand_type{  CGEN_PARSE_OPERAND_INIT,  CGEN_PARSE_OPERAND_INTEGER,  CGEN_PARSE_OPERAND_ADDRESS};/* Values for indicating what was parsed.  */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};#ifdef __BFD_H_SEEN__ /* Don't require bfd.h unnecessarily.  */typedef const char * (cgen_parse_operand_fn)  (CGEN_CPU_DESC,   enum cgen_parse_operand_type, const char **, int, int,   enum cgen_parse_operand_result *, bfd_vma *);#elsetypedef const char * (cgen_parse_operand_fn) ();#endif/* Set the cgen_parse_operand_fn callback.  */extern void cgen_set_parse_operand_fn  (CGEN_CPU_DESC, cgen_parse_operand_fn);/* Called before trying to match a table entry with the insn.  */extern void cgen_init_parse_operand (CGEN_CPU_DESC);/* Operand values (keywords, integers, symbols, etc.)  *//* Types of assembler elements.  */enum cgen_asm_type{  CGEN_ASM_NONE, CGEN_ASM_KEYWORD, CGEN_ASM_MAX};#ifndef CGEN_ARCHenum cgen_hw_type { CGEN_HW_MAX };#endif/* List of hardware elements.  */typedef struct{  char *name;  enum cgen_hw_type type;  /* There is currently no example where both index specs and value specs     are required, so for now both are clumped under "asm_data".  */  enum cgen_asm_type asm_type;  void *asm_data;#ifndef CGEN_HW_NBOOL_ATTRS#define CGEN_HW_NBOOL_ATTRS 1#endif  CGEN_ATTR_TYPE (CGEN_HW_NBOOL_ATTRS) attrs;#define CGEN_HW_ATTRS(hw) (&(hw)->attrs)} CGEN_HW_ENTRY;/* Return value of attribute ATTR in HW.  */#define CGEN_HW_ATTR_VALUE(hw, attr) \CGEN_ATTR_VALUE ((hw), CGEN_HW_ATTRS (hw), (attr))/* Table of hardware elements for selected mach, computed at runtime.   enum cgen_hw_type is an index into this table (specifically `entries').  */typedef struct {  /* Pointer to null terminated table of all compiled in entries.  */  const CGEN_HW_ENTRY *init_entries;  unsigned int entry_size; /* since the attribute member is variable sized */  /* Array of all entries, initial and run-time added.  */  const CGEN_HW_ENTRY **entries;  /* Number of elements in `entries'.  */  unsigned int num_entries;  /* For now, xrealloc is called each time a new entry is added at runtime.     ??? May wish to keep track of some slop to reduce the number of calls to     xrealloc, except that there's unlikely to be many and not expected to be     in speed critical code.  */} CGEN_HW_TABLE;extern const CGEN_HW_ENTRY * cgen_hw_lookup_by_name  (CGEN_CPU_DESC, const char *);extern const CGEN_HW_ENTRY * cgen_hw_lookup_by_num  (CGEN_CPU_DESC, unsigned int);/* This struct is used to describe things like register names, etc.  */typedef struct cgen_keyword_entry{  /* Name (as in register name).  */  char * name;  /* Value (as in register number).     The value cannot be -1 as that is used to indicate "not found".     IDEA: Have "FUNCTION" attribute? [function is called to fetch value].  */  int value;  /* Attributes.     This should, but technically needn't, appear last.  It is a variable sized     array in that one architecture may have 1 nonbool attribute and another     may have more.  Having this last means the non-architecture specific code     needn't care.  The goal is to eventually record     attributes in their raw form, evaluate them at run-time, and cache the     values, so this worry will go away anyway.  */  /* ??? Moving this last should be done by treating keywords like insn lists     and moving the `next' fields into a CGEN_KEYWORD_LIST struct.  */  /* FIXME: Not used yet.  */#ifndef CGEN_KEYWORD_NBOOL_ATTRS#define CGEN_KEYWORD_NBOOL_ATTRS 1#endif  CGEN_ATTR_TYPE (CGEN_KEYWORD_NBOOL_ATTRS) attrs;  /* ??? Putting these here means compiled in entries can't be const.     Not a really big deal, but something to consider.  */  /* Next name hash table entry.  */  struct cgen_keyword_entry *next_name;  /* Next value hash table entry.  */  struct cgen_keyword_entry *next_value;} CGEN_KEYWORD_ENTRY;/* Top level struct for describing a set of related keywords   (e.g. register names).   This struct supports run-time entry of new values, and hashed lookups.  */typedef struct cgen_keyword{  /* Pointer to initial [compiled in] values.  */  CGEN_KEYWORD_ENTRY *init_entries;    /* Number of entries in `init_entries'.  */  unsigned int num_init_entries;    /* Hash table used for name lookup.  */  CGEN_KEYWORD_ENTRY **name_hash_table;    /* Hash table used for value lookup.  */  CGEN_KEYWORD_ENTRY **value_hash_table;    /* Number of entries in the hash_tables.  */  unsigned int hash_table_size;    /* Pointer to null keyword "" entry if present.  */  const CGEN_KEYWORD_ENTRY *null_entry;  /* String containing non-alphanumeric characters used     in keywords.       At present, the highest number of entries used is 1.  */  char nonalpha_chars[8];} CGEN_KEYWORD;/* Structure used for searching.  */typedef struct{  /* Table being searched.  */  const CGEN_KEYWORD *table;    /* Specification of what is being searched for.  */  const char *spec;    /* Current index in hash table.  */  unsigned int current_hash;    /* Current element in current hash chain.  */  CGEN_KEYWORD_ENTRY *current_entry;} CGEN_KEYWORD_SEARCH;/* Lookup a keyword from its name.  */const CGEN_KEYWORD_ENTRY *cgen_keyword_lookup_name  (CGEN_KEYWORD *, const char *);/* Lookup a keyword from its value.  */const CGEN_KEYWORD_ENTRY *cgen_keyword_lookup_value  (CGEN_KEYWORD *, int);/* Add a keyword.  */void cgen_keyword_add (CGEN_KEYWORD *, CGEN_KEYWORD_ENTRY *);/* Keyword searching.   This can be used to retrieve every keyword, or a subset.  */CGEN_KEYWORD_SEARCH cgen_keyword_search_init  (CGEN_KEYWORD *, const char *);const CGEN_KEYWORD_ENTRY *cgen_keyword_search_next  (CGEN_KEYWORD_SEARCH *);/* Operand value support routines.  */extern const char *cgen_parse_keyword  (CGEN_CPU_DESC, const char **, CGEN_KEYWORD *, long *);#ifdef __BFD_H_SEEN__ /* Don't require bfd.h unnecessarily.  */extern const char *cgen_parse_signed_integer  (CGEN_CPU_DESC, const char **, int, long *);extern const char *cgen_parse_unsigned_integer  (CGEN_CPU_DESC, const char **, int, unsigned long *);extern const char *cgen_parse_address  (CGEN_CPU_DESC, const char **, int, int,   enum cgen_parse_operand_result *, bfd_vma *);extern const char *cgen_validate_signed_integer  (long, long, long);extern const char *cgen_validate_unsigned_integer  (unsigned long, unsigned long, unsigned long);#endif/* Operand modes.  *//* ??? This duplicates the values in arch.h.  Revisit.   These however need the CGEN_ prefix [as does everything in this file].  *//* ??? Targets may need to add their own modes so we may wish to move this   to <arch>-opc.h, or add a hook.  */enum cgen_mode {  CGEN_MODE_VOID, /* ??? rename simulator's VM to VOID? */  CGEN_MODE_BI, CGEN_MODE_QI, CGEN_MODE_HI, CGEN_MODE_SI, CGEN_MODE_DI,  CGEN_MODE_UBI, CGEN_MODE_UQI, CGEN_MODE_UHI, CGEN_MODE_USI, CGEN_MODE_UDI,  CGEN_MODE_SF, CGEN_MODE_DF, CGEN_MODE_XF, CGEN_MODE_TF,  CGEN_MODE_TARGET_MAX,  CGEN_MODE_INT, CGEN_MODE_UINT,  CGEN_MODE_MAX};/* FIXME: Until simulator is updated.  */#define CGEN_MODE_VM CGEN_MODE_VOID/* Operands.  */#ifndef CGEN_ARCHenum cgen_operand_type { CGEN_OPERAND_MAX };#endif/* "nil" indicator for the operand instance table */#define CGEN_OPERAND_NIL CGEN_OPERAND_MAX/* A tree of these structs represents the multi-ifield   structure of an operand's hw-index value, if it exists.  */struct cgen_ifld;typedef struct cgen_maybe_multi_ifield{  int count; /* 0: indexed by single cgen_ifld (possibly null: dead entry);		n: indexed by array of more cgen_maybe_multi_ifields.  */  union  {    const void *p;    const struct cgen_maybe_multi_ifield * multi;    const struct cgen_ifld * leaf;  } val;}CGEN_MAYBE_MULTI_IFLD;/* This struct defines each entry in the operand table.  */typedef struct{  /* Name as it appears in the syntax string.  */  char *name;  /* Operand type.  */  enum cgen_operand_type type;  /* 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;  /* The (possibly-multi) ifield used as an index for this operand, if it     is indexed by a field at all. This substitutes / extends the start and     length fields above, but unsure at this time whether they are used     anywhere.  */  CGEN_MAYBE_MULTI_IFLD index_fields;#if 0 /* ??? Interesting idea but relocs tend to get too complicated,	 and ABI dependent, for simple table lookups to work.  */  /* Ideally this would be the internal (external?) reloc type.  */  int reloc_type;#endif  /* Attributes.     This should, but technically needn't, appear last.  It is a variable sized     array in that one architecture may have 1 nonbool attribute and another     may have more.  Having this last means the non-architecture specific code     needn't care, now or tomorrow.  The goal is to eventually record     attributes in their raw form, evaluate them at run-time, and cache the     values, so this worry will go away anyway.  */#ifndef CGEN_OPERAND_NBOOL_ATTRS#define CGEN_OPERAND_NBOOL_ATTRS 1#endif  CGEN_ATTR_TYPE (CGEN_OPERAND_NBOOL_ATTRS) attrs;#define CGEN_OPERAND_ATTRS(operand) (&(operand)->attrs)} CGEN_OPERAND;/* Return value of attribute ATTR in OPERAND.  */#define CGEN_OPERAND_ATTR_VALUE(operand, attr) \CGEN_ATTR_VALUE ((operand), CGEN_OPERAND_ATTRS (operand), (attr))/* Table of operands for selected mach/isa, computed at runtime.   enum cgen_operand_type is an index into this table (specifically   `entries').  */typedef struct {  /* Pointer to null terminated table of all compiled in entries.  */  const CGEN_OPERAND *init_entries;  unsigned int entry_size; /* since the attribute member is variable sized */  /* Array of all entries, initial and run-time added.  */  const CGEN_OPERAND **entries;  /* Number of elements in `entries'.  */  unsigned int num_entries;  /* For now, xrealloc is called each time a new entry is added at runtime.     ??? May wish to keep track of some slop to reduce the number of calls to     xrealloc, except that there's unlikely to be many and not expected to be     in speed critical code.  */} CGEN_OPERAND_TABLE;extern const CGEN_OPERAND * cgen_operand_lookup_by_name  (CGEN_CPU_DESC, const char *);extern const CGEN_OPERAND * cgen_operand_lookup_by_num  (CGEN_CPU_DESC, int);/* Instruction operand instances.   For each instruction, a list of the hardware elements that are read and   written are recorded.  *//* The type of the instance.  */enum cgen_opinst_type {  /* End of table marker.  */  CGEN_OPINST_END = 0,  CGEN_OPINST_INPUT, CGEN_OPINST_OUTPUT};typedef struct{  /* Input or output indicator.  */  enum cgen_opinst_type type;  /* Name of operand.  */  const char *name;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -