Skip to content

Commit bba56df

Browse files
authored
Merge pull request #8419 from WalterBright/goh.d
convert go.h to goh.d
2 parents f30abcd + 5199769 commit bba56df

4 files changed

Lines changed: 141 additions & 42 deletions

File tree

src/dmd/backend/glocal.d

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import dmd.backend.cdef;
3030
import dmd.backend.code_x86;
3131
import dmd.backend.oper;
3232
import dmd.backend.global;
33+
import dmd.backend.goh;
3334
import dmd.backend.el;
3435
import dmd.backend.ty;
3536
import dmd.backend.type;
@@ -39,46 +40,6 @@ import dmd.backend.dvec;
3940

4041
extern (C++):
4142

42-
alias mftype = uint;
43-
44-
/**********************************
45-
* Definition elem vector, used for reaching definitions.
46-
*/
47-
48-
struct DefNode
49-
{
50-
elem *DNelem; // pointer to definition elem
51-
block *DNblock; // pointer to block that the elem is in
52-
vec_t DNunambig; // vector of unambiguous definitions
53-
}
54-
55-
/* Global Optimizer variables
56-
*/
57-
struct GlobalOptimizer
58-
{
59-
mftype mfoptim;
60-
uint changes; // # of optimizations performed
61-
62-
DefNode *defnod; // array of definition elems
63-
uint deftop; // # of entries in defnod[]
64-
uint defmax; // capacity of defnod[]
65-
uint unambigtop; // number of unambiguous defininitions ( <= deftop )
66-
67-
vec_base_t *dnunambig; // pool to allocate DNunambig vectors from
68-
uint dnunambigmax; // capacity of dnunambig[]
69-
70-
elem **expnod; // array of expression elems
71-
uint exptop; // top of expnod[]
72-
block **expblk; // parallel array of block pointers
73-
74-
vec_t defkill; // vector of AEs killed by an ambiguous definition
75-
vec_t starkill; // vector of AEs killed by a definition of something that somebody could be
76-
// pointing to
77-
vec_t vptrkill; // vector of AEs killed by an access
78-
}
79-
80-
extern __gshared GlobalOptimizer go;
81-
8243
int REGSIZE();
8344

8445

