diff -Naur ../../testmd/gcc-4.3.1/gcc/common.opt gcc/common.opt --- ../../testmd/gcc-4.3.1/gcc/common.opt 2008-01-22 19:41:44.000000000 +0530 +++ gcc/common.opt 2008-10-15 20:32:49.000000000 +0530 @@ -491,6 +491,10 @@ Common Report Var(flag_forward_propagate) Optimization Perform a forward propagation pass on RTL +fdump-cs715 +Common Report Var(flag_dump_cs715) +Dump information to the file + ; Nonzero means don't put addresses of constant functions in registers. ; Used for compiling the Unix kernel, where strange substitutions are ; done on the assembly output. diff -Naur ../../testmd/gcc-4.3.1/gcc/cs715.c gcc/cs715.c --- ../../testmd/gcc-4.3.1/gcc/cs715.c 1970-01-01 05:30:00.000000000 +0530 +++ gcc/cs715.c 2008-10-22 14:33:44.000000000 +0530 @@ -0,0 +1,588 @@ +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "tm.h" +#include "tree.h" +#include "rtl.h" +#include "tm_p.h" +#include "hard-reg-set.h" +#include "basic-block.h" +#include "output.h" +#include "flags.h" +#include "function.h" +#include "expr.h" +#include "ggc.h" +#include "langhooks.h" +#include "diagnostic.h" +#include "tree-flow.h" +#include "timevar.h" +#include "tree-dump.h" +#include "tree-pass.h" +#include "toplev.h" +#include "except.h" +#include "cfgloop.h" +#include "cfglayout.h" +#include "tree-ssa-propagate.h" +#include "value-prof.h" +#include "pointer-set.h" +#include "tree-inline.h" +#include "vec.h" +#include "errors.h" +#include "hashtab.h" +#include "cgraph.h" +#include "regs.h" + + +int cs715_main(void); +extern FILE * dump_file; + + +struct tree_opt_pass pass_cs715 = +{ + "cs715", /* name */ + NULL, /* gate */ + cs715_main, /* execute */ + NULL, /* sub */ + NULL, /* next */ + 0, /* static_pass_number */ + 0, /* tv_id */ + 0, /* properties_required */ + 0, /* properties_provided */ + 0, /* properties_destroyed */ + 0, /* todo_flags_start */ + 0, /* todo_flags_finish */ + 0 /* letter */ +}; + +void eval_rtx(rtx); + +struct reginfo +{ + int regno; + char class; +}fixedreg[54]; +int num=0; + +int search(int val) +{ + int i; + for(i=0;idest : e->src); + if (cfun && side == ENTRY_BLOCK_PTR) + printf (" ENTRY"); + else if (cfun && side == EXIT_BLOCK_PTR) + printf(" EXIT"); + else + printf (" %d", side->index); + + if (e->flags) + { + static const char * const bitnames[] = {"fallthru", "ab", "abcall", "eh", "fake", "dfs_back", "can_fallthru", "irreducible", "sibcall", "loop_exit", "true", "false", "exec"}; + int comma = 0; + int i, flags = e->flags; + + printf(" ("); + for(i = 0; flags; i++) + if(flags & (1 << i)) + { + flags &= ~(1 << i); + + if(comma) + printf(","); + if(i < (int) ARRAY_SIZE (bitnames)) + printf("%s",bitnames[i]); + else + printf("%d", i); + comma = 1; + } + printf(")"); + } +} + +void dump_basic_block_info (basic_block bb) +{ + edge e; + edge_iterator ei; + printf ("\n;; Predecessors: "); + FOR_EACH_EDGE (e, ei, bb->preds) + dump_edge_information (e, 0); + printf ("\n;; Successors: "); + FOR_EACH_EDGE (e, ei, bb->succs) + dump_edge_information (e, 1); +} + + +int cs715_main(void) +{ + basic_block bb; + rtx last; + rtx insn; + int code,labelno=-1; + int regno,val,type,bbno; + rtx opd1,opd2; + for (insn = get_insns(), last = get_last_insn(), last = NEXT_INSN(last); insn != last; insn = NEXT_INSN (insn)) + { + int is_insn; + is_insn = INSN_P (insn); + if(flag_dump_cs715) + print_rtl_single(dump_file,insn); + code = GET_CODE(insn); + //printf("\nName : %s\tLength = %d\tFormat = %s",GET_RTX_NAME(code),GET_RTX_LENGTH(code),GET_RTX_FORMAT(code)); + if(code==NOTE) + { + type = (int)XINT(insn,5); + if(type==NOTE_INSN_BASIC_BLOCK) + { + bb = (basic_block)XEXP(insn,3); + bbno = bb->index; + if(bbno>2) + { + print(); + printf("\n;; End of basic block %d",bbno-1); + } + printf("\n\n\n;; Start of basic block %d",bbno); + dump_basic_block_info(bb); + dump_register_info(bbno); + if(labelno!=-1){ + printf("\nLABEL %d",labelno); + labelno=-1; + } + } + } + if(code==CODE_LABEL) + labelno = XINT(insn,0); + if(is_insn){ + labelno=-1; + rtx subexp = XEXP(insn,5); + code = GET_CODE(subexp); + //printf("\nName : %s\tLength = %d\tFormat = %s",GET_RTX_NAME(code),GET_RTX_LENGTH(code),GET_RTX_FORMAT(code)); + switch(code) + { + case PARALLEL: + opd1 = XVEC(subexp, 0); + int veclen = XVECLEN(subexp, 0); + int i; + for(i = 0; i < veclen; i++) + { + opd2 = XVECEXP(subexp, 0, i); + int c = GET_CODE(opd2); + //printf("\nName : %s\tLength = %d\tFormat = %s",GET_RTX_NAME(c),GET_RTX_LENGTH(c),GET_RTX_FORMAT(c)); + } + break; + case SET: + opd2 = XEXP(subexp,1); + int c1 = GET_CODE(opd2); + //printf("\nName : %s\tLength = %d\tFormat = %s",GET_RTX_NAME(c1),GET_RTX_LENGTH(c1),GET_RTX_FORMAT(c1)); + default: + printf(""); + } + printf("\n"); + eval_rtx(subexp); + } + } + print(); + printf("\n;; End of basic block %d\n",bbno); + return 0; +} + +int conv(rtx exp) +{ + int val; + int rt_code = GET_CODE(exp); + if(rt_code == CONST_INT) + { + val = XINT(exp,0); + if(val >= 0) + return 1; + else + return (-1); + } + return 0; +} + +void eval_rtx_sp(rtx exp) +{ + int val; + int rt_code = GET_CODE(exp); + if(rt_code == CONST_INT) + { + val = XINT(exp,0); + if(val >= 0) + printf("%d", val); + else + printf("%d", -val); + } + return 0; +} + +void eval_rtx(rtx exp) +{ + rtx opd1,opd2,temp,opd3; + int val,regno,veclen,i, chk; + int rt_code = GET_CODE(exp); + switch(rt_code) + { + case PLUS: + case SS_PLUS: + case US_PLUS: + case MINUS: + case SS_MINUS: + case US_MINUS: + case MULT: + case DIV: + case MOD: + case AND: + case IOR: + case XOR: + case GE: + case GT: + case LE: + case LT: + case UNGE: + case UNGT: + case UNLE: + case UNLT: + case GEU: + case GTU: + case LEU: + case LTU: + case NE: + case LTGT: + case SS_MULT: + case US_MULT: + case UDIV: + case SS_DIV: + case US_DIV: + case UMOD: + case EQ: + case UNEQ: + case ASHIFT: + case ASHIFTRT: + opd1 = XEXP(exp,0); + opd2 = XEXP(exp,1); + chk = conv(opd2); + switch(chk) + { + case 0: + break; + case 1: + break; + case -1: + if(rt_code == PLUS) + rt_code = MINUS; + else if(rt_code==MINUS) + rt_code = PLUS; + break; + default: + printf(""); + } + eval_rtx(opd1); + switch(rt_code) + { + case PLUS: + case SS_PLUS: + case US_PLUS: + printf(" + "); + break; + case MINUS: + case SS_MINUS: + case US_MINUS: + printf(" - "); + break; + case MULT: + case SS_MULT: + case US_MULT: + printf(" * "); + break; + case DIV: + case UDIV: + case US_DIV: + case SS_DIV: + printf(" / "); + break; + case MOD: + case UMOD: + printf(" %% "); + break; + case AND: + printf(" & "); + break; + case IOR: + printf(" | "); + break; + case XOR: + printf(" ^ "); + break; + case GT: + case GTU: + case UNGT: + printf(" > "); + break; + case GE: + case GEU: + case UNGE: + printf(" >= "); + break; + case LT: + case LTU: + case UNLT: + printf(" < "); + break; + case LE: + case LEU: + case UNLE: + printf(" <= "); + break; + case EQ: + case UNEQ: + printf(" == "); + break; + case NE: + case LTGT: + printf(" != "); + break; + case ASHIFT: + printf(" << "); + break; + case ASHIFTRT: + printf(" >> "); + break; + default: + printf(""); + } + if(chk == -1) + eval_rtx_sp(opd2); + else + eval_rtx(opd2); + break; + case NEG: + case SS_NEG: + case US_NEG: + case NOT: + opd1 = XEXP(exp,0); + if(rt_code==NEG || rt_code==US_NEG || rt_code==SS_NEG) + printf("- "); + else + printf("~ "); + eval_rtx(opd1); + break; + case FLOAT: + case UNSIGNED_FLOAT: + opd1 = XEXP(exp,0); + printf("(float) "); + eval_rtx(opd1); + break; + case FIX: + case UNSIGNED_FIX: + opd1 = XEXP(exp,0); + printf("(fix) "); + eval_rtx(opd1); + break; + case SET: + opd1 = XEXP(exp,0); + opd2 = XEXP(exp,1); + eval_rtx(opd1); + printf(" = "); + eval_rtx(opd2); + break; + case PARALLEL: + opd1 = XVEC(exp, 0); + veclen = XVECLEN(exp, 0); + for(i = 0; i < veclen-1; i++) + { + temp = XVECEXP(exp, 0, i); + eval_rtx(temp); + printf(" || "); + } + temp = XVECEXP(exp, 0, i); + eval_rtx(temp); + break; + case UNSPEC: + opd1 = XVEC(exp, 0); + veclen = XVECLEN(exp, 0); + printf("unspec [ "); + for(i = 0; i < veclen; i++) + { + temp = XVECEXP(exp, 0, i); + printf("("); + eval_rtx(temp); + printf(") "); + } + val = XINT(exp,1); + printf(", %d ]",val); + break; + case MEM: + opd1 = XEXP(exp,0); + printf("*("); + //find_ar(opd1); + eval_rtx(opd1); + printf(")"); + break; + case REG: + regno = XINT(exp,0); + printf("r%d",regno); + if(regno<=53) + { + if(!search(regno)) + { + fixedreg[num].regno=regno; + fixedreg[num++].class = reg_class(exp); + } + } + break; + case CONST_INT: + val = XINT(exp,0); + printf("%d",val); + break; + case SYMBOL_REF: + printf("ref (%s)",XSTR(exp,0)); + break; + case CLOBBER: + printf("clobber "); + opd1 = XEXP(exp,0); + eval_rtx(opd1); + break; + case CALL: + printf("CALL ["); + opd1 = XEXP(exp,0); + opd2 = XEXP(exp,1); + eval_rtx(opd1); + printf(" "); + eval_rtx(opd2); + printf("]"); + break; + case PC: + printf("pc"); + break; + case COMPARE: + printf("compare {("); + opd1 = XEXP(exp,0); + opd2 = XEXP(exp,1); + eval_rtx(opd1); + printf(") , ("); + eval_rtx(opd2); + printf(")}"); + break; + case IF_THEN_ELSE: + opd1 = XEXP(exp,0); + opd2 = XEXP(exp,1); + opd3 = XEXP(exp,2); + eval_rtx(opd1); + printf(" ? "); + eval_rtx(opd2); + printf(" : "); + eval_rtx(opd3); + break; + case LABEL_REF: + opd1 = XEXP(exp,0); + printf("label(%d)",XINT(opd1,0)); + break; + case USE: + printf("use "); + opd1 = XEXP(exp,0); + eval_rtx(opd1); + break; + case CC0: + printf("CC0"); + break; + case ZERO_EXTRACT: + case SIGN_EXTRACT: + if(rt_code==ZERO_EXTRACT) + printf("zeroextract [ ("); + else + printf("signextract [ ("); + opd1 = XEXP(exp,0); + eval_rtx(opd1); + printf("),("); + opd2 = XEXP(exp,1); + eval_rtx(opd2); + printf("),("); + opd3 = XEXP(exp,2); + eval_rtx(opd3); + printf(") ]"); + break; + case CONST_STRING: + printf("%s",XSTR(exp,0)); + break; + case FLOAT_EXTEND: + printf("floatextend ("); + opd1 = XEXP(exp,0); + eval_rtx(opd1); + printf(")"); + break; + case SIGN_EXTEND: + case ZERO_EXTEND: + if(rt_code==ZERO_EXTEND) + printf("zeroextend ("); + else + printf("signextend ("); + opd1 = XEXP(exp,0); + eval_rtx(opd1); + printf(")"); + break; + default: + printf(" default "); + } +} diff -Naur ../../testmd/gcc-4.3.1/gcc/Makefile.in gcc/Makefile.in --- ../../testmd/gcc-4.3.1/gcc/Makefile.in 2008-05-12 00:24:15.000000000 +0530 +++ gcc/Makefile.in 2008-10-10 22:36:17.000000000 +0530 @@ -1224,7 +1224,8 @@ version.o \ vmsdbgout.o \ web.o \ - xcoffout.o + xcoffout.o \ + cs715.o # Target object files. OBJS-md = $(out_object_file) @@ -2881,6 +2882,14 @@ $(MACHMODE_H) $(TM_H) $(RTL_H) $(TM_P_H) $(TIMEVAR_H) $(FLAGS_H) \ insn-config.h $(BASIC_BLOCK_H) $(RECOG_H) $(OBSTACK_H) bitmap.h \ $(EXPR_H) $(REGS_H) tree-pass.h $(DF_H) +#cs715 +cs715.o : cs715.c +#$(TREE_FLOW_H) $(CONFIG_H) $(SYSTEM_H) \ +#$(RTL_H) $(TREE_H) $(TM_P_H) $(EXPR_H) $(GGC_H) $(FLAGS_H) output.h \ +#$(DIAGNOSTIC_H) $(FUNCTION_H) $(TIMEVAR_H) $(TM_H) coretypes.h \ +#$(TREE_DUMP_H) except.h langhooks.h $(CFGLOOP_H) tree-pass.h \ +#$(CFGLAYOUT_H) $(BASIC_BLOCK_H) hard-reg-set.h toplev.h \ +#tree-ssa-propagate.h $(TREE_INLINE_H) $(CGRAPH_H) $(HASHTAB_H) errors.h $(out_object_file): $(out_file) $(CONFIG_H) coretypes.h $(TM_H) $(TREE_H) \ $(RTL_H) $(REGS_H) hard-reg-set.h insn-config.h conditions.h \ @@ -3119,7 +3128,7 @@ $(srcdir)/ipa-reference.c $(srcdir)/tree-ssa-structalias.h \ $(srcdir)/tree-ssa-structalias.c $(srcdir)/tree-parloops.c \ $(srcdir)/omp-low.c $(srcdir)/varpool.c \ - $(srcdir)/targhooks.c $(out_file) $(srcdir)/passes.c $(srcdir)/cgraphunit.c \ + $(srcdir)/targhooks.c $(out_file) $(srcdir)/passes.c $(srcdir)/cgraphunit.c $(srcdir)/cs715.c\ @all_gtfiles@ GTFILES_H = $(subst /,-, $(patsubst $(srcdir)/%,gt-%, $(patsubst %.c,%.h, \ diff -Naur ../../testmd/gcc-4.3.1/gcc/passes.c gcc/passes.c --- ../../testmd/gcc-4.3.1/gcc/passes.c 2008-01-22 18:57:52.000000000 +0530 +++ gcc/passes.c 2008-10-17 11:31:14.000000000 +0530 @@ -487,6 +487,7 @@ NEXT_PASS (pass_lower_vector); NEXT_PASS (pass_warn_function_return); NEXT_PASS (pass_build_cgraph_edges); + //NEXT_PASS (pass_cs715); NEXT_PASS (pass_inline_parameters); *p = NULL; @@ -738,6 +739,7 @@ NEXT_PASS (pass_sched); NEXT_PASS (pass_subregs_of_mode_init); NEXT_PASS (pass_local_alloc); + NEXT_PASS (pass_cs715); NEXT_PASS (pass_global_alloc); NEXT_PASS (pass_subregs_of_mode_finish); NEXT_PASS (pass_postreload); diff -Naur ../../testmd/gcc-4.3.1/gcc/tree-pass.h gcc/tree-pass.h --- ../../testmd/gcc-4.3.1/gcc/tree-pass.h 2008-02-13 16:45:51.000000000 +0530 +++ gcc/tree-pass.h 2008-10-10 22:36:17.000000000 +0530 @@ -247,6 +247,9 @@ extern struct tree_opt_pass pass_refactor_eh; extern struct tree_opt_pass pass_lower_eh; extern struct tree_opt_pass pass_build_cfg; +/*cs715 */ +extern struct tree_opt_pass pass_cs715; + extern struct tree_opt_pass pass_tree_profile; extern struct tree_opt_pass pass_early_tree_profile; extern struct tree_opt_pass pass_cleanup_cfg;