re PR target/64003 (valgrind complains about get_attr_length_nobnd in insn-attrtab...
authorUros Bizjak <ubizjak@gmail.com>
Fri, 24 Jul 2015 16:25:56 +0000 (18:25 +0200)
committerUros Bizjak <uros@gcc.gnu.org>
Fri, 24 Jul 2015 16:25:56 +0000 (18:25 +0200)
PR target/64003
* config/i386/i386.h (ADJUST_INSN_LENGTH): New define.
* config/i386/i386.md (maybe_prefix_bnd): New attribute.
(*jcc_1, *jcc_2, jump, simple_return_internal)
(simple_return_pop_internal): Set attribute maybe_prefix_bnd.
Set length_nobnd attribute instead of length attribute.
(indirect_jump, *tablejump_1): Set attribute maybe_prefix_bnd.
(length_nobnd): Remove attribute.
(length): Remove length_nobnd processing.

From-SVN: r226173

gcc/ChangeLog
gcc/config/i386/i386.h
gcc/config/i386/i386.md

index 6fa9959..9f2f87b 100644 (file)
@@ -1,3 +1,15 @@
+2015-07-24  Uros Bizjak  <ubizjak@gmail.com>
+
+       PR target/64003
+       * config/i386/i386.h (ADJUST_INSN_LENGTH): New define.
+       * config/i386/i386.md (maybe_prefix_bnd): New attribute.
+       (*jcc_1, *jcc_2, jump, simple_return_internal)
+       (simple_return_pop_internal): Set attribute maybe_prefix_bnd.
+       Set length_nobnd attribute instead of length attribute.
+       (indirect_jump, *tablejump_1): Set attribute maybe_prefix_bnd.
+       (length_nobnd): Remove attribute.
+       (length): Remove length_nobnd processing.
+
 2015-07-24  Nathan Sidwell  <nathan@codesourcery.com>
 
        * gimplify.c (omp_default_clause): New function.  Reorganize flow
index ab668fe..72ec74d 100644 (file)
@@ -2260,6 +2260,14 @@ do {                                                                     \
 /* Default threshold for putting data in large sections
    with x86-64 medium memory model */
 #define DEFAULT_LARGE_SECTION_THRESHOLD 65536
+
+/* Adjust the length of the insn with the length of BND prefix.  */
+#define ADJUST_INSN_LENGTH(INSN, LENGTH)       \
+do {                                           \
+  if (recog_memoized (INSN) >= 0               \
+      && get_attr_maybe_prefix_bnd (INSN))     \
+    LENGTH += ix86_bnd_prefixed_insn_p (INSN); \
+} while (0)
 \f
 /* Which processor to tune code generation for.  These must be in sync
    with processor_target_table in i386.c.  */ 
index 18d0503..6b924e7 100644 (file)
        ]
        (const_int 0)))
 
+;; Set when BND opcode prefix may be used.
+(define_attr "maybe_prefix_bnd" "" (const_int 0))
+
 ;; Prefix used: original, VEX or maybe VEX.
 (define_attr "prefix" "orig,vex,maybe_vex,evex,maybe_evex"
   (cond [(eq_attr "mode" "OI,V8SF,V4DF")
         ]
         (const_int 1)))
 
