1 /* Implement tasking-related actions for CHILL.
2 Copyright (C) 1992, 93, 1994 Free Software Foundation, Inc.
4 This file is part of GNU CC.
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING. If not, write to
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
33 /* from ch-lex.l, from compiler directives */
34 extern tree process_type;
35 extern tree send_signal_prio;
36 extern tree send_buffer_prio;
38 tree tasking_message_type;
39 tree instance_type_node;
40 tree generic_signal_type_node;
42 /* the type a tasking code variable has */
43 tree chill_taskingcode_type_node;
45 /* forward declarations */
46 void validate_process_parameters PROTO((tree));
47 tree make_process_struct PROTO((tree, tree));
49 /* list of this module's process, buffer, etc. decls.
50 This is a list of TREE_VECs, chain by their TREE_CHAINs. */
51 tree tasking_list = NULL_TREE;
52 /* The parts of a tasking_list element. */
53 #define TASK_INFO_PDECL(NODE) TREE_VEC_ELT(NODE,0)
54 #define TASK_INFO_ENTRY(NODE) TREE_VEC_ELT(NODE,1)
55 #define TASK_INFO_CODE_DECL(NODE) TREE_VEC_ELT(NODE,2)
56 #define TASK_INFO_STUFF_NUM(NODE) TREE_VEC_ELT(NODE,3)
57 #define TASK_INFO_STUFF_TYPE(NODE) TREE_VEC_ELT(NODE,4)
59 /* name template for process argument type */
60 static char * struct_name = "__tmp_%s_arg_type";
62 /* name template for process arguments for debugging type */
63 static char * struct_debug_name = "__tmp_%s_debug_type";
66 /* name template for process argument variable */
67 static char * data_name = "__tmp_%s_arg_variable";
70 /* name template for process wrapper */
71 static char * wrapper_name = "__tmp_%s_wrapper";
74 static tree void_ftype_void;
75 static tree pointer_to_instance;
76 static tree infinite_buffer_event_length_node;
79 get_struct_type_name (name)
82 char *idp = IDENTIFIER_POINTER (name); /* process name */
83 char *tmpname = xmalloc (strlen (idp) + strlen (struct_name) + 1);
85 sprintf (tmpname, struct_name, idp);
86 return get_identifier (tmpname);
90 get_struct_debug_type_name (name)
93 char *idp = IDENTIFIER_POINTER (name); /* process name */
94 char *tmpname = xmalloc (strlen (idp) + strlen (struct_debug_name) + 1);
96 sprintf (tmpname, struct_debug_name, idp);
97 return get_identifier (tmpname);
102 get_tasking_code_name (name)
105 char *skelname = "__tmp_%s_code";
106 char *name_str = IDENTIFIER_POINTER (name);
107 char *tmpname = (char *)alloca (IDENTIFIER_LENGTH (name) +
108 strlen (skelname) + 1);
110 sprintf (tmpname, skelname, name_str);
111 return get_identifier (tmpname);
116 get_struct_variable_name (name)
119 char *idp = IDENTIFIER_POINTER (name); /* process name */
120 char *tmpname = xmalloc (strlen (idp) + strlen (data_name) + 1);
122 sprintf (tmpname, data_name, idp);
123 return get_identifier (tmpname);
128 get_process_wrapper_name (name)
131 char *idp = IDENTIFIER_POINTER (name);
132 char *tmpname = xmalloc (strlen (idp) + strlen (wrapper_name) + 1);
134 sprintf (tmpname, wrapper_name, idp);
135 return get_identifier (tmpname);
139 * If this is a quasi declaration - parsed within a SPEC MODULE,
140 * QUASI_FLAG is TRUE, to indicate that the variable should not
141 * be initialized. The other module will do that.
144 generate_tasking_code_variable (name, tasking_code_ptr, quasi_flag)
145 tree name, *tasking_code_ptr;
150 tree tasking_code_name = get_tasking_code_name (name);
152 if (pass == 2 && ! quasi_flag && *tasking_code_ptr != NULL_TREE)
154 /* check for value should be assigned is out of range */
155 if (TREE_INT_CST_LOW (*tasking_code_ptr) >
156 TREE_INT_CST_LOW (TYPE_MAX_VALUE (chill_taskingcode_type_node)))
157 error ("Tasking code %d out of range for `%s'.",
158 TREE_INT_CST_LOW (*tasking_code_ptr),
159 IDENTIFIER_POINTER (name));
162 decl = do_decl (tasking_code_name,
163 chill_taskingcode_type_node, 1, 1,
164 quasi_flag ? NULL_TREE : *tasking_code_ptr,
167 /* prevent granting of this type */
168 DECL_SOURCE_LINE (decl) = 0;
170 if (pass == 2 && ! quasi_flag && *tasking_code_ptr != NULL_TREE)
171 *tasking_code_ptr = fold (build (PLUS_EXPR, chill_taskingcode_type_node,
179 * If this is a quasi declaration - parsed within a SPEC MODULE,
180 * QUASI_FLAG is TRUE, to indicate that the variable should not
181 * be initialized. The other module will do that. This is just
182 * for BUFFERs and EVENTs.
185 decl_tasking_code_variable (name, tasking_code_ptr, quasi_flag)
186 tree name, *tasking_code_ptr;
189 extern struct obstack permanent_obstack;
190 tree tasking_code_name = get_tasking_code_name (name);
193 /* guarantee that RTL for the code_variable resides in
194 the permanent obstack. The BUFFER or EVENT may be
195 declared in a PROC, not at global scope... */
196 push_obstacks (&permanent_obstack, &permanent_obstack);
197 push_obstacks_nochange ();
199 if (pass == 2 && ! quasi_flag && *tasking_code_ptr != NULL_TREE)
201 /* check for value should be assigned is out of range */
202 if (TREE_INT_CST_LOW (*tasking_code_ptr) >
203 TREE_INT_CST_LOW (TYPE_MAX_VALUE (chill_taskingcode_type_node)))
204 error ("Tasking code %d out of range for `%s'.",
205 TREE_INT_CST_LOW (*tasking_code_ptr),
206 IDENTIFIER_POINTER (name));
209 decl = decl_temp1 (tasking_code_name,
210 chill_taskingcode_type_node, 1,
211 quasi_flag ? NULL_TREE : *tasking_code_ptr,
213 /* prevent granting of this type */
214 DECL_SOURCE_LINE (decl) = 0;
216 /* Return to the ambient context. */
219 if (pass == 2 && ! quasi_flag && *tasking_code_ptr != NULL_TREE)
220 *tasking_code_ptr = fold (build (PLUS_EXPR, chill_taskingcode_type_node,
227 * Transmute a process parameter list into an argument structure
228 * TYPE_DECL for the start_process call to reference. Create a
229 * proc_type variable for later. Returns the new struct type.
232 make_process_struct (name, processparlist)
233 tree name, processparlist;
237 tree field_decls = NULL_TREE;
239 if (name == NULL_TREE || TREE_CODE (name) == ERROR_MARK)
240 return error_mark_node;
242 if (processparlist == NULL_TREE)
243 return tree_cons (NULL_TREE, NULL_TREE, void_list_node);
245 if (TREE_CODE (processparlist) == ERROR_MARK)
246 return error_mark_node;
248 /* build list of field decls for build_chill_struct_type */
249 for (a_parm = processparlist; a_parm != NULL_TREE;
250 a_parm = TREE_CHAIN (a_parm))
252 tree parnamelist = TREE_VALUE (a_parm);
253 tree purpose = TREE_PURPOSE (a_parm);
254 tree mode = TREE_VALUE (purpose);
255 tree parm_attr = TREE_PURPOSE (purpose);
258 /* build a FIELD_DECL node */
259 if (parm_attr != NULL_TREE)
261 if (parm_attr == ridpointers[(int)RID_LOC])
262 mode = build_chill_reference_type (mode);
263 else if (parm_attr == ridpointers[(int)RID_IN])
267 for (field = parnamelist; field != NULL_TREE;
268 field = TREE_CHAIN (field))
269 error ("invalid attribute for argument `%s' (only IN or LOC allowed).",
270 IDENTIFIER_POINTER (TREE_VALUE (field)));
274 field = grok_chill_fixedfields (parnamelist, mode, NULL_TREE);
276 /* chain the fields in reverse */
277 if (field_decls == NULL_TREE)
280 chainon (field_decls, field);
283 temp = build_chill_struct_type (field_decls);
287 /* Build a function for a PROCESS and define some
288 types for the process arguments.
289 After the PROCESS a wrapper function will be
290 generated which gets the PROCESS arguments via a pointer
291 to a structure having the same layout as the arguments.
292 This wrapper function then will call the PROCESS.
293 The advantage in doing it this way is, that PROCESS
294 arguments may be displayed by gdb without any change
298 build_process_header (plabel, paramlist)
299 tree plabel, paramlist;
301 tree struct_ptr_type = NULL_TREE;
302 tree new_param_list = NULL_TREE;
303 tree struct_decl = NULL_TREE;
304 tree process_struct = NULL_TREE;
305 tree struct_debug_type = NULL_TREE;
308 if (! global_bindings_p ())
310 error ("PROCESS may only be declared at module level");
311 return error_mark_node;
316 /* must make the structure OUTSIDE the parameter scope */
319 process_struct = make_process_struct (plabel, paramlist);
320 struct_ptr_type = build_chill_pointer_type (process_struct);
324 process_struct = NULL_TREE;
325 struct_ptr_type = NULL_TREE;
328 struct_decl = push_modedef (get_struct_type_name (plabel),
329 struct_ptr_type, -1);
330 DECL_SOURCE_LINE (struct_decl) = 0;
331 struct_debug_type = push_modedef (get_struct_debug_type_name (plabel),
333 DECL_SOURCE_LINE (struct_debug_type) = 0;
337 /* build a list of PARM_DECL's */
338 tree wrk = paramlist;
339 tree tmp, list = NULL_TREE;
341 while (wrk != NULL_TREE)
343 tree wrk1 = TREE_VALUE (wrk);
345 while (wrk1 != NULL_TREE)
347 tmp = make_node (PARM_DECL);
348 DECL_ASSEMBLER_NAME (tmp) = DECL_NAME (tmp) = TREE_VALUE (wrk1);
349 if (list == NULL_TREE)
350 new_param_list = list = tmp;
353 TREE_CHAIN (list) = tmp;
356 wrk1 = TREE_CHAIN (wrk1);
358 wrk = TREE_CHAIN (wrk);
363 /* build a list of modes */
364 tree wrk = paramlist;
366 while (wrk != NULL_TREE)
368 tree wrk1 = TREE_VALUE (wrk);
370 while (wrk1 != NULL_TREE)
372 new_param_list = tree_cons (TREE_PURPOSE (TREE_PURPOSE (wrk)),
373 TREE_VALUE (TREE_PURPOSE (wrk)),
375 wrk1 = TREE_CHAIN (wrk1);
377 wrk = TREE_CHAIN (wrk);
379 new_param_list = nreverse (new_param_list);
383 /* declare the code variable outside the process */
384 code_decl = generate_tasking_code_variable (plabel,
387 /* start the parameter scope */
388 push_chill_function_context ();
390 if (! start_chill_function (plabel, void_type_node,
391 new_param_list, NULL_TREE, NULL_TREE))
392 return error_mark_node;
394 current_module->procedure_seen = 1;
395 CH_DECL_PROCESS (current_function_decl) = 1;
396 /* remember the code variable in the function decl */
397 DECL_TASKING_CODE_DECL (current_function_decl) =
398 (struct lang_decl *)code_decl;
399 if (paramlist == NULL_TREE)
400 /* do it here, cause we don't have a wrapper */
401 add_taskstuff_to_list (code_decl, "_TT_Process", process_type,
402 current_function_decl, NULL_TREE);
404 return perm_tree_cons (code_decl, struct_decl, NULL_TREE);
407 /* Generate a function which gets a pointer
408 to an argument block and call the corresponding
412 build_process_wrapper (plabel, processdata)
416 tree args = NULL_TREE;
417 tree wrapper = NULL_TREE;
418 tree parammode = TREE_VALUE (processdata);
419 tree code_decl = TREE_PURPOSE (processdata);
420 tree func = lookup_name (plabel);
422 /* check the mode. If it is an ERROR_MARK there was an error
423 in build_process_header, if it is a NULL_TREE the process
424 don't have parameters, so we must not generate a wrapper */
425 if (parammode == NULL_TREE ||
426 TREE_CODE (parammode) == ERROR_MARK)
429 /* get the function name */
430 wrapper = get_process_wrapper_name (plabel);
432 /* build the argument */
435 /* build a PARM_DECL */
436 args = make_node (PARM_DECL);
437 DECL_ASSEMBLER_NAME (args) = DECL_NAME (args) = get_identifier ("x");
441 /* build a tree list with the mode */
442 args = tree_cons (NULL_TREE,
443 TREE_TYPE (parammode),
447 /* start the function */
448 push_chill_function_context ();
450 if (! start_chill_function (wrapper, void_type_node,
451 args, NULL_TREE, NULL_TREE))
454 /* to avoid granting */
455 DECL_SOURCE_LINE (current_function_decl) = 0;
459 /* make the call to the PROCESS */
461 tree x = lookup_name (get_identifier ("x"));
462 /* no need to check this pointer to be NULL */
463 tree indref = build_chill_indirect_ref (x, NULL_TREE, 0);
466 wrk = TYPE_FIELDS (TREE_TYPE (TREE_TYPE (x)));
467 while (wrk != NULL_TREE)
469 args = tree_cons (NULL_TREE,
470 build_component_ref (indref, DECL_NAME (wrk)),
472 wrk = TREE_CHAIN (wrk);
474 CH_DECL_PROCESS (func) = 0;
476 build_chill_function_call (func, nreverse (args)));
477 CH_DECL_PROCESS (func) = 1;
480 add_taskstuff_to_list (code_decl, "_TT_Process", process_type,
481 func, current_function_decl);
483 /* finish the function */
484 finish_chill_function ();
485 pop_chill_function_context ();
488 /* Generate errors for INOUT, OUT parameters.
490 "Only if LOC is specified may the mode have the non-value
495 validate_process_parameters (parms)
496 tree parms ATTRIBUTE_UNUSED;
501 * build the tree for a start process action. Loop through the
502 * actual parameters, making a constructor list, which we use to
503 * initialize the argument structure. NAME is the process' name.
504 * COPYNUM is its copy number, whatever that is. EXPRLIST is the
505 * list of actual parameters passed by the start call. They must
506 * match. EXPRLIST must still be in reverse order; we'll reverse it here.
508 * Note: the OPTSET name is not now used - it's here for
509 * possible future support for the optional 'SET instance-var'
513 build_start_process (process_name, copynum,
515 tree process_name, copynum, exprlist, optset;
517 tree process_decl, struct_type_node;
519 tree valtail, typetail;
520 tree tuple = NULL_TREE, actuallist = NULL_TREE;
524 tree filename, linenumber;
526 if (exprlist != NULL_TREE && TREE_CODE (exprlist) == ERROR_MARK)
527 process_decl = NULL_TREE;
530 process_decl = lookup_name (process_name);
531 if (process_decl == NULL_TREE)
532 error ("process name %s never declared",
533 IDENTIFIER_POINTER (process_name));
534 else if (TREE_CODE (process_decl) != FUNCTION_DECL
535 || ! CH_DECL_PROCESS (process_decl))
537 error ("You may only START a process, not a proc");
538 process_decl = NULL_TREE;
540 else if (DECL_EXTERNAL (process_decl))
542 args = TYPE_ARG_TYPES (TREE_TYPE (process_decl));
543 if (TREE_VALUE (args) != void_type_node)
544 struct_type_node = TREE_TYPE (TREE_VALUE (args));
546 struct_type_node = NULL_TREE;
550 tree debug_type = lookup_name (
551 get_struct_debug_type_name (DECL_NAME (process_decl)));
553 if (debug_type == NULL_TREE)
554 /* no debug type, no arguments */
555 struct_type_node = NULL_TREE;
557 struct_type_node = TREE_TYPE (debug_type);
561 /* begin a new name scope */
566 expand_start_bindings (0);
568 if (! ignoring && process_decl != NULL_TREE)
570 if (optset == NULL_TREE) ;
571 else if (!CH_REFERABLE (optset))
573 error ("SET expression not a location.");
576 else if (!CH_IS_INSTANCE_MODE (TREE_TYPE (optset)))
578 error ("SET location must be INSTANCE mode");
582 optset = force_addr_of (optset);
584 optset = convert (ptr_type_node, integer_zero_node);
586 if (struct_type_node != NULL_TREE)
588 typelist = TYPE_FIELDS (struct_type_node);
590 for (valtail = nreverse (exprlist), typetail = typelist;
591 valtail != NULL_TREE && typetail != NULL_TREE; parmno++,
592 valtail = TREE_CHAIN (valtail), typetail = TREE_CHAIN (typetail))
594 register tree actual = valtail ? TREE_VALUE (valtail) : 0;
595 register tree type = typetail ? TREE_TYPE (typetail) : 0;
597 sprintf (place, "signal field %d", parmno);
598 actual = chill_convert_for_assignment (type, actual, place);
599 actuallist = tree_cons (NULL_TREE, actual,
603 tuple = build_nt (CONSTRUCTOR, NULL_TREE,
604 nreverse (actuallist));
609 typetail = NULL_TREE;
612 if (valtail != 0 && TREE_VALUE (valtail) != void_type_node)
614 char *errstr = "too many arguments to process";
616 error ("%s `%s'", errstr, IDENTIFIER_POINTER (process_name));
620 else if (typetail != 0 && TREE_VALUE (typetail) != void_type_node)
622 char *errstr = "too few arguments to process";
624 error ("%s `%s'", errstr, IDENTIFIER_POINTER (process_name));
630 tree process_decl = lookup_name (process_name);
631 tree process_type = (tree)DECL_TASKING_CODE_DECL (process_decl);
632 tree struct_size, struct_pointer;
634 if (struct_type_node != NULL_TREE)
637 decl_temp1 (get_unique_identifier ("START_ARG"),
638 struct_type_node, 0, tuple, 0, 0);
639 /* prevent granting of this type */
640 DECL_SOURCE_LINE (result) = 0;
642 mark_addressable (result);
645 build_chill_pointer_type (struct_type_node),
647 struct_size = size_in_bytes (struct_type_node);
651 struct_size = integer_zero_node;
652 struct_pointer = null_pointer_node;
655 filename = force_addr_of (get_chill_filename ());
656 linenumber = get_chill_linenumber ();
659 build_chill_function_call (lookup_name (get_identifier ("__start_process")),
660 tree_cons (NULL_TREE, process_type,
661 tree_cons (NULL_TREE, convert (integer_type_node, copynum),
662 tree_cons (NULL_TREE, struct_size,
663 tree_cons (NULL_TREE, struct_pointer,
664 tree_cons (NULL_TREE, optset,
665 tree_cons (NULL_TREE, filename,
666 build_tree_list (NULL_TREE, linenumber)))))))));
672 expand_end_bindings (getdecls (), kept_level_p (), 0);
673 poplevel (kept_level_p (), 0, 0);
678 * A CHILL SET which represents all of the possible tasking
682 build_tasking_enum ()
686 tree list = NULL_TREE;
687 tree value = integer_zero_node;
689 enum1 = start_enum (NULL_TREE);
690 result = build_enumerator (get_identifier ("_TT_UNUSED"),
692 list = chainon (result, list);
693 value = fold (build (PLUS_EXPR, integer_type_node,
694 value, integer_one_node));
696 result = build_enumerator (get_identifier ("_TT_Process"),
698 list = chainon (result, list);
699 value = fold (build (PLUS_EXPR, integer_type_node,
700 value, integer_one_node));
702 result = build_enumerator (get_identifier ("_TT_Signal"),
704 list = chainon (result, list);
705 value = fold (build (PLUS_EXPR, integer_type_node,
706 value, integer_one_node));
708 result = build_enumerator (get_identifier ("_TT_Buffer"),
710 list = chainon (result, list);
711 value = fold (build (PLUS_EXPR, integer_type_node,
712 value, integer_one_node));
714 result = build_enumerator (get_identifier ("_TT_Event"),
716 list = chainon (result, list);
717 value = fold (build (PLUS_EXPR, integer_type_node,
718 value, integer_one_node));
720 result = build_enumerator (get_identifier ("_TT_Synonym"),
722 list = chainon (result, list);
723 value = fold (build (PLUS_EXPR, integer_type_node,
724 value, integer_one_node));
726 result = build_enumerator (get_identifier ("_TT_Exception"),
728 list = chainon (result, list);
729 value = fold (build (PLUS_EXPR, integer_type_node,
730 value, integer_one_node));
732 result = finish_enum (enum1, list);
734 decl1 = build_decl (TYPE_DECL,
735 get_identifier ("__tmp_TaskingEnum"),
738 satisfy_decl (decl1, 0);
743 build_tasking_struct ()
745 tree listbase, decl1, decl2, result;
746 tree enum_type = TREE_TYPE (build_tasking_enum ());
747 /* We temporarily reset the maximum_field_alignment to zero so the
748 compiler's init data structures can be compatible with the
749 run-time system, even when we're compiling with -fpack. */
750 extern int maximum_field_alignment;
751 int save_maximum_field_alignment = maximum_field_alignment;
752 maximum_field_alignment = 0;
754 decl1 = build_decl (FIELD_DECL, get_identifier ("TaskName"),
755 build_chill_pointer_type (char_type_node));
756 DECL_INITIAL (decl1) = NULL_TREE;
759 decl2 = build_decl (FIELD_DECL, get_identifier ("TaskValue"),
760 build_chill_pointer_type (chill_taskingcode_type_node));
761 TREE_CHAIN (decl1) = decl2;
762 DECL_INITIAL (decl2) = NULL_TREE;
765 decl2 = build_decl (FIELD_DECL, get_identifier ("TaskValueDefined"),
767 TREE_CHAIN (decl1) = decl2;
768 DECL_INITIAL (decl2) = NULL_TREE;
771 decl2 = build_decl (FIELD_DECL, get_identifier ("TaskEntry"),
772 build_chill_pointer_type (void_ftype_void));
773 TREE_CHAIN (decl1) = decl2;
774 DECL_INITIAL (decl2) = NULL_TREE;
777 decl2 = build_decl (FIELD_DECL, get_identifier ("TaskType"),
779 TREE_CHAIN (decl1) = decl2;
780 DECL_INITIAL (decl2) = NULL_TREE;
783 TREE_CHAIN (decl2) = NULL_TREE;
784 result = build_chill_struct_type (listbase);
785 satisfy_decl (result, 0);
786 maximum_field_alignment = save_maximum_field_alignment;
791 * build data structures describing each task/signal, etc.
803 struct_type = TREE_TYPE (lookup_name (
804 get_identifier ("__tmp_TaskingStruct")));
806 for (tasknode = tasking_list; tasknode != NULL_TREE;
807 tasknode = TREE_CHAIN (tasknode))
809 /* This is the tasking_code_variable's decl */
810 tree stuffnumber = TASK_INFO_STUFF_NUM (tasknode);
811 tree code_decl = TASK_INFO_CODE_DECL (tasknode);
812 tree proc_decl = TASK_INFO_PDECL (tasknode);
813 tree entry = TASK_INFO_ENTRY (tasknode);
814 tree name = DECL_NAME (proc_decl);
815 char *init_struct = (char *) alloca (IDENTIFIER_LENGTH(name) + 20);
816 /* take care of zero termination */
818 /* these are the fields of the struct, in declaration order */
819 tree init_flag = (stuffnumber == NULL_TREE) ?
820 integer_zero_node : integer_one_node;
821 tree type = DECL_INITIAL (TASK_INFO_STUFF_TYPE (tasknode));
829 if (TREE_CODE (proc_decl) == FUNCTION_DECL
830 && CH_DECL_PROCESS (proc_decl)
831 && ! DECL_EXTERNAL (proc_decl))
833 if (entry == NULL_TREE)
835 mark_addressable (entry);
836 entry_point = build1 (ADDR_EXPR,
837 build_chill_pointer_type (void_ftype_void),
841 entry_point = build1 (NOP_EXPR,
842 build_chill_pointer_type (void_ftype_void),
845 /* take care of zero termination */
847 build_chill_string (IDENTIFIER_LENGTH (name) + 1,
848 IDENTIFIER_POINTER (name));
850 mark_addressable (code_decl);
851 int_addr = build1 (ADDR_EXPR,
852 build_chill_pointer_type (chill_integer_type_node),
855 mark_addressable (task_name);
856 name_ptr = build1 (ADDR_EXPR,
857 build_chill_pointer_type (char_type_node),
860 sprintf (init_struct, "__tmp_%s_struct",
861 IDENTIFIER_POINTER (name));
863 struct_id = get_identifier (init_struct);
864 initializer = build (CONSTRUCTOR, struct_type, NULL_TREE,
865 tree_cons (NULL_TREE, name_ptr,
866 tree_cons (NULL_TREE, int_addr,
867 tree_cons (NULL_TREE, init_flag,
868 tree_cons (NULL_TREE, entry_point,
869 tree_cons (NULL_TREE, type, NULL_TREE))))));
870 TREE_CONSTANT (initializer) = 1;
871 decl = decl_temp1 (struct_id, struct_type, 1, initializer, 0, 0);
872 /* prevent granting of this type */
873 DECL_SOURCE_LINE (decl) = 0;
875 /* pass the decl to tasking_registry() in the symbol table */
876 IDENTIFIER_LOCAL_VALUE (struct_id) = decl;
882 * Generate code to register the tasking-related stuff
883 * with the runtime. Only in pass 2.
888 tree tasknode, fn_decl;
893 fn_decl = lookup_name (get_identifier ("__register_tasking"));
895 for (tasknode = tasking_list; tasknode != NULL_TREE;
896 tasknode = TREE_CHAIN (tasknode))
898 tree proc_decl = TASK_INFO_PDECL (tasknode);
899 tree name = DECL_NAME (proc_decl);
901 char *init_struct = (char *) alloca (IDENTIFIER_LENGTH (name) + 20);
903 sprintf (init_struct, "__tmp_%s_struct",
904 IDENTIFIER_POINTER (name));
905 arg_decl = lookup_name (get_identifier (init_struct));
908 build_chill_function_call (fn_decl,
909 build_tree_list (NULL_TREE, force_addr_of (arg_decl))));
914 * Put a tasking entity (a PROCESS, or SIGNAL) onto
915 * the list for tasking_setup (). CODE_DECL is the integer code
916 * variable's DECL, which describes the shadow integer which
917 * accompanies each tasking entity. STUFFTYPE is a string
918 * representing the sort of tasking entity we have here (i.e.
919 * process, signal, etc.). STUFFNUMBER is an enumeration
920 * value saying the same thing. PROC_DECL is the declaration of
921 * the entity. It's a FUNCTION_DECL if the entity is a PROCESS, it's
922 * a TYPE_DECL if the entity is a SIGNAL.
925 add_taskstuff_to_list (code_decl, stufftype, stuffnumber,
929 tree stuffnumber, proc_decl, entry;
932 /* tell chill_finish_compile that there's
933 task-level code to be processed. */
934 tasking_list = integer_one_node;
936 /* do only in pass 2 so we know in chill_finish_compile whether
937 to generate a constructor function, and to avoid double the
938 correct number of entries. */
941 tree task_node = make_tree_vec (5);
942 TASK_INFO_PDECL (task_node) = proc_decl;
943 TASK_INFO_ENTRY (task_node) = entry;
944 TASK_INFO_CODE_DECL (task_node) = code_decl;
945 TASK_INFO_STUFF_NUM (task_node) = stuffnumber;
946 TASK_INFO_STUFF_TYPE (task_node)
947 = lookup_name (get_identifier (stufftype));
948 TREE_CHAIN (task_node) = tasking_list;
949 tasking_list = task_node;
954 * These next routines are called out of build_generalized_call
957 build_copy_number (instance_expr)
962 if (instance_expr == NULL_TREE
963 || TREE_CODE (instance_expr) == ERROR_MARK)
964 return error_mark_node;
965 if (! CH_IS_INSTANCE_MODE (TREE_TYPE (instance_expr)))
967 error ("COPY_NUMBER argument must be INSTANCE expression");
968 return error_mark_node;
970 result = build_component_ref (instance_expr,
971 get_identifier (INS_COPY));
972 CH_DERIVED_FLAG (result) = 1;
978 build_gen_code (decl)
983 if (decl == NULL_TREE || TREE_CODE (decl) == ERROR_MARK)
984 return error_mark_node;
986 if ((TREE_CODE (decl) == FUNCTION_DECL && CH_DECL_PROCESS (decl))
987 || (TREE_CODE (decl) == TYPE_DECL && CH_DECL_SIGNAL (decl)))
988 result = (tree)(DECL_TASKING_CODE_DECL (decl));
991 error ("GEN_CODE argument must be a process or signal name.");
992 return error_mark_node;
994 CH_DERIVED_FLAG (result) = 1;
1000 build_gen_inst (process, copyn)
1001 tree process, copyn;
1006 if (copyn == NULL_TREE || TREE_CODE (copyn) == ERROR_MARK)
1007 return error_mark_node;
1008 if (process == NULL_TREE || TREE_CODE (process) == ERROR_MARK)
1009 return error_mark_node;
1011 if (TREE_CODE (TREE_TYPE (copyn)) != INTEGER_TYPE)
1013 error ("GEN_INST parameter 2 must be an integer mode");
1014 copyn = integer_zero_node;
1017 copyn = check_range (copyn, copyn,
1018 TYPE_MIN_VALUE (chill_taskingcode_type_node),
1019 TYPE_MAX_VALUE (chill_taskingcode_type_node));
1021 if (TREE_CODE (process) == FUNCTION_DECL
1022 && CH_DECL_PROCESS (process))
1023 ptype = (tree)DECL_TASKING_CODE_DECL (process);
1024 else if (TREE_TYPE (process) != NULL_TREE
1025 && TREE_CODE (TREE_TYPE (process)) == INTEGER_TYPE)
1027 process = check_range (process, process,
1028 TYPE_MIN_VALUE (chill_taskingcode_type_node),
1029 TYPE_MAX_VALUE (chill_taskingcode_type_node));
1030 ptype = convert (chill_taskingcode_type_node, process);
1034 error ("GEN_INST parameter 1 must be a PROCESS or an integer expression");
1035 return (error_mark_node);
1038 result = convert (instance_type_node,
1039 build_nt (CONSTRUCTOR, NULL_TREE,
1040 tree_cons (NULL_TREE, ptype,
1041 tree_cons (NULL_TREE,
1042 convert (chill_taskingcode_type_node, copyn), NULL_TREE))));
1043 CH_DERIVED_FLAG (result) = 1;
1049 build_gen_ptype (process_decl)
1054 if (process_decl == NULL_TREE || TREE_CODE (process_decl) == ERROR_MARK)
1055 return error_mark_node;
1057 if (TREE_CODE (process_decl) != FUNCTION_DECL
1058 || ! CH_DECL_PROCESS (process_decl))
1060 error_with_decl (process_decl, "%s is not a declared process");
1061 return error_mark_node;
1064 result = (tree)DECL_TASKING_CODE_DECL (process_decl);
1065 CH_DERIVED_FLAG (result) = 1;
1071 build_proc_type (instance_expr)
1076 if (instance_expr == NULL_TREE || TREE_CODE (instance_expr) == ERROR_MARK)
1077 return error_mark_node;
1079 if (! CH_IS_INSTANCE_MODE (TREE_TYPE (instance_expr)))
1081 error ("PROC_TYPE argument must be INSTANCE expression");
1082 return error_mark_node;
1084 result = build_component_ref (instance_expr,
1085 get_identifier (INS_PTYPE));
1086 CH_DERIVED_FLAG (result) = 1;
1091 build_queue_length (buf_ev)
1094 if (buf_ev == NULL_TREE || TREE_CODE (buf_ev) == ERROR_MARK)
1095 return error_mark_node;
1096 if (TREE_TYPE (buf_ev) == NULL_TREE ||
1097 TREE_CODE (TREE_TYPE (buf_ev)) == ERROR_MARK)
1098 return error_mark_node;
1100 if (CH_IS_BUFFER_MODE (TREE_TYPE (buf_ev)) ||
1101 CH_IS_EVENT_MODE (TREE_TYPE (buf_ev)))
1106 if (CH_IS_EVENT_MODE (TREE_TYPE (buf_ev)))
1108 field_name = "__event_data";
1109 arg2 = integer_one_node;
1113 field_name = "__buffer_data";
1114 arg2 = integer_zero_node;
1116 arg1 = build_component_ref (buf_ev, get_identifier (field_name));
1117 return build_chill_function_call (
1118 lookup_name (get_identifier ("__queue_length")),
1119 tree_cons (NULL_TREE, arg1,
1120 tree_cons (NULL_TREE, arg2, NULL_TREE)));
1123 error ("QUEUE_LENGTH argument must be a BUFFER/EVENT location.");
1124 return error_mark_node;
1128 build_signal_struct_type (signame, sigmodelist, optsigdest)
1129 tree signame, sigmodelist, optsigdest;
1136 tree mode, field_decls = NULL_TREE;
1138 for (mode = sigmodelist; mode != NULL_TREE; mode = TREE_CHAIN (mode))
1143 if (TREE_VALUE (mode) == NULL_TREE)
1145 sprintf (fldname, "fld%03d", fldcnt++);
1146 field = build_decl (FIELD_DECL,
1147 get_identifier (fldname),
1149 if (field_decls == NULL_TREE)
1150 field_decls = field;
1152 chainon (field_decls, field);
1154 if (field_decls == NULL_TREE)
1155 field_decls = build_decl (FIELD_DECL,
1156 get_identifier ("__tmp_empty"),
1158 temp = build_chill_struct_type (field_decls);
1160 /* save the destination process name of the signal */
1161 IDENTIFIER_SIGNAL_DEST (signame) = optsigdest;
1162 IDENTIFIER_SIGNAL_DATA (signame) = fldcnt;
1166 /* optsigset is only valid in pass 2, so we have to save it now */
1167 IDENTIFIER_SIGNAL_DEST (signame) = optsigdest;
1168 temp = NULL_TREE; /* Actually, don't care. */
1171 decl = push_modedef (signame, temp, -1);
1172 if (decl != NULL_TREE)
1173 CH_DECL_SIGNAL (decl) = 1;
1178 * An instance type is a unique process identifier in the CHILL
1179 * tasking arena. It consists of a process type and a copy number.
1182 build_instance_type ()
1184 tree decl1, decl2, tdecl;
1186 decl1 = build_decl (FIELD_DECL, get_identifier (INS_PTYPE),
1187 chill_taskingcode_type_node);
1189 TREE_CHAIN (decl1) = decl2 =
1190 build_decl (FIELD_DECL, get_identifier (INS_COPY),
1191 chill_taskingcode_type_node);
1192 TREE_CHAIN (decl2) = NULL_TREE;
1194 instance_type_node = build_chill_struct_type (decl1);
1195 tdecl = build_decl (TYPE_DECL, ridpointers[(int) RID_INSTANCE],
1196 instance_type_node);
1197 TYPE_NAME (instance_type_node) = tdecl;
1198 CH_NOVELTY (instance_type_node) = tdecl;
1199 DECL_SOURCE_LINE (tdecl) = 0;
1202 pointer_to_instance = build_chill_pointer_type (instance_type_node);
1207 * The tasking message descriptor looks like this C structure:
1211 * short *sc; /* ptr to code integer */
1212 * int data_len; /* length of signal/buffer data msg */
1213 * void *data; /* ptr to signal/buffer data */
1220 build_tasking_message_type ()
1224 /* We temporarily reset maximum_field_alignment to deal with
1225 the runtime system. */
1226 extern int maximum_field_alignment;
1227 int save_maximum_field_alignment = maximum_field_alignment;
1228 tree field1, field2, field3;
1230 maximum_field_alignment = 0;
1231 field1 = build_decl (FIELD_DECL,
1232 get_identifier ("_SD_code_ptr"),
1233 build_pointer_type (chill_integer_type_node));
1234 field2 = build_decl (FIELD_DECL,
1235 get_identifier ("_SD_data_len"),
1237 field3 = build_decl (FIELD_DECL,
1238 get_identifier ("_SD_data_ptr"),
1240 TREE_CHAIN (field1) = field2;
1241 TREE_CHAIN (field2) = field3;
1242 temp = build_chill_struct_type (field1);
1244 type_name = get_identifier ("__tmp_SD_struct");
1245 tasking_message_type = build_decl (TYPE_DECL, type_name, temp);
1247 /* This won't get seen in pass 2, so lay it out now. */
1248 layout_chill_struct_type (temp);
1249 pushdecl (tasking_message_type);
1250 maximum_field_alignment = save_maximum_field_alignment;
1254 build_signal_descriptor (sigdef, exprlist)
1255 tree sigdef, exprlist;
1257 tree fieldlist, typetail, valtail;
1258 tree actuallist = NULL_TREE;
1259 tree signame = DECL_NAME (sigdef);
1260 tree dataptr, datalen;
1263 if (sigdef == NULL_TREE
1264 || TREE_CODE (sigdef) == ERROR_MARK)
1265 return error_mark_node;
1267 if (exprlist != NULL_TREE
1268 && TREE_CODE (exprlist) == ERROR_MARK)
1269 return error_mark_node;
1271 if (TREE_CODE (sigdef) != TYPE_DECL
1272 || ! CH_DECL_SIGNAL (sigdef))
1274 error ("SEND requires a SIGNAL; %s is not a SIGNAL name",
1276 return error_mark_node;
1278 if (CH_TYPE_NONVALUE_P (TREE_TYPE (sigdef)))
1279 return error_mark_node;
1281 fieldlist = TYPE_FIELDS (TREE_TYPE (sigdef));
1282 if (IDENTIFIER_SIGNAL_DATA (signame) == 0)
1283 fieldlist = TREE_CHAIN (fieldlist);
1285 for (valtail = exprlist, typetail = fieldlist;
1286 valtail != NULL_TREE && typetail != NULL_TREE;
1287 parmno++, valtail = TREE_CHAIN (valtail),
1288 typetail = TREE_CHAIN (typetail))
1290 register tree actual = valtail ? TREE_VALUE (valtail) : 0;
1291 register tree type = typetail ? TREE_TYPE (typetail) : 0;
1293 sprintf (place, "signal field %d", parmno);
1294 actual = chill_convert_for_assignment (type, actual, place);
1295 actuallist = tree_cons (NULL_TREE, actual, actuallist);
1297 if (valtail != 0 && TREE_VALUE (valtail) != void_type_node)
1299 error ("too many values for SIGNAL `%s'",
1300 IDENTIFIER_POINTER (signame));
1301 return error_mark_node;
1303 else if (typetail != 0 && TREE_VALUE (typetail) != void_type_node)
1305 error ("too few values for SIGNAL `%s'",
1306 IDENTIFIER_POINTER (signame));
1307 return error_mark_node;
1311 /* build signal data structure */
1312 tree sigdataname = get_unique_identifier (
1313 IDENTIFIER_POINTER (signame));
1314 if (exprlist == NULL_TREE)
1316 dataptr = null_pointer_node;
1317 datalen = integer_zero_node;
1321 tree tuple = build_nt (CONSTRUCTOR,
1322 NULL_TREE, nreverse (actuallist));
1323 tree decl = decl_temp1 (sigdataname, TREE_TYPE (sigdef),
1325 /* prevent granting of this type */
1326 DECL_SOURCE_LINE (decl) = 0;
1328 dataptr = force_addr_of (decl);
1329 datalen = size_in_bytes (TREE_TYPE (decl));
1332 /* build descriptor pointing to signal data */
1335 tree tasking_message_var = get_unique_identifier (
1336 IDENTIFIER_POINTER (signame));
1339 (tree)DECL_TASKING_CODE_DECL (lookup_name (signame));
1341 mark_addressable (tasking_code);
1342 tuple = build_nt (CONSTRUCTOR, NULL_TREE,
1343 tree_cons (NULL_TREE,
1345 build_chill_pointer_type (chill_integer_type_node),
1347 tree_cons (NULL_TREE, datalen,
1348 tree_cons (NULL_TREE, dataptr, NULL_TREE))));
1350 decl = decl_temp1 (tasking_message_var,
1351 TREE_TYPE (tasking_message_type), 0,
1353 /* prevent granting of this type */
1354 DECL_SOURCE_LINE (decl) = 0;
1356 tuple = force_addr_of (decl);
1363 expand_send_signal (sigmsgbuffer, optroutinginfo, optsendto,
1364 optpriority, signame)
1366 tree optroutinginfo;
1371 tree routing_size, routing_addr;
1372 tree filename, linenumber;
1373 tree sigdest = IDENTIFIER_SIGNAL_DEST (signame);
1375 /* check the presence of priority */
1376 if (optpriority == NULL_TREE)
1378 if (send_signal_prio == NULL_TREE)
1380 /* issue a warning in case of -Wall */
1383 warning ("Signal sent without priority");
1384 warning (" and no default priority was set.");
1385 warning (" PRIORITY defaulted to 0");
1387 optpriority = integer_zero_node;
1390 optpriority = send_signal_prio;
1393 /* check the presence of a destination.
1394 optdest either may be an instance location
1395 or a process declaration */
1396 if (optsendto == NULL_TREE)
1398 if (sigdest == NULL_TREE)
1400 error ("SEND without a destination instance");
1401 error (" and no destination process specified");
1402 error (" for the signal");
1403 optsendto = convert (instance_type_node,
1408 /* build an instance [sigdest; -1] */
1409 tree process_name = DECL_NAME (sigdest);
1410 tree copy_number = fold (build (MINUS_EXPR, integer_type_node,
1413 tree tasking_code = (tree)DECL_TASKING_CODE_DECL (
1414 lookup_name (process_name));
1416 optsendto = build (CONSTRUCTOR, instance_type_node, NULL_TREE,
1417 tree_cons (NULL_TREE, tasking_code,
1418 tree_cons (NULL_TREE, copy_number, NULL_TREE)));
1419 /* as our system doesn't allow that and Z.200 specifies it,
1420 we issue a warning */
1421 warning ("SEND to ANY copy of process `%s'.", IDENTIFIER_POINTER (process_name));
1424 else if (! CH_IS_INSTANCE_MODE (TREE_TYPE (optsendto)))
1426 error ("SEND TO must be an INSTANCE mode");
1427 optsendto = convert (instance_type_node, null_pointer_node);
1430 optsendto = check_non_null (convert (instance_type_node, optsendto));
1432 /* check the routing stuff */
1433 if (optroutinginfo != NULL_TREE)
1438 if (TREE_TYPE (optroutinginfo) == NULL_TREE)
1440 error ("SEND WITH must have a mode");
1441 optroutinginfo = integer_zero_node;
1443 routing_name = get_unique_identifier ("RI");
1444 decl = decl_temp1 (routing_name,
1445 TREE_TYPE (optroutinginfo), 0,
1446 optroutinginfo, 0, 0);
1447 /* prevent granting of this type */
1448 DECL_SOURCE_LINE (decl) = 0;
1450 routing_addr = force_addr_of (decl);
1451 routing_size = size_in_bytes (TREE_TYPE (decl));
1455 routing_size = integer_zero_node;
1456 routing_addr = null_pointer_node;
1458 /* get filename and linenumber */
1459 filename = force_addr_of (get_chill_filename ());
1460 linenumber = get_chill_linenumber ();
1462 /* Now (at last!) we can call the runtime */
1464 build_chill_function_call (lookup_name (get_identifier ("__send_signal")),
1465 tree_cons (NULL_TREE, sigmsgbuffer,
1466 tree_cons (NULL_TREE, optsendto,
1467 tree_cons (NULL_TREE, optpriority,
1468 tree_cons (NULL_TREE, routing_size,
1469 tree_cons (NULL_TREE, routing_addr,
1470 tree_cons (NULL_TREE, filename,
1471 tree_cons (NULL_TREE, linenumber, NULL_TREE)))))))));
1475 * The following code builds a RECEIVE CASE action, which actually
1476 * has 2 different functionalities:
1478 * 1) RECEIVE signal CASE action
1479 * which looks like this:
1482 * SIGNAL terminate = (CHAR);
1483 * SIGNAL sig1 = (CHAR);
1485 * DCL user, system INSTANCE;
1486 * DCL count INT, char_code CHAR;
1487 * DCL instance_loc INSTANCE;
1490 * RECEIVE CASE SET instance_loc;
1493 * (terminate IN char_code):
1494 * SEND sig1(char_code) TO system;
1500 * Because we don''t know until we get to the ESAC how
1501 * many signals need processing, we generate the following
1502 * C-equivalent code:
1504 * /* define the codes for the signals */
1505 * static short __tmp_advance_code;
1506 * static short __tmp_terminate_code;
1507 * static short __tmp_sig1_code;
1509 * /* define the types of the signals */
1513 * } __tmp_terminate_struct;
1518 * } __tmp_sig1_struct;
1520 * static INSTANCE user, system, instance_loc;
1521 * static short count;
1522 * static char char_code;
1524 * { /* start a new symbol context */
1525 * int number_of_sigs;
1526 * short *sig_code [];
1534 * int timedout = __wait_signal (&sigcode
1540 * if (sigcode == __tmp_advance_code)
1542 * /* code for advance alternative's action_statement_list */
1545 * else if (sigcode == __tmp_terminate_code)
1547 * /* copy signal's data to where they belong,
1548 * with range-check, if enabled */
1549 * char_code = ((__tmp_terminate_struct *)sigdatabuf)->fld0;
1551 * /* code for terminate alternative's action_statement_list */
1552 * __send_signal (sig1 ..... );
1553 * goto __workloop_end;
1557 * /* code here for the ELSE action_statement_list */
1558 * __stop_process ();
1563 * union { __tmp_terminate_struct terminate;
1564 * __tmp_sig1_struct } databuf;
1565 * short *sig_code_ptr [2] = { &__tmp_advance_code,
1566 * &__tmp_terminate_code };
1567 * sigdatabuf = &databuf;
1568 * sigdatalen = sizeof (databuf);
1569 * sig_code = &sig_code_ptr[0];
1570 * number_of_sigs = 2;
1574 * } /* end the new symbol context */
1578 * 2) RECEIVE buffer CASE action:
1579 * which looks like this:
1581 * NEWMODE m_s = STRUCT (mini INT, maxi INT);
1582 * DCL b1 BUFFER INT;
1583 * DCL b2 BUFFER (30) s;
1585 * DCL i INT, s m_s, ins INSTANCE;
1589 * RECEIVE CASE SET ins;
1593 * IF count < s.mini OR count > s.maxi THEN
1600 * Because we don''t know until we get to the ESAC how
1601 * many buffers need processing, we generate the following
1602 * C-equivalent code:
1614 * static INSTANCE ins;
1615 * static short count;
1618 * { /* start a new symbol context */
1619 * int number_of_sigs;
1620 * void *sig_code [];
1623 * void *buflocation;
1629 * timedout = __wait_buffer (&buflocation,
1635 * if (buflocation == &b1)
1637 * i = ((short *)sigdatabuf)->fld0;
1640 * else if (buflocation == &b2)
1642 * s = ((m_s)*sigdatabuf)->fld1;
1643 * if (count < s.mini || count > s.maxi)
1644 * goto __workloop_end;
1647 * __stop_process ();
1654 * unsigned maxqueuesize;
1658 * Buffer_Descr bufptr [2] =
1663 * void * bufarray[2] = { &bufptr[0],
1665 * sigdatabuf = &databuf;
1666 * sigdatalen = sizeof (databuf);
1667 * sig_code = &bufarray[0];
1668 * number_of_sigs = 2;
1672 * } /* end of symbol context */
1677 struct rc_state_type
1679 struct rc_state_type *enclosing;
1687 tree received_signal;
1688 tree received_buffer;
1698 struct rc_state_type *current_rc_state = NULL;
1701 * this function tells if there is an if to terminate
1705 build_receive_case_if_generated()
1707 if (!current_rc_state)
1709 error ("internal error: RECEIVE CASE stack invalid.");
1712 return current_rc_state->if_generated;
1715 /* build_receive_case_start returns an INTEGER_CST node
1716 containing the case-label number to be used by
1717 build_receive_case_end to generate correct labels */
1719 build_receive_case_start (optset)
1722 /* counter to generate unique receive_case labels */
1723 static int rc_lbl_count = 0;
1724 tree current_label_value =
1725 build_int_2 ((HOST_WIDE_INT)rc_lbl_count, 0);
1726 tree sigcodename, filename, linenumber;
1728 struct rc_state_type *rc_state
1729 = (struct rc_state_type*) xmalloc (sizeof (struct rc_state_type));
1730 rc_state->rcdoit = gen_label_rtx ();
1731 rc_state->rcsetup = gen_label_rtx ();
1732 rc_state->enclosing = current_rc_state;
1733 current_rc_state = rc_state;
1734 rc_state->sigseen = 0;
1735 rc_state->bufseen = 0;
1736 rc_state->call_generated = 0;
1737 rc_state->if_generated = 0;
1738 rc_state->bufcnt = 0;
1741 if (optset == NULL_TREE || TREE_CODE (optset) == ERROR_MARK)
1742 optset = null_pointer_node;
1745 if (CH_IS_INSTANCE_MODE (TREE_TYPE (optset)) && CH_LOCATION_P (optset))
1746 optset = force_addr_of (optset);
1749 error ("SET requires INSTANCE location");
1750 optset = null_pointer_node;
1754 rc_state->to_loc = build_timeout_preface ();
1757 decl_temp1 (get_identifier ("number_of_sigs"),
1758 integer_type_node, 0, integer_zero_node, 0, 0);
1760 rc_state->sig_code =
1761 decl_temp1 (get_identifier ("sig_codep"),
1762 ptr_type_node, 0, null_pointer_node, 0, 0);
1764 rc_state->databufp =
1765 decl_temp1 (get_identifier ("databufp"),
1766 ptr_type_node, 0, null_pointer_node, 0, 0);
1769 decl_temp1 (get_identifier ("datalen"),
1770 integer_type_node, 0, integer_zero_node, 0, 0);
1772 rc_state->else_clause =
1773 decl_temp1 (get_identifier ("else_clause"),
1774 integer_type_node, 0, integer_zero_node, 0, 0);
1776 /* wait_signal will store the signal number in here */
1777 sigcodename = get_identifier ("received_signal");
1778 rc_state->received_signal =
1779 decl_temp1 (sigcodename, chill_integer_type_node, 0,
1782 /* wait_buffer will store the buffer address in here */
1783 sigcodename = get_unique_identifier ("received_buffer");
1784 rc_state->received_buffer =
1785 decl_temp1 (sigcodename, ptr_type_node, 0,
1788 /* now jump to the end of RECEIVE CASE actions, to
1789 set up variables for them. */
1790 emit_jump (rc_state->rcsetup);
1792 /* define the __rcdoit label. We come here after
1793 initialization of all variables, to execute the
1795 emit_label (rc_state->rcdoit);
1797 filename = force_addr_of (get_chill_filename ());
1798 linenumber = get_chill_linenumber ();
1800 /* Argument list for calling the runtime routine. We'll call it
1801 the first time we call build_receive_case_label, when we know
1802 whether to call wait_signal or wait_buffer. NOTE: at this time
1803 the first argument will be set. */
1804 rc_state->actuallist =
1805 tree_cons (NULL_TREE, NULL_TREE,
1806 tree_cons (NULL_TREE, rc_state->n_sigs,
1807 tree_cons (NULL_TREE, rc_state->sig_code,
1808 tree_cons (NULL_TREE, rc_state->databufp,
1809 tree_cons (NULL_TREE, rc_state->datalen,
1810 tree_cons (NULL_TREE, optset,
1811 tree_cons (NULL_TREE, rc_state->else_clause,
1812 tree_cons (NULL_TREE, rc_state->to_loc,
1813 tree_cons (NULL_TREE, filename,
1814 tree_cons (NULL_TREE, linenumber, NULL_TREE))))))))));
1815 return current_label_value;
1819 build_receive_signal_case_label (sigdecl, loclist)
1820 tree sigdecl, loclist;
1822 struct rc_state_type *rc_state = current_rc_state;
1823 tree signame = DECL_NAME (sigdecl);
1826 if (rc_state->bufseen != 0)
1828 error ("SIGNAL in RECEIVE CASE alternative follows");
1829 error (" a BUFFER name on line %d", rc_state->bufseen);
1830 return error_mark_node;
1832 rc_state->sigseen = lineno;
1833 rc_state->bufseen = 0;
1835 if (!IDENTIFIER_SIGNAL_DATA (signame) && loclist != NULL_TREE)
1837 error ("SIGNAL `%s' has no data fields", IDENTIFIER_POINTER (signame));
1838 return error_mark_node;
1840 if (IDENTIFIER_SIGNAL_DATA (signame) && loclist == NULL_TREE)
1842 error ("SIGNAL `%s' requires data fields", IDENTIFIER_POINTER (signame));
1843 return error_mark_node;
1846 if (!rc_state->call_generated)
1850 TREE_VALUE (rc_state->actuallist) = force_addr_of (rc_state->received_signal);
1851 wait_call = build_chill_function_call (lookup_name
1852 (get_identifier ("__wait_signal_timed")),
1853 rc_state->actuallist);
1855 chill_expand_assignment (rc_state->received_signal,
1856 NOP_EXPR, wait_call);
1858 build_timesupervised_call (wait_call, rc_state->to_loc);
1860 rc_state->call_generated = 1;
1863 /* build the conditional expression */
1864 expr = build (EQ_EXPR, boolean_type_node,
1865 rc_state->received_signal,
1866 (tree)DECL_TASKING_CODE_DECL (sigdecl));
1868 if (!rc_state->if_generated)
1870 expand_start_cond (expr, 0);
1871 rc_state->if_generated = 1;
1874 expand_start_elseif (expr);
1876 if (IDENTIFIER_SIGNAL_DATA (signame))
1878 /* copy data from signal buffer to user's variables */
1879 tree typelist = TYPE_FIELDS (TREE_TYPE (sigdecl));
1880 tree valtail, typetail;
1882 tree pointer_type = build_chill_pointer_type (TREE_TYPE (sigdecl));
1883 tree pointer = convert (pointer_type, rc_state->databufp);
1885 for (valtail = nreverse (loclist), typetail = typelist;
1886 valtail != NULL_TREE && typetail != NULL_TREE;
1887 parmno++, valtail = TREE_CHAIN (valtail),
1888 typetail = TREE_CHAIN (typetail))
1890 register tree actual = valtail ? TREE_VALUE (valtail) : 0;
1891 register tree type = typetail ? TREE_TYPE (typetail) : 0;
1892 register tree assgn;
1894 sprintf (place, "signal field %d", parmno);
1896 assgn = build_component_ref (build1 (INDIRECT_REF,
1897 TREE_TYPE (sigdecl),
1899 DECL_NAME (typetail));
1900 if (!CH_TYPE_NONVALUE_P (type))
1901 /* don't assign to non-value type. Error printed at signal definition */
1902 chill_expand_assignment (actual, NOP_EXPR, assgn);
1905 if (valtail == NULL_TREE && typetail != NULL_TREE)
1906 error ("too few data fields provided for `%s'",
1907 IDENTIFIER_POINTER (signame));
1908 if (valtail != NULL_TREE && typetail == NULL_TREE)
1909 error ("too many data fields provided for `%s'",
1910 IDENTIFIER_POINTER (signame));
1913 /* last action here */
1914 emit_line_note (input_filename, lineno);
1916 return build_tree_list (loclist, signame);
1920 build_receive_buffer_case_label (buffer, loclist)
1921 tree buffer, loclist;
1923 struct rc_state_type *rc_state = current_rc_state;
1924 tree buftype = buffer_element_mode (TREE_TYPE (buffer));
1926 tree pointer_type, pointer, assgn;
1928 tree x, y, z, bufaddr;
1930 if (rc_state->sigseen != 0)
1932 error ("BUFFER in RECEIVE CASE alternative follows");
1933 error (" a SIGNAL name on line %d", rc_state->sigseen);
1934 return error_mark_node;
1936 rc_state->bufseen = lineno;
1937 rc_state->sigseen = 0;
1939 if (! CH_REFERABLE (buffer))
1941 error ("BUFFER in RECEIVE CASE alternative must be a location.");
1942 return error_mark_node;
1945 if (TREE_CHAIN (loclist) != NULL_TREE)
1947 error ("buffer receive alternative requires only 1 defining occurence.");
1948 return error_mark_node;
1951 if (!rc_state->call_generated)
1955 /* here we change the mode of rc_state->sig_code to
1956 REF ARRAY (0:65535) REF __tmp_DESCR_type.
1957 This is neccesary, cause we cannot evaluate the buffer twice
1958 (once here where we compare against the address of the buffer
1959 and second in build_receive_buffer_case_end, where we use the
1960 address build the descriptor, which gets passed to __wait_buffer).
1961 So we change the comparison from
1962 if (rc_state->received_buffer == &buffer)
1964 if (rc_state->received_buffer ==
1965 rc_state->sig_codep->[rc_state->bufcnt]->datap).
1967 This will evaluate the buffer location only once
1968 (in build_receive_buffer_case_end) and therefore doesn't confuse
1971 tree reftmpdescr = build_chill_pointer_type (
1972 TREE_TYPE (lookup_name (
1973 get_identifier ("__tmp_DESCR_type"))));
1974 tree idxtype = build_chill_range_type (NULL_TREE,
1976 build_int_2 (65535, 0)); /* should be enough, probably use ULONG */
1977 tree arrtype = build_chill_array_type (reftmpdescr,
1978 tree_cons (NULL_TREE, idxtype, NULL_TREE),
1980 tree refarrtype = build_chill_pointer_type (arrtype);
1982 TREE_VALUE (rc_state->actuallist) = force_addr_of (rc_state->received_buffer);
1983 wait_call = build_chill_function_call (
1984 lookup_name (get_identifier ("__wait_buffer")),
1985 rc_state->actuallist);
1987 chill_expand_assignment (rc_state->received_buffer,
1988 NOP_EXPR, wait_call);
1990 build_timesupervised_call (wait_call, rc_state->to_loc);
1992 /* do this after the call, otherwise there will be a mode mismatch */
1993 TREE_TYPE (rc_state->sig_code) = refarrtype;
1995 /* now we are ready to generate the call */
1996 rc_state->call_generated = 1;
1999 x = build_chill_indirect_ref (rc_state->sig_code, NULL_TREE, 0);
2000 y = build_chill_array_ref (x,
2001 tree_cons (NULL_TREE, build_int_2 (rc_state->bufcnt, 0), NULL_TREE));
2002 z = build_chill_indirect_ref (y, NULL_TREE, 0);
2003 bufaddr = build_chill_component_ref (z, get_identifier ("datap"));
2005 /* build the conditional expression */
2006 expr = build (EQ_EXPR, boolean_type_node,
2007 rc_state->received_buffer,
2010 /* next buffer in list */
2013 if (!rc_state->if_generated)
2015 expand_start_cond (expr, 0);
2016 rc_state->if_generated = 1;
2019 expand_start_elseif (expr);
2021 /* copy buffer's data to destination */
2022 var = TREE_VALUE (loclist);
2024 if (buftype != NULL_TREE && TREE_CODE (buftype) == ERROR_MARK)
2026 else if (! CH_COMPATIBLE (var, buftype))
2028 error ("incompatible modes in receive buffer alternative.");
2032 if (! CH_LOCATION_P (var))
2034 error ("defining occurence in receive buffer alternative must be a location.");
2040 pointer_type = build_chill_pointer_type (TREE_TYPE (var));
2041 pointer = convert (pointer_type,
2042 rc_state->databufp);
2043 /* no need to check this pointer being NULL */
2044 assgn = build_chill_indirect_ref (pointer, NULL_TREE, 0);
2046 chill_expand_assignment (var, NOP_EXPR, assgn);
2049 /* last action here */
2050 emit_line_note (input_filename, lineno);
2052 return build_tree_list (loclist, buffer);
2055 * SIGNAME is the signal name or buffer location,
2056 * LOCLIST is a list of possible locations to store data in
2059 build_receive_case_label (signame, loclist)
2060 tree signame, loclist;
2062 /* now see what we have got and do some checks */
2063 if (TREE_CODE (signame) == TYPE_DECL && CH_DECL_SIGNAL (signame))
2064 return build_receive_signal_case_label (signame, loclist);
2066 if (TREE_TYPE (signame) != NULL_TREE
2067 && CH_IS_BUFFER_MODE (TREE_TYPE (signame)))
2069 if (loclist == NULL_TREE)
2071 error ("buffer receive alternative without `IN location'.");
2072 return error_mark_node;
2074 return build_receive_buffer_case_label (signame, loclist);
2077 error ("RECEIVE CASE alternative must specify a SIGNAL name or BUFFER location.");
2078 return error_mark_node;
2082 * LABEL_CNT is the case-label counter passed from build_receive_case_start.
2083 * ELSE_CLAUSE defines if the RECEIVE CASE action had an ELSE(1) or not(0).
2084 * BUF_LIST is a tree-list of tree-lists, where TREE_VALUE defines the
2085 * BUFFER location and TREE_PURPOSE defines the defining occurence.
2088 build_receive_buffer_case_end (label_cnt, buf_list, else_clause)
2089 tree label_cnt, buf_list, else_clause;
2091 struct rc_state_type *rc_state = current_rc_state;
2093 tree field_decls = NULL_TREE; /* list of all buffer types, for the union */
2095 tree descr_type = lookup_name (get_identifier ("__tmp_DESCR_type"));
2096 tree tuple = NULL_TREE; /* constructors for array of ptrs */
2097 tree union_type_node = NULL_TREE;
2099 /* walk thru all the buffers */
2100 for (alist = buf_list; alist != NULL_TREE;
2101 buffer_cnt++, alist = TREE_CHAIN (alist))
2103 tree value = TREE_VALUE (alist);
2104 tree buffer = TREE_VALUE (value); /* this is the buffer */
2105 tree data = TREE_VALUE (TREE_PURPOSE (value)); /* the location to receive in */
2107 tree buffer_descr_init;
2112 /* build descriptor for buffer */
2113 buffer_length = max_queue_size (TREE_TYPE (buffer));
2114 if (buffer_length == NULL_TREE)
2115 buffer_length = infinite_buffer_event_length_node;
2116 buffer_descr_init = build_nt (CONSTRUCTOR, NULL_TREE,
2117 tree_cons (NULL_TREE, force_addr_of (buffer),
2118 tree_cons (NULL_TREE, buffer_length, NULL_TREE)));
2119 buffer_descr = decl_temp1 (get_unique_identifier ("RCbuffer"),
2120 TREE_TYPE (descr_type), 0,
2121 buffer_descr_init, 0, 0);
2122 tuple = tree_cons (NULL_TREE,
2123 force_addr_of (buffer_descr),
2126 /* make a field for the union */
2127 sprintf (fldname, "fld%03d", buffer_cnt);
2128 field = grok_chill_fixedfields (
2129 tree_cons (NULL_TREE, get_identifier (fldname), NULL_TREE),
2130 TREE_TYPE (data), NULL_TREE);
2131 if (field_decls == NULL_TREE)
2132 field_decls = field;
2134 chainon (field_decls, field);
2137 /* generate the union */
2138 if (field_decls != NULL_TREE)
2140 tree data_id = get_identifier ("databuffer");
2143 union_type_node = finish_struct (
2144 start_struct (UNION_TYPE, NULL_TREE),
2146 data_decl = decl_temp1 (data_id, union_type_node, 0, NULL_TREE, 0, 0);
2148 chill_expand_assignment (rc_state->databufp, NOP_EXPR,
2149 force_addr_of (data_decl));
2151 chill_expand_assignment (rc_state->datalen, NOP_EXPR,
2152 size_in_bytes (TREE_TYPE (data_decl)));
2155 /* tell runtime system if we had an else or not */
2156 chill_expand_assignment (rc_state->else_clause, NOP_EXPR, else_clause);
2158 /* generate the array of pointers to all buffers */
2160 tree array_id = get_identifier ("buf_ptr_array");
2161 tree array_type_node =
2162 build_chill_array_type (ptr_type_node,
2163 tree_cons (NULL_TREE,
2164 build_chill_range_type (NULL_TREE,
2166 build_int_2 (buffer_cnt, 0)),
2169 tree constr = build_nt (CONSTRUCTOR, NULL_TREE, nreverse (tuple));
2170 tree array_decl = decl_temp1 (array_id, array_type_node, 0,
2173 chill_expand_assignment (build_chill_cast (ptr_type_node, rc_state->sig_code),
2175 force_addr_of (array_decl));
2176 chill_expand_assignment (rc_state->n_sigs, NOP_EXPR,
2177 build_int_2 (buffer_cnt, 0));
2182 * SIG_LIST is a tree list. The TREE_VALUEs are VAR_DECLs of
2183 * __tmp_%s_code variables, and the TREE_PURPOSEs are the
2184 * TYPE_DECLs of the __tmp_%s_struct types. LABEL_CNT is the
2185 * case-label counter passed from build_receive_case_start.
2188 build_receive_signal_case_end (label_cnt, sig_list, else_clause)
2189 tree label_cnt, sig_list, else_clause;
2191 struct rc_state_type *rc_state = current_rc_state;
2193 tree union_type_node = NULL_TREE;
2194 tree field_decls = NULL_TREE; /* list of signal
2195 structure, for the union */
2196 tree tuple = NULL_TREE; /* constructor for array of ptrs */
2200 /* for each list of locations, validate it against the
2201 corresponding signal's list of fields. */
2203 for (alist = sig_list; alist != NULL_TREE;
2204 signal_cnt++, alist = TREE_CHAIN (alist))
2206 tree value = TREE_VALUE (alist);
2207 tree signame = TREE_VALUE (value); /* signal's ID node */
2208 tree sigdecl = lookup_name (signame);
2209 tree sigtype = TREE_TYPE (sigdecl);
2213 if (IDENTIFIER_SIGNAL_DATA (signame))
2215 sprintf (fldname, "fld%03d", fldcnt++);
2216 field = grok_chill_fixedfields (
2217 tree_cons (NULL_TREE,
2218 get_identifier (fldname),
2220 sigtype, NULL_TREE);
2221 if (field_decls == NULL_TREE)
2222 field_decls = field;
2224 chainon (field_decls, field);
2228 temp1 = (tree)DECL_TASKING_CODE_DECL (sigdecl);
2229 mark_addressable (temp1);
2230 tuple = tree_cons (NULL_TREE,
2232 build_chill_pointer_type (chill_integer_type_node),
2238 /* generate the union of all of the signal data types */
2239 if (field_decls != NULL_TREE)
2241 tree data_id = get_identifier ("databuffer");
2243 union_type_node = finish_struct (start_struct (UNION_TYPE,
2247 decl_temp1 (data_id, union_type_node, 0, NULL_TREE, 0, 0);
2249 chill_expand_assignment (rc_state->databufp, NOP_EXPR,
2250 force_addr_of (data_decl));
2252 chill_expand_assignment (rc_state->datalen, NOP_EXPR,
2253 size_in_bytes (TREE_TYPE (data_decl)));
2256 /* tell runtime system if we had an else or not */
2257 chill_expand_assignment (rc_state->else_clause, NOP_EXPR, else_clause);
2259 /* generate the array of all signal codes */
2261 tree array_id = get_identifier ("sig_code_array");
2262 tree array_type_node
2263 = build_chill_array_type (
2264 build_chill_pointer_type (chill_integer_type_node),
2265 tree_cons (NULL_TREE,
2266 build_chill_range_type (NULL_TREE,
2268 build_int_2 (signal_cnt, 0)),
2271 tree constr = build_nt (CONSTRUCTOR, NULL_TREE,
2274 decl_temp1 (array_id, array_type_node, 0, constr, 0, 0);
2276 chill_expand_assignment (rc_state->sig_code, NOP_EXPR,
2277 force_addr_of (array_decl));
2279 /* give number of signals to runtime system */
2280 chill_expand_assignment (rc_state->n_sigs, NOP_EXPR,
2281 build_int_2 (signal_cnt, 0));
2285 /* General function for the end of a RECEIVE CASE action */
2288 build_receive_case_end (label_cnt, alist, else_clause)
2289 tree label_cnt, alist, else_clause;
2291 rtx rcdone = gen_label_rtx ();
2292 struct rc_state_type *rc_state = current_rc_state;
2296 /* finish the if's, if generated */
2297 if (rc_state->if_generated)
2300 /* check alist for errors */
2301 for (tmp = alist; tmp != NULL_TREE; tmp = TREE_CHAIN (tmp))
2303 if (TREE_CODE (TREE_VALUE (tmp)) == ERROR_MARK)
2307 /* jump to the end of RECEIVE CASE processing */
2310 /* define the __rcsetup label. We come here to initialize
2312 emit_label (rc_state->rcsetup);
2314 if (alist == NULL_TREE && !had_errors)
2316 error ("RECEIVE CASE without alternatives");
2320 if (TREE_CODE (alist) == ERROR_MARK || had_errors)
2323 /* now call the actual end function */
2324 if (rc_state->bufseen)
2325 build_receive_buffer_case_end (label_cnt, alist, else_clause);
2327 build_receive_signal_case_end (label_cnt, alist, else_clause);
2329 /* now jump to the beginning of RECEIVE CASE processing */
2331 emit_jump (rc_state->rcdoit);
2333 /* define the __rcdone label. We come here when the whole
2334 receive case is done. */
2335 emit_label (rcdone);
2337 current_rc_state = rc_state->enclosing;
2341 /* build a CONTINUE action */
2343 void expand_continue_event (evloc)
2346 tree filename, linenumber, evaddr;
2348 /* do some checks */
2349 if (evloc == NULL_TREE || TREE_CODE (evloc) == ERROR_MARK)
2352 if (! CH_REFERABLE (evloc) || ! CH_IS_EVENT_MODE (TREE_TYPE (evloc)))
2354 error ("CONTINUE requires an event location.");
2358 evaddr = force_addr_of (evloc);
2359 filename = force_addr_of (get_chill_filename ());
2360 linenumber = get_chill_linenumber ();
2363 build_chill_function_call (lookup_name (get_identifier ("__continue")),
2364 tree_cons (NULL_TREE, evaddr,
2365 tree_cons (NULL_TREE, filename,
2366 tree_cons (NULL_TREE, linenumber, NULL_TREE)))));
2370 * The following code builds a DELAY CASE statement,
2371 * which looks like this in CHILL:
2373 * DCL ev1, ev2 EVENT, ins INSTANCE;
2374 * DCL ev3 EVENT (10);
2375 * DCL count1 INT := 0, count2 INT := 0;
2377 * DELAY CASE SET ins;
2378 * (ev1): count1 +:= 1;
2379 * (ev2, ev3): count2 +:= 1;
2382 * Because we don''t know until we get to the ESAC how
2383 * many events need processing, we generate the following
2384 * C-equivalent code:
2387 * { /* start a new symbol context */
2391 * unsigned long len;
2393 * int number_of_events;
2394 * Descr *event_codes;
2399 * void *whatevent = __delay_event (number_of_events,
2405 * if (whatevent == &ev1)
2407 * /* code for ev1 alternative's action_statement_list */
2410 * else if (whatevent == &ev2 || whatevent == &ev3)
2412 * /* code for ev2 and ev3 alternative's action_statement_list */
2418 * Descr event_code_ptr [3] = {
2422 * event_codes = &event_code_ptr[0];
2423 * number_of_events = 3;
2428 * } /* end the new symbol context */
2432 struct dl_state_type
2434 struct dl_state_type *enclosing;
2439 tree received_event;
2442 struct dl_state_type *current_dl_state = NULL;
2444 /* build_receive_case_start returns an INTEGER_CST node
2445 containing the case-label number to be used by
2446 build_receive_case_end to generate correct labels */
2448 build_delay_case_start (optset, optpriority)
2449 tree optset, optpriority;
2451 /* counter to generate unique delay case labels */
2452 static int dl_lbl_count = 0;
2453 tree current_label_value =
2454 build_int_2 ((HOST_WIDE_INT)dl_lbl_count, 0);
2456 tree actuallist = NULL_TREE;
2457 tree filename, linenumber;
2460 struct dl_state_type *dl_state
2461 = (struct dl_state_type*) xmalloc (sizeof (struct dl_state_type));
2462 dl_state->enclosing = current_dl_state;
2463 current_dl_state = dl_state;
2464 dl_state->dldoit = gen_label_rtx ();
2465 dl_state->dlsetup = gen_label_rtx ();
2469 /* check the optional SET location */
2470 if (optset == NULL_TREE
2471 || TREE_CODE (optset) == ERROR_MARK)
2472 optset = null_pointer_node;
2473 else if (CH_IS_INSTANCE_MODE (TREE_TYPE (optset)) && CH_LOCATION_P (optset))
2474 optset = force_addr_of (optset);
2477 error ("SET requires INSTANCE location");
2478 optset = null_pointer_node;
2481 /* check the presence of the PRIORITY expression */
2482 if (optpriority == NULL_TREE)
2483 optpriority = integer_zero_node;
2484 else if (TREE_CODE (optpriority) == ERROR_MARK)
2485 optpriority = integer_zero_node;
2486 else if (TREE_CODE (TREE_TYPE (optpriority)) != INTEGER_TYPE)
2488 error ("PRIORITY must be of integer type.");
2489 optpriority = integer_zero_node;
2492 /* check for time supervised */
2493 to_loc = build_timeout_preface ();
2495 dl_state->n_events =
2496 decl_temp1 (get_identifier ("number_of_events"),
2497 integer_type_node, 0, integer_zero_node, 0, 0);
2499 dl_state->event_codes =
2500 decl_temp1 (get_identifier ("event_codes"),
2501 ptr_type_node, 0, null_pointer_node, 0, 0);
2503 /* wait_event will store the signal number in here */
2504 dl_state->received_event =
2505 decl_temp1 (get_identifier ("received_event"),
2506 ptr_type_node, 0, NULL_TREE, 0, 0);
2508 /* now jump to the end of RECEIVE CASE actions, to
2509 set up variables for them. */
2510 emit_jump (dl_state->dlsetup);
2512 /* define the __rcdoit label. We come here after
2513 initialization of all variables, to execute the
2515 emit_label (dl_state->dldoit);
2517 filename = force_addr_of (get_chill_filename ());
2518 linenumber = get_chill_linenumber ();
2520 /* here we go, call the runtime routine */
2521 actuallist = tree_cons (NULL_TREE, force_addr_of (dl_state->received_event),
2522 tree_cons (NULL_TREE, dl_state->n_events,
2523 tree_cons (NULL_TREE, dl_state->event_codes,
2524 tree_cons (NULL_TREE, optpriority,
2525 tree_cons (NULL_TREE, to_loc,
2526 tree_cons (NULL_TREE, optset,
2527 tree_cons (NULL_TREE, filename,
2528 tree_cons (NULL_TREE, linenumber, NULL_TREE))))))));
2530 wait_call = build_chill_function_call (
2531 lookup_name (get_identifier ("__delay_event")),
2535 chill_expand_assignment (dl_state->received_event, NOP_EXPR, wait_call);
2537 build_timesupervised_call (wait_call, to_loc);
2538 return current_label_value;
2542 EVENTLIST is the list of this alternative's events
2543 and IF_OR_ELSEIF indicates what action (1 for if and
2544 0 for else if) should be generated.
2547 build_delay_case_label (eventlist, if_or_elseif)
2551 tree eventp, expr = NULL_TREE;
2553 if (eventlist == NULL_TREE || TREE_CODE (eventlist) == ERROR_MARK)
2556 for (eventp = eventlist; eventp != NULL_TREE;
2557 eventp = TREE_CHAIN (eventp))
2559 tree event = TREE_VALUE (eventp);
2562 if (event == NULL_TREE || TREE_CODE (event) == ERROR_MARK)
2563 temp1 = null_pointer_node;
2564 else if (! CH_IS_EVENT_MODE (TREE_TYPE (event)) || ! CH_REFERABLE (event))
2566 error ("delay alternative must be an EVENT location.");
2567 temp1 = null_pointer_node;
2570 temp1 = force_addr_of (event);
2572 /* build the conditional expression */
2573 if (expr == NULL_TREE)
2574 expr = build (EQ_EXPR, boolean_type_node,
2575 current_dl_state->received_event, temp1);
2578 build (TRUTH_ORIF_EXPR, boolean_type_node, expr,
2579 build (EQ_EXPR, boolean_type_node,
2580 current_dl_state->received_event, temp1));
2583 expand_start_cond (expr, 0);
2585 expand_start_elseif (expr);
2587 /* last action here */
2588 emit_line_note (input_filename, lineno);
2592 * EVENT_LIST is a tree list. The TREE_VALUEs are VAR_DECLs of
2593 * EVENT variables. LABEL_CNT is the case-label counter
2594 * passed from build_delay_case_start.
2597 build_delay_case_end (label_cnt, event_list)
2598 tree label_cnt, event_list;
2600 struct dl_state_type *dl_state = current_dl_state;
2601 rtx dldone = gen_label_rtx ();
2602 tree tuple = NULL_TREE; /* constructor for array of descrs */
2606 /* if we have an empty event_list, there was no alternatives and we
2607 havn't started an if therefor don't run expand_end_cond */
2608 if (event_list != NULL_TREE)
2609 /* finish the if's */
2612 /* jump to the end of RECEIVE CASE processing */
2615 /* define the __dlsetup label. We come here to initialize
2617 emit_label (dl_state->dlsetup);
2619 if (event_list == NULL_TREE)
2621 error ("DELAY CASE without alternatives");
2625 if (event_list == NULL_TREE
2626 || TREE_CODE (event_list) == ERROR_MARK)
2629 /* make a list of pointers (in reverse order)
2630 to the event code variables */
2631 for (acode = event_list; acode != NULL_TREE;
2632 acode = TREE_CHAIN (acode))
2634 tree event = TREE_VALUE (acode);
2638 if (event == NULL_TREE || TREE_CODE (event) == ERROR_MARK)
2641 tree_cons (NULL_TREE, null_pointer_node,
2642 tree_cons (NULL_TREE, integer_zero_node, NULL_TREE));
2646 event_length = max_queue_size (TREE_TYPE (event));
2647 if (event_length == NULL_TREE)
2648 event_length = infinite_buffer_event_length_node;
2650 tree_cons (NULL_TREE, force_addr_of (event),
2651 tree_cons (NULL_TREE, event_length, NULL_TREE));
2653 tuple = tree_cons (NULL_TREE,
2654 build_nt (CONSTRUCTOR, NULL_TREE, descr_init),
2659 /* generate the array of all event code pointers */
2661 tree descr_type = TREE_TYPE (lookup_name (get_identifier ("__tmp_DESCR_type")));
2662 tree array_id = get_identifier ("event_code_array");
2663 tree array_type_node
2664 = build_chill_array_type (descr_type,
2665 tree_cons (NULL_TREE,
2666 build_chill_range_type (NULL_TREE,
2668 build_int_2 (event_cnt, 0)),
2671 tree constr = build_nt (CONSTRUCTOR, NULL_TREE,
2674 decl_temp1 (array_id, array_type_node, 0, constr, 0, 0);
2676 chill_expand_assignment (dl_state->event_codes, NOP_EXPR,
2677 force_addr_of (array_decl));
2679 /* give number of signals to runtime system */
2680 chill_expand_assignment (dl_state->n_events, NOP_EXPR,
2681 build_int_2 (event_cnt, 0));
2684 /* now jump to the beginning of DELAY CASE processing */
2686 emit_jump (dl_state->dldoit);
2688 /* define the __dldone label. We come here when the whole
2689 DELAY CASE is done. */
2690 emit_label (dldone);
2692 current_dl_state = dl_state->enclosing;
2697 * The following code builds a simple delay statement,
2698 * which looks like this in CHILL:
2700 * DCL ev1 EVENT(5), ins INSTANCE;
2702 * DELAY ev1 PRIORITY 7;
2704 * This statement unconditionally delays the current
2705 * PROCESS, until some other process CONTINUEs it.
2707 * Here is the generated C code:
2712 * unsigned long len;
2715 * static short __tmp_ev1_code;
2717 * { /* start a new symbol context */
2719 * Descr __delay_array[1] = { { ev1, 5 } };
2721 * __delay_event (1, &__delay_array, 7, NULL,
2722 * filename, linenumber);
2724 * } /* end of symbol scope */
2728 build_delay_action (event, optpriority)
2729 tree event, optpriority;
2732 tree to_loc = NULL_TREE;
2733 /* we discard the return value of __delay_event, cause in
2734 a normal DELAY action no selections have to be made */
2735 tree ev_got = null_pointer_node;
2737 /* check the event */
2738 if (event == NULL_TREE || TREE_CODE (event) == ERROR_MARK)
2740 else if (! CH_IS_EVENT_MODE (TREE_TYPE (event)) || ! CH_REFERABLE (event))
2742 error ("DELAY action requires an event location.");
2746 /* check the presence of priority */
2747 if (optpriority != NULL_TREE)
2749 if (TREE_CODE (optpriority) == ERROR_MARK)
2751 if (TREE_CODE (TREE_TYPE (optpriority)) != INTEGER_TYPE)
2753 error ("PRIORITY in DELAY action must be of integer type.");
2759 /* issue a warning in case of -Wall */
2762 warning ("DELAY action without priority.");
2763 warning (" PRIORITY defaulted to 0.");
2765 optpriority = integer_zero_node;
2772 tree array_type_node;
2776 tree event_length = max_queue_size (TREE_TYPE (event));
2778 tree filename = force_addr_of (get_chill_filename ());
2779 tree linenumber = get_chill_linenumber ();
2782 to_loc = build_timeout_preface ();
2784 descr_type = TREE_TYPE (lookup_name (get_identifier ("__tmp_DESCR_type")));
2787 build_chill_array_type (descr_type,
2788 tree_cons (NULL_TREE,
2789 build_chill_range_type (NULL_TREE, integer_one_node,
2793 if (event_length == NULL_TREE)
2794 event_length = infinite_buffer_event_length_node;
2797 tree_cons (NULL_TREE, force_addr_of (event),
2798 tree_cons (NULL_TREE, event_length, NULL_TREE));
2800 tree_cons (NULL_TREE,
2801 build_nt (CONSTRUCTOR, NULL_TREE, descr_init),
2804 decl_temp1 (get_unique_identifier ("event_codes_array"),
2806 build_nt (CONSTRUCTOR, NULL_TREE, array_init),
2810 decl_temp1 (get_unique_identifier ("event_ptr"),
2812 force_addr_of (array_decl),
2816 tree_cons (NULL_TREE, ev_got,
2817 tree_cons (NULL_TREE, integer_one_node,
2818 tree_cons (NULL_TREE, event_codes,
2819 tree_cons (NULL_TREE, optpriority,
2820 tree_cons (NULL_TREE, to_loc,
2821 tree_cons (NULL_TREE, null_pointer_node,
2822 tree_cons (NULL_TREE, filename,
2823 tree_cons (NULL_TREE, linenumber, NULL_TREE))))))));
2826 build_timesupervised_call (
2827 build_chill_function_call (
2828 lookup_name (get_identifier ("__delay_event")),
2829 actuallist), to_loc);
2834 expand_send_buffer (buffer, value, optpriority, optwith, optto)
2835 tree buffer, value, optpriority, optwith, optto;
2837 tree filename, linenumber;
2838 tree buffer_mode_decl = NULL_TREE;
2839 tree buffer_ptr, value_ptr;
2841 tree timeout_value, fcall;
2843 /* check buffer location */
2844 if (buffer == NULL_TREE || TREE_CODE (buffer) == ERROR_MARK)
2849 if (buffer != NULL_TREE)
2851 if (! CH_IS_BUFFER_MODE (TREE_TYPE (buffer)) || ! CH_REFERABLE (buffer))
2853 error ("send buffer action requires a BUFFER location.");
2857 buffer_mode_decl = TREE_CHAIN (TYPE_FIELDS (TREE_TYPE (buffer)));
2860 /* check value and type */
2861 if (value == NULL_TREE || TREE_CODE (value) == ERROR_MARK)
2866 if (value != NULL_TREE)
2868 if (TREE_CHAIN (value) != NULL_TREE)
2870 error ("there must be only 1 value for send buffer action.");
2875 value = TREE_VALUE (value);
2876 if (value == NULL_TREE || TREE_CODE (value) == ERROR_MARK)
2881 if (value != NULL_TREE && buffer_mode_decl != NULL_TREE)
2883 if (TREE_TYPE (buffer_mode_decl) != NULL_TREE &&
2884 TREE_CODE (TREE_TYPE (buffer_mode_decl)) == ERROR_MARK)
2886 else if (CH_COMPATIBLE (value, TREE_TYPE (buffer_mode_decl)))
2888 value = convert (TREE_TYPE (buffer_mode_decl), value);
2889 if (value == NULL_TREE || TREE_CODE (value) == ERROR_MARK)
2891 error ("convert failed for send buffer action.");
2897 error ("incompatible modes in send buffer action.");
2904 /* check the presence of priority */
2905 if (optpriority == NULL_TREE)
2907 if (send_buffer_prio == NULL_TREE)
2909 /* issue a warning in case of -Wall */
2912 warning ("Buffer sent without priority");
2913 warning (" and no default priority was set.");
2914 warning (" PRIORITY defaulted to 0.");
2916 optpriority = integer_zero_node;
2919 optpriority = send_buffer_prio;
2921 else if (TREE_CODE (optpriority) == ERROR_MARK)
2923 else if (TREE_CODE (TREE_TYPE (optpriority)) != INTEGER_TYPE)
2925 error ("PRIORITY must be of integer type.");
2929 if (optwith != NULL_TREE)
2931 error ("WITH not allowed for send buffer action.");
2934 if (optto != NULL_TREE)
2936 error ("TO not allowed for send buffer action.");
2944 tree buffer_descr, buffer_init, buffer_length;
2947 /* process timeout */
2948 timeout_value = build_timeout_preface ();
2950 descr_type = lookup_name (get_identifier ("__tmp_DESCR_type"));
2952 /* build descr for buffer */
2953 buffer_length = max_queue_size (TREE_TYPE (buffer));
2954 if (buffer_length == NULL_TREE)
2955 buffer_length = infinite_buffer_event_length_node;
2956 buffer_init = build_nt (CONSTRUCTOR, NULL_TREE,
2957 tree_cons (NULL_TREE, force_addr_of (buffer),
2958 tree_cons (NULL_TREE, buffer_length, NULL_TREE)));
2959 buffer_descr = decl_temp1 (get_unique_identifier ("buffer_descr"),
2960 TREE_TYPE (descr_type), 0, buffer_init,
2962 buffer_ptr = decl_temp1 (get_unique_identifier ("buffer_ptr"),
2964 force_addr_of (buffer_descr),
2967 /* build descr for value */
2968 if (! CH_REFERABLE (value))
2969 val = decl_temp1 (get_identifier ("buffer_value"),
2970 TREE_TYPE (value), 0,
2975 value_ptr = build_chill_descr (val);
2979 /* get filename and linenumber */
2980 filename = force_addr_of (get_chill_filename ());
2981 linenumber = get_chill_linenumber ();
2983 /* Now, we can call the runtime */
2984 fcall = build_chill_function_call (
2985 lookup_name (get_identifier ("__send_buffer")),
2986 tree_cons (NULL_TREE, buffer_ptr,
2987 tree_cons (NULL_TREE, value_ptr,
2988 tree_cons (NULL_TREE, optpriority,
2989 tree_cons (NULL_TREE, timeout_value,
2990 tree_cons (NULL_TREE, filename,
2991 tree_cons (NULL_TREE, linenumber, NULL_TREE)))))));
2992 build_timesupervised_call (fcall, timeout_value);
2997 process_buffer_decls (namelist, mode, optstatic)
2998 tree namelist, mode;
3002 int quasi_flag = current_module->is_spec_module;
3007 for (names = namelist; names != NULL_TREE; names = TREE_CHAIN (names))
3009 tree name = TREE_VALUE (names);
3010 tree bufdecl = lookup_name (name);
3012 decl_tasking_code_variable (name, &buffer_code, quasi_flag);
3014 /* remember the code variable in the buffer decl */
3015 DECL_TASKING_CODE_DECL (bufdecl) = (struct lang_decl *)code_decl;
3017 add_taskstuff_to_list (code_decl, "_TT_Buffer",
3018 quasi_flag ? NULL_TREE : buffer_code,
3025 * if no queue size was specified, QUEUESIZE is integer_zero_node.
3028 build_buffer_type (element_type, queuesize)
3029 tree element_type, queuesize;
3032 if (element_type == NULL_TREE || TREE_CODE (element_type) == ERROR_MARK)
3033 return error_mark_node;
3034 if (queuesize != NULL_TREE && TREE_CODE (queuesize) == ERROR_MARK)
3035 return error_mark_node;
3037 type = make_node (RECORD_TYPE);
3038 field = build_decl (FIELD_DECL, get_identifier("__buffer_data"),
3040 TYPE_FIELDS (type) = field;
3042 = build_lang_decl (TYPE_DECL, get_identifier ("__element_mode"),
3044 field = TREE_CHAIN (field);
3047 tree size_field = build_decl (CONST_DECL, get_identifier("__queue_max"),
3049 DECL_INITIAL (size_field) = queuesize;
3050 TREE_CHAIN (field) = size_field;
3052 CH_IS_BUFFER_MODE (type) = 1;
3053 CH_TYPE_NONVALUE_P (type) = 1;
3055 type = layout_chill_struct_type (type);
3061 build_buffer_descriptor (bufname, expr, optpriority)
3062 tree bufname, expr, optpriority;
3066 if (bufname == NULL_TREE
3067 || TREE_CODE (bufname) == ERROR_MARK)
3068 return error_mark_node;
3070 if (expr != NULL_TREE
3071 && TREE_CODE (expr) == ERROR_MARK)
3072 return error_mark_node;
3074 /* FIXME: is this what we really want to test? */
3075 bufdecl = lookup_name (bufname);
3076 if (TREE_CODE (bufdecl) != TYPE_DECL
3077 || ! CH_IS_BUFFER_MODE (TREE_TYPE (bufdecl)))
3079 error ("SEND requires a BUFFER; `%s' is not a BUFFER name",
3081 return error_mark_node;
3085 /* build buffer/signal data structure */
3086 tree bufdataname = get_unique_identifier (IDENTIFIER_POINTER (bufname));
3089 if (expr == NULL_TREE)
3090 dataptr = null_pointer_node;
3094 decl_temp1 (bufdataname, TREE_TYPE (bufdecl), 0,
3096 /* prevent granting of this variable */
3097 DECL_SOURCE_LINE (decl) = 0;
3099 dataptr = force_addr_of (decl);
3102 /* build descriptor pointing to buffer data */
3104 tree tasking_message_var = get_unique_identifier (IDENTIFIER_POINTER (bufname));
3105 tree data_len = (expr == NULL_TREE) ? integer_zero_node :
3106 size_in_bytes (TREE_TYPE (bufdecl));
3107 tree tasking_code = (tree)DECL_TASKING_CODE_DECL (bufdecl);
3108 tree tuple = build_nt (CONSTRUCTOR, NULL_TREE,
3109 tree_cons (NULL_TREE,
3111 build_chill_pointer_type (chill_integer_type_node),
3113 tree_cons (NULL_TREE, data_len,
3114 tree_cons (NULL_TREE, dataptr, NULL_TREE))));
3116 tree decl = decl_temp1 (tasking_message_var,
3117 TREE_TYPE (tasking_message_type), 0,
3119 mark_addressable (tasking_code);
3120 /* prevent granting of this variable */
3121 DECL_SOURCE_LINE (decl) = 0;
3123 tuple = force_addr_of (decl);
3132 process_event_decls (namelist, mode, optstatic)
3133 tree namelist, mode;
3137 int quasi_flag = current_module->is_spec_module;
3142 for (names = namelist; names != NULL_TREE; names = TREE_CHAIN (names))
3144 tree name = TREE_VALUE (names);
3145 tree eventdecl = lookup_name (name);
3147 decl_tasking_code_variable (name, &event_code, quasi_flag);
3149 /* remember the code variable in the event decl */
3150 DECL_TASKING_CODE_DECL (eventdecl) = (struct lang_decl *)code_decl;
3152 add_taskstuff_to_list (code_decl, "_TT_Event",
3153 quasi_flag ? NULL_TREE : event_code,
3159 /* Return the buffer or event length of a buffer or event mode.
3160 (NULL_TREE means unlimited.) */
3163 max_queue_size (mode)
3166 tree field = TYPE_FIELDS (mode);
3167 for ( ; field != NULL_TREE ; field = TREE_CHAIN (field))
3169 if (TREE_CODE (field) == CONST_DECL)
3170 return DECL_INITIAL (field);
3175 /* Return the buffer element mode of a buffer mode. */
3178 buffer_element_mode (bufmode)
3181 tree field = TYPE_FIELDS (bufmode);
3182 for ( ; field != NULL_TREE; field = TREE_CHAIN (field))
3184 if (TREE_CODE (field) == TYPE_DECL)
3185 return TREE_TYPE (field);
3190 /* invalidate buffer element mode in case we detect, that the
3191 elelment mode has the non-value property */
3194 invalidate_buffer_element_mode (bufmode)
3197 tree field = TYPE_FIELDS (bufmode);
3198 for ( ; field != NULL_TREE; field = TREE_CHAIN (field))
3200 if (TREE_CODE (field) == TYPE_DECL)
3202 TREE_TYPE (field) = error_mark_node;
3208 /* For an EVENT or BUFFER mode TYPE, with a give maximum queue size QSIZE,
3209 perform various error checks. Return a new queue size. */
3212 check_queue_size (type, qsize)
3215 if (qsize == NULL_TREE || TREE_CODE (qsize) == ERROR_MARK)
3217 if (TREE_TYPE (qsize) == NULL_TREE
3218 || !CH_SIMILAR (TREE_TYPE (qsize), integer_type_node))
3220 error ("non-integral max queue size for EVENT/BUFFER mode");
3221 return integer_one_node;
3223 if (TREE_CODE (qsize) != INTEGER_CST)
3225 error ("non-constant max queue size for EVENT/BUFFER mode");
3226 return integer_one_node;
3228 if (compare_int_csts (pedantic ? LE_EXPR : LT_EXPR,
3232 error ("max queue_size for EVENT/BUFFER is not positive");
3233 return integer_one_node;
3239 * An EVENT type is modelled as a boolean type, which should
3240 * allocate the minimum amount of space.
3243 build_event_type (queuesize)
3246 tree type = make_node (RECORD_TYPE);
3247 tree field = build_decl (FIELD_DECL, get_identifier("__event_data"),
3249 TYPE_FIELDS (type) = field;
3252 tree size_field = build_decl (CONST_DECL, get_identifier("__queue_max"),
3254 DECL_INITIAL (size_field) = queuesize;
3255 TREE_CHAIN (field) = size_field;
3257 CH_IS_EVENT_MODE (type) = 1;
3258 CH_TYPE_NONVALUE_P (type) = 1;
3260 type = layout_chill_struct_type (type);
3265 * Initialize the various types of tasking data.
3270 extern int ignore_case;
3271 extern int special_UC;
3272 extern tree chill_predefined_function_type;
3273 tree temp, ins_ftype_void;
3274 tree endlink = void_list_node;
3275 tree int_ftype_ptr_int_ptr_ptr_int_ptr_int_ptr_ptr_int;
3276 tree void_ftype_ptr;
3277 tree void_ftype_ptr_ins_int_int_ptr_ptr_int;
3278 tree int_ftype_ptr_ptr_int_ptr_ptr_int;
3279 tree void_ftype_int_int_int_ptr_ptr_ptr_int;
3280 tree int_ftype_ptr_int_ptr_int_ptr_ptr_ptr_int;
3281 tree int_ftype_ptr_int;
3283 /* type of tasking code variables */
3284 chill_taskingcode_type_node = short_unsigned_type_node;
3287 build_function_type (void_type_node,
3288 tree_cons (NULL_TREE, void_type_node, NULL_TREE));
3290 build_instance_type ();
3292 = build_function_type (instance_type_node,
3293 tree_cons (NULL_TREE, void_type_node,
3294 build_tree_list (NULL_TREE, void_type_node)));
3296 builtin_function ("__whoami", ins_ftype_void,
3297 NOT_BUILT_IN, NULL_PTR);
3299 build_tasking_message_type ();
3301 temp = build_decl (TYPE_DECL,
3302 get_identifier ("__tmp_TaskingStruct"),
3303 build_tasking_struct ());
3305 DECL_SOURCE_LINE (temp) = 0;
3307 /* any SIGNAL will be compatible with this one */
3308 generic_signal_type_node = copy_node (boolean_type_node);
3310 builtin_function ((ignore_case || ! special_UC) ? "copy_number" : "COPY_NUMBER",
3311 chill_predefined_function_type,
3312 BUILT_IN_COPY_NUMBER, NULL_PTR);
3313 builtin_function ((ignore_case || ! special_UC) ? "gen_code" : "GEN_CODE",
3314 chill_predefined_function_type,
3315 BUILT_IN_GEN_CODE, NULL_PTR);
3316 builtin_function ((ignore_case || ! special_UC) ? "gen_inst" : "GEN_INST",
3317 chill_predefined_function_type,
3318 BUILT_IN_GEN_INST, NULL_PTR);
3319 builtin_function ((ignore_case || ! special_UC) ? "gen_ptype" : "GEN_PTYPE",
3320 chill_predefined_function_type,
3321 BUILT_IN_GEN_PTYPE, NULL_PTR);
3322 builtin_function ((ignore_case || ! special_UC) ? "proc_type" : "PROC_TYPE",
3323 chill_predefined_function_type,
3324 BUILT_IN_PROC_TYPE, NULL_PTR);
3325 builtin_function ((ignore_case || ! special_UC) ? "queue_length" : "QUEUE_LENGTH",
3326 chill_predefined_function_type,
3327 BUILT_IN_QUEUE_LENGTH, NULL_PTR);
3329 int_ftype_ptr_int_ptr_ptr_int_ptr_int_ptr_ptr_int
3330 = build_function_type (integer_type_node,
3331 tree_cons (NULL_TREE, ptr_type_node,
3332 tree_cons (NULL_TREE, integer_type_node,
3333 tree_cons (NULL_TREE, ptr_type_node,
3334 tree_cons (NULL_TREE, ptr_type_node,
3335 tree_cons (NULL_TREE, integer_type_node,
3336 tree_cons (NULL_TREE, ptr_type_node,
3337 tree_cons (NULL_TREE, integer_type_node,
3338 tree_cons (NULL_TREE, ptr_type_node,
3339 tree_cons (NULL_TREE, ptr_type_node,
3340 tree_cons (NULL_TREE, integer_type_node,
3343 = build_function_type (void_type_node,
3344 tree_cons (NULL_TREE, ptr_type_node, endlink));
3346 int_ftype_ptr_int_ptr_int_ptr_ptr_ptr_int
3347 = build_function_type (integer_type_node,
3348 tree_cons (NULL_TREE, ptr_type_node,
3349 tree_cons (NULL_TREE, integer_type_node,
3350 tree_cons (NULL_TREE, ptr_type_node,
3351 tree_cons (NULL_TREE, integer_type_node,
3352 tree_cons (NULL_TREE, ptr_type_node,
3353 tree_cons (NULL_TREE, ptr_type_node,
3354 tree_cons (NULL_TREE, ptr_type_node,
3355 tree_cons (NULL_TREE, integer_type_node,
3358 void_ftype_ptr_ins_int_int_ptr_ptr_int
3359 = build_function_type (void_type_node,
3360 tree_cons (NULL_TREE, ptr_type_node,
3361 tree_cons (NULL_TREE, instance_type_node,
3362 tree_cons (NULL_TREE, integer_type_node,
3363 tree_cons (NULL_TREE, integer_type_node,
3364 tree_cons (NULL_TREE, ptr_type_node,
3365 tree_cons (NULL_TREE, ptr_type_node,
3366 tree_cons (NULL_TREE, integer_type_node,
3368 int_ftype_ptr_ptr_int_ptr_ptr_int
3369 = build_function_type (integer_type_node,
3370 tree_cons (NULL_TREE, ptr_type_node,
3371 tree_cons (NULL_TREE, ptr_type_node,
3372 tree_cons (NULL_TREE, integer_type_node,
3373 tree_cons (NULL_TREE, ptr_type_node,
3374 tree_cons (NULL_TREE, ptr_type_node,
3375 tree_cons (NULL_TREE, integer_type_node,
3378 void_ftype_int_int_int_ptr_ptr_ptr_int
3379 = build_function_type (void_type_node,
3380 tree_cons (NULL_TREE, integer_type_node,
3381 tree_cons (NULL_TREE, integer_type_node,
3382 tree_cons (NULL_TREE, integer_type_node,
3383 tree_cons (NULL_TREE, ptr_type_node,
3384 tree_cons (NULL_TREE, ptr_type_node,
3385 tree_cons (NULL_TREE, ptr_type_node,
3386 tree_cons (NULL_TREE, integer_type_node,
3390 = build_function_type (integer_type_node,
3391 tree_cons (NULL_TREE, ptr_type_node,
3392 tree_cons (NULL_TREE, integer_type_node,
3395 builtin_function ("__delay_event", int_ftype_ptr_int_ptr_int_ptr_ptr_ptr_int,
3396 NOT_BUILT_IN, NULL_PTR);
3397 builtin_function ("__queue_length", int_ftype_ptr_int,
3398 NOT_BUILT_IN, NULL_PTR);
3399 builtin_function ("__register_tasking", void_ftype_ptr,
3400 NOT_BUILT_IN, NULL_PTR);
3401 builtin_function ("__send_signal", void_ftype_ptr_ins_int_int_ptr_ptr_int,
3402 NOT_BUILT_IN, NULL_PTR);
3403 builtin_function ("__send_buffer", int_ftype_ptr_ptr_int_ptr_ptr_int,
3404 NOT_BUILT_IN, NULL_PTR);
3405 builtin_function ("__start_process", void_ftype_int_int_int_ptr_ptr_ptr_int,
3406 NOT_BUILT_IN, NULL_PTR);
3407 builtin_function ("__stop_process", void_ftype_void, NOT_BUILT_IN,
3409 builtin_function ("__wait_buffer", int_ftype_ptr_int_ptr_ptr_int_ptr_int_ptr_ptr_int,
3410 NOT_BUILT_IN, NULL_PTR);
3411 builtin_function ("__wait_signal_timed", int_ftype_ptr_int_ptr_ptr_int_ptr_int_ptr_ptr_int,
3412 NOT_BUILT_IN, NULL_PTR);
3414 infinite_buffer_event_length_node = build_int_2 (-1, 0);
3415 TREE_TYPE (infinite_buffer_event_length_node) = long_integer_type_node;
3416 TREE_UNSIGNED (infinite_buffer_event_length_node) = 1;