2 * This file implements the creation of the achitecture specific firm opcodes
3 * and the coresponding node constructors for the $arch assembler irg.
4 * @author Christian Wuerdig
21 #include "irgraph_t.h"
27 #include "firm_common_t.h"
31 #include "../bearch.h"
33 #include "ia32_nodes_attr.h"
34 #include "ia32_new_nodes.h"
35 #include "gen_ia32_regalloc_if.h"
37 #ifdef obstack_chunk_alloc
38 # undef obstack_chunk_alloc
39 # define obstack_chunk_alloc xmalloc
41 # define obstack_chunk_alloc xmalloc
42 # define obstack_chunk_free free
45 extern int obstack_printf(struct obstack *obst, char *fmt, ...);
47 /***********************************************************************************
50 * __| |_ _ _ __ ___ _ __ ___ _ __ _ _ __ | |_ ___ _ __| |_ __ _ ___ ___
51 * / _` | | | | '_ ` _ \| '_ \ / _ \ '__| | | '_ \| __/ _ \ '__| _/ _` |/ __/ _ \
52 * | (_| | |_| | | | | | | |_) | __/ | | | | | | || __/ | | || (_| | (_| __/
53 * \__,_|\__,_|_| |_| |_| .__/ \___|_| |_|_| |_|\__\___|_| |_| \__,_|\___\___|
56 ***********************************************************************************/
59 * Returns the name of a SymConst.
60 * @param symc the SymConst
61 * @return name of the SymConst
63 const char *get_sc_name(ir_node *symc) {
64 if (get_irn_opcode(symc) != iro_SymConst)
67 switch (get_SymConst_kind(symc)) {
68 case symconst_addr_name:
69 return get_id_str(get_SymConst_name(symc));
71 case symconst_addr_ent:
72 return get_entity_ld_name(get_SymConst_entity(symc));
75 assert(0 && "Unsupported SymConst");
82 * Returns a string containing the names of all registers within the limited bitset
84 static char *get_limited_regs(const arch_register_req_t *req, char *buf, int max) {
85 bitset_t *bs = bitset_alloca(req->cls->n_regs);
90 req->limited(NULL, bs);
92 for (i = 0; i < req->cls->n_regs; i++) {
93 if (bitset_is_set(bs, i)) {
94 cnt = snprintf(p, max - size, " %s", req->cls->regs[i].name);
96 fprintf(stderr, "dumper problem, exiting\n");
112 * Dumps the register requirements for either in or out.
114 static void dump_reg_req(FILE *F, ir_node *n, const ia32_register_req_t **reqs, int inout) {
115 char *dir = inout ? "out" : "in";
116 int max = inout ? get_ia32_n_res(n) : get_irn_arity(n);
117 char *buf = alloca(1024);
120 memset(buf, 0, 1024);
123 for (i = 0; i < max; i++) {
124 fprintf(F, "%sreq #%d =", dir, i);
126 if (reqs[i]->req.type == arch_register_req_type_none) {
130 if (reqs[i]->req.type & arch_register_req_type_normal) {
131 fprintf(F, " %s", reqs[i]->req.cls->name);
134 if (reqs[i]->req.type & arch_register_req_type_limited) {
135 fprintf(F, " %s", get_limited_regs(&reqs[i]->req, buf, 1024));
138 if (reqs[i]->req.type & arch_register_req_type_should_be_same) {
139 ir_fprintf(F, " same as %+F", get_irn_n(n, reqs[i]->same_pos));
142 if (reqs[i]->req.type & arch_register_req_type_should_be_different) {
143 ir_fprintf(F, " different from %+F", get_irn_n(n, reqs[i]->different_pos));
152 fprintf(F, "%sreq = N/A\n", dir);
157 * Dumper interface for dumping ia32 nodes in vcg.
158 * @param n the node to dump
159 * @param F the output file
160 * @param reason indicates which kind of information should be dumped
161 * @return 0 on success or != 0 on failure
163 static int dump_node_ia32(ir_node *n, FILE *F, dump_reason_t reason) {
164 ir_mode *mode = NULL;
166 int i, n_res, am_flav, flags;
167 const ia32_register_req_t **reqs;
168 const arch_register_t **slots;
171 case dump_node_opcode_txt:
172 fprintf(F, "%s", get_irn_opname(n));
175 case dump_node_mode_txt:
176 mode = get_irn_mode(n);
178 if (is_ia32_Ld(n) || is_ia32_St(n)) {
179 mode = get_ia32_ls_mode(n);
182 fprintf(F, "[%s]", mode ? get_mode_name(mode) : "?NOMODE?");
185 case dump_node_nodeattr_txt:
186 if (get_ia32_cnst(n)) {
189 if (get_ia32_sc(n)) {
193 fprintf(F, "[%s%s]", pref, get_ia32_cnst(n));
196 if (! is_ia32_Lea(n)) {
197 if (is_ia32_AddrModeS(n)) {
198 fprintf(F, "[AM S] ");
200 else if (is_ia32_AddrModeD(n)) {
201 fprintf(F, "[AM D] ");
207 case dump_node_info_txt:
208 n_res = get_ia32_n_res(n);
209 fprintf(F, "=== IA32 attr begin ===\n");
211 /* dump IN requirements */
212 if (get_irn_arity(n) > 0) {
213 reqs = get_ia32_in_req_all(n);
214 dump_reg_req(F, n, reqs, 0);
217 /* dump OUT requirements */
219 reqs = get_ia32_out_req_all(n);
220 dump_reg_req(F, n, reqs, 1);
223 /* dump assigned registers */
224 slots = get_ia32_slots(n);
225 if (slots && n_res > 0) {
226 for (i = 0; i < n_res; i++) {
227 fprintf(F, "reg #%d = %s\n", i, slots[i] ? slots[i]->name : "n/a");
234 switch (get_ia32_op_type(n)) {
236 fprintf(F, "Normal");
242 fprintf(F, "SymConst");
245 fprintf(F, "AM Dest (Load+Store)");
248 fprintf(F, "AM Source (Load)");
251 fprintf(F, "unknown (%d)", get_ia32_op_type(n));
257 /* dump supported am */
258 fprintf(F, "AM support = ");
259 switch (get_ia32_am_support(n)) {
264 fprintf(F, "source only (Load)");
267 fprintf(F, "dest only (Load+Store)");
273 fprintf(F, "unknown (%d)", get_ia32_am_support(n));
278 /* dump am flavour */
279 fprintf(F, "AM flavour =");
280 am_flav = get_ia32_am_flavour(n);
281 if (am_flav == ia32_am_N) {
285 if (am_flav & ia32_O) {
288 if (am_flav & ia32_B) {
291 if (am_flav & ia32_I) {
294 if (am_flav & ia32_S) {
298 fprintf(F, " (%d)\n", am_flav);
301 fprintf(F, "AM offset = ");
302 if (get_ia32_am_offs(n)) {
303 fprintf(F, "%s", get_ia32_am_offs(n));
311 fprintf(F, "AM scale = %d\n", get_ia32_am_scale(n));
314 fprintf(F, "pn_code = %ld\n", get_ia32_pncode(n));
317 fprintf(F, "n_res = %d\n", get_ia32_n_res(n));
320 fprintf(F, "use_frame = %d\n", is_ia32_use_frame(n));
323 fprintf(F, "commutative = %d\n", is_ia32_commutative(n));
326 fprintf(F, "flags =");
327 flags = get_ia32_flags(n);
328 if (flags == arch_irn_flags_none) {
332 if (flags & arch_irn_flags_dont_spill) {
333 fprintf(F, " unspillable");
335 if (flags & arch_irn_flags_rematerializable) {
336 fprintf(F, " remat");
338 if (flags & arch_irn_flags_ignore) {
339 fprintf(F, " ignore");
342 fprintf(F, " (%d)\n", flags);
344 /* dump frame entity */
345 fprintf(F, "frame entity = ");
346 if (get_ia32_frame_ent(n)) {
347 ir_fprintf(F, "%+F", get_ia32_frame_ent(n));
355 /* dump original ir node name */
356 fprintf(F, "orig node = ");
357 if (get_ia32_orig_node(n)) {
358 fprintf(F, "%s", get_ia32_orig_node(n));
366 fprintf(F, "=== IA32 attr end ===\n");
367 /* end of: case dump_node_info_txt */
376 /***************************************************************************************************
378 * | | | | | | / / | | | | | | | |
379 * __ _| |_| |_ _ __ ___ ___| |_ / /_ _ ___| |_ _ __ ___ ___| |_| |__ ___ __| |___
380 * / _` | __| __| '__| / __|/ _ \ __| / / _` |/ _ \ __| | '_ ` _ \ / _ \ __| '_ \ / _ \ / _` / __|
381 * | (_| | |_| |_| | \__ \ __/ |_ / / (_| | __/ |_ | | | | | | __/ |_| | | | (_) | (_| \__ \
382 * \__,_|\__|\__|_| |___/\___|\__/_/ \__, |\___|\__| |_| |_| |_|\___|\__|_| |_|\___/ \__,_|___/
385 ***************************************************************************************************/
387 static char *copy_str(char *dst, const char *src) {
388 dst = xcalloc(1, strlen(src) + 1);
389 strncpy(dst, src, strlen(src) + 1);
393 static char *set_cnst_from_tv(char *cnst, tarval *tv) {
398 cnst = xcalloc(1, 64);
399 assert(tarval_snprintf(cnst, 63, tv));
404 * Wraps get_irn_generic_attr() as it takes no const ir_node, so we need to do a cast.
405 * Firm was made by people hating const :-(
407 ia32_attr_t *get_ia32_attr(const ir_node *node) {
408 assert(is_ia32_irn(node) && "need ia32 node to get ia32 attributes");
409 return (ia32_attr_t *)get_irn_generic_attr((ir_node *)node);
413 * Gets the type of an ia32 node.
415 ia32_op_type_t get_ia32_op_type(const ir_node *node) {
416 ia32_attr_t *attr = get_ia32_attr(node);
417 return attr->data.tp;
421 * Sets the type of an ia32 node.
423 void set_ia32_op_type(ir_node *node, ia32_op_type_t tp) {
424 ia32_attr_t *attr = get_ia32_attr(node);
429 * Gets the supported addrmode of an ia32 node
431 ia32_am_type_t get_ia32_am_support(const ir_node *node) {
432 ia32_attr_t *attr = get_ia32_attr(node);
433 return attr->data.am_support;
437 * Sets the supported addrmode of an ia32 node
439 void set_ia32_am_support(ir_node *node, ia32_am_type_t am_tp) {
440 ia32_attr_t *attr = get_ia32_attr(node);
441 attr->data.am_support = am_tp;
445 * Gets the addrmode flavour of an ia32 node
447 ia32_am_flavour_t get_ia32_am_flavour(const ir_node *node) {
448 ia32_attr_t *attr = get_ia32_attr(node);
449 return attr->data.am_flavour;
453 * Sets the addrmode flavour of an ia32 node
455 void set_ia32_am_flavour(ir_node *node, ia32_am_flavour_t am_flavour) {
456 ia32_attr_t *attr = get_ia32_attr(node);
457 attr->data.am_flavour = am_flavour;
461 * Joins all offsets to one string with adds.
463 char *get_ia32_am_offs(const ir_node *node) {
464 ia32_attr_t *attr = get_ia32_attr(node);
468 if (! attr->am_offs) {
472 size = obstack_object_size(attr->am_offs);
474 res = xcalloc(1, size + 2);
475 res[0] = attr->data.offs_sign ? '-' : '+';
476 memcpy(&res[1], obstack_base(attr->am_offs), size);
479 res[size + 1] = '\0';
484 * Add an offset for addrmode.
486 static void extend_ia32_am_offs(ir_node *node, char *offset, char op) {
487 ia32_attr_t *attr = get_ia32_attr(node);
492 /* offset could already have an explicit sign */
493 /* -> supersede op if necessary */
494 if (offset[0] == '-' || offset[0] == '+') {
495 if (offset[0] == '-') {
496 op = (op == '-') ? '+' : '-';
499 /* skip explicit sign */
503 if (! attr->am_offs) {
504 /* obstack is not initialized */
505 attr->am_offs = xcalloc(1, sizeof(*(attr->am_offs)));
506 obstack_init(attr->am_offs);
508 attr->data.offs_sign = (op == '-') ? 1 : 0;
511 /* If obstack is initialized, connect the new offset with op */
512 obstack_printf(attr->am_offs, "%c", op);
515 obstack_printf(attr->am_offs, "%s", offset);
519 * Add an offset for addrmode.
521 void add_ia32_am_offs(ir_node *node, char *offset) {
522 extend_ia32_am_offs(node, offset, '+');
526 * Sub an offset for addrmode.
528 void sub_ia32_am_offs(ir_node *node, char *offset) {
529 extend_ia32_am_offs(node, offset, '-');
533 * Gets the addr mode const.
535 int get_ia32_am_scale(const ir_node *node) {
536 ia32_attr_t *attr = get_ia32_attr(node);
537 return attr->data.am_scale;
541 * Sets the index register scale for addrmode.
543 void set_ia32_am_scale(ir_node *node, int scale) {
544 ia32_attr_t *attr = get_ia32_attr(node);
545 attr->data.am_scale = scale;
549 * Return the tarval of an immediate operation or NULL in case of SymConst
551 tarval *get_ia32_Immop_tarval(const ir_node *node) {
552 ia32_attr_t *attr = get_ia32_attr(node);
557 * Sets the attributes of an immediate operation to the specified tarval
559 void set_ia32_Immop_tarval(ir_node *node, tarval *tv) {
560 ia32_attr_t *attr = get_ia32_attr(node);
562 attr->cnst = set_cnst_from_tv(attr->cnst, attr->tv);
566 * Return the sc attribute.
568 char *get_ia32_sc(const ir_node *node) {
569 ia32_attr_t *attr = get_ia32_attr(node);
574 * Sets the sc attribute.
576 void set_ia32_sc(ir_node *node, char *sc) {
577 ia32_attr_t *attr = get_ia32_attr(node);
578 attr->sc = copy_str(attr->sc, sc);
583 attr->cnst = attr->sc;
587 * Gets the string representation of the internal const (tv or symconst)
589 char *get_ia32_cnst(const ir_node *node) {
590 ia32_attr_t *attr = get_ia32_attr(node);
595 * Sets the uses_frame flag.
597 void set_ia32_use_frame(ir_node *node) {
598 ia32_attr_t *attr = get_ia32_attr(node);
599 attr->data.use_frame = 1;
603 * Clears the uses_frame flag.
605 void clear_ia32_use_frame(ir_node *node) {
606 ia32_attr_t *attr = get_ia32_attr(node);
607 attr->data.use_frame = 0;
611 * Gets the uses_frame flag.
613 int is_ia32_use_frame(const ir_node *node) {
614 ia32_attr_t *attr = get_ia32_attr(node);
615 return attr->data.use_frame;
619 * Sets node to commutative.
621 void set_ia32_commutative(ir_node *node) {
622 ia32_attr_t *attr = get_ia32_attr(node);
623 attr->data.is_commutative = 1;
627 * Sets node to non-commutative.
629 void clear_ia32_commutative(ir_node *node) {
630 ia32_attr_t *attr = get_ia32_attr(node);
631 attr->data.is_commutative = 0;
635 * Checks if node is commutative.
637 int is_ia32_commutative(const ir_node *node) {
638 ia32_attr_t *attr = get_ia32_attr(node);
639 return attr->data.is_commutative;
643 * Gets the mode of the stored/loaded value (only set for Store/Load)
645 ir_mode *get_ia32_ls_mode(const ir_node *node) {
646 ia32_attr_t *attr = get_ia32_attr(node);
647 return attr->ls_mode;
651 * Sets the mode of the stored/loaded value (only set for Store/Load)
653 void set_ia32_ls_mode(ir_node *node, ir_mode *mode) {
654 ia32_attr_t *attr = get_ia32_attr(node);
655 attr->ls_mode = mode;
659 * Gets the mode of the result.
661 ir_mode *get_ia32_res_mode(const ir_node *node) {
662 ia32_attr_t *attr = get_ia32_attr(node);
663 return attr->res_mode;
667 * Sets the mode of the result.
669 void set_ia32_res_mode(ir_node *node, ir_mode *mode) {
670 ia32_attr_t *attr = get_ia32_attr(node);
671 attr->res_mode = mode;
675 * Gets the frame entity assigned to this node;
677 entity *get_ia32_frame_ent(const ir_node *node) {
678 ia32_attr_t *attr = get_ia32_attr(node);
679 return attr->frame_ent;
683 * Sets the frame entity for this node;
685 void set_ia32_frame_ent(ir_node *node, entity *ent) {
686 ia32_attr_t *attr = get_ia32_attr(node);
687 attr->frame_ent = ent;
691 * Returns the argument register requirements of an ia32 node.
693 const ia32_register_req_t **get_ia32_in_req_all(const ir_node *node) {
694 ia32_attr_t *attr = get_ia32_attr(node);
699 * Sets the argument register requirements of an ia32 node.
701 void set_ia32_in_req_all(ir_node *node, const ia32_register_req_t **reqs) {
702 ia32_attr_t *attr = get_ia32_attr(node);
707 * Returns the result register requirements of an ia32 node.
709 const ia32_register_req_t **get_ia32_out_req_all(const ir_node *node) {
710 ia32_attr_t *attr = get_ia32_attr(node);
711 return attr->out_req;
715 * Sets the result register requirements of an ia32 node.
717 void set_ia32_out_req_all(ir_node *node, const ia32_register_req_t **reqs) {
718 ia32_attr_t *attr = get_ia32_attr(node);
719 attr->out_req = reqs;
723 * Returns the argument register requirement at position pos of an ia32 node.
725 const ia32_register_req_t *get_ia32_in_req(const ir_node *node, int pos) {
726 ia32_attr_t *attr = get_ia32_attr(node);
727 return attr->in_req[pos];
731 * Returns the result register requirement at position pos of an ia32 node.
733 const ia32_register_req_t *get_ia32_out_req(const ir_node *node, int pos) {
734 ia32_attr_t *attr = get_ia32_attr(node);
735 return attr->out_req[pos];
739 * Sets the OUT register requirements at position pos.
741 void set_ia32_req_out(ir_node *node, const ia32_register_req_t *req, int pos) {
742 ia32_attr_t *attr = get_ia32_attr(node);
743 attr->out_req[pos] = req;
747 * Sets the IN register requirements at position pos.
749 void set_ia32_req_in(ir_node *node, const ia32_register_req_t *req, int pos) {
750 ia32_attr_t *attr = get_ia32_attr(node);
751 attr->in_req[pos] = req;
755 * Returns the register flag of an ia32 node.
757 arch_irn_flags_t get_ia32_flags(const ir_node *node) {
758 ia32_attr_t *attr = get_ia32_attr(node);
759 return attr->data.flags;
763 * Sets the register flag of an ia32 node.
765 void set_ia32_flags(ir_node *node, arch_irn_flags_t flags) {
766 ia32_attr_t *attr = get_ia32_attr(node);
767 attr->data.flags = flags;
771 * Returns the result register slots of an ia32 node.
773 const arch_register_t **get_ia32_slots(const ir_node *node) {
774 ia32_attr_t *attr = get_ia32_attr(node);
779 * Sets the number of results.
781 void set_ia32_n_res(ir_node *node, int n_res) {
782 ia32_attr_t *attr = get_ia32_attr(node);
783 attr->data.n_res = n_res;
787 * Returns the number of results.
789 int get_ia32_n_res(const ir_node *node) {
790 ia32_attr_t *attr = get_ia32_attr(node);
791 return attr->data.n_res;
795 * Returns the flavour of an ia32 node,
797 ia32_op_flavour_t get_ia32_flavour(const ir_node *node) {
798 ia32_attr_t *attr = get_ia32_attr(node);
799 return attr->data.op_flav;
803 * Sets the flavour of an ia32 node to flavour_Div/Mod/DivMod/Mul/Mulh.
805 void set_ia32_flavour(ir_node *node, ia32_op_flavour_t op_flav) {
806 ia32_attr_t *attr = get_ia32_attr(node);
807 attr->data.op_flav = op_flav;
811 * Returns the projnum code.
813 long get_ia32_pncode(const ir_node *node) {
814 ia32_attr_t *attr = get_ia32_attr(node);
815 return attr->pn_code;
819 * Sets the projnum code
821 void set_ia32_pncode(ir_node *node, long code) {
822 ia32_attr_t *attr = get_ia32_attr(node);
823 attr->pn_code = code;
829 * Returns the name of the original ir node.
831 const char *get_ia32_orig_node(const ir_node *node) {
832 ia32_attr_t *attr = get_ia32_attr(node);
833 return attr->orig_node;
837 * Sets the name of the original ir node.
839 void set_ia32_orig_node(ir_node *node, const char *name) {
840 ia32_attr_t *attr = get_ia32_attr(node);
841 attr->orig_node = name;
846 /******************************************************************************************************
848 * (_) | | | | | | / _| | | (_)
849 * ___ _ __ ___ ___ _ __ _| | __ _| |_| |_ _ __ | |_ _ _ _ __ ___| |_ _ ___ _ __ ___
850 * / __| '_ \ / _ \/ __| |/ _` | | / _` | __| __| '__| | _| | | | '_ \ / __| __| |/ _ \| '_ \ / __|
851 * \__ \ |_) | __/ (__| | (_| | | | (_| | |_| |_| | | | | |_| | | | | (__| |_| | (_) | | | | \__ \
852 * |___/ .__/ \___|\___|_|\__,_|_| \__,_|\__|\__|_| |_| \__,_|_| |_|\___|\__|_|\___/|_| |_| |___/
855 ******************************************************************************************************/
858 * Gets the type of an ia32_Const.
860 unsigned get_ia32_Const_type(const ir_node *node) {
861 ia32_attr_t *attr = get_ia32_attr(node);
863 assert(is_ia32_Cnst(node) && "Need ia32_Const to get type");
865 return attr->data.tp;
869 * Sets the type of an ia32_Const.
871 void set_ia32_Const_type(ir_node *node, int type) {
872 ia32_attr_t *attr = get_ia32_attr(node);
874 assert(is_ia32_Cnst(node) && "Need ia32_Const to set type");
875 assert((type == ia32_Const || type == ia32_SymConst) && "Unsupported ia32_Const type");
877 attr->data.tp = type;
881 * Copy the attributes from an ia32_Const to an Immop (Add_i, Sub_i, ...) node
883 void set_ia32_Immop_attr(ir_node *node, ir_node *cnst) {
884 ia32_attr_t *na = get_ia32_attr(node);
885 ia32_attr_t *ca = get_ia32_attr(cnst);
887 assert(is_ia32_Cnst(cnst) && "Need ia32_Const to set Immop attr");
892 na->sc = copy_str(na->sc, ca->sc);
896 na->cnst = set_cnst_from_tv(na->cnst, na->tv);
902 * Copy the attributes from a Const to an ia32_Const
904 void set_ia32_Const_attr(ir_node *ia32_cnst, ir_node *cnst) {
905 ia32_attr_t *attr = get_ia32_attr(ia32_cnst);
907 assert(is_ia32_Cnst(ia32_cnst) && "Need ia32_Const to set Const attr");
909 switch (get_irn_opcode(cnst)) {
911 attr->data.tp = ia32_Const;
912 attr->tv = get_Const_tarval(cnst);
913 attr->cnst = set_cnst_from_tv(attr->cnst, attr->tv);
916 attr->data.tp = ia32_SymConst;
918 attr->sc = copy_str(attr->sc, get_sc_name(cnst));
919 attr->cnst = attr->sc;
922 assert(0 && "Unknown Const NYI");
925 assert(0 && "Cannot create ia32_Const for this opcode");
930 * Sets the AddrMode(S|D) attribute
932 void set_ia32_AddrMode(ir_node *node, char direction) {
933 ia32_attr_t *attr = get_ia32_attr(node);
937 attr->data.tp = ia32_AddrModeD;
940 attr->data.tp = ia32_AddrModeS;
943 assert(0 && "wrong AM type");
948 * Returns whether or not the node is an AddrModeS node.
950 int is_ia32_AddrModeS(const ir_node *node) {
951 ia32_attr_t *attr = get_ia32_attr(node);
952 return (attr->data.tp == ia32_AddrModeS);
956 * Returns whether or not the node is an AddrModeD node.
958 int is_ia32_AddrModeD(const ir_node *node) {
959 ia32_attr_t *attr = get_ia32_attr(node);
960 return (attr->data.tp == ia32_AddrModeD);
964 * Checks if node is a Load or fLoad.
966 int is_ia32_Ld(const ir_node *node) {
967 return is_ia32_Load(node) || is_ia32_fLoad(node);
971 * Checks if node is a Store or fStore.
973 int is_ia32_St(const ir_node *node) {
974 return is_ia32_Store(node) || is_ia32_fStore(node);
978 * Checks if node is a Const or fConst.
980 int is_ia32_Cnst(const ir_node *node) {
981 return is_ia32_Const(node) || is_ia32_fConst(node);
985 * Returns the name of the OUT register at position pos.
987 const char *get_ia32_out_reg_name(const ir_node *node, int pos) {
988 ia32_attr_t *attr = get_ia32_attr(node);
990 assert(is_ia32_irn(node) && "Not an ia32 node.");
991 assert(pos < attr->data.n_res && "Invalid OUT position.");
992 assert(attr->slots[pos] && "No register assigned");
994 return arch_register_get_name(attr->slots[pos]);
998 * Returns the index of the OUT register at position pos within its register class.
1000 int get_ia32_out_regnr(const ir_node *node, int pos) {
1001 ia32_attr_t *attr = get_ia32_attr(node);
1003 assert(is_ia32_irn(node) && "Not an ia32 node.");
1004 assert(pos < attr->data.n_res && "Invalid OUT position.");
1005 assert(attr->slots[pos] && "No register assigned");
1007 return arch_register_get_index(attr->slots[pos]);
1011 * Returns the OUT register at position pos.
1013 const arch_register_t *get_ia32_out_reg(const ir_node *node, int pos) {
1014 ia32_attr_t *attr = get_ia32_attr(node);
1016 assert(is_ia32_irn(node) && "Not an ia32 node.");
1017 assert(pos < attr->data.n_res && "Invalid OUT position.");
1018 assert(attr->slots[pos] && "No register assigned");
1020 return attr->slots[pos];
1024 * Allocates num register slots for node.
1026 void alloc_ia32_reg_slots(ir_node *node, int num) {
1027 ia32_attr_t *attr = get_ia32_attr(node);
1030 attr->slots = xcalloc(num, sizeof(attr->slots[0]));
1036 attr->data.n_res = num;
1040 * Initializes the nodes attributes.
1042 void init_ia32_attributes(ir_node *node, arch_irn_flags_t flags, const ia32_register_req_t **in_reqs,
1043 const ia32_register_req_t **out_reqs, int n_res)
1045 set_ia32_flags(node, flags);
1046 set_ia32_in_req_all(node, in_reqs);
1047 set_ia32_out_req_all(node, out_reqs);
1048 alloc_ia32_reg_slots(node, n_res);
1051 /***************************************************************************************
1054 * _ __ ___ __| | ___ ___ ___ _ __ ___| |_ _ __ _ _ ___| |_ ___ _ __ ___
1055 * | '_ \ / _ \ / _` |/ _ \ / __/ _ \| '_ \/ __| __| '__| | | |/ __| __/ _ \| '__/ __|
1056 * | | | | (_) | (_| | __/ | (_| (_) | | | \__ \ |_| | | |_| | (__| || (_) | | \__ \
1057 * |_| |_|\___/ \__,_|\___| \___\___/|_| |_|___/\__|_| \__,_|\___|\__\___/|_| |___/
1059 ***************************************************************************************/
1061 /* default compare operation to compare immediate ops */
1062 int ia32_compare_immop_attr(ia32_attr_t *a, ia32_attr_t *b) {
1063 if (a->data.tp == b->data.tp) {
1064 if (! (a->cnst && b->cnst))
1067 return strcmp(a->cnst, b->cnst);
1073 /* Include the generated constructor functions */
1074 #include "gen_ia32_new_nodes.c.inl"