7822533aff39079b2d131fef6fb438478c0b4610
[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 /** possible flags for a type opcode */
29 enum tp_op_flags_t {
30   TP_OP_FLAG_COMPOUND = 1   /**< is a compound type */
31 };
32
33 /** The type opcode */
34 struct tp_op {
35   tp_opcode code;       /**< the tpop code */
36   ident *name;          /**< the name of the type opcode */
37   size_t attr_size;     /**< the attribute size for a type of this opcode */
38   unsigned flags;       /**< flags for this opcode */
39 };
40
41 /**
42  *   Returns a new type opcode.
43  *
44  *   Allocates a new tp_op struct and initializes it's fields with
45  *   the passed values.  This function is only to be used during
46  *   initialization of the library.
47  *
48  *   @param code        the enum for this type opcode.
49  *   @param name        an ident for the name of the type opcode.
50  *   @param flags       additional flags
51  *   @param attr_size   the size of the attributes necessary for a type with
52  *                      this opcode
53  *   @return A new type opcode.
54  */
55 tp_op *new_tpop (tp_opcode code, ident *name, unsigned flags, size_t attr_size);
56
57 /**
58  * Free a tpop datastructure.
59  */
60 void free_tpop(tp_op* tpop);
61
62 /**
63  *   Initialize the tpop module.
64  *
65  *   Must be called during the initialization of the library. Allocates
66  *   opcodes and sets the globals that are external visible as specified
67  *   in tpop.h.
68  *   Allocates opcodes for classes, struct, method, union, array,
69  *   enumeration, pointer and primitive and sets the according values.
70  */
71 void init_tpop (void);
72
73 /**
74  *  Finalize the tpop module.
75  *
76  *  Frees all type opcodes.
77  */
78 void finish_tpop(void);
79
80 /**
81  *   Returns the size of the attribute to this kind
82  *   of type.
83  *
84  *   Internal feature.
85  *
86  *   @param op  The type opcode to get the size for.
87  *   @return The size of the attribute of types with this opcode.
88  *
89  */
90 int get_tpop_attr_size (const tp_op *op);
91
92
93 /* ---------------- *
94  * inline functions *
95  * -----------------*/
96
97 static INLINE tp_opcode
98 __get_tpop_code(const tp_op *op) {
99   return op->code;
100 }
101
102 static INLINE ident *
103 __get_tpop_ident(const tp_op *op){
104   return op->name;
105 }
106
107 static INLINE int
108 __get_tpop_attr_size(const tp_op *op) {
109   return op->attr_size;
110 }
111
112 #define get_tpop_code(op)      __get_tpop_code(op)
113 #define get_tpop_ident(op)     __get_tpop_ident(op)
114 #define get_tpop_attr_size(op) __get_tpop_attr_size(op)
115
116 #endif /* _TPOP_T_H_ */