cleanups/fixes for ASM handling
[libfirm] / ir / be / ia32 / ia32_transform.h
index cf02150..f43c804 100644 (file)
-/**
- * Function prototypes for Firm into ia32-Firm transformations.
- * @author Christian Wuerdig
- * $Id$
+/*
+ * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
  */
 
-#ifndef _IA32_TRANSFORM_H_
-#define _IA32_TRANSFORM_H_
+/**
+ * @file
+ * @brief       This file implements the IR transformation from firm into ia32-Firm.
+ * @author      Christian Wuerdig, Matthias Braun
+ * @version     $Id$
+ */
+#ifndef FIRM_BE_IA32_IA32_TRANSFORM_H
+#define FIRM_BE_IA32_IA32_TRANSFORM_H
 
 #include "firm_config.h"
 #include "bearch_ia32_t.h"
 
 /**
- * Enters all transform functions into the generic pointer
+ * Transform firm nodes to x86 assembler nodes
  */
-void ia32_register_transformers(void);
+void ia32_transform_graph(ia32_code_gen_t *cg);
 
+#ifndef NDEBUG
 /**
- * Transforms the given Firm node into one or more appropriate ia32 nodes.
+ * Prints the old node name on cg obst and returns a pointer to it.
  */
-void ia32_transform_node(ir_node *node, void *env);
+const char *ia32_get_old_node_name(ia32_code_gen_t *cg, ir_node *irn);
+#endif /* NDEBUG */
 
 /**
- * The Psi selector can be a tree of compares combined with "And"s and "Or"s.
- * We create a Set node, respectively a xCmp in case the Psi is a float, for each
- * compare, which causes the compare result to be stores in a register.  The
- * "And"s and "Or"s are transformed later, we only adjust their mode.
+ * Some constants needed for code generation.
+ * Generated on demand.
  */
-void ia32_transform_psi_cond_tree(ir_node *node, void *env);
+typedef enum {
+       ia32_SSIGN,          /**< SSE2 single precision sign */
+       ia32_DSIGN,          /**< SSE2 double precision sign */
+       ia32_SABS,           /**< SSE2 single precision ABS mask */
+       ia32_DABS,           /**< SSE2 double precision ABS mask */
+       ia32_INTMAX,         /**< x87 single precision INTMAX */
+       ia32_known_const_max /**< last constant */
+} ia32_known_const_t;
+
+static const arch_register_req_t no_register_req = {
+       arch_register_req_type_none,
+       NULL,                         /* regclass */
+       NULL,                         /* limit bitset */
+       0,                            /* same pos */
+       0                             /* different pos */
+};
 
 /**
- * Transforms a Minus node.
- *
- * @param env   The transformation environment
- * @param op    The Minus operand
- * @return The created ia32 Minus node
+ * An assembler constraint.
  */
-ir_node *gen_Minus_ex(ia32_transform_env_t *env, ir_node *op);
+typedef struct constraint_t constraint_t;
+struct constraint_t {
+       const arch_register_class_t *cls;
+       unsigned                     allowed_registers;
+       bool                         all_registers_allowed;
+       bool                         memory_possible;
+       char                         immediate_type;
+       int                          same_as;
+};
 
-#ifndef NDEBUG
 /**
- * Prints the old node name on cg obst and returns a pointer to it.
+ * Generate a known floating point constant
  */
-const char *ia32_get_old_node_name(ia32_code_gen_t *cg, ir_node *irn);
-#endif /* NDEBUG */
+ir_entity *ia32_gen_fp_known_const(ia32_known_const_t kct);
+
+void ia32_add_missing_keeps(ia32_code_gen_t *cg);
+
+/**
+ * Skip all Down-Conv's on a given node and return the resulting node.
+ */
+ir_node *ia32_skip_downconv(ir_node *node);
+
+/**
+ * Get a primitive type for a mode.
+ */
+ir_type *ia32_get_prim_type(pmap *types, ir_mode *mode);
+
+/**
+ * Return true if a mode can be stored in the GP register set
+ */
+int ia32_mode_needs_gp_reg(ir_mode *mode);
+
+void ia32_parse_asm_constraints(constraint_t *constraint, const char *c);
+void ia32_parse_clobber(ir_node *node, int pos, constraint_t *constraint,
+                        const char *clobber);
+
+/**
+ * returns register by name (used for determining clobber specifications in
+ * asm instructions)
+ */
+const arch_register_t *ia32_get_clobber_register(const char *clobber);
 
-#endif /* _IA32_TRANSFORM_H_ */
+#endif /* FIRM_BE_IA32_IA32_TRANSFORM_H */