public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: [PATCH, i386, MPX, 2/X] Pointers Checker [21/25] Size relocation
@ 2013-11-18 23:31 Uros Bizjak
  2013-11-19 21:58 ` Ilya Enkovich
  0 siblings, 1 reply; 13+ messages in thread
From: Uros Bizjak @ 2013-11-18 23:31 UTC (permalink / raw)
  To: gcc-patches
  Cc: Илья
	Энкович

Hello!

> Here is a patch to add size relocation and instruction to obtain object's size in i386 target.

+(define_insn "move_size_reloc_<mode>"
+  [(set (match_operand:SWI48 0 "register_operand" "=r")
+        (match_operand:<MODE> 1 "size_relocation" "Z"))]
+  ""
+{
+  return "mov{<imodesuffix>}\t{%1, %0|%0, %1}";

Please don't change x86_64_immediate_operand just to use "Z"
constraint The predicate is used in a couple of other places that for
sure don't accept your change.

Better write this insn in an explicit way (see for example
tls_initial_exec_64_sun). Something like:

(define_insn "move_size_reloc_<mode>"
  [(set (match_operand:SWI48 0 "register_operand" "=r")
    (unspec:SWI48
     [(match_operand 1 "symbolic_operand" "..." )]
     UNSPEC_SIZEOF))]
  ""
  "mov{<imodesuffix>}\t{%a1@SIZE, %0|%0, %a1@SIZE}")

You will probably need to define new operand 1 predicate and constraint.

Uros.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH, i386, MPX, 2/X] Pointers Checker [21/25] Size relocation
  2013-11-18 23:31 [PATCH, i386, MPX, 2/X] Pointers Checker [21/25] Size relocation Uros Bizjak
@ 2013-11-19 21:58 ` Ilya Enkovich
  2013-11-20  9:59   ` Uros Bizjak
  0 siblings, 1 reply; 13+ messages in thread
From: Ilya Enkovich @ 2013-11-19 21:58 UTC (permalink / raw)
  To: Uros Bizjak; +Cc: gcc-patches

On 18 Nov 22:00, Uros Bizjak wrote:
> Hello!
> 
> > Here is a patch to add size relocation and instruction to obtain object's size in i386 target.
> 
> +(define_insn "move_size_reloc_<mode>"
> +  [(set (match_operand:SWI48 0 "register_operand" "=r")
> +        (match_operand:<MODE> 1 "size_relocation" "Z"))]
> +  ""
> +{
> +  return "mov{<imodesuffix>}\t{%1, %0|%0, %1}";
> 
> Please don't change x86_64_immediate_operand just to use "Z"
> constraint The predicate is used in a couple of other places that for
> sure don't accept your change.
> 
> Better write this insn in an explicit way (see for example
> tls_initial_exec_64_sun). Something like:
> 
> (define_insn "move_size_reloc_<mode>"
>   [(set (match_operand:SWI48 0 "register_operand" "=r")
>     (unspec:SWI48
>      [(match_operand 1 "symbolic_operand" "..." )]
>      UNSPEC_SIZEOF))]
>   ""
>   "mov{<imodesuffix>}\t{%a1@SIZE, %0|%0, %a1@SIZE}")
> 
> You will probably need to define new operand 1 predicate and constraint.
> 
> Uros.

Hi, Uros!  Thanks for comments!  Here is what I got trying to follow your suggestion.  Does it look better?

Thanks,
Ilya
--
2013-11-19  Ilya Enkovich  <ilya.enkovich@intel.com>

	* config/i386/i386.md (UNSPEC_SIZEOF): New.
	(move_size_reloc_<mode>): New.
	* gcc/config/i386/constraints.md (TS): New.
	* config/i386/predicates.md (symbol_operand): New.


diff --git a/gcc/config/i386/constraints.md b/gcc/config/i386/constraints.md
index 7289ae4..1697065 100644
--- a/gcc/config/i386/constraints.md
+++ b/gcc/config/i386/constraints.md
@@ -241,6 +241,7 @@
 ;;   s - address with no segment register
 ;;   i - address with no index and no rip
 ;;   b - address with no base and no rip
+;;   S - symbol reference
 
 (define_address_constraint "Tv"
   "VSIB address operand"
@@ -257,3 +258,7 @@
 (define_address_constraint "Tb"
   "MPX address operand without base"
   (match_operand 0 "address_mpx_no_base_operand"))
+
+(define_address_constraint "TS"
+  "Symbol reference"
+  (match_operand 0 "symbol_operand"))
diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
index e23b3b6..dc7d81a 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
@@ -18446,6 +18447,14 @@
   "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:<MODE>
+	 [(match_operand:<MODE> 1 "symbol_operand" "TS")]
+	 UNSPEC_SIZEOF))]
+  ""
+  "mov{<imodesuffix>}\t{$%p1@SIZE, %0|%0, $%p1@SIZE}")
+
 (include "mmx.md")
 (include "sse.md")
 (include "sync.md")
diff --git a/gcc/config/i386/predicates.md b/gcc/config/i386/predicates.md
index 66ac52f..5c758ab 100644
--- a/gcc/config/i386/predicates.md
+++ b/gcc/config/i386/predicates.md
@@ -119,6 +119,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")

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH, i386, MPX, 2/X] Pointers Checker [21/25] Size relocation
  2013-11-19 21:58 ` Ilya Enkovich
@ 2013-11-20  9:59   ` Uros Bizjak
  2013-11-20 14:02     ` Ilya Enkovich
  0 siblings, 1 reply; 13+ messages in thread
From: Uros Bizjak @ 2013-11-20  9:59 UTC (permalink / raw)
  To: Ilya Enkovich; +Cc: gcc-patches

On Tue, Nov 19, 2013 at 9:43 PM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:

