This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PATCH: pseudo conditional traps for ix86
- To: greg at mcgary dot org, gcc-patches at gcc dot gnu dot org
- Subject: Re: PATCH: pseudo conditional traps for ix86
- From: Linus Torvalds <torvalds at transmeta dot com>
- Date: Mon, 28 Aug 2000 18:40:06 -0700
- Newsgroups: linux.egcs.patches
In article <200008280704.AAA07356@kayak.mcgary.org> you write:
>+
>+;;; ix86 doesn't have conditional trap instructions, but we fake them
>+;;; for the sake of bounds checking. By emitting bounds checks as
>+;;; conditional traps rather than as conditional jumps around
>+;;; unconditional traps we avoid introducing spurious basic-block
>+;;; boundaries and facilitate elimination of redundant checks. In
>+;;; honor of the too-inflexible-for-BPs `bound' instruction, we use
>+;;; interrupt 5.
Why not use "into"?
The x86 _does_ have a conditional trap instruction, it's just not very
commonly used and thus easily overlooked.
Sure, it has strange behaviour - it looks at the overflow flag and
nothing else - but it's still saner than doing an "int $5" and having
jumps around it etc. And quite often you probably _can_ use the
overflow flag directly.
You could make it do an "into" when it can use the overflow flag, and
use a conditional "int $4" when it cannot.
Linus