diff options
author | Damien Lespiau <damien.lespiau@intel.com> | 2013-01-21 19:28:41 +0000 |
---|---|---|
committer | Damien Lespiau <damien.lespiau@intel.com> | 2013-03-04 15:54:38 +0000 |
commit | a45a47183a98e07f7a44330cd68bf65fec8d6dea (patch) | |
tree | 7192a15ac245a9d340b429d5efaca1e8d185008b /assembler/gen4asm.h | |
parent | 73d58edab9fca04d9b00f9e1a9095bbbb00f25a4 (diff) |
assembler: Make explicit that labels are part of the instructions list
The output of the parsing is a list of struct brw_program_instruction.
These instructions can be either GEN instructions aka struct
brw_instruction or labels. To make this more explicit we now have a type
to test to determine which instruction we are dealing with.
This will also allow to to pull the relocation bits into struct
brw_program_instruction instead of having them in the structure
representing the opcodes.
Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
Diffstat (limited to 'assembler/gen4asm.h')
-rw-r--r-- | assembler/gen4asm.h | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/assembler/gen4asm.h b/assembler/gen4asm.h index a2ab5e8b..aa380e1d 100644 --- a/assembler/gen4asm.h +++ b/assembler/gen4asm.h @@ -30,6 +30,8 @@ #define __GEN4ASM_H__ #include <inttypes.h> +#include <stdbool.h> +#include <assert.h> typedef unsigned char GLubyte; typedef short GLshort; @@ -133,18 +135,40 @@ typedef struct { } u; } imm32_t; +enum assembler_instruction_type { + GEN4ASM_INSTRUCTION_GEN, + GEN4ASM_INSTRUCTION_LABEL, +}; + +struct label_instruction { + char *name; +}; + /** * This structure is just the list container for instructions accumulated by * the parser and labels. */ struct brw_program_instruction { - struct brw_instruction instruction; - struct brw_program_instruction *next; - GLuint islabel; - GLuint inst_offset; - char *string; + enum assembler_instruction_type type; + unsigned inst_offset; + union { + struct brw_instruction gen; + struct label_instruction label; + } instruction; + struct brw_program_instruction *next; }; +static inline bool is_label(struct brw_program_instruction *instruction) +{ + return instruction->type == GEN4ASM_INSTRUCTION_LABEL; +} + +static inline char *label_name(struct brw_program_instruction *i) +{ + assert(is_label(i)); + return i->instruction.label.name; +} + /** * This structure is a list of instructions. It is the final output of the * parser. @@ -188,7 +212,7 @@ struct declared_register { }; struct declared_register *find_register(char *name); void insert_register(struct declared_register *reg); -void add_label(char *name, int addr); +void add_label(struct brw_program_instruction *instruction); int label_to_addr(char *name, int start_addr); int yyparse(void); |