73a6e67df5432c4c2d4f4b6eb8dd64a38ff5ca31
[libfirm] / ir / be / beinsn_t.h
1 /*
2  * Copyright (C) 1995-2007 University of Karlsruhe.  All right reserved.
3  *
4  * This file is part of libFirm.
5  *
6  * This file may be distributed and/or modified under the terms of the
7  * GNU General Public License version 2 as published by the Free Software
8  * Foundation and appearing in the file LICENSE.GPL included in the
9  * packaging of this file.
10  *
11  * Licensees holding valid libFirm Professional Edition licenses may use
12  * this file in accordance with the libFirm Commercial License.
13  * Agreement provided with the Software.
14  *
15  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17  * PURPOSE.
18  */
19
20 /**
21  * Instructions
22  *
23  * A data structure to treat nodes and node-proj collections uniformly.
24  */
25
26 #ifndef _BEINSN_T_H
27 #define _BEINSN_T_H
28
29 #include "bitset.h"
30
31 #include "bearch_t.h"
32
33 typedef struct _be_operand_t  be_operand_t;
34 typedef struct _be_insn_t     be_insn_t;
35 typedef struct _be_insn_env_t be_insn_env_t;
36
37 struct _be_operand_t {
38         ir_node *irn;                   /**< firm node of the insn this operand blongs to */
39         ir_node *carrier;               /**< node representing the operand value (proj or the node itself for defs, the value itself for uses */
40         be_operand_t *partner;          /**< used in bechordal later... (TODO what does it do?) */
41         bitset_t *regs;                 /**< admissible register bitset */
42         int pos;                        /**< pos of the operand (0 to n are inputs, -1 to -n are outputs) */
43         const arch_register_req_t *req; /**< register constraints for the carrier node */
44         unsigned has_constraints : 1;   /**< the carrier node has register constraints (the constraint type is limited) */
45 };
46
47 struct _be_insn_t {
48         be_operand_t *ops;             /**< the values used and defined by the insn */
49         int n_ops;                     /**< length of the ops array */
50         int use_start;                 /**< entries [0-use_start) in ops are defs,
51                                             [use_start-n_ops) uses */
52         ir_node *next_insn;            /**< next instruction in schedule */
53         ir_node *irn;                  /**< ir_node of the instruction */
54         unsigned in_constraints  : 1;  /**< instruction has input contraints */
55         unsigned out_constraints : 1;  /**< instruction has output constraints */
56         unsigned has_constraints : 1;  /**< in_constraints or out_constraints true */
57         unsigned pre_colored     : 1;  /**< all defined values already have a register assigned */
58 };
59
60 struct _be_insn_env_t {
61         struct obstack              *obst;
62         const arch_env_t            *aenv;
63         const arch_register_class_t *cls;
64         bitset_t                    *ignore_colors;
65 };
66
67 #define be_insn_n_defs(insn) ((insn)->use_start)
68 #define be_insn_n_uses(insn) ((insn)->n_ops - (insn)->use_start)
69
70 be_insn_t *be_scan_insn(const be_insn_env_t *env, ir_node *irn);
71
72 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);
73
74 #endif /* _BEINSN_T_H */