Re: Using C as a back end

Tom Payne <thp@roam-thp2.cs.ucr.edu>
4 Nov 2000 01:43:21 -0500

          From comp.compilers

Related articles
[24 earlier articles]
Re: Using C as a back end conway@ender.cs.mu.oz.au (2000-11-01)
Re: Using C as a back end kst@cts.com (Keith Thompson) (2000-11-01)
Re: Using C as a back end rhyde@cs.ucr.edu (Randall Hyde) (2000-11-01)
Re: Using C as a back end rhyde@cs.ucr.edu (Randall Hyde) (2000-11-01)
Re: Using C as a back end vbdis@aol.com (2000-11-04)
Re: Using C as a back end joachim_d@gmx.de (Joachim Durchholz) (2000-11-04)
Re: Using C as a back end thp@roam-thp2.cs.ucr.edu (Tom Payne) (2000-11-04)
Re: Using C as a back end gneuner@dyn.com (2000-11-04)
Re: Using C as a back end fjh@cs.mu.OZ.AU (2000-11-05)
Re: Using C as a back end freitag@alancoxonachip.com (Andi Kleen) (2000-11-05)
Re: Using C as a back end christl@rosalind.fmi.uni-passau.de (2000-11-05)
| List of all articles for this month |

From: Tom Payne <thp@roam-thp2.cs.ucr.edu>
Newsgroups: comp.compilers
Date: 4 Nov 2000 01:43:21 -0500
Organization: University of California, Riverside
References: 00-10-148 00-10-154 00-10-212 00-10-228 00-11-017
Keywords: C
Posted-Date: 04 Nov 2000 01:43:21 EST

Randall Hyde <rhyde@cs.ucr.edu> wrote:
> Tom Payne at thp@cs.ucr.edu wrote on 10/31/00 12:39 PM:


>> For many applications, indirect jumps (computed gotos) are essential.
[...]
>> [Once again, an indirect jump is, in Fortran-ese, an assigned goto.
>> Or if you speak Cobol, it's an ALTERed goto. -John]


> In Tom's defense, I'd point out that you could create an array of
> these pointers and do the equivalent of a FORTRAN assigned GOTO
> by indexing into the array. Arguably a bit more flexible than
> a switch statement.


Good point. The point I was making went in the opposite direction,
namely, one can use a switch-based hack to emulate gcc's indirect goto
(assigned goto, altered goto, or whatever) within standard C. Here's
the general idea:


      // gcc // standard C equivalent
                                                                  #define LABEL enum pseudolabel
                                                                  #define GOTO(X) target = X; goto target
                                                                  LABEL { L1, L2 };
                                                                  LABEL target;
      ... ...
      void* p; LABEL p;
      ... ...
      L1: ... L1: ...
      ... ...
      ... ...
      L2: ... L2: ...
      ... ...
      p =&& whatever ? L1 : L2; p = whatever ? L1 : L2;
      ... ...
      goto* p; GOTO(p);
      ... ...
                                                                  target: switch ( target ) {
                                                                      case L1: goto L1;
                                                                      case L2: goto L2;
                                                                  }


Tom Payne


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.