Rename arch_register_req_type_should_be_different to the more appropriate arch_regist...
[libfirm] / ir / be / bearch.h
index 3bac389..4b0d187 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1995-2007 University of Karlsruhe.  All right reserved.
+ * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
  *
  * This file is part of libFirm.
  *
  * PURPOSE.
  */
 
-#ifndef _FIRM_BEARCH_H_
-#define _FIRM_BEARCH_H_
+/**
+ * @file
+ * @brief       Processor architecture specification.
+ * @author      Sebastian Hack
+ * @version     $Id$
+ */
+#ifndef FIRM_BE_BEARCH_H
+#define FIRM_BE_BEARCH_H
 
 #include "firm_types.h"
 #include "bitset.h"
 #include "be.h"
+#include "obst.h"
 
 typedef struct arch_register_class_t     arch_register_class_t;
 typedef struct arch_register_req_t       arch_register_req_t;
@@ -30,14 +37,16 @@ typedef struct arch_register_t           arch_register_t;
 typedef struct arch_flag_t               arch_flag_t;
 typedef struct arch_inverse_t            arch_inverse_t;
 typedef struct arch_isa_if_t             arch_isa_if_t;
-typedef struct arch_isa_t                arch_isa_t;
 typedef struct arch_env_t                arch_env_t;
-typedef struct arch_irn_ops_if_t         arch_irn_ops_if_t;
-typedef struct arch_irn_ops_t            arch_irn_ops_t;
-typedef struct arch_irn_handler_t        arch_irn_handler_t;
 typedef struct arch_code_generator_t     arch_code_generator_t;
 typedef struct arch_code_generator_if_t  arch_code_generator_if_t;
 
+typedef enum arch_register_class_flags_t {
+       arch_register_class_flag_none      = 0,
+       arch_register_class_flag_manual_ra = 1,  /**< don't do automatic register allocation for this class */
+       arch_register_class_flag_state     = 2
+} arch_register_class_flags_t;
+
 typedef enum arch_register_type_t {
        arch_register_type_none         = 0,
        arch_register_type_caller_save  = 1,  /**< The register must be saved by the caller
@@ -48,8 +57,11 @@ typedef enum arch_register_type_t {
                                              in the called function. */
        arch_register_type_ignore       = 4,  /**< Do not consider this register when allocating. */
        arch_register_type_joker        = 8,  /**< The emitter can choose an arbitrary register */
-       arch_register_type_virtual      = 16, /**< This is just a virtual register  */
-       arch_register_type_state        = 32,
+       arch_register_type_virtual      = 16, /**< This is just a virtual register.Virtual registers have
+                                               nearly no constraints, it is a allowed to have multiple
+                                                                                          definition for the same register at a point) */
+       arch_register_type_state        = 32, /**< The register represents a state that should be handled by
+                                                  bestate code */
 } arch_register_type_t;
 
 /**
@@ -73,12 +85,11 @@ typedef enum arch_operand_type_t {
  * Different types of register allocation requirements.
  */
 typedef enum arch_register_req_type_t {
-       arch_register_req_type_none                         = 0,  /**< No register requirement. */
-       arch_register_req_type_normal                       = 1,  /**< All registers in the class are allowed. */
-       arch_register_req_type_limited                      = 2,  /**< Only a real subset of the class is allowed. */
-       arch_register_req_type_should_be_same               = 4,  /**< The register should be equal another one at the node. */
-       arch_register_req_type_should_be_different          = 8,  /**< The register must be unequal to some other at the node. */
-       arch_register_req_type_should_be_different_from_all = 16, /**< The register must be different from all in's at the node */
+       arch_register_req_type_none              = 0,  /**< No register requirement. */
+       arch_register_req_type_normal            = 1,  /**< All registers in the class are allowed. */
+       arch_register_req_type_limited           = 2,  /**< Only a real subset of the class is allowed. */
+       arch_register_req_type_should_be_same    = 4,  /**< The register should be equal to another one at the node. */
+       arch_register_req_type_must_be_different = 8,  /**< The register must be unequal from some other at the node. */
 } arch_register_req_type_t;
 
 extern const arch_register_req_t *arch_no_register_req;
