diff options
author | Greg McGary <greg@mcgary.org> | 2000-08-28 21:48:05 +0000 |
---|---|---|
committer | Greg McGary <greg@mcgary.org> | 2000-08-28 21:48:05 +0000 |
commit | a364425ca9eb18e55e26826d8399d93714b2f3b2 (patch) | |
tree | 4afd2c90f17b6c9584b7293aaa8366d3ee23a0c5 /gcc/config/i386/i386.md | |
parent | db3aeaab110e26a33e84fd5edc5317fe1008ba3a (diff) |
* config/i386/i386-protos.h (ix86_expand_compare): Add extern decl.
* config/i386/i386.c (ix86_expand_compare): Remove `static'.
* config/i386/i386.md (trap, conditional_trap): New insn & expand.
git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@36019 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/config/i386/i386.md')
-rw-r--r-- | gcc/config/i386/i386.md | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index cada4dfcf56..7d4faf347cb 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -11129,3 +11129,52 @@ return \"call\\t%*%1\"; }" [(set_attr "type" "callv")]) + +(define_insn "trap" + [(trap_if (const_int 1) (const_int 5))] + "" + "int\\t$5") + +;;; 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. +;;; +;;; FIXME: Static branch prediction rules for ix86 are such that +;;; forward conditional branches predict as untaken. As implemented +;;; below, pseudo conditional traps violate that rule. We should use +;;; .pushsection/.popsection to place all of the `int 5's in a special +;;; section loaded at the end of the text segment and branch forward +;;; there on bounds-failure, and then jump back immediately (in case +;;; the system chooses to ignore bounds violations, or to report +;;; violations and continue execution). + +(define_expand "conditional_trap" + [(trap_if (match_operator 0 "comparison_operator" + [(match_dup 2) (const_int 0)]) + (match_operand 1 "const_int_operand" ""))] + "" + " +{ + emit_insn (gen_rtx_TRAP_IF (VOIDmode, + ix86_expand_compare (GET_CODE (operands[0])), + operands[1])); + DONE; +}") + +(define_insn "" + [(trap_if (match_operator 0 "comparison_operator" + [(reg 17) (const_int 0)]) + (match_operand 1 "const_int_operand" ""))] + "" + "* +{ + operands[2] = gen_label_rtx (); + output_asm_insn (\"j%c0\\t%l2\; int\\t%1\", operands); + ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, \"L\", + CODE_LABEL_NUMBER (operands[2])); + RET; +}") |