From 92c43a69835d96b6bec29019b449f0dffa1b831a Mon Sep 17 00:00:00 2001 From: Florian Liekweg Date: Mon, 22 Apr 2002 14:07:01 +0000 Subject: [PATCH] Added exc.c exc.h Updated Makefile.in to include exc.c exc.h --flo [r357] --- ir/st/Makefile.in | 2 +- ir/st/exc.c | 30 ++++++++++++++++++++++++------ ir/st/exc.h | 24 +++++++++++++++++++----- 3 files changed, 44 insertions(+), 12 deletions(-) diff --git a/ir/st/Makefile.in b/ir/st/Makefile.in index aa067ae19..794dd0db2 100644 --- a/ir/st/Makefile.in +++ b/ir/st/Makefile.in @@ -14,7 +14,7 @@ INSTALL_HEADERS = st.h SOURCES = $(INSTALL_HEADERS) -SOURCES += Makefile.in st.c st.h +SOURCES += Makefile.in st.c st.h exc.c exc.h include $(topdir)/MakeRules diff --git a/ir/st/exc.c b/ir/st/exc.c index 4dc924b1f..8a00173f1 100644 --- a/ir/st/exc.c +++ b/ir/st/exc.c @@ -17,11 +17,15 @@ ***/ # include "exc.h" -# include "st.h" -# include "irop.h" -# include "irouts.h" -# include +static char* exc_strings [] = { + "Invalid", + "Normal", + "Region Entry", + "Handler Entry", + "Cont" +}; + /* Return true iff (block b is a handler entry AND a dominates b) OR @@ -118,10 +122,10 @@ bool is_handler_entry (ir_graph *graph, ir_node *block) is_entry = false; if (true == is_entry) - set_Block_exc (block, exc_entry); + set_Block_exc (block, exc_handler); } - return (exc_entry == get_Block_exc (block)); + return (exc_handler == get_Block_exc (block)); } /* @@ -228,3 +232,17 @@ bool is_cont_entry (ir_graph *graph, ir_node *block) return (exc_cont == get_Block_exc (block)); } + +/* + Convert a value of type exc_t to a descriptive string. + Returns a reference to a statically allocated, constant string. +*/ + +const char *exc_to_string (exc_t exc) +{ + int exc_val = (int) exc; + + assert ((0 <= (int) exc_val) && (exc_val < (int) exc_max)); + + return (exc_strings [exc_val]); +} diff --git a/ir/st/exc.h b/ir/st/exc.h index 96957703f..27d3ed80b 100644 --- a/ir/st/exc.h +++ b/ir/st/exc.h @@ -16,23 +16,37 @@ $Id$ ***/ -# include "irnode.h" - # ifndef _EXC_H_ # define _EXC_H_ +# include "irnode.h" + +# include "st.h" +# include "irop.h" +# include "irouts.h" + +# include + typedef enum { exc_invalid, /* not yet computed */ exc_normal, /* normal CF */ - exc_entry, /* handler entry */ - exc_handler, /* handler block */ + + // must push a new exc contrext at entry of block: exc_region, /* region entry */ - exc_cont /* cont block */ + + // must pop current exc contrext at entry of block + exc_handler, /* handler entry */ + exc_cont, /* cont block */ + + exc_max /* maximum value of enum for 'bounds checking' */ } exc_t; +const char *exc_to_string (exc_t); + bool is_handler_entry (ir_graph*, ir_node*); bool is_region_entry (ir_graph*, ir_node*); bool is_handler_block (ir_graph*, ir_node*); bool is_cont_entry (ir_graph*, ir_node*); + # endif /* def _EXC_H_ */ -- 2.20.1