>> > Here is a patch to add size relocation and instruction to obtain object's size in i386 target.
>>
>> +(define_insn "move_size_reloc_<mode>"
>> +  [(set (match_operand:SWI48 0 "register_operand" "=r")
>> +        (match_operand:<MODE> 1 "size_relocation" "Z"))]
>> +  ""
>> +{
>> +  return "mov{<imodesuffix>}\t{%1, %0|%0, %1}";
>>
>> Please don't change x86_64_immediate_operand just to use "Z"
>> constraint The predicate is used in a couple of other places that for
>> sure don't accept your change.
>>
>> Better write this insn in an explicit way (see for example
>> tls_initial_exec_64_sun). Something like:
>>
>> (define_insn "move_size_reloc_<mode>"
>>   [(set (match_operand:SWI48 0 "register_operand" "=r")
>>     (unspec:SWI48
>>      [(match_operand 1 "symbolic_operand" "..." )]
>>      UNSPEC_SIZEOF))]
>>   ""
>>   "mov{<imodesuffix>}\t{%a1@SIZE, %0|%0, %a1@SIZE}")
>>
>> You will probably need to define new operand 1 predicate and constraint.
>>
>> Uros.
>
> Hi, Uros!  Thanks for comments!  Here is what I got trying to follow your suggestion.  Does it look better?

You actually don't need any operand modifiers in the insn template. Simply use:

"mov{<imodesuffix>}\t{%1@SIZE, %0|%0, %1@SIZE}"

and you will automatically get

"movl $zzz, %eax" or "mov %eax, OFFSET FLAT: zzz".

Since your pattern allows only symbolic_operand, there is no reload,
so you can avoid the constraint alltogether.

BTW: Did you consider various -mcmodel=... options? For DImode moves,
you should check x86_64_zext_immediate_operand predicate and output
either "movl $zzz, %eax" or "movabs $zzz, %rax". There is no movq with
64bit immediate. Please see movdi pattern.

Uros.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH, i386, MPX, 2/X] Pointers Checker [21/25] Size relocation
  2013-11-20  9:59   ` Uros Bizjak
@ 2013-11-20 14:02     ` Ilya Enkovich
  2013-11-20 17:04       ` Uros Bizjak
  0 siblings, 1 reply; 13+ messages in thread
From: Ilya Enkovich @ 2013-11-20 14:02 UTC (permalink / raw)
  To: Uros Bizjak; +Cc: gcc-patches

On 20 Nov 09:49, Uros Bizjak wrote:
> On Tue, Nov 19, 2013 at 9:43 PM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
> 
> >> > Here is a patch to add size relocation and instruction to obtain object's size in i386 target.
> >>
> >> +(define_insn "move_size_reloc_<mode>"
> >> +  [(set (match_operand:SWI48 0 "register_operand" "=r")
> >> +        (match_operand:<MODE> 1 "size_relocation" "Z"))]
> >> +  ""
> >> +{
> >> +  return "mov{<imodesuffix>}\t{%1, %0|%0, %1}";
> >>
> >> Please don't change x86_64_immediate_operand just to use "Z"
> >> constraint The predicate is used in a couple of other places that for
> >> sure don't accept your change.
> >>
> >> Better write this insn in an explicit way (see for example
> >> tls_initial_exec_64_sun). Something like:
> >>
> >> (define_insn "move_size_reloc_<mode>"
> >>   [(set (match_operand:SWI48 0 "register_operand" "=r")
> >>     (unspec:SWI48
> >>      [(match_operand 1 "symbolic_operand" "..." )]
> >>      UNSPEC_SIZEOF))]
> >>   ""
> >>   "mov{<imodesuffix>}\t{%a1@SIZE, %0|%0, %a1@SIZE}")
> >>
> >> You will probably need to define new operand 1 predicate and constraint.
> >>
> >> Uros.
> >
> > Hi, Uros!  Thanks for comments!  Here is what I got trying to follow your suggestion.  Does it look better?
> 
> You actually don't need any operand modifiers in the insn template. Simply use:
> 
> "mov{<imodesuffix>}\t{%1@SIZE, %0|%0, %1@SIZE}"
> 
> and you will automatically get
> 
> "movl $zzz, %eax" or "mov %eax, OFFSET FLAT: zzz".
> 
> Since your pattern allows only symbolic_operand, there is no reload,
> so you can avoid the constraint alltogether.
> 
> BTW: Did you consider various -mcmodel=... options? For DImode moves,
> you should check x86_64_zext_immediate_operand predicate and output
> either "movl $zzz, %eax" or "movabs $zzz, %rax". There is no movq with
> 64bit immediate. Please see movdi pattern.
> 
> Uros.

Yep, for large objects it may work wrongly. Does anyone use static objects >4Gb? :)

Large address does not mean large object but seems we have to be conservative here. I added  x86_64_zext_immediate_operand check with additional CM_KERNEL check because in this model object size should always fit 32 bits.

Thanks,
Ilya
--

gcc/

2013-11-19  Ilya Enkovich  <ilya.enkovich@intel.com>

	* config/i386/i386.md (UNSPEC_SIZEOF): New.
	(move_size_reloc_<mode>): New.
	* config/i386/predicates.md (symbol_operand): New.

diff --git a/gcc/config/i386/constraints.md b/gcc/config/i386/constraints.md
index 7289ae4..b29fadb 100644
--- a/gcc/config/i386/constraints.md
+++ b/gcc/config/i386/constraints.md
@@ -241,6 +241,7 @@
 ;;   s - address with no segment register
 ;;   i - address with no index and no rip
 ;;   b - address with no base and no rip
+;;   S - symbol reference
 
 (define_address_constraint "Tv"
   "VSIB address operand"
diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
index e23b3b6..772c09d 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
@@ -18446,6 +18447,22 @@
   "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:<MODE>
+	 [(match_operand:<MODE> 1 "symbol_operand")]
+	 UNSPEC_SIZEOF))]
+  ""
+{
+  if (GET_MODE (operands[0]) == SImode)
+    return "mov{l}\t{%1@SIZE, %k0|%k0, %1@SIZE}";
+  else if (x86_64_zext_immediate_operand (operands[1], VOIDmode)
+	   || ix86_cmodel == CM_KERNEL)
+    return "mov{q}\t{%1@SIZE, %0|%0, %1@SIZE}";
+  else
+    return "movabs{q}\t{%1@SIZE, %0|%0, %1@SIZE}";
+})
+
 (include "mmx.md")
 (include "sse.md")
 (include "sync.md")
diff --git a/gcc/config/i386/predicates.md b/gcc/config/i386/predicates.md
index 66ac52f..5c758ab 100644
--- a/gcc/config/i386/predicates.md
+++ b/gcc/config/i386/predicates.md
@@ -119,6 +119,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")

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH, i386, MPX, 2/X] Pointers Checker [21/25] Size relocation
  2013-11-20 14:02     ` Ilya Enkovich
@ 2013-11-20 17:04       ` Uros Bizjak
  2013-11-20 17:12         ` Ilya Enkovich
  0 siblings, 1 reply; 13+ messages in thread
From: Uros Bizjak @ 2013-11-20 17:04 UTC (permalink / raw)
  To: Ilya Enkovich; +Cc: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 2426 bytes --]

