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
* [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).