+/**
+ * Sets the number of results.
+ */
+void set_ia32_n_res(ir_node *node, int n_res) {
+ ia32_attr_t *attr = get_ia32_attr(node);
+ attr->data.n_res = n_res;
+}
+
+/**
+ * Returns the number of results.
+ */
+int get_ia32_n_res(const ir_node *node) {
+ ia32_attr_t *attr = get_ia32_attr(node);
+ return attr->data.n_res;
+}
+
+/**
+ * Returns the flavour of an ia32 node,
+ */
+ia32_op_flavour_t get_ia32_flavour(const ir_node *node) {
+ ia32_attr_t *attr = get_ia32_attr(node);
+ return attr->data.op_flav;
+}
+
+/**
+ * Sets the flavour of an ia32 node to flavour_Div/Mod/DivMod/Mul/Mulh.
+ */
+void set_ia32_flavour(ir_node *node, ia32_op_flavour_t op_flav) {
+ ia32_attr_t *attr = get_ia32_attr(node);
+ attr->data.op_flav = op_flav;
+}
+
+/**
+ * Returns the projnum code.
+ */
+long get_ia32_pncode(const ir_node *node) {
+ ia32_attr_t *attr = get_ia32_attr(node);
+ return attr->pn_code;
+}
+
+/**
+ * Sets the projnum code
+ */
+void set_ia32_pncode(ir_node *node, long code) {
+ ia32_attr_t *attr = get_ia32_attr(node);
+ attr->pn_code = code;
+}
+
+/**
+ * Sets the flags for the n'th out.
+ */
+void set_ia32_out_flags(ir_node *node, arch_irn_flags_t flags, int pos) {
+ ia32_attr_t *attr = get_ia32_attr(node);
+ assert(pos < (int) attr->data.n_res && "Invalid OUT position.");
+ attr->out_flags[pos] = flags;
+}
+
+/**
+ * Gets the flags for the n'th out.
+ */
+arch_irn_flags_t get_ia32_out_flags(const ir_node *node, int pos) {
+ ia32_attr_t *attr = get_ia32_attr(node);
+ return pos < (int)attr->data.n_res ? attr->out_flags[pos] : arch_irn_flags_none;
+}
+
+#ifndef NDEBUG
+
+/**
+ * Returns the name of the original ir node.
+ */
+const char *get_ia32_orig_node(const ir_node *node) {
+ ia32_attr_t *attr = get_ia32_attr(node);
+ return attr->orig_node;
+}
+
+/**
+ * Sets the name of the original ir node.
+ */
+void set_ia32_orig_node(ir_node *node, const char *name) {
+ ia32_attr_t *attr = get_ia32_attr(node);
+ attr->orig_node = name;
+}
+
+#endif /* NDEBUG */
+
+/******************************************************************************************************
+ * _ _ _ _ __ _ _
+ * (_) | | | | | | / _| | | (_)
+ * ___ _ __ ___ ___ _ __ _| | __ _| |_| |_ _ __ | |_ _ _ _ __ ___| |_ _ ___ _ __ ___
+ * / __| '_ \ / _ \/ __| |/ _` | | / _` | __| __| '__| | _| | | | '_ \ / __| __| |/ _ \| '_ \ / __|
+ * \__ \ |_) | __/ (__| | (_| | | | (_| | |_| |_| | | | | |_| | | | | (__| |_| | (_) | | | | \__ \
+ * |___/ .__/ \___|\___|_|\__,_|_| \__,_|\__|\__|_| |_| \__,_|_| |_|\___|\__|_|\___/|_| |_| |___/
+ * | |
+ * |_|
+ ******************************************************************************************************/
+
+/**
+ * Gets the type of an ia32_Const.
+ */
+unsigned get_ia32_Const_type(const ir_node *node) {
+ ia32_attr_t *attr = get_ia32_attr(node);
+
+ assert(is_ia32_Cnst(node) && "Need ia32_Const to get type");
+
+ return attr->data.tp;
+}
+
+/**
+ * Sets the type of an ia32_Const.
+ */
+void set_ia32_Const_type(ir_node *node, int type) {
+ ia32_attr_t *attr = get_ia32_attr(node);
+
+ assert(is_ia32_Cnst(node) && "Need ia32_Const to set type");
+ assert((type == ia32_Const || type == ia32_SymConst) && "Unsupported ia32_Const type");
+
+ attr->data.tp = type;
+}
+
+/**
+ * Copy the attributes from an ia32_Const to an Immop (Add_i, Sub_i, ...) node
+ */
+void set_ia32_Immop_attr(ir_node *node, ir_node *cnst) {
+ ia32_attr_t *na = get_ia32_attr(node);
+ ia32_attr_t *ca = get_ia32_attr(cnst);
+
+ switch(get_ia32_Const_type(cnst)) {
+ case ia32_Const:
+ na->cnst_val.tv = ca->cnst_val.tv;
+ na->cnst = ca->cnst;
+ set_ia32_immop_type(node, ia32_ImmConst);
+ break;
+ case ia32_SymConst:
+ na->cnst_val.sc = ca->cnst_val.sc;
+ na->cnst = na->cnst_val.sc;
+ set_ia32_immop_type(node, ia32_ImmSymConst);
+ break;
+ default:
+ assert(0 && "Need ia32_Const to set Immop attr");
+ }
+}
+
+/**
+ * Copy the attributes from Immop to an Immop
+ */
+void copy_ia32_Immop_attr(ir_node *dst, ir_node *src) {
+ ia32_attr_t *da = get_ia32_attr(dst);
+ ia32_attr_t *sa = get_ia32_attr(src);
+
+ switch(get_ia32_immop_type(src)) {
+ case ia32_ImmConst:
+ da->cnst_val.tv = sa->cnst_val.tv;
+ da->cnst = sa->cnst;
+ set_ia32_immop_type(dst, ia32_ImmConst);
+ break;
+ case ia32_ImmSymConst:
+ da->cnst_val.sc = sa->cnst_val.sc;
+ da->cnst = sa->cnst;
+ set_ia32_immop_type(dst, ia32_ImmSymConst);
+ break;
+ default:
+ assert(0 && "Need Immop to copy Immop attr");
+ }
+}
+
+/**
+ * Copy the attributes from a Firm Const/SymConst to an ia32_Const
+ */
+void set_ia32_Const_attr(ir_node *ia32_cnst, ir_node *cnst) {
+ ia32_attr_t *attr = get_ia32_attr(ia32_cnst);
+ ir_mode *mode;
+
+ assert(is_ia32_Cnst(ia32_cnst) && "Need ia32_Const to set Const attr");
+
+ switch (get_irn_opcode(cnst)) {
+ case iro_Const:
+ attr->data.tp = ia32_Const;
+ attr->cnst_val.tv = get_Const_tarval(cnst);
+ mode = get_tarval_mode(attr->cnst_val.tv);
+ if (mode_is_reference(mode) &&
+ get_mode_null(mode) == attr->cnst_val.tv) {
+ attr->cnst_val.tv = get_mode_null(mode_Iu);
+ }
+ attr->cnst = get_ident_for_tv(attr->cnst_val.tv);
+ break;
+ case iro_SymConst:
+ attr->data.tp = ia32_SymConst;
+ attr->cnst_val.sc = get_sc_ident(cnst);
+ attr->cnst = attr->cnst_val.sc;
+ break;
+ case iro_Unknown:
+ assert(0 && "Unknown Const NYI");
+ break;
+ default:
+ assert(0 && "Cannot create ia32_Const for this opcode");
+ }
+}
+
+/**
+ * Sets the AddrMode(S|D) attribute
+ */
+void set_ia32_AddrMode(ir_node *node, char direction) {
+ ia32_attr_t *attr = get_ia32_attr(node);
+
+ switch (direction) {
+ case 'D':
+ attr->data.tp = ia32_AddrModeD;
+ break;
+ case 'S':
+ attr->data.tp = ia32_AddrModeS;
+ break;
+ default:
+ assert(0 && "wrong AM type");
+ }
+}
+
+/**
+ * Returns whether or not the node is an immediate operation with Const.
+ */
+int is_ia32_ImmConst(const ir_node *node) {
+ ia32_attr_t *attr = get_ia32_attr(node);
+ return (attr->data.imm_tp == ia32_ImmConst);
+}
+
+/**
+ * Returns whether or not the node is an immediate operation with SymConst.
+ */
+int is_ia32_ImmSymConst(const ir_node *node) {
+ ia32_attr_t *attr = get_ia32_attr(node);
+ return (attr->data.imm_tp == ia32_ImmSymConst);
+}
+
+/**
+ * Returns whether or not the node is an AddrModeS node.
+ */
+int is_ia32_AddrModeS(const ir_node *node) {
+ ia32_attr_t *attr = get_ia32_attr(node);
+ return (attr->data.tp == ia32_AddrModeS);
+}
+
+/**
+ * Returns whether or not the node is an AddrModeD node.
+ */
+int is_ia32_AddrModeD(const ir_node *node) {
+ ia32_attr_t *attr = get_ia32_attr(node);
+ return (attr->data.tp == ia32_AddrModeD);
+}
+
+/**
+ * Checks if node is a Load or xLoad/vfLoad.
+ */
+int is_ia32_Ld(const ir_node *node) {
+ int op = get_ia32_irn_opcode(node);
+ return op == iro_ia32_Load || op == iro_ia32_xLoad || op == iro_ia32_vfld || op == iro_ia32_fld;
+}
+
+/**
+ * Checks if node is a Store or xStore/vfStore.
+ */
+int is_ia32_St(const ir_node *node) {
+ int op = get_ia32_irn_opcode(node);
+ return op == iro_ia32_Store || op == iro_ia32_xStore || op == iro_ia32_vfst || op == iro_ia32_fst || op == iro_ia32_fstp;
+}
+
+/**
+ * Checks if node is a Const or xConst/vfConst.
+ */
+int is_ia32_Cnst(const ir_node *node) {
+ int op = get_ia32_irn_opcode(node);
+ return op == iro_ia32_Const || op == iro_ia32_xConst || op == iro_ia32_vfConst;
+}
+