On Wed, Nov 20, 2013 at 1:32 PM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:

>> >> > Here is a patch to add size relocation and instruction to obtain object's size in i386 target.
>> >>
>> >> +(define_insn "move_size_reloc_<mode>"
>> >> +  [(set (match_operand:SWI48 0 "register_operand" "=r")
>> >> +        (match_operand:<MODE> 1 "size_relocation" "Z"))]
>> >> +  ""
>> >> +{
>> >> +  return "mov{<imodesuffix>}\t{%1, %0|%0, %1}";
>> >>
>> >> Please don't change x86_64_immediate_operand just to use "Z"
>> >> constraint The predicate is used in a couple of other places that for
>> >> sure don't accept your change.
>> >>
>> >> Better write this insn in an explicit way (see for example
>> >> tls_initial_exec_64_sun). Something like:
>> >>
>> >> (define_insn "move_size_reloc_<mode>"
>> >>   [(set (match_operand:SWI48 0 "register_operand" "=r")
>> >>     (unspec:SWI48
>> >>      [(match_operand 1 "symbolic_operand" "..." )]
>> >>      UNSPEC_SIZEOF))]
>> >>   ""
>> >>   "mov{<imodesuffix>}\t{%a1@SIZE, %0|%0, %a1@SIZE}")
>> >>
>> >> You will probably need to define new operand 1 predicate and constraint.
>> >>
>> >> Uros.
>> >
>> > Hi, Uros!  Thanks for comments!  Here is what I got trying to follow your suggestion.  Does it look better?
>>
>> You actually don't need any operand modifiers in the insn template. Simply use:
>>
>> "mov{<imodesuffix>}\t{%1@SIZE, %0|%0, %1@SIZE}"
>>
>> and you will automatically get
>>
>> "movl $zzz, %eax" or "mov %eax, OFFSET FLAT: zzz".
>>
>> Since your pattern allows only symbolic_operand, there is no reload,
>> so you can avoid the constraint alltogether.
>>
>> BTW: Did you consider various -mcmodel=... options? For DImode moves,
>> you should check x86_64_zext_immediate_operand predicate and output
>> either "movl $zzz, %eax" or "movabs $zzz, %rax". There is no movq with
>> 64bit immediate. Please see movdi pattern.
>
> Yep, for large objects it may work wrongly. Does anyone use static objects >4Gb? :)
>
> Large address does not mean large object but seems we have to be conservative here. I added  x86_64_zext_immediate_operand check with additional CM_KERNEL check because in this model object size should always fit 32 bits.

IMO, we should list code models that support object sizes > 31bits for
64bit target. The object size in small models will never be > 31bits
(and never negative), so we can use movl unconditionally.

Please try attached patch.

Uros.

[-- Attachment #2: p.diff.txt --]
[-- Type: text/plain, Size: 1713 bytes --]

Index: i386.md
===================================================================
--- i386.md	(revision 205051)
+++ i386.md	(working copy)
@@ -79,6 +79,7 @@
   UNSPEC_PLTOFF
   UNSPEC_MACHOPIC_OFFSET
   UNSPEC_PCREL
+  UNSPEC_SIZEOF
 
   ;; Prologue support
   UNSPEC_STACK_ALLOC
@@ -18458,6 +18459,30 @@
   "bndstx\t{%2, %3|%3, %2}"
   [(set_attr "type" "mpxst")])
 
+(define_insn "move_size_reloc_si"
+  [(set (match_operand:SI 0 "register_operand" "=r")
+	(unspec:SI
+	 [(match_operand:SI 1 "symbol_operand")]
+	 UNSPEC_SIZEOF))]
+  "TARGET_MPX"
+  "mov{l}\t{%1@SIZE, %0|%0, %1@SIZE}"
+  [(set_attr "type" "imov")])
+
+(define_insn "move_size_reloc_di"
+  [(set (match_operand:DI 0 "register_operand" "=r")
+	(unspec:DI
+	 [(match_operand:DI 1 "symbol_operand")]
+	 UNSPEC_SIZEOF))]
+  "TARGET_64BIT && TARGET_MPX"
+{
+  if (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE
+      || ix86_cmodel == CM_MEDIUM_PIC || ix86_cmodel == CM_LARGE_PIC)
+    return "movabs{q}\t{%1@SIZE, %0|%0, %1@SIZE}";
+  else
+    return "mov{l}\t{%1@SIZE, %k0|%k0, %1@SIZE}";
+}
+  [(set_attr "type" "imov")])
+
 (include "mmx.md")
 (include "sse.md")
 (include "sync.md")
Index: predicates.md
===================================================================
--- predicates.md	(revision 205051)
+++ predicates.md	(working copy)
@@ -119,6 +119,10 @@
        (match_test "TARGET_64BIT")
        (match_test "REGNO (op) > BX_REG")))
 