@@ -103,10 +114,9 @@ typedef enum arch_irn_class_t {
        arch_irn_class_perm       = 1 << 4,
        arch_irn_class_branch     = 1 << 5,
        arch_irn_class_call       = 1 << 6,
-       arch_irn_class_const      = 1 << 7,
-       arch_irn_class_load       = 1 << 8,
-       arch_irn_class_store      = 1 << 9,
-       arch_irn_class_stackparam = 1 << 10,
+       arch_irn_class_load       = 1 << 7,
+       arch_irn_class_store      = 1 << 8,
+       arch_irn_class_stackparam = 1 << 9,
 } arch_irn_class_t;
 
 /**
@@ -118,7 +128,8 @@ typedef enum arch_irn_flags_t {
        arch_irn_flags_rematerializable = 2, /**< This can be replicated instead of spilled/reloaded. */
        arch_irn_flags_ignore           = 4, /**< Ignore node during register allocation. */
        arch_irn_flags_modify_sp        = 8, /**< I modify the stack pointer. */
-       arch_irn_flags_last             = arch_irn_flags_modify_sp
+       arch_irn_flags_modify_flags     = 16, /**< I modify flags. */
+       arch_irn_flags_last             = arch_irn_flags_modify_flags
 } arch_irn_flags_t;
 
 /**
@@ -134,7 +145,7 @@ extern const arch_irn_ops_t *arch_get_irn_ops(const arch_env_t *env,
 
 extern void arch_set_frame_offset(const arch_env_t *env, ir_node *irn, int bias);
 
-extern ir_entity *arch_get_frame_entity(const arch_env_t *env, ir_node *irn);
+extern ir_entity *arch_get_frame_entity(const arch_env_t *env, const ir_node *irn);
 extern void arch_set_frame_entity(const arch_env_t *env, ir_node *irn, ir_entity *ent);
 extern int arch_get_sp_bias(const arch_env_t *env, ir_node *irn);
 
@@ -146,12 +157,9 @@ extern void arch_perform_memory_operand(const arch_env_t *env, ir_node *irn, ir_
 /**
  * Get the register requirements for a node.
  * @param env The architecture environment.
- * @param req A pointer to a requirements structure, where the data can
- *            be put into.
  * @param irn The node.
  * @param pos The position of the operand you're interested in.
- * @return    A pointer to the register requirements which may <b>not</b>
- *            neccessarily be equal to @p req. If NULL is returned, the
+ * @return    A pointer to the register requirements.  If NULL is returned, the
  *            operand was no register operand.
  */
 extern const arch_register_req_t *
@@ -226,7 +234,6 @@ arch_get_irn_register(const arch_env_t *env, const ir_node *irn);
  * Set the register for a certain output operand.
  * @param env The architecture environment.
  * @param irn The node.
- * @param idx The index of the output operand.
  * @param reg The register.
  */
 extern void arch_set_irn_register(const arch_env_t *env, ir_node *irn,
@@ -258,33 +265,26 @@ extern arch_irn_flags_t arch_irn_get_flags(const arch_env_t *env, const ir_node
 #define arch_irn_consider_in_reg_alloc(env, cls, irn) \
        (arch_irn_has_reg_class(env, irn, -1, cls) && !arch_irn_is(env, irn, ignore))
 
+/**
+ * Get the operations of an irn.
+ * @param self The handler from which the method is invoked.
+ * @param irn Some node.
+ * @return Operations for that irn.
+ */
+typedef const void *(arch_get_irn_ops_t)(const ir_node *irn);
+
 /**
  * Initialize the architecture environment struct.
  * @param isa           The isa which shall be put into the environment.
  * @param file_handle   The file handle
  * @return The environment.
  */
-extern arch_env_t *arch_env_init(arch_env_t *env, const arch_isa_if_t *isa,
+extern arch_env_t *arch_env_init(const arch_isa_if_t *isa,
                                  FILE *file_handle, be_main_env_t *main_env);
 
-/**
- * Add a node handler to the environment.
- * @param env The environment.
- * @param handler A node handler.
- * @return The environment itself.
- */
-extern arch_env_t *arch_env_push_irn_handler(arch_env_t *env, const arch_irn_handler_t *handler);
-
-/**
- * Remove a node handler from the handler stack.
- * @param env The architecture environment.
- * @return The popped handler.
- */
-extern const arch_irn_handler_t *arch_env_pop_irn_handler(arch_env_t *env);
-
 /**
  * Register an instruction set architecture
  */
 void be_register_isa_if(const char *name, const arch_isa_if_t *isa);
 
-#endif /* _FIRM_BEARCH_H_ */
+#endif /* FIRM_BE_BEARCH_H */