1230130Smav/* Implement powerset-related runtime actions for CHILL.
2230130Smav   Copyright (C) 1992, 93, 1994 Free Software Foundation, Inc.
3230130Smav   Author: Bill Cox
4230130Smav
5230130SmavThis file is part of GNU CC.
6230130Smav
7230130SmavGNU CC is free software; you can redistribute it and/or modify
8230130Smavit under the terms of the GNU General Public License as published by
9230130Smavthe Free Software Foundation; either version 2, or (at your option)
10230130Smavany later version.
11230130Smav
12230130SmavGNU CC is distributed in the hope that it will be useful,
13230130Smavbut WITHOUT ANY WARRANTY; without even the implied warranty of
14230130SmavMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15230130SmavGNU General Public License for more details.
16230130Smav
17230130SmavYou should have received a copy of the GNU General Public License
18230130Smavalong with GNU CC; see the file COPYING.  If not, write to
19230130Smavthe Free Software Foundation, 59 Temple Place - Suite 330,
20230130SmavBoston, MA 02111-1307, USA.  */
21230130Smav
22230130Smav/* As a special exception, if you link this library with other files,
23230130Smav   some of which are compiled with GCC, to produce an executable,
24230130Smav   this library does not by itself cause the resulting executable
25230130Smav   to be covered by the GNU General Public License.
26230130Smav   This exception does not however invalidate any other reasons why
27230130Smav   the executable file might be covered by the GNU General Public License.  */
28230130Smav
29230130Smav#define __CHILL_LIB__
30230130Smav
31230130Smav#include "powerset.h"
32230130Smav
33230130Smavextern void cause_exception (char *exname, char *file, int lineno);
34230130Smav
35230130Smav/*
36230130Smav * function __concatps
37230130Smav *
38230130Smav * parameters:
39230130Smav *     OUT      - pointer to output PS
40230130Smav *     LEFT     - pointer to left PS
41230130Smav *     LEFTLEN  - length of left PS in bits
42230130Smav *     RIGHT    - pointer to right PS
43230130Smav *     RIGHTLEN - length of right PS in bits
44230130Smav *
45230130Smav * returns:
46230130Smav *     void
47230130Smav *
48230130Smav * exceptions:
49230130Smav *     none
50230130Smav *
51230130Smav * abstract:
52230130Smav *     concatenates two powersets into the output powerset.
53230130Smav *
54230130Smav */
55230130Smav
56230130Smavextern void
57230130Smav__pscpy (SET_WORD      *dps,
58230130Smav	 unsigned long  dbl,
59230130Smav	 unsigned long  doffset,
60230130Smav	 SET_WORD      *sps,
61230130Smav	 unsigned long  sbl,
62230130Smav	 unsigned long  start,
63230130Smav	 unsigned long  length);
64230130Smav
65230130Smavvoid
66230130Smav__concatps (out, left, leftlen, right, rightlen)
67230130Smav     SET_WORD      *out;
68230130Smav     SET_WORD      *left;
69230130Smav     unsigned long  leftlen;
70230130Smav     SET_WORD      *right;
71230130Smav     unsigned long  rightlen;
72230130Smav{
73230130Smav  /* allocated sizes for each set involved */
74230130Smav  unsigned long outall, leftall, rightall;
75230130Smav
76230130Smav  if (!out)
77230130Smav    {
78230130Smav      /* FIXME: cause an exception */
79230130Smav    }
80230130Smav  else if (leftlen == 0 || !left)
81230130Smav    {
82230130Smav      if (rightlen == 0 || !right)
83230130Smav	return;               /* no work to do */
84230130Smav      __pscpy (out, rightlen, (unsigned long)0,
85230130Smav	       right, rightlen, (unsigned long)0, rightlen);
86230130Smav    }
87230130Smav  else if (rightlen == 0 || !right)
88230130Smav    {
89230130Smav      if (leftlen == 0 || !left)
90230130Smav	return;               /* no work to do */
91230130Smav      __pscpy (out, leftlen, (unsigned long)0,
92230130Smav	       left, leftlen, (unsigned long)0, leftlen);
93230130Smav    }
94230130Smav  /* copy the left powerset into bits 0..leftlen - 1 */
95230571Smav  __pscpy (out, leftlen + rightlen, (unsigned long)0,
96230571Smav	   left, leftlen, (unsigned long)0, leftlen);
97230130Smav
98230130Smav  /* copy the right powerset into bits leftlen..leftlen+rightlen-1 */
99230130Smav  __pscpy (out, leftlen + rightlen, leftlen,
100230130Smav	   right, rightlen, (unsigned long)0, rightlen);
101230130Smav}
102230130Smav