Use libFirm's obst.h instead of obstack.h
[libfirm] / ir / ana2 / pto_ctx.c
1 /* -*- c -*- */
2
3 /*
4  * Copyright (C) 1995-2007 University of Karlsruhe.  All right reserved.
5  *
6  * This file is part of libFirm.
7  *
8  * This file may be distributed and/or modified under the terms of the
9  * GNU General Public License version 2 as published by the Free Software
10  * Foundation and appearing in the file LICENSE.GPL included in the
11  * packaging of this file.
12  *
13  * Licensees holding valid libFirm Professional Edition licenses may use
14  * this file in accordance with the libFirm Commercial License.
15  * Agreement provided with the Software.
16  *
17  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
18  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19  * PURPOSE.
20  */
21
22 /**
23  * @file
24  * @brief   Manage context-sensitivity markers
25  * @author  Florian
26  * @date    Sat Nov 13 19:35:27 CET 2004
27  * @version $Id$
28  */
29 # ifdef HAVE_CONFIG_H
30 #  include "config.h"
31 # endif
32
33 #include <assert.h>
34
35 /*
36  pto_ctx: Manage context-sensitivity markers
37 */
38
39 # include "pto_ctx.h"
40 # include "pto_debug.h"
41 # include "pto_comp.h"
42 # include "ecg.h"
43
44 # include "irnode.h"
45 /* # include "xmalloc.h" */
46
47 /* Local Defines: */
48
49 /* Local Data Types: */
50
51 /* Local Variables: */
52 static ctx_info_t *curr_ctx = NULL;
53
54 /* Local Prototypes: */
55
56 /* ===================================================
57    Local Implementation:
58    =================================================== */
59
60
61 /* ===================================================
62    Exported Implementation:
63    =================================================== */
64 /* Find the appropriate ctx for the given call and the given graph */
65 /* ctx_info_t *find_ctx (ir_node *call, graph_info_t *ginfo, ctx_info_t *curr_ctx) */
66 int find_ctx_idx (ir_node *call, graph_info_t *ginfo, ctx_info_t *curr_ctx)
67 {
68   int i;
69   const int n_ctxs = ginfo->n_ctxs;
70
71   for (i = 0; i < n_ctxs; i ++) {
72     ctx_info_t *ctx = ginfo->ctxs [i];
73
74     if ((ctx->enc == curr_ctx) && (ctx->call == call)) {
75       return (i);
76     }
77   }
78
79   fflush (stdout);
80   assert (0 && "CTX not found");
81
82   return (-1);
83 }
84
85 /* Get the current ctx */
86 ctx_info_t *get_curr_ctx (void)
87 {
88   return (curr_ctx);
89 }
90
91 /* Set the current ctx to the given ctx.  Return the old value */
92 ctx_info_t *set_curr_ctx (ctx_info_t *ctx)
93 {
94   ctx_info_t *old_ctx = curr_ctx;
95
96   curr_ctx = ctx;
97
98   return (old_ctx);
99 }
100
101 \f
102 /*
103   $Log$
104   Revision 1.6  2005/12/05 12:19:54  beck
105   added missing include <assert.h> (not anymore included in libFirm)
106
107   Revision 1.5  2005/01/14 13:37:55  liekweg
108   Insert purpose descr
109
110   Revision 1.4  2004/12/02 16:17:51  beck
111   fixed config.h include
112
113   Revision 1.3  2004/11/24 14:53:55  liekweg
114   Bugfixes
115
116   Revision 1.2  2004/11/20 21:21:35  liekweg
117   Add pto_ctx_allocs
118
119   Revision 1.1  2004/11/18 16:37:34  liekweg
120   rewritten
121
122
123 */