+
+int arch_reg_is_allocatable(const ir_node *irn, int pos, const arch_register_t *reg)
+{
+ const arch_register_req_t *req = arch_get_register_req(irn, pos);
+
+ if(req->type == arch_register_req_type_none)
+ return 0;
+
+ if(arch_register_req_is(req, limited)) {
+ assert(arch_register_get_class(reg) == req->cls);
+ return rbitset_is_set(req->limited, arch_register_get_index(reg));
+ }
+
+ return req->cls == reg->reg_class;
+}
+
+const arch_register_class_t *arch_get_irn_reg_class(const ir_node *irn, int pos)
+{
+ const arch_irn_ops_t *ops = get_irn_ops(irn);
+ const arch_register_req_t *req = ops->get_irn_reg_req(irn, pos);
+
+ assert(req->type != arch_register_req_type_none || req->cls == NULL);
+
+ return req->cls;
+}
+
+const arch_register_t *arch_get_irn_register(const ir_node *irn)
+{
+ const arch_irn_ops_t *ops = get_irn_ops(irn);
+ return ops->get_irn_reg(irn);
+}
+
+void arch_set_irn_register(ir_node *irn, const arch_register_t *reg)
+{
+ const arch_irn_ops_t *ops = get_irn_ops(irn);
+ ops->set_irn_reg(irn, reg);
+}
+
+arch_irn_class_t arch_irn_classify(const ir_node *irn)
+{
+ const arch_irn_ops_t *ops = get_irn_ops(irn);
+ return ops->classify(irn);
+}
+
+arch_irn_flags_t arch_irn_get_flags(const ir_node *irn)
+{
+ const arch_irn_ops_t *ops = get_irn_ops(irn);
+ return ops->get_flags(irn);
+}
+
+extern char *arch_register_req_format(char *buf, size_t len,
+ const arch_register_req_t *req,
+ const ir_node *node)
+{
+ char tmp[128];
+ snprintf(buf, len, "class: %s", req->cls->name);
+
+ if(arch_register_req_is(req, limited)) {
+ unsigned n_regs = req->cls->n_regs;
+ unsigned i;
+
+ strncat(buf, " limited:", len);
+ for(i = 0; i < n_regs; ++i) {
+ if(rbitset_is_set(req->limited, i)) {
+ const arch_register_t *reg = &req->cls->regs[i];
+ strncat(buf, " ", len);
+ strncat(buf, reg->name, len);
+ }
+ }
+ }
+
+ if(arch_register_req_is(req, should_be_same)) {
+ const unsigned other = req->other_same;
+ int i;
+
+ ir_snprintf(tmp, sizeof(tmp), " same to:");
+ for (i = 0; 1U << i <= other; ++i) {
+ if (other & (1U << i)) {
+ ir_snprintf(tmp, sizeof(tmp), " %+F", get_irn_n(skip_Proj_const(node), i));
+ strncat(buf, tmp, len);
+ }
+ }
+ }
+
+ if (arch_register_req_is(req, must_be_different)) {
+ const unsigned other = req->other_different;
+ int i;
+
+ ir_snprintf(tmp, sizeof(tmp), " different from:");
+ for (i = 0; 1U << i <= other; ++i) {
+ if (other & (1U << i)) {
+ ir_snprintf(tmp, sizeof(tmp), " %+F", get_irn_n(skip_Proj_const(node), i));
+ strncat(buf, tmp, len);
+ }
+ }
+ }
+
+ return buf;
+}
+
+static const arch_register_req_t no_requirement = {
+ arch_register_req_type_none,
+ NULL,
+ NULL,
+ 0,
+ 0
+};
+const arch_register_req_t *arch_no_register_req = &no_requirement;