X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fcommon%2Ffirm_common.c;h=2196b9c73cf246fa1e860b802de3e7fccb3a01f3;hb=d6d1e63d711a02598710dec93219353b9fdad2dd;hp=0011ef7cb987130470c94621cc05058bda69d79c;hpb=75bf2687f404f557b206ab44b59fe729ac43b7c0;p=libfirm diff --git a/ir/common/firm_common.c b/ir/common/firm_common.c index 0011ef7cb..2196b9c73 100644 --- a/ir/common/firm_common.c +++ b/ir/common/firm_common.c @@ -1,46 +1,41 @@ -/* Copyright (C) 1998 - 2000 by Universitaet Karlsruhe -* All rights reserved. -* -* Authors: Martin Trapp, Christian Schaefer & -* Goetz Lindenmaier -* -* firm_common.c: -*/ +/* + * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved. + * + * This file is part of libFirm. + * + * This file may be distributed and/or modified under the terms of the + * GNU General Public License version 2 as published by the Free Software + * Foundation and appearing in the file LICENSE.GPL included in the + * packaging of this file. + * + * Licensees holding valid libFirm Professional Edition licenses may use + * this file in accordance with the libFirm Commercial License. + * Agreement provided with the Software. + * + * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE + * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ -/* $Id$ */ +/** + * @file + * @author Martin Trapp, Christian Schaefer, Goetz Lindenmaier, Michael Beck + * @version $Id$ + */ +#include "config.h" -#ifdef HAVE_CONFIG_H -# include -#endif - -#include "firm_common_t.h" #include "irgraph.h" +#include "irloop.h" +#include "tv.h" -/* returns the kind of the thing */ -firm_kind -get_kind (const void *firm_thing) { - assert (firm_thing); - return *(firm_kind *)firm_thing; -} - +/** + * Ideally, this macro would check if size bytes could be read at + * pointer p. No generic solution. + */ +#define POINTER_READ(p, size) (p) -const char* print_firm_kind(void *firm_thing) { - assert (firm_thing); - switch (*(firm_kind *)firm_thing) { - case k_entity: { return "k_enitity"; } break; - case k_type: { return "k_type"; } break; -#if 0 - case k_type_class: { return "k_type_class"; } break; - case k_type_strct: { return "k_type_strct:"; } break; - case k_type_method: { return "k_type_method:"; } break; - case k_type_union: { return "k_type_union"; } break; - case k_type_array: { return "k_type_array"; } break; - case k_type_enumeration: { return "k_type_enumeration"; } break; - case k_type_pointer: { return "k_type_pointer"; } break; - case k_type_primitive: { return "k_type_primitive"; } break; -#endif - case k_ir_node: { return "k_ir_node"; } break; - default: break; - } - return ""; -} +/* returns the kind of the thing */ +firm_kind get_kind(const void *firm_thing) +{ + return POINTER_READ(firm_thing, sizeof(firm_kind)) ? *(firm_kind *)firm_thing : k_BAD; +} /* get_kind */