+;; Return true if VALUE is a 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")

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH, i386, MPX, 2/X] Pointers Checker [21/25] Size relocation
  2013-11-20 17:04       ` Uros Bizjak
@ 2013-11-20 17:12         ` Ilya Enkovich
  2013-11-20 17:27           ` Uros Bizjak
  0 siblings, 1 reply; 13+ messages in thread
From: Ilya Enkovich @ 2013-11-20 17:12 UTC (permalink / raw)
  To: Uros Bizjak; +Cc: gcc-patches

2013/11/20 Uros Bizjak <ubizjak@gmail.com>:
> On Wed, Nov 20, 2013 at 1:32 PM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>
>>> >> > Here is a patch to add size relocation and instruction to obtain object's size in i386 target.
>>> >>
>>> >> +(define_insn "move_size_reloc_<mode>"
>>> >> +  [(set (match_operand:SWI48 0 "register_operand" "=r")
>>> >> +        (match_operand:<MODE> 1 "size_relocation" "Z"))]
>>> >> +  ""
>>> >> +{
>>> >> +  return "mov{<imodesuffix>}\t{%1, %0|%0, %1}";
>>> >>
>>> >> Please don't change x86_64_immediate_operand just to use "Z"
>>> >> constraint The predicate is used in a couple of other places that for
>>> >> sure don't accept your change.
>>> >>
>>> >> Better write this insn in an explicit way (see for example
>>> >> tls_initial_exec_64_sun). Something like:
>>> >>
>>> >> (define_insn "move_size_reloc_<mode>"
>>> >>   [(set (match_operand:SWI48 0 "register_operand" "=r")
>>> >>     (unspec:SWI48
>>> >>      [(match_operand 1 "symbolic_operand" "..." )]
>>> >>      UNSPEC_SIZEOF))]
>>> >>   ""
>>> >>   "mov{<imodesuffix>}\t{%a1@SIZE, %0|%0, %a1@SIZE}")
>>> >>
>>> >> You will probably need to define new operand 1 predicate and constraint.
>>> >>
>>> >> Uros.
>>> >
>>> > Hi, Uros!  Thanks for comments!  Here is what I got trying to follow your suggestion.  Does it look better?
>>>
>>> You actually don't need any operand modifiers in the insn template. Simply use:
>>>
>>> "mov{<imodesuffix>}\t{%1@SIZE, %0|%0, %1@SIZE}"
>>>
>>> and you will automatically get
>>>
>>> "movl $zzz, %eax" or "mov %eax, OFFSET FLAT: zzz".
>>>
>>> Since your pattern allows only symbolic_operand, there is no reload,
>>> so you can avoid the constraint alltogether.
>>>
>>> BTW: Did you consider various -mcmodel=... options? For DImode moves,
>>> you should check x86_64_zext_immediate_operand predicate and output
>>> either "movl $zzz, %eax" or "movabs $zzz, %rax". There is no movq with
>>> 64bit immediate. Please see movdi pattern.
>>
>> Yep, for large objects it may work wrongly. Does anyone use static objects >4Gb? :)
>>
>> Large address does not mean large object but seems we have to be conservative here. I added  x86_64_zext_immediate_operand check with additional CM_KERNEL check because in this model object size should always fit 32 bits.
>
> IMO, we should list code models that support object sizes > 31bits for
> 64bit target. The object size in small models will never be > 31bits
> (and never negative), so we can use movl unconditionally.

For medium models x86_64_zext_immediate_operand returns true for
object is known to go to lower 2Gb space.  It should allow us to use
movl.  Why do you always emit movabs for medium model?

Ilya

>
> Please try attached patch.
>
> Uros.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH, i386, MPX, 2/X] Pointers Checker [21/25] Size relocation
  2013-11-20 17:12         ` Ilya Enkovich
@ 2013-11-20 17:27           ` Uros Bizjak
  2013-11-20 18:08             ` Ilya Enkovich
  0 siblings, 1 reply; 13+ messages in thread
From: Uros Bizjak @ 2013-11-20 17:27 UTC (permalink / raw)
  To: Ilya Enkovich; +Cc: gcc-patches

