C:/Users/Dennis/src/lang/russell.orig/src/pass5d/trace.c

Go to the documentation of this file.
00001 /* Routines to generate RIC trace code for function entry and exit */
00002 # include "parm.h"
00003 # include <stdio.h>
00004 # include "stree/ststructs.mh"
00005 # include "codegen.h"
00006 # include "op_codes.h"
00007 # include "pass4/sigs.h"
00008 # include "pass3/is_local.h"
00009 
00010 extern int avail_loc;
00011 
00012 extern FILE * Goutfile;
00013 
00014 int GGbase;       /* implicit parameters to the following */
00015 boolean GGFflag;
00016 int GGoffset;
00017 
00018 /*
00019  *  Generate call to trace an argument
00020  *         param is the parameter node
00021  *         GGbase is a base location for accessing argument
00022  *              - the first argument should be at an offset of 1
00023  *         GGoffset is the current offset from GGbase; it is decremented
00024  *              by this routine
00025  *         GGFflag is true iff we are generating code which assumes no s.l.
00026  */
00027 Garg_trace(param)
00028 NODE * param;
00029 {
00030     NODE * put_sel = (NODE *)mk_put_selection(param, GGFflag);
00031     int put_loc = avail_loc++;
00032     int arg_loc = avail_loc++;
00033 
00034     /* Load print function value */
00035       gen2(DCL, put_loc, DCL_ADDR);
00036       if (put_sel != NIL) {
00037         Gexpression(put_sel, put_loc);
00038       } else {                      
00039         gen2(HINT, ET, DCL_INT);
00040         genl(EXT, "_FV_put_any");
00041         genl(LBA, "_FV_put_any");
00042         gen1(LDL, put_loc);
00043       }
00044 
00045     /* Push argument value */
00046       gen2(DCL, arg_loc, DCL_INT);
00047       gen3(LDI, GGbase, GGoffset, arg_loc);
00048       GGoffset -= 1;
00049 
00050     /* Make trace call */
00051       gen2(TAR, arg_loc, put_loc);
00052       gen2(UDC, arg_loc, 1);
00053       gen2(UDC, put_loc, 1);
00054 }
00055 
00056 /*
00057  *  Generate calls to trace function entry
00058  *         name is the name of the routine being entered
00059  *         params is the parameter list to the function construction
00060  *         Fflag is true iff we are generating jsb code.
00061  */
00062 Gentry_trace(name, params, Fflag)
00063 char * name;
00064 NODE * params;
00065 boolean Fflag;
00066 {
00067     /* Add argument information in reverse order */
00068         if (Fflag) {
00069             GGbase = SP;
00070             GGoffset = length(params) + 1 /* compensate for print fn */;
00071         } else {
00072             GGbase = AR;
00073             GGoffset = length(params);
00074         }
00075         GGFflag = Fflag;
00076         maprlist(params, Garg_trace);
00077         genl(TFB, name);
00078 }
00079 
00080 /* Generate call to trace function exit */
00081 Gexit_trace(name)
00082 {
00083     genl(TFE, name);
00084 }
00085 

Generated on Fri Jan 25 10:39:47 2008 for russell by  doxygen 1.5.4