Added support for lowering to entites, types.
[libfirm] / ir / tr / tpop.c
1 /* Copyright (C) 2001 by Universitaet Karlsruhe
2 ** All rights reserved.
3 **
4 ** Authors: Goetz Lindenmaier
5 **
6 */
7
8 #ifdef HAVE_CONFIG_H
9 # include <config.h>
10 #endif
11
12 # include "tpop_t.h"
13 # include "type_t.h"
14
15 tp_op *type_class;
16 tp_op *type_struct;
17 tp_op *type_method;
18 tp_op *type_union;
19 tp_op *type_array;
20 tp_op *type_enumeration;
21 tp_op *type_pointer;
22 tp_op *type_primitive;
23
24 tp_op *
25 new_tpop (tp_opcode code, ident *name, size_t attr_size)
26 {
27   tp_op *res;
28
29   res = (tp_op *) xmalloc (sizeof (tp_op));
30   res->code = code;
31   res->name = name;
32   res->attr_size = attr_size;
33   return res;
34 }
35
36 void
37 init_tpop(void)
38 {
39   type_class       = new_tpop (tpo_class      , id_from_str("class"      , 5), sizeof (cls_attr));
40   type_struct      = new_tpop (tpo_struct     , id_from_str("struct"     , 6), sizeof (stc_attr));
41   type_method      = new_tpop (tpo_method     , id_from_str("method"     , 6), sizeof (mtd_attr));
42   type_union       = new_tpop (tpo_union      , id_from_str("union"      , 5), sizeof (uni_attr));
43   type_array       = new_tpop (tpo_array      , id_from_str("array"      , 5), sizeof (arr_attr));
44   type_enumeration = new_tpop (tpo_enumeration, id_from_str("enumeration",11), sizeof (enm_attr));
45   type_pointer     = new_tpop (tpo_pointer    , id_from_str("pointer"    , 7), sizeof (ptr_attr));
46   type_primitive   = new_tpop (tpo_primitive  , id_from_str("primitive"  , 9), /* sizeof (pri_attr) */ 0);
47 }
48
49 /* Returns the string for the tp_opcode. */
50 const char  *get_tpop_name      (tp_op *op) {
51   return id_to_str(op->name);
52 }
53
54 tp_opcode get_tpop_code (tp_op *op){
55   return op->code;
56 }
57
58 ident *get_tpop_ident(tp_op *op){
59   return op->name;
60 }
61
62 /* returns the attribute size of the operator. */
63 int get_tpop_attr_size (tp_op *op) {
64   return op->attr_size;
65 }