On Wed, Nov 20, 2013 at 5:11 PM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
> 2013/11/20 Uros Bizjak <ubizjak@gmail.com>:
>> On Wed, Nov 20, 2013 at 1:32 PM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>>
>>>> >> > Here is a patch to add size relocation and instruction to obtain object's size in i386 target.
>>>> >>
>>>> >> +(define_insn "move_size_reloc_<mode>"
>>>> >> +  [(set (match_operand:SWI48 0 "register_operand" "=r")
>>>> >> +        (match_operand:<MODE> 1 "size_relocation" "Z"))]
>>>> >> +  ""
>>>> >> +{
>>>> >> +  return "mov{<imodesuffix>}\t{%1, %0|%0, %1}";
>>>> >>
>>>> >> Please don't change x86_64_immediate_operand just to use "Z"
>>>> >> constraint The predicate is used in a couple of other places that for
>>>> >> sure don't accept your change.
>>>> >>
>>>> >> Better write this insn in an explicit way (see for example
>>>> >> tls_initial_exec_64_sun). Something like:
>>>> >>
>>>> >> (define_insn "move_size_reloc_<mode>"
>>>> >>   [(set (match_operand:SWI48 0 "register_operand" "=r")
>>>> >>     (unspec:SWI48
>>>> >>      [(match_operand 1 "symbolic_operand" "..." )]
>>>> >>      UNSPEC_SIZEOF))]
>>>> >>   ""
>>>> >>   "mov{<imodesuffix>}\t{%a1@SIZE, %0|%0, %a1@SIZE}")
>>>> >>
>>>> >> You will probably need to define new operand 1 predicate and constraint.
>>>> >>
>>>> >> Uros.
>>>> >
>>>> > Hi, Uros!  Thanks for comments!  Here is what I got trying to follow your suggestion.  Does it look better?
>>>>
>>>> You actually don't need any operand modifiers in the insn template. Simply use:
>>>>
>>>> "mov{<imodesuffix>}\t{%1@SIZE, %0|%0, %1@SIZE}"
>>>>
>>>> and you will automatically get
>>>>
>>>> "movl $zzz, %eax" or "mov %eax, OFFSET FLAT: zzz".
>>>>
>>>> Since your pattern allows only symbolic_operand, there is no reload,
>>>> so you can avoid the constraint alltogether.
>>>>
>>>> BTW: Did you consider various -mcmodel=... options? For DImode moves,
>>>> you should check x86_64_zext_immediate_operand predicate and output
>>>> either "movl $zzz, %eax" or "movabs $zzz, %rax". There is no movq with
>>>> 64bit immediate. Please see movdi pattern.
>>>
>>> Yep, for large objects it may work wrongly. Does anyone use static objects >4Gb? :)
>>>
>>> Large address does not mean large object but seems we have to be conservative here. I added  x86_64_zext_immediate_operand check with additional CM_KERNEL check because in this model object size should always fit 32 bits.
>>
>> IMO, we should list code models that support object sizes > 31bits for
>> 64bit target. The object size in small models will never be > 31bits
>> (and never negative), so we can use movl unconditionally.
>
> For medium models x86_64_zext_immediate_operand returns true for
> object is known to go to lower 2Gb space.  It should allow us to use
> movl.  Why do you always emit movabs for medium model?

CM_MEDIUM has unlimited data size.

i386-opts.h:  CM_MEDIUM,        /* Assumes code fits in the low 31
bits; data unlimited.  */

The x86_64_zext_immediate_operand allows _address_ to be loaded by
movl. The @SIZE reloc returns object size, which is unlimited and has
no connection to its address. For CM_MEDIUM,
x86_64_zext_immediate_operand allows:

      return (ix86_cmodel == CM_SMALL
          || (ix86_cmodel == CM_MEDIUM
          && !SYMBOL_REF_FAR_ADDR_P (op)));

Uros.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH, i386, MPX, 2/X] Pointers Checker [21/25] Size relocation
  2013-11-20 17:27           ` Uros Bizjak
@ 2013-11-20 18:08             ` Ilya Enkovich
  2013-11-20 18:22               ` Ilya Enkovich
  0 siblings, 1 reply; 13+ messages in thread
From: Ilya Enkovich @ 2013-11-20 18:08 UTC (permalink / raw)
  To: Uros Bizjak; +Cc: gcc-patches

2013/11/20 Uros Bizjak <ubizjak@gmail.com>:
> On Wed, Nov 20, 2013 at 5:11 PM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>> 2013/11/20 Uros Bizjak <ubizjak@gmail.com>:
>>> On Wed, Nov 20, 2013 at 1:32 PM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>>>
>>>>> >> > Here is a patch to add size relocation and instruction to obtain object's size in i386 target.
>>>>> >>
>>>>> >> +(define_insn "move_size_reloc_<mode>"
>>>>> >> +  [(set (match_operand:SWI48 0 "register_operand" "=r")
>>>>> >> +        (match_operand:<MODE> 1 "size_relocation" "Z"))]
>>>>> >> +  ""
>>>>> >> +{
>>>>> >> +  return "mov{<imodesuffix>}\t{%1, %0|%0, %1}";
>>>>> >>
>>>>> >> Please don't change x86_64_immediate_operand just to use "Z"
>>>>> >> constraint The predicate is used in a couple of other places that for
>>>>> >> sure don't accept your change.
>>>>> >>
>>>>> >> Better write this insn in an explicit way (see for example
>>>>> >> tls_initial_exec_64_sun). Something like:
>>>>> >>
>>>>> >> (define_insn "move_size_reloc_<mode>"
>>>>> >>   [(set (match_operand:SWI48 0 "register_operand" "=r")
>>>>> >>     (unspec:SWI48
>>>>> >>      [(match_operand 1 "symbolic_operand" "..." )]
>>>>> >>      UNSPEC_SIZEOF))]
>>>>> >>   ""
>>>>> >>   "mov{<imodesuffix>}\t{%a1@SIZE, %0|%0, %a1@SIZE}")
>>>>> >>
>>>>> >> You will probably need to define new operand 1 predicate and constraint.
>>>>> >>
>>>>> >> Uros.
>>>>> >
>>>>> > Hi, Uros!  Thanks for comments!  Here is what I got trying to follow your suggestion.  Does it look better?
>>>>>
>>>>> You actually don't need any operand modifiers in the insn template. Simply use:
>>>>>
>>>>> "mov{<imodesuffix>}\t{%1@SIZE, %0|%0, %1@SIZE}"
>>>>>
>>>>> and you will automatically get
>>>>>
>>>>> "movl $zzz, %eax" or "mov %eax, OFFSET FLAT: zzz".
>>>>>
>>>>> Since your pattern allows only symbolic_operand, there is no reload,
>>>>> so you can avoid the constraint alltogether.
>>>>>
>>>>> BTW: Did you consider various -mcmodel=... options? For DImode moves,
>>>>> you should check x86_64_zext_immediate_operand predicate and output
>>>>> either "movl $zzz, %eax" or "movabs $zzz, %rax". There is no movq with
>>>>> 64bit immediate. Please see movdi pattern.
>>>>
>>>> Yep, for large objects it may work wrongly. Does anyone use static objects >4Gb? :)
>>>>
>>>> Large address does not mean large object but seems we have to be conservative here. I added  x86_64_zext_immediate_operand check with additional CM_KERNEL check because in this model object size should always fit 32 bits.
>>>
>>> IMO, we should list code models that support object sizes > 31bits for
>>> 64bit target. The object size in small models will never be > 31bits
>>> (and never negative), so we can use movl unconditionally.
>>
>> For medium models x86_64_zext_immediate_operand returns true for
>> object is known to go to lower 2Gb space.  It should allow us to use
>> movl.  Why do you always emit movabs for medium model?
>
> CM_MEDIUM has unlimited data size.
>
> i386-opts.h:  CM_MEDIUM,        /* Assumes code fits in the low 31
> bits; data unlimited.  */
>
> The x86_64_zext_immediate_operand allows _address_ to be loaded by
> movl. The @SIZE reloc returns object size, which is unlimited and has
> no connection to its address. For CM_MEDIUM,
> x86_64_zext_immediate_operand allows:
>
>       return (ix86_cmodel == CM_SMALL
>           || (ix86_cmodel == CM_MEDIUM
>           && !SYMBOL_REF_FAR_ADDR_P (op)));

Yes, but large symbols never have SYMBOL_FLAG_FAR_ADDR set.

Ilya

>
> Uros.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH, i386, MPX, 2/X] Pointers Checker [21/25] Size relocation
  2013-11-20 18:08             ` Ilya Enkovich