-;; When this attribute is set, calculate total insn length from
-;; length_nobnd attribute, prefixed with eventual bnd prefix byte
-(define_attr "length_nobnd" "" (const_int 0))
-
 ;; The (bounding maximum) length of an instruction in bytes.
 ;; ??? fistp and frndint are in fact fldcw/{fistp,frndint}/fldcw sequences.
 ;; Later we may want to split them and compute proper length as for
 ;; other insns.
 (define_attr "length" ""
-  (cond [(eq_attr "length_nobnd" "!0")
-          (plus (symbol_ref ("ix86_bnd_prefixed_insn_p (insn)"))
-                (attr "length_nobnd"))
-        (eq_attr "type" "other,multi,fistp,frndint")
+  (cond [(eq_attr "type" "other,multi,fistp,frndint")
           (const_int 16)
         (eq_attr "type" "fcmp")
           (const_int 4)
   "%!%+j%C1\t%l0"
   [(set_attr "type" "ibr")
    (set_attr "modrm" "0")
-   (set (attr "length_nobnd")
+   (set (attr "length")
        (if_then_else
          (and (ge (minus (match_dup 0) (pc))
                   (const_int -126))
               (lt (minus (match_dup 0) (pc))
                   (const_int 128)))
          (const_int 2)
-         (const_int 6)))])
+         (const_int 6)))
+   (set_attr "maybe_prefix_bnd" "1")])
 
 (define_insn "*jcc_2"
   [(set (pc)
   "%!%+j%c1\t%l0"
   [(set_attr "type" "ibr")
    (set_attr "modrm" "0")
-   (set (attr "length_nobnd")
+   (set (attr "length")
        (if_then_else
          (and (ge (minus (match_dup 0) (pc))
                   (const_int -126))
               (lt (minus (match_dup 0) (pc))
                   (const_int 128)))
          (const_int 2)
-         (const_int 6)))])
+         (const_int 6)))
+   (set_attr "maybe_prefix_bnd" "1")])
 
 ;; In general it is not safe to assume too much about CCmode registers,
 ;; so simplify-rtx stops when it sees a second one.  Under certain
   "%!jmp\t%l0"
   [(set_attr "type" "ibr")
    (set_attr "modrm" "0")
-   (set (attr "length_nobnd")
+   (set (attr "length")
        (if_then_else
          (and (ge (minus (match_dup 0) (pc))
                   (const_int -126))
               (lt (minus (match_dup 0) (pc))
                   (const_int 128)))
          (const_int 2)
-         (const_int 5)))])
+         (const_int 5)))
+   (set_attr "maybe_prefix_bnd" "1")])
 
 (define_expand "indirect_jump"
   [(set (pc) (match_operand 0 "indirect_branch_operand"))]
   ""
   "%!jmp\t%A0"
   [(set_attr "type" "ibr")
-   (set_attr "length_immediate" "0")])
+   (set_attr "length_immediate" "0")
+   (set_attr "maybe_prefix_bnd" "1")])
 
 (define_expand "tablejump"
   [(parallel [(set (pc) (match_operand 0 "indirect_branch_operand"))
   ""
   "%!jmp\t%A0"
   [(set_attr "type" "ibr")
-   (set_attr "length_immediate" "0")])
+   (set_attr "length_immediate" "0")
+   (set_attr "maybe_prefix_bnd" "1")])
 \f
 ;; Convert setcc + movzbl to xor + setcc if operands don't overlap.
 
   [(simple_return)]
   "reload_completed"
   "%!ret"
-  [(set_attr "length_nobnd" "1")
+  [(set_attr "length" "1")
    (set_attr "atom_unit" "jeu")
    (set_attr "length_immediate" "0")
-   (set_attr "modrm" "0")])
+   (set_attr "modrm" "0")
+   (set_attr "maybe_prefix_bnd" "1")])
 
 ;; Used by x86_machine_dependent_reorg to avoid penalty on single byte RET
 ;; instruction Athlon and K8 have.
    (use (match_operand:SI 0 "const_int_operand"))]
   "reload_completed"
   "%!ret\t%0"
-  [(set_attr "length_nobnd" "3")
+  [(set_attr "length" "3")
    (set_attr "atom_unit" "jeu")
    (set_attr "length_immediate" "2")
-   (set_attr "modrm" "0")])
+   (set_attr "modrm" "0")
+   (set_attr "maybe_prefix_bnd" "1")])
 
 (define_insn "simple_return_indirect_internal"
   [(simple_return)
   "reload_completed"
   "%!jmp\t%A0"
   [(set_attr "type" "ibr")
-   (set_attr "length_immediate" "0")])
+   (set_attr "length_immediate" "0")
+   (set_attr "maybe_prefix_bnd" "1")])
 
 (define_insn "nop"
   [(const_int 0)]