00001 /* 00002 * Copyright 2007 Google, Inc. All Rights Reserved. 00003 * 00004 * This program is free software; you can redistribute it and/or modify it 00005 * under the terms of version 2 of the GNU General Public License as 00006 * published by the Free Software Foundation. 00007 * 00008 * This program is distributed in the hope that it would be useful, but 00009 * WITHOUT ANY WARRANTY; without even the implied warranty of 00010 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00011 * 00012 * You should have received a copy of the GNU General Public License along 00013 * with this program; if not, write the Free Software Foundation, Inc., 59 00014 * Temple Place - Suite 330, Boston MA 02111-1307, USA. 00015 * 00016 */ 00017 00018 /************************************************************ 00019 * Tracing framework for wgen. 00020 * Outputs GIMPLE/WHIRL nodes to the trace file as 00021 * they are read/created. 00022 ************************************************************/ 00023 00024 extern "C" { 00025 #include "gspin-wgen-interface.h" 00026 } 00027 00028 #include <stdio.h> 00029 #include "tracing.h" 00030 #include "opcode.h" 00031 #include "mtypes.h" 00032 #include "wn.h" 00033 #include "ir_reader.h" 00034 #include "wgen_tracing.h" 00035 00036 int WGEN_TRACE::gimple_depth = 0; 00037 00038 static void print_indent(FILE *fp); 00039 00040 static void print_indent(FILE *fp) 00041 { 00042 for (int i=0; i<WGEN_TRACE::gimple_depth; i++) { 00043 fprintf(fp, " "); 00044 } 00045 } 00046 00047 void WGEN_TRACE::trace_gs(gs_t n) 00048 { 00049 if (Get_Trace(TKIND_IR, TP_WGEN)) { 00050 gs_code_t c = gs_tree_code(n); 00051 print_indent(TFile); 00052 fprintf(TFile, "--- %s\n", gs_code_name(c)); 00053 } 00054 } 00055 00056 WN* WGEN_Trace_wn(WN *wn) 00057 { 00058 if (Get_Trace(TKIND_IR, TP_WGEN)) { 00059 print_indent(TFile); 00060 const char * fmt_str = (sizeof(INTPTR) == 8) ? 00061 "+++ (0x%016x) " : "+++ (0x%08x) "; 00062 fprintf(TFile, fmt_str, (INTPTR) wn); 00063 fdump_wn(TFile, wn); 00064 } 00065 return wn; 00066 }
1.5.6