@ 2013-11-20 18:22               ` Ilya Enkovich
  2013-11-21 20:40                 ` Uros Bizjak
  0 siblings, 1 reply; 13+ messages in thread
From: Ilya Enkovich @ 2013-11-20 18:22 UTC (permalink / raw)
  To: Uros Bizjak; +Cc: gcc-patches

2013/11/20 Ilya Enkovich <enkovich.gnu@gmail.com>:
> 2013/11/20 Uros Bizjak <ubizjak@gmail.com>:
>> On Wed, Nov 20, 2013 at 5:11 PM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>>> 2013/11/20 Uros Bizjak <ubizjak@gmail.com>:
>>>> On Wed, Nov 20, 2013 at 1:32 PM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>>>>
>>>>>> >> > Here is a patch to add size relocation and instruction to obtain object's size in i386 target.
>>>>>> >>
>>>>>> >> +(define_insn "move_size_reloc_<mode>"
>>>>>> >> +  [(set (match_operand:SWI48 0 "register_operand" "=r")
>>>>>> >> +        (match_operand:<MODE> 1 "size_relocation" "Z"))]
>>>>>> >> +  ""
>>>>>> >> +{
>>>>>> >> +  return "mov{<imodesuffix>}\t{%1, %0|%0, %1}";
>>>>>> >>
>>>>>> >> Please don't change x86_64_immediate_operand just to use "Z"
>>>>>> >> constraint The predicate is used in a couple of other places that for
>>>>>> >> sure don't accept your change.
>>>>>> >>
>>>>>> >> Better write this insn in an explicit way (see for example
>>>>>> >> tls_initial_exec_64_sun). Something like:
>>>>>> >>
>>>>>> >> (define_insn "move_size_reloc_<mode>"
>>>>>> >>   [(set (match_operand:SWI48 0 "register_operand" "=r")
>>>>>> >>     (unspec:SWI48
>>>>>> >>      [(match_operand 1 "symbolic_operand" "..." )]
>>>>>> >>      UNSPEC_SIZEOF))]
>>>>>> >>   ""
>>>>>> >>   "mov{<imodesuffix>}\t{%a1@SIZE, %0|%0, %a1@SIZE}")
>>>>>> >>
>>>>>> >> You will probably need to define new operand 1 predicate and constraint.
>>>>>> >>
>>>>>> >> Uros.
>>>>>> >
>>>>>> > Hi, Uros!  Thanks for comments!  Here is what I got trying to follow your suggestion.  Does it look better?
>>>>>>
>>>>>> You actually don't need any operand modifiers in the insn template. Simply use:
>>>>>>
>>>>>> "mov{<imodesuffix>}\t{%1@SIZE, %0|%0, %1@SIZE}"
>>>>>>
>>>>>> and you will automatically get
>>>>>>
>>>>>> "movl $zzz, %eax" or "mov %eax, OFFSET FLAT: zzz".
>>>>>>
>>>>>> Since your pattern allows only symbolic_operand, there is no reload,
>>>>>> so you can avoid the constraint alltogether.
>>>>>>
>>>>>> BTW: Did you consider various -mcmodel=... options? For DImode moves,
>>>>>> you should check x86_64_zext_immediate_operand predicate and output
>>>>>> either "movl $zzz, %eax" or "movabs $zzz, %rax". There is no movq with
>>>>>> 64bit immediate. Please see movdi pattern.
>>>>>
>>>>> Yep, for large objects it may work wrongly. Does anyone use static objects >4Gb? :)
>>>>>
>>>>> Large address does not mean large object but seems we have to be conservative here. I added  x86_64_zext_immediate_operand check with additional CM_KERNEL check because in this model object size should always fit 32 bits.
>>>>
>>>> IMO, we should list code models that support object sizes > 31bits for
>>>> 64bit target. The object size in small models will never be > 31bits
>>>> (and never negative), so we can use movl unconditionally.
>>>
>>> For medium models x86_64_zext_immediate_operand returns true for
>>> object is known to go to lower 2Gb space.  It should allow us to use
>>> movl.  Why do you always emit movabs for medium model?
>>
>> CM_MEDIUM has unlimited data size.
>>
>> i386-opts.h:  CM_MEDIUM,        /* Assumes code fits in the low 31
>> bits; data unlimited.  */
>>
>> The x86_64_zext_immediate_operand allows _address_ to be loaded by
>> movl. The @SIZE reloc returns object size, which is unlimited and has
>> no connection to its address. For CM_MEDIUM,
>> x86_64_zext_immediate_operand allows:
>>
>>       return (ix86_cmodel == CM_SMALL
>>           || (ix86_cmodel == CM_MEDIUM
>>           && !SYMBOL_REF_FAR_ADDR_P (op)));
>
> Yes, but large symbols never have SYMBOL_FLAG_FAR_ADDR set.

Sorry, I mean all large symbols have this flag set.

>
> Ilya
>
>>
>> Uros.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH, i386, MPX, 2/X] Pointers Checker [21/25] Size relocation
  2013-11-20 18:22               ` Ilya Enkovich
@ 2013-11-21 20:40                 ` Uros Bizjak
  2013-11-26 14:15                   ` Ilya Enkovich
  0 siblings, 1 reply; 13+ messages in thread
From: Uros Bizjak @ 2013-11-21 20:40 UTC (permalink / raw)
  To: Ilya Enkovich; +Cc: gcc-patches

On Wed, Nov 20, 2013 at 5:33 PM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>>> CM_MEDIUM has unlimited data size.
>>>
>>> i386-opts.h:  CM_MEDIUM,        /* Assumes code fits in the low 31
>>> bits; data unlimited.  */
>>>
>>> The x86_64_zext_immediate_operand allows _address_ to be loaded by
>>> movl. The @SIZE reloc returns object size, which is unlimited and has
>>> no connection to its address. For CM_MEDIUM,
>>> x86_64_zext_immediate_operand allows:
>>>
>>>       return (ix86_cmodel == CM_SMALL
>>>           || (ix86_cmodel == CM_MEDIUM
>>>           && !SYMBOL_REF_FAR_ADDR_P (op)));
>>
>> Yes, but large symbols never have SYMBOL_FLAG_FAR_ADDR set.
>
> Sorry, I mean all large symbols have this flag set.

This flag marks the fact that object size is bigger than
-mlarge-data-threshold and goes into large section. It is true that
UInt option argument currently overflows at 4G, and consequently all
sizes larger than 4G go to large sections, but IMO, we should not rely
on this. The specification says unlimited data size, so we have to be
prepared for this.

The reason I am against checking "Z" constraint is that "@SIZE"
relocation returns _size_ of the object (which is only remotely
connected to its address), while "Z" checks the address of the object.
So, it looks to me that this check would be conceptually wrong.

The right place to "fix" movabs is in a linker relaxation pass that
can check the real size and change movabs to movl if the size fits
32bits.

As a side note, perhaps generic option subsystem should reject
overflows as e.g. -mlarge-data-threshold=5368709120 when 32bit UInt is
used for option argument. The effects of overflow are surprising.

Uros.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH, i386, MPX, 2/X] Pointers Checker [21/25] Size relocation
  2013-11-21 20:40                 ` Uros Bizjak
