RTL obscurities
Andrew Haley
aph-gcc@littlepinkcloud.COM
Fri May 25 14:06:00 GMT 2007
Nick Maclaren writes:
> > If course, but you haven't told us what you want to know. The
> > question above reads like a request for a detailed RTL cookbook and
> > manual, and you aren't going to get that in an email response.
>
> ANY pointer to ANY information that will save me time reverse
> engineering the code!
Well, I don't know what you don't know. Have you found the GCC
internals manual?
> It is the same requirement that I had before, and which you gave me
> some pointers on the second aspect. Unfortunately, it is the first
> one that is critical :-(
>
> I really do mean that I have drawn a complete blank looking for any
> useful information, and have looked through several gcc internals
> documents
Okay, so you have found the GCC internals manual.
> and searched the Web as far as I can! Some time back, I found the
> right place to modify (ix86_expand_prologue in i386.c), and have
> inserted some RTL, but not useful RTL.
>
> What I need to do is to insert the following:
>
> extern void *__limit;
> extern void __failure (void);
> if (%SP < __limit) __failure();
>
>
> And the call doesn't need to be a standard one, either, though it
> does need to provide __failure with a way of getting back.
Firstly, you'll need to generate decls for the externs. Then you'll
need to generate RTL like this:
(insn 13 12 14 1 (set (reg:CC 17 flags)
(compare:CC (reg:SP)
(mem:DI (symbol_ref:DI ("__limit") <var_decl 0x2aaaae1958f0 __limit>) ))) -1 (nil)
(nil))
(jump_insn 14 13 15 1 (set (pc)
(if_then_else (geu (reg:CC 17 flags)
(const_int 0 [0x0]))
(label_ref 18)
(pc))) -1 (nil)
)
(call_insn 17 16 18 2 (call (mem:DI (symbol_ref:DI ("__failure") <function_decl 0x2aaaae196b00 __failure>))
(const_int 0 [0x0])) -1 (nil)
(nil)
(nil))
(code_label 18 17 19 3 2 "" [1 uses])
This construct doesn't need any scratch registers. This is good.
You've already seen how to generate RTL by perusing
ix86_expand_prologue, so you know that generating this RTL will be
done by things like
tmp = ix86_expand_int_compare (GEU, stack_pointer_rtx, limit);
tmp = gen_rtx_IF_THEN_ELSE (VOIDmode, tmp,
gen_rtx_LABEL_REF (VOIDmode, label),
pc_rtx);
emit_jump_insn (tmp);
emit_call_insn ...
emit_label (label);
... etc.
Andrew.
More information about the Gcc-help
mailing list