new SymConst semantics
[libfirm] / ir / tr / tpop_t.h
1 /*
2  * Project:     libFIRM
3  * File name:   ir/tr/tpop_t.h
4  * Purpose:     Opcode of types -- private header.
5  * Author:      Goetz Lindenmaier
6  * Modified by:
7  * Created:
8  * CVS-ID:      $Id$
9  * Copyright:   (c) 2001-2003 Universität Karlsruhe
10  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
11  */
12
13
14 # ifndef _TPOP_T_H_
15 # define _TPOP_T_H_
16
17 # include <stddef.h>
18 # include "tpop.h"
19 /**
20  * @file tpop_t.h
21  *
22  * This file contains the datatypes hidden in tpop.h.
23  *
24  * @autor Goetz Lindenmaier
25  * @see  tpop.h
26  */
27
28 /** The type opcode */
29 struct tp_op {
30   tp_opcode code;
31   ident *name;
32   size_t attr_size;
33 };
34
35 /**
36  *   Returns a new type opcode.
37  *
38  *   Allocates a new tp_op struct and initializes it's fields with
39  *   the passed values.  This function is only to be used during
40  *   initialization of the library.
41  *
42  *   @param code        the enum for this type opcode.
43  *   @param name        an ident for the name of the type opcode.
44  *   @param attr_size   the size of the attributes necessary for a type with
45  *                      this opcode
46  *   @return A new type opcode.
47  *
48  */
49 tp_op *new_tpop (tp_opcode code, ident *name, size_t attr_size);
50
51 /**
52  * Free a tpop datastructure.
53  */
54 void free_tpop(tp_op* tpop);
55
56 /**
57  *   Initialize the tpop module.
58  *
59  *   Must be called during the initizlization of the library. Allocates
60  *   opcodes and sets the globals that are external visible as specified
61  *   in tpop.h.
62  *   Allocates opcodes for classes, struct, method, union, array,
63  *   enumeration, pointer and primitive and sets the according values.
64  */
65 void init_tpop (void);
66
67 /**
68  *  Finalize the topo module.
69  *
70  *  Frees all type opcodes.
71  */
72 void finish_tpop(void);
73
74 /**
75  *   Returns the size of the attribute to this kind
76  *   of type.
77  *
78  *   Internal feature.
79  *
80  *   @param op  The type opcode to get the size for.
81  *   @return The size of the attribute of types with this opcode.
82  *
83  */
84 int get_tpop_attr_size (tp_op *op);
85
86
87 /* ---------------- *
88  * inline functions *
89  * -----------------*/
90
91 static INLINE tp_opcode
92 __get_tpop_code(tp_op *op) {
93   return op->code;
94 }
95
96 static INLINE ident *
97 __get_tpop_ident(tp_op *op){
98   return op->name;
99 }
100
101 static INLINE int
102 __get_tpop_attr_size(tp_op *op) {
103   return op->attr_size;
104 }
105
106 #define get_tpop_code(op)      __get_tpop_code(op)
107 #define get_tpop_ident(op)     __get_tpop_ident(op)
108 #define get_tpop_attr_size(op) __get_tpop_attr_size(op)
109
110 #endif /* _TPOP_T_H_ */