src/dmd/backend/goh.d

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
/**
2+
* Compiler implementation of the
3+
* $(LINK2 http://www.dlang.org, D programming language).
4+
*
5+
* Copyright: Copyright (C) 1986-1998 by Symantec
6+
* Copyright (c) 2000-2017 by Digital Mars, All Rights Reserved
7+
* Authors: $(LINK2 http://www.digitalmars.com, Walter Bright)
8+
* License: Distributed under the Boost Software License, Version 1.0.
9+
* http://www.boost.org/LICENSE_1_0.txt
10+
* Source: https://github.com/dlang/dmd/blob/master/src/dmd/backend/goh.d
11+
*/
12+
13+
module dmd.backend.goh;
14+
15+
import core.stdc.stdio;
16+
import core.stdc.stdlib;
17+
import core.stdc.string;
18+
import core.stdc.time;
19+
20+
import dmd.backend.cc;
21+
import dmd.backend.cdef;
22+
import dmd.backend.oper;
23+
import dmd.backend.global;
24+
import dmd.backend.el;
25+
import dmd.backend.ty;
26+
import dmd.backend.type;
27+
28+
import dmd.backend.dlist;
29+
import dmd.backend.dvec;
30+
31+
extern (C++):
32+
33+
34+
/***************************************
35+
* Bit masks for various optimizations.
36+
*/
37+
38+
alias mftype = uint; /* a type big enough for all the flags */
39+
enum
40+
{
41+
MFdc = 1, // dead code
42+
MFda = 2, // dead assignments
43+
MFdv = 4, // dead variables
44+
MFreg = 8, // register variables
45+
MFcse = 0x10, // global common subexpressions
46+
MFvbe = 0x20, // very busy expressions
47+
MFtime = 0x40, // favor time (speed) over space
48+
MFli = 0x80, // loop invariants
49+
MFliv = 0x100, // loop induction variables
50+
MFcp = 0x200, // copy propagation
51+
MFcnp = 0x400, // constant propagation
52+
MFloop = 0x800, // loop till no more changes
53+
MFtree = 0x1000, // optelem (tree optimization)
54+
MFlocal = 0x2000, // localize expressions
55+
MFall = 0xFFFF, // do everything
56+
}
57+
58+
/**********************************
59+
* Definition elem vector, used for reaching definitions.
60+
*/
61+
62+
struct DefNode
63+
{
64+
elem *DNelem; // pointer to definition elem
65+
block *DNblock; // pointer to block that the elem is in
66+
vec_t DNunambig; // vector of unambiguous definitions
67+
}
68+
69+
/* Global Variables */
70+
//extern __gshared uint[] optab;
71+
72+
/* Global Optimizer variables
73+
*/
74+
struct GlobalOptimizer
75+
{
76+
mftype mfoptim;
77+
uint changes; // # of optimizations performed
78+
79+
DefNode *defnod; // array of definition elems
80+
uint deftop; // # of entries in defnod[]
81+
uint defmax; // capacity of defnod[]
82+
uint unambigtop; // number of unambiguous defininitions ( <= deftop )
83+
84+
vec_base_t *dnunambig; // pool to allocate DNunambig vectors from
85+
uint dnunambigmax; // capacity of dnunambig[]
86+
87+
elem **expnod; // array of expression elems
88+
uint exptop; // top of expnod[]
89+
block **expblk; // parallel array of block pointers
90+
91+
vec_t defkill; // vector of AEs killed by an ambiguous definition
92+
vec_t starkill; // vector of AEs killed by a definition of something that somebody could be
93+
// pointing to
94+
vec_t vptrkill; // vector of AEs killed by an access
95+
}
96+
97+
extern __gshared GlobalOptimizer go;
98+
99+
/* gdag.c */
100+
void builddags();
101+
void boolopt();
102+
void opt_arraybounds();
103+
104+
/* gflow.c */
105+
void flowrd();
106+
void flowlv();
107+
void flowae();
108+
void flowvbe();
109+
void flowcp();
110+
void flowae();
111+
void genkillae();
112+
void flowarraybounds();
113+
int ae_field_affect(elem *lvalue,elem *e);
114+
115+
/* glocal.c */
116+
void localize();
117+
118+
/* gloop.c */
119+
int blockinit();
120+
void compdom();
121+
void loopopt();
122+
void fillInDNunambig(vec_t v, elem *e);
123+
void updaterd(elem *n,vec_t GEN,vec_t KILL);
124+
125+
/* gother.c */
126+
void rd_arraybounds();
127+
void rd_free();
128+
void constprop();
129+
void copyprop();
130+
void rmdeadass();
131+
void elimass(elem *);
132+
void deadvar();
133+
void verybusyexp();
134+
list_t listrds(vec_t, elem *, vec_t);
135+
136+
/* gslice.c */
137+
void sliceStructs();
138+

src/posix.mak

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ BACK_SRC = \
407407
$C/xmm.h $C/obj.h $C/pdata.c $C/cv8.c $C/backconfig.c $C/divcoeff.d \
408408
$C/varstats.c $C/varstats.h $C/dvec.d \
409409
$C/md5.c $C/md5.h \
410-
$C/ph2.c $C/util2.c $C/dwarfeh.c \
410+
$C/ph2.c $C/util2.c $C/dwarfeh.c $C/goh.d \
411411
$(TARGET_CH)
412412

413413
TK_SRC = \

src/win32.mak

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ GLUE_SRCS=$D/irstate.d $D/toctype.d $D/glue.d $D/gluelayer.d $D/todt.d $D/tocsym
180180
BACK_HDRS=$C/cc.d $C/cdef.d $C/cgcv.d $C/code.d $C/cv4.d $C/dt.d $C/el.d $C/global.d \
181181
$C/obj.d $C/oper.d $C/outbuf.d $C/rtlsym.d $C/code_x86.d $C/iasm.d \
182182
$C/ty.d $C/type.d $C/exh.d $C/mach.d $C/md5.d $C/mscoff.d $C/dwarf.d $C/dwarf2.d $C/xmm.d \
183-
$C/dlist.d
183+
$C/dlist.d $C/goh.d
184184

185185
TK_HDRS=
186186

0 commit comments

Comments
 (0)