@ 2013-11-26 14:15                   ` Ilya Enkovich
  2013-11-26 14:54                     ` Uros Bizjak
  0 siblings, 1 reply; 13+ messages in thread
From: Ilya Enkovich @ 2013-11-26 14:15 UTC (permalink / raw)
  To: Uros Bizjak; +Cc: gcc-patches

2013/11/21 Uros Bizjak <ubizjak@gmail.com>:
> On Wed, Nov 20, 2013 at 5:33 PM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>>>> CM_MEDIUM has unlimited data size.
>>>>
>>>> i386-opts.h:  CM_MEDIUM,        /* Assumes code fits in the low 31
>>>> bits; data unlimited.  */
>>>>
>>>> The x86_64_zext_immediate_operand allows _address_ to be loaded by
>>>> movl. The @SIZE reloc returns object size, which is unlimited and has
>>>> no connection to its address. For CM_MEDIUM,
>>>> x86_64_zext_immediate_operand allows:
>>>>
>>>>       return (ix86_cmodel == CM_SMALL
>>>>           || (ix86_cmodel == CM_MEDIUM
>>>>           && !SYMBOL_REF_FAR_ADDR_P (op)));
>>>
>>> Yes, but large symbols never have SYMBOL_FLAG_FAR_ADDR set.
>>
>> Sorry, I mean all large symbols have this flag set.
>
> This flag marks the fact that object size is bigger than
> -mlarge-data-threshold and goes into large section. It is true that
> UInt option argument currently overflows at 4G, and consequently all
> sizes larger than 4G go to large sections, but IMO, we should not rely
> on this. The specification says unlimited data size, so we have to be
> prepared for this.
>
> The reason I am against checking "Z" constraint is that "@SIZE"
> relocation returns _size_ of the object (which is only remotely
> connected to its address), while "Z" checks the address of the object.
> So, it looks to me that this check would be conceptually wrong.
>
> The right place to "fix" movabs is in a linker relaxation pass that
> can check the real size and change movabs to movl if the size fits
> 32bits.
>
> As a side note, perhaps generic option subsystem should reject
> overflows as e.g. -mlarge-data-threshold=5368709120 when 32bit UInt is
> used for option argument. The effects of overflow are surprising.

Hi Uros,

Thanks for explanations! I'll make a fix for the patch.

BTW Pointer Bounds Checker feature does not go to 4.9 and therefore
this size relocation instructions is not required in 4.9. Suppose it
should go into 4.10 because doubt this feature is useful for anyone
except me.

This also affects all MPX instructions. With no checker in 4.9, no one
actually uses them.  Please tell me if I should pull them back from
trunk.

Thanks,
Ilya

>
> Uros.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH, i386, MPX, 2/X] Pointers Checker [21/25] Size relocation
  2013-11-26 14:15                   ` Ilya Enkovich
@ 2013-11-26 14:54                     ` Uros Bizjak
  0 siblings, 0 replies; 13+ messages in thread
From: Uros Bizjak @ 2013-11-26 14:54 UTC (permalink / raw)
  To: Ilya Enkovich; +Cc: gcc-patches

