+#include "belistsched.h"
+#include "beabi_t.h"
+#include "bearch_t.h"
+#include "be_t.h"
+
+struct _be_node_factory_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
+ upon a function call. It thus can be overwritten
+ in the called function. */
+ arch_register_type_callee_save = 2, /**< The register must be saved by the caller
+ upon a function call. It thus can be overwritten
+ in the called function. */
+ arch_register_type_ignore = 4, /**< Do not consider this register when allocating. */
+} arch_register_type_t;
+
+/**
+ * Convenience macro to check for register type.
+ * @param req A pointer to register.
+ * @param kind The kind of type to check for (see arch_register_type_t).
+ * @return 1, If register is of given kind, 0 if not.
+ */
+#define arch_register_type_is(reg, kind) \
+ (((reg)->type & arch_register_type_ ## kind) != 0)
+
+/**
+ * A register.
+ */
+struct _arch_register_t {
+ const char *name; /**< The name of the register. */
+ const arch_register_class_t *reg_class; /**< The class the register belongs to. */
+ int index; /**< The index of the register in the class. */
+ arch_register_type_t type; /**< The type of the register. */
+ void *data; /**< Custom data. */
+};
+
+static INLINE const arch_register_class_t *
+_arch_register_get_class(const arch_register_t *reg)
+{
+ return reg->reg_class;
+}
+
+static INLINE int _arch_register_get_index(const arch_register_t *reg)
+{
+ return reg->index;
+}
+
+#define arch_register_get_class(reg) _arch_register_get_class(reg)
+#define arch_register_get_index(reg) _arch_register_get_index(reg)
+#define arch_register_get_name(reg) ((reg)->name)
+
+/**
+ * A class of registers.
+ * Like general purpose or floating point.
+ */
+struct _arch_register_class_t {
+ const char *name; /**< The name of the register class. */
+ int n_regs; /**< Number of registers in this class. */
+ ir_mode *mode; /**< The mode of the register class. */
+ const arch_register_t *regs; /**< The array of registers. */
+};
+
+#define arch_register_class_n_regs(cls) ((cls)->n_regs)
+
+/**
+ * Put all registers in a class into a bitset.
+ * @param cls The class.
+ * @param bs The bitset. May be NULL.
+ * @return The number of registers in the class.
+ */
+extern int arch_register_class_put(const arch_register_class_t *cls, bitset_t *bs);
+
+static INLINE const arch_register_t *
+_arch_register_for_index(const arch_register_class_t *cls, int idx)
+{
+ assert(0 <= idx && idx < cls->n_regs);
+ return &cls->regs[idx];
+}
+
+#define arch_register_for_index(cls, idx) \
+ _arch_register_for_index(cls, idx)
+
+typedef enum _arch_operand_type_t {
+ arch_operand_type_invalid,
+ arch_operand_type_memory,
+ arch_operand_type_register,
+ arch_operand_type_immediate,
+ arch_operand_type_symconst,
+ arch_operand_type_last
+} 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_t;
+
+/**
+ * Convenience macro to check for set constraints.
+ * @param req A pointer to register requirements.
+ * @param kind The kind of constraint to check for (see arch_register_req_type_t).
+ * @return 1, If the kind of constraint is present, 0 if not.