char and word cases

Matthew Fluet fluet@CS.Cornell.EDU
Fri, 8 Dec 2000 14:39:27 -0500 (EST)


> I am in the process of adding in char and word cases to all the ILs.  I have to
> decide how to change MACHINE.  My current thinking is to add two new kinds of
> switch statements to the signature, so it looks something like:
> 
> 	    val switch: {
> 			 test: Operand.t,
> 			 cases: (int * Label.t) list,
> 			 default: Label.t option
> 			} -> t
> 	    val switchChar: {
> 			 test: Operand.t,
> 			 cases: (char * Label.t) list,
> 			 default: Label.t option
> 			} -> t
> 	    val switchWord: {
> 			 test: Operand.t,
> 			 cases: (word * Label.t) list,
> 			 default: Label.t option
> 			} -> t

I like the way it's done in cps-tree.sig, assuming that you extended
it this way there:

      structure Cases:
	 sig
	    datatype 'a t =
	       Con of (Con.t * 'a) list
	     | Int of (int * 'a) list
             | Char of (char * 'a) list
             | Word of (word * 'a) list
            ...
         end


with a Transfer.t variant:
	     | Case of {
			cause: Cause.t,
			test: Var.t,
			cases: Jump.t Cases.t,
			default: Jump.t option  (* jump is nullary *)
		       }