On Tue, Nov 26, 2013 at 12:30 PM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>>>> CM_MEDIUM has unlimited data size.
>>>>>
>>>>> i386-opts.h:  CM_MEDIUM,        /* Assumes code fits in the low 31
>>>>> bits; data unlimited.  */
>>>>>
>>>>> The x86_64_zext_immediate_operand allows _address_ to be loaded by
>>>>> movl. The @SIZE reloc returns object size, which is unlimited and has
>>>>> no connection to its address. For CM_MEDIUM,
>>>>> x86_64_zext_immediate_operand allows:
>>>>>
>>>>>       return (ix86_cmodel == CM_SMALL
>>>>>           || (ix86_cmodel == CM_MEDIUM
>>>>>           && !SYMBOL_REF_FAR_ADDR_P (op)));
>>>>
>>>> Yes, but large symbols never have SYMBOL_FLAG_FAR_ADDR set.
>>>
>>> Sorry, I mean all large symbols have this flag set.
>>
>> This flag marks the fact that object size is bigger than
>> -mlarge-data-threshold and goes into large section. It is true that
>> UInt option argument currently overflows at 4G, and consequently all
>> sizes larger than 4G go to large sections, but IMO, we should not rely
>> on this. The specification says unlimited data size, so we have to be
>> prepared for this.
>>
>> The reason I am against checking "Z" constraint is that "@SIZE"
>> relocation returns _size_ of the object (which is only remotely
>> connected to its address), while "Z" checks the address of the object.
>> So, it looks to me that this check would be conceptually wrong.
>>
>> The right place to "fix" movabs is in a linker relaxation pass that
>> can check the real size and change movabs to movl if the size fits
>> 32bits.
>>
>> As a side note, perhaps generic option subsystem should reject
>> overflows as e.g. -mlarge-data-threshold=5368709120 when 32bit UInt is
>> used for option argument. The effects of overflow are surprising.
>
> Hi Uros,
>
> Thanks for explanations! I'll make a fix for the patch.
>
> BTW Pointer Bounds Checker feature does not go to 4.9 and therefore
> this size relocation instructions is not required in 4.9. Suppose it
> should go into 4.10 because doubt this feature is useful for anyone
> except me.
>
> This also affects all MPX instructions. With no checker in 4.9, no one
> actually uses them.  Please tell me if I should pull them back from
> trunk.

The instructions in *.md are usually well isolated, so I'd suggest to
remove them. Since all issues in this part ware resolved, they could
be added back without problems.

BR,
Uros.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH, i386, MPX, 2/X] Pointers Checker [21/25] Size relocation
@ 2013-11-18 14:10 Ilya Enkovich
  0 siblings, 0 replies; 13+ messages in thread
From: Ilya Enkovich @ 2013-11-18 14:10 UTC (permalink / raw)
  To: gcc-patches

Hi,

Here is a patch to add size relocation and instruction to obtain object's size in i386 target.

Thanks,
Ilya
--
2013-11-15  Ilya Enkovich  <ilya.enkovich@intel.com>

	* config/i386/i386.md (UNSPEC_SIZEOF): New.
	(move_size_reloc_<mode>): New.
	* config/i386/predicates.md (size_relocation): New.
	(x86_64_zext_immediate_operand): Support UNSPEC_SIZEOF.
	* config/i386/i386.c (output_pic_addr_const): Support UNSPEC_SIZEOF.
	(i386_asm_output_addr_const_extra): Likewise.


diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index d581b96..a427c15 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -13809,6 +13809,10 @@ output_pic_addr_const (FILE *file, rtx x, int code)
 	  machopic_output_function_base_name (file);
 	  break;
 #endif
+	case UNSPEC_SIZEOF:
+	  fputs ("@SIZE", file);
+	  break;
+
 	default:
 	  output_operand_lossage ("invalid UNSPEC as operand");
 	  break;
@@ -15387,6 +15391,11 @@ i386_asm_output_addr_const_extra (FILE *file, rtx x)
       }
       break;
 
+    case UNSPEC_SIZEOF:
+      output_addr_const (file, op);
+      fputs ("@SIZE", file);
+      break;
+
     default:
       return false;
     }
diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
index e23b3b6..97dd89c 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
@@ -18446,6 +18447,14 @@
   "bndstx\t{%2, %3|%3, %2}"
   [(set_attr "type" "mpxst")])
 
+(define_insn "move_size_reloc_<mode>"
+  [(set (match_operand:SWI48 0 "register_operand" "=r")
+        (match_operand:<MODE> 1 "size_relocation" "Z"))]
+  ""
+{
+  return "mov{<imodesuffix>}\t{%1, %0|%0, %1}";
+})
+
 (include "mmx.md")
 (include "sse.md")
 (include "sync.md")
diff --git a/gcc/config/i386/predicates.md b/gcc/config/i386/predicates.md
index 66ac52f..23231b1 100644
--- a/gcc/config/i386/predicates.md
+++ b/gcc/config/i386/predicates.md
@@ -119,6 +119,15 @@
        (match_test "TARGET_64BIT")
        (match_test "REGNO (op) > BX_REG")))
 
+;; Return true if VALUE is size relocation
+(define_predicate "size_relocation"
+  (match_code "const")
+{
+  return (GET_CODE (op) == CONST
+          && GET_CODE (XEXP (op, 0)) == UNSPEC
+	  && XINT (XEXP (op, 0), 1) == UNSPEC_SIZEOF);
+})
+
 ;; 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")
@@ -323,6 +332,13 @@
 	      return false;
 	    }
 	}
+      else if (GET_CODE (XEXP (op, 0)) == UNSPEC)
+        {
+          if (XINT (XEXP (op, 0), 1) == UNSPEC_SIZEOF
+	      && XVECLEN (XEXP (op, 0), 0) == 1
+	      && GET_CODE (XVECEXP (XEXP (op, 0), 0, 0)) == SYMBOL_REF)
+	    return true;
+        }
       break;
 
     default:

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2013-11-26 12:20 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-18 23:31 [PATCH, i386, MPX, 2/X] Pointers Checker [21/25] Size relocation Uros Bizjak
2013-11-19 21:58 ` Ilya Enkovich
2013-11-20  9:59   ` Uros Bizjak
2013-11-20 14:02     ` Ilya Enkovich
2013-11-20 17:04       ` Uros Bizjak
2013-11-20 17:12         ` Ilya Enkovich
2013-11-20 17:27           ` Uros Bizjak
2013-11-20 18:08             ` Ilya Enkovich
2013-11-20 18:22               ` Ilya Enkovich
2013-11-21 20:40                 ` Uros Bizjak
2013-11-26 14:15                   ` Ilya Enkovich
2013-11-26 14:54                     ` Uros Bizjak
  -- strict thread matches above, loose matches on Subject: below --
2013-11-18 14:10 Ilya Enkovich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).