ir/ir/irop_t.h added
[libfirm] / ir / ana2 / pto_ctx.c
1 /* -*- c -*- */
2
3 /*
4    Project:     libFIRM
5    File name:   ir/ana/pto_ctx.c
6    Purpose:     Manage context-sensitivity markers
7    Author:      Florian
8    Modified by:
9    Created:     Sat Nov 13 19:35:27 CET 2004
10    CVS-ID:      $Id$
11    Copyright:   (c) 1999-2004 Universität Karlsruhe
12    Licence:     This file is protected by the GPL -  GNU GENERAL PUBLIC LICENSE.
13 */
14
15 # ifdef HAVE_CONFIG_H
16 #  include "config.h"
17 # endif
18
19 #include <assert.h>
20
21 /*
22  pto_ctx: Manage context-sensitivity markers
23 */
24
25 # include "pto_ctx.h"
26 # include "pto_debug.h"
27 # include "pto_comp.h"
28 # include "ecg.h"
29
30 # include "irnode.h"
31 /* # include "xmalloc.h" */
32
33 /* Local Defines: */
34
35 /* Local Data Types: */
36
37 /* Local Variables: */
38 static ctx_info_t *curr_ctx = NULL;
39
40 /* Local Prototypes: */
41
42 /* ===================================================
43    Local Implementation:
44    =================================================== */
45
46
47 /* ===================================================
48    Exported Implementation:
49    =================================================== */
50 /* Find the appropriate ctx for the given call and the given graph */
51 /* ctx_info_t *find_ctx (ir_node *call, graph_info_t *ginfo, ctx_info_t *curr_ctx) */
52 int find_ctx_idx (ir_node *call, graph_info_t *ginfo, ctx_info_t *curr_ctx)
53 {
54   int i;
55   const int n_ctxs = ginfo->n_ctxs;
56
57   for (i = 0; i < n_ctxs; i ++) {
58     ctx_info_t *ctx = ginfo->ctxs [i];
59
60     if ((ctx->enc == curr_ctx) && (ctx->call == call)) {
61       return (i);
62     }
63   }
64
65   fflush (stdout);
66   assert (0 && "CTX not found");
67
68   return (-1);
69 }
70
71 /* Get the current ctx */
72 ctx_info_t *get_curr_ctx (void)
73 {
74   return (curr_ctx);
75 }
76
77 /* Set the current ctx to the given ctx.  Return the old value */
78 ctx_info_t *set_curr_ctx (ctx_info_t *ctx)
79 {
80   ctx_info_t *old_ctx = curr_ctx;
81
82   curr_ctx = ctx;
83
84   return (old_ctx);
85 }
86
87 \f
88 /*
89   $Log$
90   Revision 1.6  2005/12/05 12:19:54  beck
91   added missing include <assert.h> (not anymore included in libFirm)
92
93   Revision 1.5  2005/01/14 13:37:55  liekweg
94   Insert purpose descr
95
96   Revision 1.4  2004/12/02 16:17:51  beck
97   fixed config.h include
98
99   Revision 1.3  2004/11/24 14:53:55  liekweg
100   Bugfixes
101
102   Revision 1.2  2004/11/20 21:21:35  liekweg
103   Add pto_ctx_allocs
104
105   Revision 1.1  2004/11/18 16:37:34  liekweg
106   rewritten
107
108
109 */