Check rule sets for required target flags
authorDavid Schleef <ds@schleef.org>
Wed, 29 Apr 2009 05:06:07 +0000 (22:06 -0700)
committerDavid Schleef <ds@schleef.org>
Wed, 29 Apr 2009 05:06:07 +0000 (22:06 -0700)
orc/orccompiler.c
orc/orcopcodes.c
orc/orcprogram.h

index ed3a45a..aadea44 100644 (file)
@@ -181,7 +181,8 @@ orc_compiler_assign_rules (OrcCompiler *compiler)
   for(i=0;i<compiler->n_insns;i++) {
     OrcInstruction *insn = compiler->insns + i;
 
-    insn->rule = orc_target_get_rule (compiler->target, insn->opcode);
+    insn->rule = orc_target_get_rule (compiler->target, insn->opcode,
+        compiler->target_flags);
 
     if (insn->rule == NULL || insn->rule->emit == NULL) {
       ORC_PROGRAM_ERROR(compiler, "No rule for: %s", insn->opcode->name);
index 67e537a..2cbb9c6 100644 (file)
@@ -123,7 +123,8 @@ orc_rule_set_new (OrcOpcodeSet *opcode_set, OrcTarget *target,
 }
 
 OrcRule *
-orc_target_get_rule (OrcTarget *target, OrcStaticOpcode *opcode)
+orc_target_get_rule (OrcTarget *target, OrcStaticOpcode *opcode,
+    unsigned int target_flags)
 {
   OrcRule *rule;
   int i;
@@ -138,6 +139,7 @@ orc_target_get_rule (OrcTarget *target, OrcStaticOpcode *opcode)
 
     for(i=0;i<target->n_rule_sets;i++){
       if (target->rule_sets[i].opcode_set != opcode_sets + k) continue;
+      if (target->rule_sets[i].required_target_flags & (~target_flags)) continue;
 
       rule = target->rule_sets[i].rules + j;
       if (rule->emit) return rule;
index 7360ced..00bea9c 100644 (file)
@@ -350,7 +350,8 @@ OrcRuleSet * orc_rule_set_new (OrcOpcodeSet *opcode_set, OrcTarget *target,
     unsigned int required_flags);
 void orc_rule_register (OrcRuleSet *rule_set, const char *opcode_name,
     OrcRuleEmitFunc emit, void *emit_user);
-OrcRule * orc_target_get_rule (OrcTarget *target, OrcStaticOpcode *opcode);
+OrcRule * orc_target_get_rule (OrcTarget *target, OrcStaticOpcode *opcode,
+    unsigned int target_flags);
 OrcTarget * orc_target_get_default (void);
 
 int orc_program_allocate_register (OrcProgram *program, int is_data);