31308ec114f10bc60a57a4477f1e3c67d791a333
[libfirm] / ir / be / bearch.h
1 /*
2  * Copyright (C) 1995-2008 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  * @file
22  * @brief       Processor architecture specification.
23  * @author      Sebastian Hack
24  * @version     $Id$
25  */
26 #ifndef FIRM_BE_BEARCH_H
27 #define FIRM_BE_BEARCH_H
28
29 #include <stdbool.h>
30
31 #include "firm_types.h"
32 #include "bitset.h"
33 #include "obst.h"
34 #include "raw_bitset.h"
35
36 #include "be_types.h"
37 #include "beinfo.h"
38 #include "be.h"
39 #include "beirg.h"
40
41 typedef enum arch_register_class_flags_t {
42         arch_register_class_flag_none      = 0,
43         arch_register_class_flag_manual_ra = 1,  /**< don't do automatic register allocation for this class */
44         arch_register_class_flag_state     = 2
45 } arch_register_class_flags_t;
46
47 typedef enum arch_register_type_t {
48         arch_register_type_none         = 0,
49         arch_register_type_caller_save  = 1,  /**< The register must be saved by the caller
50                                                    upon a function call. It thus can be overwritten
51                                                    in the called function. */
52         arch_register_type_callee_save  = 2,  /**< The register must be saved by the caller
53                                                    upon a function call. It thus can be overwritten
54                                                    in the called function. */
55         arch_register_type_ignore       = 4,  /**< Do not consider this register when allocating. */
56         arch_register_type_joker        = 8,  /**< The emitter can choose an arbitrary register */
57         arch_register_type_virtual      = 16, /**< This is just a virtual register.Virtual registers have
58                                                    nearly no constraints, it is a allowed to have multiple
59                                                    definition for the same register at a point) */
60         arch_register_type_state        = 32, /**< The register represents a state that should be handled by
61                                                    bestate code */
62 } arch_register_type_t;
63
64 /**
65  * Different types of register allocation requirements.
66  */
67 typedef enum arch_register_req_type_t {
68         arch_register_req_type_none              = 0, /**< No register requirement. */
69         arch_register_req_type_normal            = 1U << 0, /**< All registers in the class are allowed. */
70         arch_register_req_type_limited           = 1U << 1, /**< Only a real subset of the class is allowed. */
71         arch_register_req_type_should_be_same    = 1U << 2, /**< The register should be equal to another one at the node. */
72         arch_register_req_type_must_be_different = 1U << 3, /**< The register must be unequal from some other at the node. */
73         arch_register_req_type_ignore            = 1U << 4, /**< ignore while allocating registers */
74         arch_register_req_type_produces_sp       = 1U << 5, /**< the output produces a new value for the stack pointer */
75 } arch_register_req_type_t;
76
77 extern const arch_register_req_t *arch_no_register_req;
78
79 /**
80  * Format a register requirements information into a string.
81  * @param buf The string where to put it to.
82  * @param len The size of @p buf.
83  * @param req The requirements structure to format.
84  * @return    A pointer to buf.
85  */
86 extern char *arch_register_req_format(char *buf, size_t len, const arch_register_req_t *req, const ir_node *node);
87
88 /**
89  * Node classification. Mainly used for statistics.
90  */
91 typedef enum arch_irn_class_t {
92         arch_irn_class_spill  = 1 << 0,
93         arch_irn_class_reload = 1 << 1,
94         arch_irn_class_remat  = 1 << 2,
95         arch_irn_class_copy   = 1 << 3,
96         arch_irn_class_perm   = 1 << 4
97 } arch_irn_class_t;
98
99 void arch_set_frame_offset(ir_node *irn, int bias);
100
101 ir_entity *arch_get_frame_entity(const ir_node *irn);
102 void       arch_set_frame_entity(ir_node *irn, ir_entity *ent);
103 int        arch_get_sp_bias(ir_node *irn);
104
105 int             arch_get_op_estimated_cost(const ir_node *irn);
106 arch_inverse_t *arch_get_inverse(const ir_node *irn, int i, arch_inverse_t *inverse, struct obstack *obstack);
107 int             arch_possible_memory_operand(const ir_node *irn, unsigned int i);
108 void            arch_perform_memory_operand(ir_node *irn, ir_node *spill, unsigned int i);
109
110 /**
111  * Get the register requirements for a node.
112  * @param irn The node.
113  * @param pos The position of the operand you're interested in.
114  * @return    A pointer to the register requirements.  If NULL is returned, the
115  *            operand was no register operand.
116  */
117 const arch_register_req_t *arch_get_register_req(const ir_node *irn, int pos);
118 const arch_register_req_t *arch_get_register_req_out(const ir_node *irn);
119
120 /**
121  * Put all registers which shall not be ignored by the register
122  * allocator in a bit set.
123  * @param cls The register class to consider.
124  * @param bs  The bit set to put the registers to.
125  */
126 extern void arch_put_non_ignore_regs(const arch_register_class_t *cls, bitset_t *bs);
127
128 /**
129  * Check, if a register is assignable to an operand of a node.
130  * @param irn The node.
131  * @param pos The position of the operand.
132  * @param reg The register.
133  * @return    1, if the register might be allocated to the operand 0 if not.
134  */
135 int arch_reg_is_allocatable(const ir_node *irn, int pos, const arch_register_t *reg);
136
137 #define arch_reg_out_is_allocatable(irn, reg) arch_reg_is_allocatable(irn, -1, reg)
138
139 /**
140  * Get the register class of an operand of a node.
141  * @param irn The node.
142  * @param pos The position of the operand, -1 for the output.
143  * @return    The register class of the operand or NULL, if
144  *            operand is a non-register operand.
145  */
146 const arch_register_class_t *arch_get_irn_reg_class(const ir_node *irn, int pos);
147
148 #define arch_get_irn_reg_class_out(irn) arch_get_irn_reg_class(irn, -1)
149
150 /**
151  * Get the register allocated at a certain output operand of a node.
152  * @param irn The node.
153  * @return    The register allocated for this operand
154  */
155 const arch_register_t *arch_get_irn_register(const ir_node *irn);
156 const arch_register_t *arch_irn_get_register(const ir_node *irn, int pos);
157
158 /**
159  * Set the register for a certain output operand.
160  * @param irn The node.
161  * @param reg The register.
162  */
163 void arch_set_irn_register(ir_node *irn, const arch_register_t *reg);
164 void arch_irn_set_register(ir_node *irn, int pos, const arch_register_t *reg);
165
166 /**
167  * Classify a node.
168  * @param irn The node.
169  * @return A classification of the node.
170  */
171 arch_irn_class_t arch_irn_classify(const ir_node *irn);
172
173 #define arch_irn_class_is(irn, irn_class) ((arch_irn_classify(irn) & arch_irn_class_ ## irn_class) != 0)
174
175 /**
176  * Get the flags of a node.
177  * @param irn The node.
178  * @return The flags.
179  */
180 arch_irn_flags_t arch_irn_get_flags(const ir_node *irn);
181
182 void arch_irn_set_flags(ir_node *node, arch_irn_flags_t flags);
183 void arch_irn_add_flags(ir_node *node, arch_irn_flags_t flags);
184
185 #define arch_irn_is(irn, flag) ((arch_irn_get_flags(irn) & arch_irn_flags_ ## flag) != 0)
186
187 /**
188  * Get the operations of an irn.
189  * @param self The handler from which the method is invoked.
190  * @param irn Some node.
191  * @return Operations for that irn.
192  */
193 typedef const void *(arch_get_irn_ops_t)(const ir_node *irn);
194
195 /**
196  * Initialize the architecture environment struct.
197  * @param isa           The isa which shall be put into the environment.
198  * @param file_handle   The file handle
199  * @return The environment.
200  */
201 extern arch_env_t *arch_env_init(const arch_isa_if_t *isa,
202                                  FILE *file_handle, be_main_env_t *main_env);
203
204 /**
205  * Register an instruction set architecture
206  */
207 void be_register_isa_if(const char *name, const arch_isa_if_t *isa);
208
209 /**
210  * A register.
211  */
212 struct arch_register_t {
213         const char                  *name;        /**< The name of the register. */
214         const arch_register_class_t *reg_class;   /**< The class the register belongs to. */
215         unsigned                    index;        /**< The index of the register in the class. */
216         arch_register_type_t        type;         /**< The type of the register. */
217 };
218
219 static inline const arch_register_class_t *
220 _arch_register_get_class(const arch_register_t *reg)
221 {
222         return reg->reg_class;
223 }
224
225 static inline
226 unsigned _arch_register_get_index(const arch_register_t *reg)
227 {
228         return reg->index;
229 }
230
231 static inline
232 const char *_arch_register_get_name(const arch_register_t *reg)
233 {
234         return reg->name;
235 }
236
237 #define arch_register_get_class(reg)      _arch_register_get_class(reg)
238 #define arch_register_get_index(reg)      _arch_register_get_index(reg)
239 #define arch_register_get_name(reg)       _arch_register_get_name(reg)
240
241 /**
242  * Convenience macro to check for register type.
243  * @param req   A pointer to register.
244  * @param kind  The kind of type to check for (see arch_register_type_t).
245  * @return      1, If register is of given kind, 0 if not.
246  */
247 #define arch_register_type_is(reg, kind) \
248   (((reg)->type & arch_register_type_ ## kind) != 0)
249
250 /**
251  * A class of registers.
252  * Like general purpose or floating point.
253  */
254 struct arch_register_class_t {
255         unsigned                     index;  /**< index of this register class */
256         const char                  *name;   /**< The name of the register class.*/
257         unsigned                     n_regs; /**< Number of registers in this
258                                                   class. */
259         ir_mode                     *mode;   /**< The mode of the register class.*/
260         const arch_register_t       *regs;   /**< The array of registers. */
261         arch_register_class_flags_t  flags;  /**< register class flags. */
262 };
263
264 /** return the number of registers in this register class */
265 #define arch_register_class_n_regs(cls) ((cls)->n_regs)
266
267 /** return the largest mode of this register class */
268 #define arch_register_class_mode(cls) ((cls)->mode)
269
270 /** return the name of this register class */
271 #define arch_register_class_name(cls) ((cls)->name)
272
273 /** return the index of this register class */
274 #define arch_register_class_index(cls)  ((cls)->index)
275
276 /** return the register class flags */
277 #define arch_register_class_flags(cls) ((cls)->flags)
278
279 static inline const arch_register_t *
280 _arch_register_for_index(const arch_register_class_t *cls, unsigned idx)
281 {
282         assert(idx < cls->n_regs);
283         return &cls->regs[idx];
284 }
285
286 #define arch_register_for_index(cls, idx)   _arch_register_for_index(cls, idx)
287
288 /**
289  * Convenience macro to check for set constraints.
290  * @param req   A pointer to register requirements.
291  * @param kind  The kind of constraint to check for (see arch_register_req_type_t).
292  * @return      1, If the kind of constraint is present, 0 if not.
293  */
294 #define arch_register_req_is(req, kind) \
295         (((req)->type & (arch_register_req_type_ ## kind)) != 0)
296
297 /**
298  * Expresses requirements to register allocation for an operand.
299  */
300 struct arch_register_req_t {
301         arch_register_req_type_t     type;  /**< The type of the constraint. */
302         const arch_register_class_t *cls;   /**< The register class this constraint belongs to. */
303
304         const unsigned *limited;            /**< allowed register bitset */
305
306         unsigned other_same;                /**< Bitmask of ins which should use the
307                                                  same register (should_be_same). */
308         unsigned other_different;           /**< Bitmask of ins which shall use a
309                                                  different register
310                                                  (must_be_different) */
311 };
312
313 static inline int reg_reqs_equal(const arch_register_req_t *req1,
314                                  const arch_register_req_t *req2)
315 {
316         if (req1 == req2)
317                 return 1;
318
319         if (req1->type != req2->type
320                         || req1->cls != req2->cls
321                         || req1->other_same != req2->other_same
322                         || req1->other_different != req2->other_different)
323                 return 0;
324
325         if (req1->limited != NULL) {
326                 size_t n_regs;
327
328                 if (req2->limited == NULL)
329                         return 0;
330
331                 n_regs = arch_register_class_n_regs(req1->cls);
332                 if (!rbitset_equal(req1->limited, req2->limited, n_regs))
333                         return 0;
334         }
335
336         return 1;
337 }
338
339 /**
340  * An inverse operation returned by the backend
341  */
342 struct arch_inverse_t {
343         int      n;       /**< count of nodes returned in nodes array */
344         int      costs;   /**< costs of this remat */
345
346         /**< nodes for this inverse operation. shall be in
347          *  schedule order. last element is the target value
348          */
349         ir_node  **nodes;
350 };
351
352 struct arch_irn_ops_t {
353
354         /**
355          * Get the register requirements for a given operand.
356          * @param irn The node.
357          * @param pos The operand's position
358          * @return    The register requirements for the selected operand.
359          *            The pointer returned is never NULL.
360          */
361         const arch_register_req_t *(*get_irn_reg_req_in)(const ir_node *irn, int pos);
362
363         /**
364          * Get the register requirements for values produced by a node
365          * @param irn The node.
366          * @param pos The operand's position (0 for most nodes,
367          *                                    0..n for mode_T nodes)
368          * @return    The register requirements for the selected operand.
369          *            The pointer returned is never NULL.
370          */
371         const arch_register_req_t *(*get_irn_reg_req_out)(const ir_node *irn, int pos);
372
373         /**
374          * Classify the node.
375          * @param irn The node.
376          * @return A classification.
377          */
378         arch_irn_class_t (*classify)(const ir_node *irn);
379
380         /**
381          * Get the entity on the stack frame this node depends on.
382          * @param irn  The node in question.
383          * @return The entity on the stack frame or NULL, if the node does not have a
384          *         stack frame entity.
385          */
386         ir_entity *(*get_frame_entity)(const ir_node *irn);
387
388         /**
389          * Set the entity on the stack frame this node depends on.
390          * @param irn  The node in question.
391          * @param ent  The entity to set
392          */
393         void (*set_frame_entity)(ir_node *irn, ir_entity *ent);
394
395         /**
396          * Set the offset of a node carrying an entity on the stack frame.
397          * @param irn  The node.
398          * @param offset The offset of the node's stack frame entity.
399          */
400         void (*set_frame_offset)(ir_node *irn, int offset);
401
402         /**
403          * Returns the delta of the stackpointer for nodes that increment or
404          * decrement the stackpointer with a constant value. (push, pop
405          * nodes on most architectures).
406          * A positive value stands for an expanding stack area, a negative value for
407          * a shrinking one.
408          *
409          * @param irn       The node
410          * @return          0 if the stackpointer is not modified with a constant
411          *                  value, otherwise the increment/decrement value
412          */
413         int (*get_sp_bias)(const ir_node *irn);
414
415         /**
416          * Returns an inverse operation which yields the i-th argument
417          * of the given node as result.
418          *
419          * @param irn       The original operation
420          * @param i         Index of the argument we want the inverse operation to yield
421          * @param inverse   struct to be filled with the resulting inverse op
422          * @param obstack   The obstack to use for allocation of the returned nodes array
423          * @return          The inverse operation or NULL if operation invertible
424          */
425         arch_inverse_t *(*get_inverse)(const ir_node *irn, int i, arch_inverse_t *inverse, struct obstack *obstack);
426
427         /**
428          * Get the estimated cycle count for @p irn.
429          *
430          * @param irn  The node.
431          *
432          * @return     The estimated cycle count for this operation
433          */
434         int (*get_op_estimated_cost)(const ir_node *irn);
435
436         /**
437          * Asks the backend whether operand @p i of @p irn can be loaded form memory internally
438          *
439          * @param irn  The node.
440          * @param i    Index of the argument we would like to know whether @p irn can load it form memory internally
441          *
442          * @return     nonzero if argument can be loaded or zero otherwise
443          */
444         int (*possible_memory_operand)(const ir_node *irn, unsigned int i);
445
446         /**
447          * Ask the backend to assimilate @p reload of operand @p i into @p irn.
448          *
449          * @param irn    The node.
450          * @param spill  The spill.
451          * @param i      The position of the reload.
452          */
453         void (*perform_memory_operand)(ir_node *irn, ir_node *spill, unsigned int i);
454 };
455
456 /**
457  * The code generator interface.
458  */
459 struct arch_code_generator_if_t {
460         /**
461          * Initialize the code generator.
462          * @param birg A backend IRG session.
463          * @return     A newly created code generator.
464          */
465         void *(*init)(be_irg_t *birg);
466
467         /**
468          * return node used as base in pic code addresses
469          */
470         ir_node* (*get_pic_base)(void *self);
471
472         /**
473          * Called before abi introduce.
474          */
475         void (*before_abi)(void *self);
476
477         /**
478          * Called, when the graph is being normalized.
479          */
480         void (*prepare_graph)(void *self);
481
482         /**
483          * Backend may provide an own spiller.
484          * This spiller needs to spill all register classes.
485          */
486         void (*spill)(void *self, be_irg_t *birg);
487
488         /**
489          * Called before register allocation.
490          */
491         void (*before_ra)(void *self);
492
493         /**
494          * Called after register allocation.
495          */
496         void (*after_ra)(void *self);
497
498         /**
499          * Called directly before done is called. This should be the last place
500          * where the irg is modified.
501          */
502         void (*finish)(void *self);
503
504         /**
505          * Called after everything happened. This call should emit the final
506          * assembly code but avoid changing the irg.
507          * The code generator must also be de-allocated here.
508          */
509         void (*done)(void *self);
510 };
511
512 /**
513  * helper macro: call function func from the code generator
514  * if it's implemented.
515  */
516 #define _arch_cg_call(cg, func) \
517 do { \
518         if((cg)->impl->func) \
519                 (cg)->impl->func(cg); \
520 } while(0)
521
522 #define _arch_cg_call_env(cg, env, func) \
523 do { \
524         if((cg)->impl->func) \
525                 (cg)->impl->func(cg, env); \
526 } while(0)
527
528 #define arch_code_generator_before_abi(cg)      _arch_cg_call(cg, before_abi)
529 #define arch_code_generator_prepare_graph(cg)   _arch_cg_call(cg, prepare_graph)
530 #define arch_code_generator_before_ra(cg)       _arch_cg_call(cg, before_ra)
531 #define arch_code_generator_after_ra(cg)        _arch_cg_call(cg, after_ra)
532 #define arch_code_generator_finish(cg)          _arch_cg_call(cg, finish)
533 #define arch_code_generator_done(cg)            _arch_cg_call(cg, done)
534 #define arch_code_generator_spill(cg, birg)     _arch_cg_call_env(cg, birg, spill)
535 #define arch_code_generator_has_spiller(cg)     ((cg)->impl->spill != NULL)
536 #define arch_code_generator_get_pic_base(cg)    \
537         ((cg)->impl->get_pic_base != NULL ? (cg)->impl->get_pic_base(cg) : NULL)
538
539 /**
540  * Code generator base class.
541  */
542 struct arch_code_generator_t {
543         const arch_code_generator_if_t *impl;
544 };
545
546 /**
547  * Architecture interface.
548  */
549 struct arch_isa_if_t {
550         /**
551          * Initialize the isa interface.
552          * @param file_handle  the file handle to write the output to
553          * @return a new isa instance
554          */
555         arch_env_t *(*init)(FILE *file_handle);
556
557         /**
558          * Free the isa instance.
559          */
560         void (*done)(void *self);
561
562         /**
563          * Called directly after initialization. Backend should handle all
564          * intrinsics here.
565          */
566         void (*handle_intrinsics)(void);
567
568         /**
569          * Get the the number of register classes in the isa.
570          * @return The number of register classes.
571          */
572         unsigned (*get_n_reg_class)(const void *self);
573
574         /**
575          * Get the i-th register class.
576          * @param i The number of the register class.
577          * @return The register class.
578          */
579         const arch_register_class_t *(*get_reg_class)(const void *self, unsigned i);
580
581         /**
582          * Get the register class which shall be used to store a value of a given mode.
583          * @param self The this pointer.
584          * @param mode The mode in question.
585          * @return A register class which can hold values of the given mode.
586          */
587         const arch_register_class_t *(*get_reg_class_for_mode)(const void *self, const ir_mode *mode);
588
589         /**
590          * Get the ABI restrictions for procedure calls.
591          * @param self        The this pointer.
592          * @param call_type   The call type of the method (procedure) in question.
593          * @param p           The array of parameter locations to be filled.
594          */
595         void (*get_call_abi)(const void *self, ir_type *call_type, be_abi_call_t *abi);
596
597         /**
598          * Get the code generator interface.
599          * @param self The this pointer.
600          * @return     Some code generator interface.
601          */
602         const arch_code_generator_if_t *(*get_code_generator_if)(void *self);
603
604         /**
605          * Get the list scheduler to use. There is already a selector given, the
606          * backend is free to modify and/or ignore it.
607          *
608          * @param self     The isa object.
609          * @param selector The selector given by options.
610          * @return         The list scheduler selector.
611          */
612         const list_sched_selector_t *(*get_list_sched_selector)(const void *self, list_sched_selector_t *selector);
613
614         /**
615          * Get the ILP scheduler to use.
616          * @param self  The isa object.
617          * @return      The ILP scheduler selector
618          */
619         const ilp_sched_selector_t *(*get_ilp_sched_selector)(const void *self);
620
621         /**
622          * Get the necessary alignment for storing a register of given class.
623          * @param self  The isa object.
624          * @param cls   The register class.
625          * @return      The alignment in bytes.
626          */
627         int (*get_reg_class_alignment)(const void *self, const arch_register_class_t *cls);
628
629         /**
630          * A "static" function, returns the frontend settings
631          * needed for this backend.
632          */
633         const backend_params *(*get_params)(void);
634
635         /**
636          * Returns an 2-dim array of execution units, @p irn can be executed on.
637          * The first dimension is the type, the second the allowed units of this
638          * type.
639          * Each dimension is a NULL terminated list.
640          * @param self  The isa object.
641          * @param irn   The node.
642          * @return An array of allowed execution units.
643          *         exec_unit = {
644          *                       { unit1_of_tp1, ..., unitX1_of_tp1, NULL },
645          *                       ...,
646          *                       { unit1_of_tpY, ..., unitXn_of_tpY, NULL },
647          *                       NULL
648          *                     };
649          */
650         const be_execution_unit_t ***(*get_allowed_execution_units)(const void *self, const ir_node *irn);
651
652         /**
653          * Return the abstract machine for this isa.
654          * @param self  The isa object.
655          */
656         const be_machine_t *(*get_machine)(const void *self);
657
658         /**
659          * Return an ordered list of irgs where code should be generated for.
660          * If NULL is returned, all irg will be taken into account and they will be
661          * generated in an arbitrary order.
662          * @param self   The isa object.
663          * @param irgs   A flexible array ARR_F of length 0 where the backend can append the desired irgs.
664          * @return A flexible array ARR_F containing all desired irgs in the desired order.
665          */
666         ir_graph **(*get_backend_irg_list)(const void *self, ir_graph ***irgs);
667
668         /**
669          * mark node as rematerialized
670          */
671         void (*mark_remat)(const void *self, ir_node *node);
672
673         /**
674          * parse an assembler constraint part and set flags according to its nature
675          * advances the *c pointer to point to the last parsed character (so if you
676          * parse a single character don't advance c)
677          */
678         asm_constraint_flags_t (*parse_asm_constraint)(const void *self, const char **c);
679
680         /**
681          * returns true if the string is a valid clobbered (register) in this
682          * backend
683          */
684         int (*is_valid_clobber)(const void *self, const char *clobber);
685 };
686
687 #define arch_env_done(env)                             ((env)->impl->done(env))
688 #define arch_env_handle_intrinsics(env)                \
689         do { if((env)->impl->handle_intrinsics != NULL) (env)->impl->handle_intrinsics(); } while(0)
690 #define arch_env_get_n_reg_class(env)                  ((env)->impl->get_n_reg_class(env))
691 #define arch_env_get_reg_class(env,i)                  ((env)->impl->get_reg_class(env, i))
692 #define arch_env_get_reg_class_for_mode(env,mode)      ((env)->impl->get_reg_class_for_mode((env), (mode)))
693 #define arch_env_get_call_abi(env,tp,abi)              ((env)->impl->get_call_abi((env), (tp), (abi)))
694 #define arch_env_get_code_generator_if(env)            ((env)->impl->get_code_generator_if((env)))
695 #define arch_env_get_list_sched_selector(env,selector) ((env)->impl->get_list_sched_selector((env), (selector)))
696 #define arch_env_get_ilp_sched_selector(env)           ((env)->impl->get_ilp_sched_selector(env))
697 #define arch_env_get_reg_class_alignment(env,cls)      ((env)->impl->get_reg_class_alignment((env), (cls)))
698 #define arch_env_get_params(env)                       ((env)->impl->get_params())
699 #define arch_env_get_allowed_execution_units(env,irn)  ((env)->impl->get_allowed_execution_units((env), (irn)))
700 #define arch_env_get_machine(env)                      ((env)->impl->get_machine(env))
701 #define arch_env_get_backend_irg_list(env,irgs)        ((env)->impl->get_backend_irg_list((env), (irgs)))
702 #define arch_env_parse_asm_constraint(env,c)           ((env)->impl->parse_asm_constraint((env), (c))
703 #define arch_env_is_valid_clobber(env,clobber)         ((env)->impl->is_valid_clobber((env), (clobber))
704 #define arch_env_mark_remat(env,node) \
705         do { if ((env)->impl->mark_remat != NULL) (env)->impl->mark_remat((env), (node)); } while(0)
706
707 /**
708  * ISA base class.
709  */
710 struct arch_env_t {
711         const arch_isa_if_t   *impl;
712         const arch_register_t *sp;               /** The stack pointer register. */
713         const arch_register_t *bp;               /** The base pointer register. */
714         const arch_register_class_t *link_class; /** The static link pointer register class. */
715         int                    stack_dir;        /** -1 for decreasing, 1 for increasing. */
716         int                    stack_alignment;  /** power of 2 stack alignment */
717         const be_main_env_t   *main_env;         /** the be main environment */
718         int                    spill_cost;       /** cost for a be_Spill node */
719         int                    reload_cost;      /** cost for a be_Reload node */
720 };
721
722 static inline unsigned arch_irn_get_n_outs(const ir_node *node)
723 {
724         backend_info_t *info = be_get_info(node);
725         return ARR_LEN(info->out_infos);
726 }
727
728 static inline bool arch_irn_consider_in_reg_alloc(
729                 const arch_register_class_t *cls, const ir_node *node)
730 {
731         const arch_register_req_t *req = arch_get_register_req_out(node);
732         return
733                 req->cls == cls &&
734                 !(req->type & arch_register_req_type_ignore);
735 }
736
737 static inline bool arch_irn_is_ignore(const ir_node *irn)
738 {
739         const arch_register_req_t *req = arch_get_register_req_out(irn);
740         return !!(req->type & arch_register_req_type_ignore);
741 }
742
743 #endif /* FIRM_BE_BEARCH_H */