The big committ:
[libfirm] / ir / be / beinsn_t.h
1 /**
2  * Instructions
3  *
4  * A data structure to treat nodes and node-proj collections uniformly.
5  */
6
7 #ifndef _BEINSN_T_H
8 #define _BEINSN_T_H
9
10 #include "bitset.h"
11
12 #include "bearch.h"
13
14 typedef struct _be_operand_t  be_operand_t;
15 typedef struct _be_insn_t     be_insn_t;
16 typedef struct _be_insn_env_t be_insn_env_t;
17
18 struct _be_operand_t {
19         ir_node *irn;                   /**< firm node of the insn this operand blongs to */
20         ir_node *carrier;               /**< node representing the operand value (proj or the node itself for defs, the value itself for uses */
21         be_operand_t *partner;          /**< used in bechordal later... (TODO what does it do?) */
22         bitset_t *regs;                 /**< admissible register bitset */
23         int pos;                        /**< pos of the operand (0 to n are inputs, -1 to -n are outputs) */
24         const arch_register_req_t *req; /**< register constraints for the carrier node */
25         unsigned has_constraints : 1;   /**< the carrier node has register constraints (the constraint type is limited) */
26 };
27
28 struct _be_insn_t {
29         be_operand_t *ops;             /**< the values used and defined by the insn */
30         int n_ops;                     /**< length of the ops array */
31         int use_start;                 /**< entries [0-use_start) in ops are defs,
32                                             [use_start-n_ops) uses */
33         ir_node *next_insn;            /**< next instruction in schedule */
34         ir_node *irn;                  /**< ir_node of the instruction */
35         unsigned in_constraints  : 1;  /**< instruction has input contraints */
36         unsigned out_constraints : 1;  /**< instruction has output constraints */
37         unsigned has_constraints : 1;  /**< in_constraints or out_constraints true */
38         unsigned pre_colored     : 1;  /**< all defined values already have a register assigned */
39 };
40
41 struct _be_insn_env_t {
42         struct obstack              *obst;
43         const arch_env_t            *aenv;
44         const arch_register_class_t *cls;
45         bitset_t                    *ignore_colors;
46 };
47
48 #define be_insn_n_defs(insn) ((insn)->use_start)
49 #define be_insn_n_uses(insn) ((insn)->n_ops - (insn)->use_start)
50
51 be_insn_t *be_scan_insn(const be_insn_env_t *env, ir_node *irn);
52
53 be_insn_env_t *be_insn_env_init(be_insn_env_t *ie, const be_irg_t *birg, const arch_register_class_t *cls, struct obstack *obst);
54
55 #endif /* _BEINSN_T_H */