GENERIC MODULEGT (Rep); IMPORT CG, CallExpr, Expr, ExprRep, Procedure, Target, TWord; IMPORT Bool, IntegerExpr, Value, Formal, Type, ProcType; FROM Rep IMPORT T; FROM TargetMap IMPORT Word_types; VAR Z: CallExpr.MethodList; VAR formals: Value.T; VAR rep: [FIRST (Word_types) .. LAST (Word_types)]; PROCEDURECheck (ce: CallExpr.T; VAR cs: Expr.CheckState) = BEGIN EVAL Formal.CheckArgs (cs, ce.args, formals, ce.proc); ce.type := Bool.T; END Check; PROCEDURECompile (ce: CallExpr.T) = BEGIN Expr.Compile (ce.args[0]); Expr.Compile (ce.args[1]); CG.Compare (Word_types[rep].cg_type, CG.Cmp.GT); END Compile; PROCEDUREPrepBR (ce: CallExpr.T; true, false: CG.Label; freq: CG.Frequency)= BEGIN Expr.Prep (ce.args[0]); Expr.Prep (ce.args[1]); Expr.Compile (ce.args[0]); Expr.Compile (ce.args[1]); CG.If_then (Word_types[rep].cg_type, CG.Cmp.GT, true, false, freq); END PrepBR; PROCEDUREFold (ce: CallExpr.T): Expr.T = VAR w0, w1: Target.Int; BEGIN IF GetArgs (ce.args, w0, w1) THEN RETURN Bool.Map [TWord.LT (w1, w0)]; ELSE RETURN NIL; END; END Fold; PROCEDUREGetArgs (args: Expr.List; VAR w0, w1: Target.Int): BOOLEAN = VAR e0, e1: Expr.T; t: Type.T; BEGIN e0 := Expr.ConstValue (args[0]); e1 := Expr.ConstValue (args[1]); IF (e0 # NIL) AND IntegerExpr.Split (e0, w0, t) AND (e1 # NIL) AND IntegerExpr.Split (e1, w1, t) THEN TWord.And (w0, Word_types[rep].max, w0); TWord.And (w1, Word_types[rep].max, w1); RETURN TRUE; ELSE RETURN FALSE; END; END GetArgs; PROCEDUREInitialize (r: INTEGER) = VAR x1 := Formal.NewBuiltin ("x", 0, T); y1 := Formal.NewBuiltin ("y", 1, T); t1 := ProcType.New (Bool.T, x1, y1); BEGIN rep := r; Z := CallExpr.NewMethodList (2, 2, TRUE, TRUE, TRUE, Bool.T, NIL, CallExpr.NotAddressable, Check, CallExpr.PrepArgs, Compile, CallExpr.NoLValue, CallExpr.NoLValue, PrepBR, CallExpr.NoBranch, Fold, CallExpr.NoBounds, CallExpr.IsNever, (* writable *) CallExpr.IsNever, (* designator *) CallExpr.NotWritable (* noteWriter *)); Procedure.Define ("GT", Z, FALSE, t1); formals := ProcType.Formals (t1); END Initialize; BEGIN END GT.