#include "bearch.h"
#include "ircons_t.h"
+#include "irnode_t.h"
#include "bitset.h"
#include "pset.h"
#include "entity.h"
-arch_env_t *arch_env_init(arch_env_t *env, const arch_isa_if_t *isa_if)
+#include "irprintf.h"
+
+/* Initialize the architecture environment struct. */
+arch_env_t *arch_env_init(arch_env_t *env, const arch_isa_if_t *isa_if, FILE *file_handle)
{
memset(env, 0, sizeof(*env));
- env->isa = isa_if->init();
+ env->isa = isa_if->init(file_handle);
return env;
}
-arch_env_t *arch_env_add_irn_handler(arch_env_t *env,
+arch_env_t *arch_env_push_irn_handler(arch_env_t *env,
const arch_irn_handler_t *handler)
{
assert(env->handlers_tos <= ARCH_MAX_HANDLERS);
return env;
}
+const arch_irn_handler_t *arch_env_pop_irn_handler(arch_env_t *env)
+{
+ assert(env->handlers_tos > 0 && env->handlers_tos <= ARCH_MAX_HANDLERS);
+ return env->handlers[--env->handlers_tos];
+}
+
static const arch_irn_ops_t *fallback_irn_ops = NULL;
int arch_register_class_put(const arch_register_class_t *cls, bitset_t *bs)
return ops->impl->get_irn_reg_req(ops, req, irn, pos);
}
-void arch_set_stack_bias(const arch_env_t *env, ir_node *irn, int bias)
+void arch_set_frame_offset(const arch_env_t *env, ir_node *irn, int offset)
{
const arch_irn_ops_t *ops = get_irn_ops(env, irn);
- ops->impl->set_stack_bias(ops, irn, bias);
+ ops->impl->set_frame_offset(ops, irn, offset);
+}
+
+entity *arch_get_frame_entity(const arch_env_t *env, ir_node *irn)
+{
+ const arch_irn_ops_t *ops = get_irn_ops(env, irn);
+ return ops->impl->get_frame_entity(ops, irn);
}
const arch_irn_ops_t *ops = get_irn_ops(env, irn);
return ops->impl->get_flags(ops, irn);
}
+
+extern const char *arch_irn_flag_str(arch_irn_flags_t fl)
+{
+ switch(fl) {
+#define XXX(x) case arch_irn_flags_ ## x: return #x;
+ XXX(dont_spill);
+ XXX(ignore);
+ XXX(rematerializable);
+ XXX(modify_sp);
+ XXX(none);
+#undef XXX
+ }
+ return "n/a";
+}
+
+extern char *arch_register_req_format(char *buf, size_t len, const arch_register_req_t *req)
+{
+ char tmp[128];
+ snprintf(buf, len, "class: %s", req->cls->name);
+
+ if(arch_register_req_is(req, limited)) {
+ bitset_pos_t elm;
+ bitset_t *bs = bitset_alloca(req->cls->n_regs);
+ req->limited(req->limited_env, bs);
+ strncat(buf, " limited:", len);
+ bitset_foreach(bs, elm) {
+ strncat(buf, " ", len);
+ strncat(buf, req->cls->regs[elm].name, len);
+ }
+ }
+
+ if(arch_register_req_is(req, should_be_same)) {
+ ir_snprintf(tmp, sizeof(tmp), " same to: %+F", req->other_different);
+ strncat(buf, tmp, len);
+ }
+
+ if(arch_register_req_is(req, should_be_different)) {
+ ir_snprintf(tmp, sizeof(tmp), " different to: %+F", req->other_different);
+ strncat(buf, tmp, len);
+ }
+
+ return buf;
+}