On Thu, Oct 2, 2014 at 10:23 AM, Ilya Enkovich <enkovich....@gmail.com> wrote:

> 2014-10-01  Ilya Enkovich  <ilya.enkov...@intel.com>
>
>         * config/i386/i386.md (UNSPEC_SIZEOF): New.
>         (move_size_reloc_<mode>): New.
>         * config/i386/predicates.md (symbol_operand): New.
>         (x86_64_immediate_size_operand): New.

OK with a trivial adjustment.

Thanks,
Uros.

> diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
> index 65990b1..1901023 100644
> --- a/gcc/config/i386/i386.md
> +++ b/gcc/config/i386/i386.md
> @@ -79,6 +79,7 @@
>    UNSPEC_PLTOFF
>    UNSPEC_MACHOPIC_OFFSET
>    UNSPEC_PCREL
> +  UNSPEC_SIZEOF
>
>    ;; Prologue support
>    UNSPEC_STACK_ALLOC
> @@ -18789,6 +18790,21 @@
>    "bndstx\t{%2, %3|%3, %2}"
>    [(set_attr "type" "mpxst")])
>
> +(define_insn "move_size_reloc_<mode>"
> +  [(set (match_operand:SWI48 0 "register_operand" "=r")
> +       (unspec:SWI48
> +        [(match_operand:SWI48 1 "symbol_operand")]
> +        UNSPEC_SIZEOF))]
> +  "TARGET_MPX"
> +{
> +  if (x86_64_immediate_size_operand (operands[1], VOIDmode))
> +    return "mov{l}\t{%1@SIZE, %k0|%k0, %1@SIZE}";
> +  else
> +    return "movabs{q}\t{%1@SIZE, %0|%0, %1@SIZE}";
> +}
> +  [(set_attr "type" "imov")
> +   (set_attr "mode" "<MODE>")])
> +
>  (include "mmx.md")
>  (include "sse.md")
>  (include "sync.md")
> diff --git a/gcc/config/i386/predicates.md b/gcc/config/i386/predicates.md
> index fea7754..1875339 100644
> --- a/gcc/config/i386/predicates.md
> +++ b/gcc/config/i386/predicates.md
> @@ -124,6 +124,10 @@
>         (match_test "TARGET_64BIT")
>         (match_test "REGNO (op) > BX_REG")))
>
> +;; Return true if VALUE is symbol reference
> +(define_predicate "symbol_operand"
> +  (match_code "symbol_ref"))
> +
>  ;; Return true if VALUE can be stored in a sign extended immediate field.
>  (define_predicate "x86_64_immediate_operand"
>    (match_code "const_int,symbol_ref,label_ref,const")
> @@ -336,6 +340,14 @@
>    return false;
>  })
>
> +;; Return true if size of VALUE can be stored in a sign
> +;; extended immediate field.
> +(define_predicate "x86_64_immediate_size_operand"
> +  (and (match_code "symbol_ref")
> +       (ior (not (match_test "TARGET_64BIT"))
> +           (ior (match_test ("ix86_cmodel == CM_SMALL"))
> +                (match_test ("ix86_cmodel == CM_KERNEL"))))))

Uh yes, I did a trivial thinko. Please note that above (ior) can be
rewritten with a multiple arguments:

(define_predicate "x86_64_immediate_size_operand"
  (and (match_code "symbol_ref")
       (ior (not (match_test "TARGET_64BIT"))
           (match_test "ix86_cmodel == CM_SMALL")
           (match_test "ix86_cmodel == CM_KERNEL"))))

Also, there were unneded parenthesis for match_test removed.

>  ;; Return true if OP is general operand representable on x86_64.
>  (define_predicate "x86_64_general_operand"
>    (if_then_else (match_test "TARGET_64BIT")

Reply via email to