annotate dmd/backend/Util.d @ 0:10317f0c89a5

Initial commit
author korDen
date Sat, 24 Oct 2009 08:42:06 +0400
parents
children 63623152e82a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1 module dmd.backend.Util;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
3 import dmd.Array;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
4 import dmd.Loc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
5
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
6 import dmd.backend.elem;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
7 import dmd.backend.Symbol;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
8 import dmd.backend.TYPE;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
9 import dmd.backend.SC;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
10 import dmd.backend.dt_t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
11 import dmd.backend.LIST;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
12 import dmd.backend.block;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
13 import dmd.backend.targ_types;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
14 import dmd.backend.SYMIDX;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
15 import dmd.backend.PARAM;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
16 import dmd.backend.Blockx;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
17 import dmd.backend.struct_t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
18 import dmd.backend.BC;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
19 import dmd.backend.code;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
20
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
21 import std.string;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
22
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
23 alias ubyte mangle_t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
24
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
25 alias SC enum_SC;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
26 alias uint SYMFLGS;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
27
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
28 version (MARS) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
29 enum SYM_PREDEF_SZ = 35;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
30 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
31 enum SYM_PREDEF_SZ = 22;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
32 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
33
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
34 //extern (C++) extern {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
35 elem* eictor;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
36 Symbol* ictorlocalgot;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
37 elem* ector;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
38 Array ectorgates;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
39 elem* edtor;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
40 elem* etest;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
41 int dtorcount;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
42 Symbol* localgot;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
43 //}
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
44
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
45 static this()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
46 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
47 ectorgates = new Array();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
48 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
49
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
50 alias uint tym_t; // data type big enough for type masks
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
51 alias elem* elem_p; // data type big enough for type masks
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
52
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
53 void el_setLoc(elem* e, Loc loc) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
54 e.Esrcpos.Sfilename = cast(char*)toStringz(loc.filename);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
55 e.Esrcpos.Slinnum = loc.linnum;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
56 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
57
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
58 void elem_setLoc(elem* e, Loc loc) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
59 return el_setLoc(e, loc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
60 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
61
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
62 struct_t* struct_calloc() {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
63 return cast(struct_t *) mem_fcalloc(struct_t.sizeof);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
64 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
65 ///#define struct_free(st) ((void)(st))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
66
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
67 extern (C++) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
68 void* mem_fcalloc(uint numbytes);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
69 void obj_initfile(const(char)* filename, const(char)* csegname, const(char)* modname);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
70 Symbol* symbol_calloc(const(char)* id);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
71 type* type_fake(tym_t);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
72 dt_t** dtnzeros(dt_t** pdtend, targ_size_t size);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
73 void outdata(Symbol* s);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
74 int reftoident(int seg, targ_size_t offset, Symbol* s, targ_size_t val, int flags);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
75 dt_t ** dtnbytes(dt_t** pdtend, targ_size_t size, const(char)* ptr);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
76 type* type_alloc(tym_t ty);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
77 elem_p el_params(elem_p, ...);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
78 elem_p el_ptr(Symbol*);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
79 elem_p el_long(tym_t, targ_long);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
80 elem_p el_bin(uint, tym_t, elem_p, elem_p);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
81 elem_p el_var(Symbol*);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
82 elem_p el_combine(elem_p, elem_p);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
83 block* block_calloc();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
84 void writefunc(Symbol* sfunc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
85 void obj_termfile();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
86 int objextdef(const(char)* name);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
87 void obj_includelib(const(char)* name);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
88 SYMIDX symbol_add(Symbol* s);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
89 elem* el_param(elem* e1, elem* e2);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
90 elem* el_una(uint op, tym_t ty, elem* e1);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
91 Symbol* symbol_name(const(char)* name, int sclass, type* t);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
92 type* type_setcv(type** pt, tym_t cv);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
93 int type_jparam(type* t);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
94 void obj_export(Symbol* s, uint argsize);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
95 void obj_startaddress(Symbol* s);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
96 void symbol_func(Symbol* s);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
97 type* type_allocn(tym_t, type* tn);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
98 param_t* param_append_type(param_t** pp, type* t);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
99 void block_appendexp(block* b, elem* e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
100 void block_next(Blockx* bctx, BC bc, block* bn);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
101 dt_t** dtxoff(dt_t** pdtend, Symbol* s,targ_size_t offset, tym_t ty);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
102 dt_t** dtdword(dt_t** pdtend, int value);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
103 dt_t** dtabytes(dt_t** pdtend, tym_t ty, targ_size_t offset, targ_size_t size, const(char)* ptr);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
104 void obj_moduleinfo(Symbol* scc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
105 Symbol* symbol_genauto(TYPE* t);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
106 elem* el_same(elem**);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
107 void el_free(elem*);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
108 Symbol* symbol_generate(int sclass, type* t);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
109 elem* el_calloc();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
110 void dt_optimize(dt_t* dt);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
111 type* type_setty(type**, int);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
112 type* type_setmangle(type** pt, mangle_t mangle);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
113 list_t list_append(list_t* plist, void* ptr);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
114 dt_t** dtcat(dt_t** pdtend, dt_t* dt);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
115 elem_p el_copytree(elem_p);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
116 elem_p el_pair(tym_t, elem_p, elem_p);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
117 int el_allbits(elem *e, int bit);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
118 block* block_goto(Blockx* bctx, BC bc, block* bn);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
119 block* block_calloc(Blockx* blx);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
120 targ_size_t type_paramsize_i(type* t);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
121 int os_critsecsize();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
122 void el_setVolatile(elem* e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
123 elem* exp2_copytotemp(elem* e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
124 elem* el_const(tym_t, eve*);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
125 elem *el_params(void** args, int length);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
126
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
127 void cod3_thunk(Symbol* sthunk, Symbol* sfunc, uint p, tym_t thisty, targ_size_t d, int i, targ_size_t d2);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
128
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
129 version (SEH) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
130 void nteh_declarvars(Blockx* bx);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
131 elem* nteh_setScopeTableIndex(Blockx* blx, int scope_index);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
132 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
133 }