diff options
author | 2004-12-12 11:48:37 -0700 | |
---|---|---|
committer | 2005-04-07 21:06:03 -0700 | |
commit | e7e35a9e3c2574a2acc593b290da7ec6ccb873d7 (patch) | |
tree | f8376830a263116e7056c62209d1f0787804eeeb /example.c | |
parent | Make asm linearization not drop the constraints. (diff) | |
download | sparse-e7e35a9e3c2574a2acc593b290da7ec6ccb873d7.tar.gz sparse-e7e35a9e3c2574a2acc593b290da7ec6ccb873d7.tar.bz2 sparse-e7e35a9e3c2574a2acc593b290da7ec6ccb873d7.zip |
Start looking at asms in code generation.
Just the infrastructure.
Diffstat (limited to 'example.c')
-rw-r--r-- | example.c | 41 |
1 files changed, 40 insertions, 1 deletions
@@ -43,7 +43,7 @@ static struct hardreg hardregs[] = { #define REGNO (sizeof(hardregs)/sizeof(struct hardreg)) struct bb_state { - struct basic_block *bb; + struct position pos; unsigned long stack_offset; struct storage_hash_list *inputs; struct storage_hash_list *outputs; @@ -834,6 +834,40 @@ static void generate_select(struct bb_state *state, struct instruction *insn) output_insn(state, "sele %s,%s", src2->name, dst->name); } +static void generate_asm_inputs(struct bb_state *state, struct asm_constraint_list *list) +{ + struct asm_constraint *entry; + + FOR_EACH_PTR(list, entry) { + const char *constraint = entry->constraint; + pseudo_t pseudo = entry->pseudo; + + output_comment(state, "\"%s\": %s", constraint, show_pseudo(pseudo)); + } END_FOR_EACH_PTR(entry); +} + +static void generate_asm_outputs(struct bb_state *state, struct asm_constraint_list *list) +{ + struct asm_constraint *entry; + + FOR_EACH_PTR(list, entry) { + const char *constraint = entry->constraint; + pseudo_t pseudo = entry->pseudo; + + while (*constraint == '=' || *constraint == '+') + constraint++; + + output_comment(state, "\"%s\": %s", constraint, show_pseudo(pseudo)); + } END_FOR_EACH_PTR(entry); +} + +static void generate_asm(struct bb_state *state, struct instruction *insn) +{ + generate_asm_inputs(state, insn->asm_rules->inputs); + output_insn(state, "ASM: %s", insn->string); + generate_asm_outputs(state, insn->asm_rules->outputs); +} + static void generate_one_insn(struct instruction *insn, struct bb_state *state) { if (verbose) @@ -921,6 +955,10 @@ static void generate_one_insn(struct instruction *insn, struct bb_state *state) generate_ret(state, insn); break; + case OP_ASM: + generate_asm(state, insn); + break; + default: output_insn(state, "unimplemented: %s", show_instruction(insn)); break; @@ -1216,6 +1254,7 @@ static void output_bb(struct basic_block *bb, unsigned long generation) /* Make sure all parents have been generated first */ generate_list(bb->parents, generation); + state.pos = bb->pos; state.inputs = gather_storage(bb, STOR_IN); state.outputs = gather_storage(bb, STOR_OUT); state.internal = NULL; |