Attachment 'C11atomic2.patch'

Download

   1 Index: gcc/tree-core.h
   2 ===================================================================
   3 *** gcc/tree-core.h	(revision 202709)
   4 --- gcc/tree-core.h	(working copy)
   5 *************** enum cv_qualifier {
   6 *** 313,319 ****
   7     TYPE_UNQUALIFIED   = 0x0,
   8     TYPE_QUAL_CONST    = 0x1,
   9     TYPE_QUAL_VOLATILE = 0x2,
  10 !   TYPE_QUAL_RESTRICT = 0x4
  11   };
  12   
  13   /* Enumerate visibility settings.  */
  14 --- 313,320 ----
  15     TYPE_UNQUALIFIED   = 0x0,
  16     TYPE_QUAL_CONST    = 0x1,
  17     TYPE_QUAL_VOLATILE = 0x2,
  18 !   TYPE_QUAL_RESTRICT = 0x4,
  19 !   TYPE_QUAL_ATOMIC   = 0x8
  20   };
  21   
  22   /* Enumerate visibility settings.  */
  23 *************** enum tree_index {
  24 *** 342,347 ****
  25 --- 343,354 ----
  26     TI_UINTDI_TYPE,
  27     TI_UINTTI_TYPE,
  28   
  29 +   TI_ATOMICQI_TYPE,
  30 +   TI_ATOMICHI_TYPE,
  31 +   TI_ATOMICSI_TYPE,
  32 +   TI_ATOMICDI_TYPE,
  33 +   TI_ATOMICTI_TYPE,
  34 + 
  35     TI_UINT16_TYPE,
  36     TI_UINT32_TYPE,
  37     TI_UINT64_TYPE,
  38 *************** struct GTY(()) tree_base {
  39 *** 677,683 ****
  40         unsigned packed_flag : 1;
  41         unsigned user_align : 1;
  42         unsigned nameless_flag : 1;
  43 !       unsigned spare0 : 4;
  44   
  45         unsigned spare1 : 8;
  46   
  47 --- 684,691 ----
  48         unsigned packed_flag : 1;
  49         unsigned user_align : 1;
  50         unsigned nameless_flag : 1;
  51 !       unsigned atomic_flag : 1;
  52 !       unsigned spare0 : 3;
  53   
  54         unsigned spare1 : 8;
  55   
  56 Index: gcc/tree.h
  57 ===================================================================
  58 *** gcc/tree.h	(revision 202709)
  59 --- gcc/tree.h	(working copy)
  60 *************** extern enum machine_mode vector_type_mod
  61 *** 1511,1516 ****
  62 --- 1511,1519 ----
  63   /* Nonzero in a type considered volatile as a whole.  */
  64   #define TYPE_VOLATILE(NODE) (TYPE_CHECK (NODE)->base.volatile_flag)
  65   
  66 + /* Nonzero in a type considered atomic as a whole.  */
  67 + #define TYPE_ATOMIC(NODE) (TYPE_CHECK (NODE)->base.u.bits.atomic_flag)
  68 + 
  69   /* Means this type is const-qualified.  */
  70   #define TYPE_READONLY(NODE) (TYPE_CHECK (NODE)->base.readonly_flag)
  71   
  72 *************** extern enum machine_mode vector_type_mod
  73 *** 1540,1545 ****
  74 --- 1543,1549 ----
  75   #define TYPE_QUALS(NODE)					\
  76     ((int) ((TYPE_READONLY (NODE) * TYPE_QUAL_CONST)		\
  77   	  | (TYPE_VOLATILE (NODE) * TYPE_QUAL_VOLATILE)		\
  78 + 	  | (TYPE_ATOMIC (NODE) * TYPE_QUAL_ATOMIC)		\
  79   	  | (TYPE_RESTRICT (NODE) * TYPE_QUAL_RESTRICT)		\
  80   	  | (ENCODE_QUAL_ADDR_SPACE (TYPE_ADDR_SPACE (NODE)))))
  81   
  82 *************** extern enum machine_mode vector_type_mod
  83 *** 1547,1554 ****
  84 --- 1551,1566 ----
  85   #define TYPE_QUALS_NO_ADDR_SPACE(NODE)				\
  86     ((int) ((TYPE_READONLY (NODE) * TYPE_QUAL_CONST)		\
  87   	  | (TYPE_VOLATILE (NODE) * TYPE_QUAL_VOLATILE)		\
  88 + 	  | (TYPE_ATOMIC (NODE) * TYPE_QUAL_ATOMIC)		\
  89 + 	  | (TYPE_RESTRICT (NODE) * TYPE_QUAL_RESTRICT)))
  90 + /* The same as TYPE_QUALS without the address space and atomic 
  91 +    qualifications.  */
  92 + #define TYPE_QUALS_NO_ADDR_SPACE_NO_ATOMIC(NODE)		\
  93 +   ((int) ((TYPE_READONLY (NODE) * TYPE_QUAL_CONST)		\
  94 + 	  | (TYPE_VOLATILE (NODE) * TYPE_QUAL_VOLATILE)		\
  95   	  | (TYPE_RESTRICT (NODE) * TYPE_QUAL_RESTRICT)))
  96   
  97 + 
  98   /* These flags are available for each language front end to use internally.  */
  99   #define TYPE_LANG_FLAG_0(NODE) (TYPE_CHECK (NODE)->type_common.lang_flag_0)
 100   #define TYPE_LANG_FLAG_1(NODE) (TYPE_CHECK (NODE)->type_common.lang_flag_1)
 101 *************** tree_operand_check_code (const_tree __t,
 102 *** 3088,3093 ****
 103 --- 3100,3111 ----
 104   #define unsigned_intDI_type_node	global_trees[TI_UINTDI_TYPE]
 105   #define unsigned_intTI_type_node	global_trees[TI_UINTTI_TYPE]
 106   
 107 + #define atomicQI_type_node	global_trees[TI_ATOMICQI_TYPE]
 108 + #define atomicHI_type_node	global_trees[TI_ATOMICHI_TYPE]
 109 + #define atomicSI_type_node	global_trees[TI_ATOMICSI_TYPE]
 110 + #define atomicDI_type_node	global_trees[TI_ATOMICDI_TYPE]
 111 + #define atomicTI_type_node	global_trees[TI_ATOMICTI_TYPE]
 112 + 
 113   #define uint16_type_node		global_trees[TI_UINT16_TYPE]
 114   #define uint32_type_node		global_trees[TI_UINT32_TYPE]
 115   #define uint64_type_node		global_trees[TI_UINT64_TYPE]
 116 Index: gcc/print-tree.c
 117 ===================================================================
 118 *** gcc/print-tree.c	(revision 202709)
 119 --- gcc/print-tree.c	(working copy)
 120 *************** print_node (FILE *file, const char *pref
 121 *** 304,309 ****
 122 --- 304,311 ----
 123   
 124     if (TYPE_P (node) ? TYPE_READONLY (node) : TREE_READONLY (node))
 125       fputs (" readonly", file);
 126 +   if (TYPE_P (node) ? TYPE_ATOMIC (node) : TYPE_ATOMIC (node))
 127 +     fputs (" atomic", file);
 128     if (!TYPE_P (node) && TREE_CONSTANT (node))
 129       fputs (" constant", file);
 130     else if (TYPE_P (node) && TYPE_SIZES_GIMPLIFIED (node))
 131 Index: gcc/tree-pretty-print.c
 132 ===================================================================
 133 *** gcc/tree-pretty-print.c	(revision 202709)
 134 --- gcc/tree-pretty-print.c	(working copy)
 135 *************** dump_generic_node (pretty_printer *buffe
 136 *** 708,713 ****
 137 --- 708,715 ----
 138   	unsigned int quals = TYPE_QUALS (node);
 139   	enum tree_code_class tclass;
 140   
 141 + 	if (quals & TYPE_QUAL_ATOMIC)
 142 + 	  pp_string (buffer, "atomic ");
 143   	if (quals & TYPE_QUAL_CONST)
 144   	  pp_string (buffer, "const ");
 145   	else if (quals & TYPE_QUAL_VOLATILE)
 146 *************** dump_generic_node (pretty_printer *buffe
 147 *** 1009,1014 ****
 148 --- 1011,1018 ----
 149         {
 150   	unsigned int quals = TYPE_QUALS (node);
 151   
 152 + 	if (quals & TYPE_QUAL_ATOMIC)
 153 + 	  pp_string (buffer, "atomic ");
 154   	if (quals & TYPE_QUAL_CONST)
 155   	  pp_string (buffer, "const ");
 156   	if (quals & TYPE_QUAL_VOLATILE)
 157 Index: gcc/tree.c
 158 ===================================================================
 159 *** gcc/tree.c	(revision 202709)
 160 --- gcc/tree.c	(working copy)
 161 *************** set_type_quals (tree type, int type_qual
 162 *** 5976,5981 ****
 163 --- 5976,5982 ----
 164     TYPE_READONLY (type) = (type_quals & TYPE_QUAL_CONST) != 0;
 165     TYPE_VOLATILE (type) = (type_quals & TYPE_QUAL_VOLATILE) != 0;
 166     TYPE_RESTRICT (type) = (type_quals & TYPE_QUAL_RESTRICT) != 0;
 167 +   TYPE_ATOMIC (type) = (type_quals & TYPE_QUAL_ATOMIC) != 0;
 168     TYPE_ADDR_SPACE (type) = DECODE_QUAL_ADDR_SPACE (type_quals);
 169   }
 170   
 171 *************** check_aligned_type (const_tree cand, con
 172 *** 6009,6014 ****
 173 --- 6010,6057 ----
 174   				   TYPE_ATTRIBUTES (base)));
 175   }
 176   
 177 + /* This function checks to see if TYPE matches the size one of the built-in 
 178 +    atomic types, and returns that core atomic type.  */
 179 + 
 180 + tree
 181 + find_atomic_core_type (tree type)
 182 + {
 183 +   tree base_atomic_type;
 184 + 
 185 +   /* Only handle complete types.  */
 186 +   if (TYPE_SIZE (type) == NULL_TREE)
 187 +     return NULL_TREE;
 188 + 
 189 +   HOST_WIDE_INT type_size = tree_low_cst (TYPE_SIZE (type), 1);
 190 +   switch (type_size)
 191 +     {
 192 +     case 8:
 193 +       base_atomic_type = atomicQI_type_node;
 194 +       break;
 195 + 
 196 +     case 16:
 197 +       base_atomic_type = atomicHI_type_node;
 198 +       break;
 199 + 
 200 +     case 32:
 201 +       base_atomic_type = atomicSI_type_node;
 202 +       break;
 203 + 
 204 +     case 64:
 205 +       base_atomic_type = atomicDI_type_node;
 206 +       break;
 207 + 
 208 +     case 128:
 209 +       base_atomic_type = atomicTI_type_node;
 210 +       break;
 211 + 
 212 +     default:
 213 +       base_atomic_type = NULL_TREE;
 214 +     }
 215 + 
 216 +   return base_atomic_type;
 217 + }
 218 + 
 219   /* Return a version of the TYPE, qualified as indicated by the
 220      TYPE_QUALS, if one exists.  If no qualified version exists yet,
 221      return NULL_TREE.  */
 222 *************** build_qualified_type (tree type, int typ
 223 *** 6048,6053 ****
 224 --- 6091,6109 ----
 225         t = build_variant_type_copy (type);
 226         set_type_quals (t, type_quals);
 227   
 228 +       if (((type_quals & TYPE_QUAL_ATOMIC) == TYPE_QUAL_ATOMIC))
 229 + 	{
 230 + 	  /* See if this object can map to a basic atomic type.  */
 231 + 	  tree atomic_type = find_atomic_core_type (type);
 232 + 	  if (atomic_type)
 233 + 	    {
 234 + 	      /* Ensure the alignment of this type is compatible with
 235 + 		 the required alignment of the atomic type.  */
 236 + 	      if (TYPE_ALIGN (atomic_type) > TYPE_ALIGN (t))
 237 + 		TYPE_ALIGN (t) = TYPE_ALIGN (atomic_type);
 238 + 	    }
 239 + 	}
 240 + 
 241         if (TYPE_STRUCTURAL_EQUALITY_P (type))
 242   	/* Propagate structural equality. */
 243   	SET_TYPE_STRUCTURAL_EQUALITY (t);
 244 *************** make_or_reuse_accum_type (unsigned size,
 245 *** 9560,9565 ****
 246 --- 9616,9646 ----
 247     return make_accum_type (size, unsignedp, satp);
 248   }
 249   
 250 + 
 251 + /* Create an atomic variant node for TYPE.  This routine is called during
 252 +    initialization of data types to create the 5 basic atomic types. The generic
 253 +    build_variant_type function requires these to already be set up in order to
 254 +    function properly, so cannot be called from there.  
 255 +    if ALIGN is non-zero, then ensure alignment is overridden to this value.  */
 256 + 
 257 + static tree
 258 + build_atomic_base (tree type, unsigned int align)
 259 + {
 260 +   tree t;
 261 + 
 262 +   /* Make sure its not already registered.  */
 263 +   if ((t = get_qualified_type (type, TYPE_QUAL_ATOMIC)))
 264 +     return t;
 265 +   
 266 +   t = build_variant_type_copy (type);
 267 +   set_type_quals (t, TYPE_QUAL_ATOMIC);
 268 + 
 269 +   if (align)
 270 +     TYPE_ALIGN (t) = align;
 271 + 
 272 +   return t;
 273 + }
 274 + 
 275   /* Create nodes for all integer types (and error_mark_node) using the sizes
 276      of C datatypes.  SIGNED_CHAR specifies whether char is signed,
 277      SHORT_DOUBLE specifies whether double should be of the same precision
 278 *************** build_common_tree_nodes (bool signed_cha
 279 *** 9642,9647 ****
 280 --- 9723,9743 ----
 281     unsigned_intDI_type_node = make_or_reuse_type (GET_MODE_BITSIZE (DImode), 1);
 282     unsigned_intTI_type_node = make_or_reuse_type (GET_MODE_BITSIZE (TImode), 1);
 283   
 284 +   /* Dont call build_qualified type for atomics.  That routine does special
 285 +      processing for atomics, and until they are initialized its better not
 286 +      to make that call.  
 287 +      
 288 +      Check to see if there is a target override for atomic types.  */
 289 + 
 290 + #define SET_ATOMIC_TYPE_NODE(TYPE, MODE, DEFAULT) 		\
 291 +  (TYPE) = build_atomic_base (DEFAULT, targetm.atomic_align_for_mode (MODE));
 292 + 
 293 +   SET_ATOMIC_TYPE_NODE (atomicQI_type_node, QImode, unsigned_intQI_type_node);
 294 +   SET_ATOMIC_TYPE_NODE (atomicHI_type_node, HImode, unsigned_intHI_type_node);
 295 +   SET_ATOMIC_TYPE_NODE (atomicSI_type_node, SImode, unsigned_intSI_type_node);
 296 +   SET_ATOMIC_TYPE_NODE (atomicDI_type_node, DImode, unsigned_intDI_type_node);
 297 +   SET_ATOMIC_TYPE_NODE (atomicTI_type_node, TImode, unsigned_intTI_type_node);
 298 + 
 299     access_public_node = get_identifier ("public");
 300     access_protected_node = get_identifier ("protected");
 301     access_private_node = get_identifier ("private");

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2013-09-26 22:28:39, 3.3 KB) [[attachment:C11atomic1.patch]]
  • [get | view] (2013-09-26 22:29:03, 10.1 KB) [[attachment:C11atomic2.patch]]
  • [get | view] (2013-09-26 22:29:32, 23.8 KB) [[attachment:C11atomic3.patch]]
  • [get | view] (2013-09-26 22:30:03, 11.1 KB) [[attachment:C11atomic4.patch]]
  • [get | view] (2013-09-26 22:30:34, 13.8 KB) [[attachment:C11atomic5.patch]]
  • [get | view] (2013-09-26 22:31:14, 0.6 KB) [[attachment:C11atomic6.patch]]
  • [get | view] (2013-09-26 22:31:49, 8.6 KB) [[attachment:C11stdatomic.patch]]
  • [get | view] (2013-09-30 15:02:51, 47.7 KB) [[attachment:atomicproto.patch]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.