br_w.c 1.49 KB
/****************************************************************
  WHAT:	RSP TEST GENERATOR
  SCCS: @(#)br_w.c	1.1 03 Aug 1994
  FILE: br_w.c
   WHO: Project Reality - Evan Y. Wang
   (C): 1994 Silicon Graphics, Inc.
 ****************************************************************/
#include <stdio.h>
#include "software.h"
#include "gen.h"
#include "suregre.h"

#define MAX_TCS	MAX_BR_W_TCS

#define GenCase(tmpl)						\
    fprintf(outp,tmpl,CurTcNo,ip->name,rA,HHW(OpA),LHW(OpA),rT);

/* Macro for condition true */
PRIVATE	char *TemplT =
    /* ChkBrWT(  n,Op,   rA,   OpAH,   OpAL,   rT); */
    "\tChkBrWT(%2d,%s,r%-2d,0x%4.4X,0x%4.4X,r%-2d)\n";

/* Macro for condition false */
PRIVATE	char *TemplF =
    /* ChkBrWF(  n,Op,   rA,   OpAH,   OpAL,   rT); */
    "\tChkBrWF(%2d,%s,r%-2d,0x%4.4X,0x%4.4X,r%-2d)\n";

int BrWGen(outp, ip)
    FILE *outp;
    I_TABLE *ip;
{
    int i = 0;

    FILE_SPLIT {
	/* Generate initial case - operand is zero */
	if (ip->proc(OpA))	{ GenCase(TemplT); }
	else			{ GenCase(TemplF); }
    }
    CurTcNo++;

    /* Generate remaining cases */
    i = 0;
    do {
	/* generate next input vector */
	if (OpA & 0x80000000) {
	    OpA = (OpA << 1) | 0x80000001;
	} else {
	    OpA = 1 << i;
	}

	FILE_SPLIT {
	    /* based on predicted result, use correct template */
	    if (ip->proc(OpA))	{ GenCase(TemplT); }
	    else		{ GenCase(TemplF); }
	}

	/* use a different register */
	UpdRegID();

    } while (CurTcNo++, i++, OpA != 0xFFFFFFFF);

    return CurTcNo = 0;

}   /* BrWGen */