Skip to content

Commit 0a90917

Browse files
committed
Initial commit
1 parent b32d4d9 commit 0a90917

File tree

327 files changed

+100070
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

327 files changed

+100070
-1
lines changed

AUTHORS.txt

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
The file lists people who have have contributed to XOC project.
2+
If you have contributed a patch or made some other contribution to XOC,
3+
please submit a patch to this file to add yourself, and it will be done!
4+
5+
Su Zhenyu, [email protected], primary architect of XOC
6+
GongKai, [email protected], dex2dex and LIR convertor
7+
JinYue, , dex2dex and LIR convertor
8+
Guo XiaoXin, [email protected],

Makefile

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
COM_OBJS +=\
2+
com/ltype.o \
3+
com/comf.o \
4+
com/smempool.o \
5+
com/sgraph.o \
6+
com/rational.o \
7+
com/flty.o \
8+
com/bs.o
9+
10+
OPT_OBJS +=\
11+
opt/cfs_opt.o\
12+
opt/dbg.o\
13+
opt/goto_opt.o\
14+
opt/if_opt.o \
15+
opt/ir.o\
16+
opt/ir_bb.o\
17+
opt/ir_du.o\
18+
opt/ir_cfg.o\
19+
opt/ir_simp.o\
20+
opt/ir_gvn.o\
21+
opt/ir_rce.o\
22+
opt/ir_dce.o\
23+
opt/ir_cp.o\
24+
opt/ir_lcse.o\
25+
opt/ir_gcse.o\
26+
opt/ir_licm.o\
27+
opt/ir_ivr.o\
28+
opt/ir_middle_opt.o\
29+
opt/ir_high_opt.o\
30+
opt/ir_expr_tab.o\
31+
opt/cdg.o\
32+
opt/ir_refine.o\
33+
opt/ir_rp.o\
34+
opt/ir_aa.o\
35+
opt/ir_ssa.o\
36+
opt/label.o\
37+
opt/data_type.o \
38+
opt/option.o\
39+
opt/region.o\
40+
opt/util.o\
41+
opt/var.o\
42+
opt/md.o\
43+
opt/cfs_mgr.o\
44+
opt/pass_mgr.o\
45+
opt/inliner.o\
46+
opt/ipa.o\
47+
opt/callg.o\
48+
opt/prdf.o
49+
50+
CFLAGS = -DFOR_DEX -D_DEBUG_ -D_LINUX_ -Wno-write-strings -Wsign-promo \
51+
-Wsign-compare -Wpointer-arith -Wno-multichar -Winit-self \
52+
-Wstrict-aliasing=3 -finline-limit=10000000 -Wswitch #-Wall
53+
#-Werror=overloaded-virtual \
54+
55+
INC=-I opt -I com -I dex -I .
56+
%.o:%.cpp
57+
@echo "build $<"
58+
gcc $(CFLAGS) $(INC) -O2 -c -g2 $< -o $@
59+
60+
com_objs: $(COM_OBJS)
61+
opt_objs: $(OPT_OBJS)
62+
63+
all: com_objs opt_objs
64+
ar rcs libxoc.a $(COM_OBJS) $(OPT_OBJS)
65+
@echo "success!!"
66+
67+
clean:
68+
@find -name "*.o" | xargs rm -f
69+
@find -name "*.a" | xargs rm -f
70+
@find -name "*.dot" | xargs rm -f
71+
@find -name "*.exe" | xargs rm -f
72+
@find -name "*.elf" | xargs rm -f
73+
@find -name "*.out" | xargs rm -f
74+
@find -name "*.tmp" | xargs rm -f
75+
@find -name "*.vcg" | xargs rm -f
76+
@find -name "*.cxx" | xargs rm -f
77+
@find -name "*.asm" | xargs rm -f
78+

README.md

+31-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,32 @@
11
# xoc
2-
XOC is a compiler infrastructure that provides multi-level operations, flexibility, and the capability of representing almost all popular languages. There are two level IR representations used throughout all phases of the compilation.
2+
3+
Welcome to use XOC
4+
5+
What does XOC mean
6+
eXtremely Optimizing Compiler.
7+
We build XOC compiler that intent to be a finely honed tool to squeezing
8+
the last performance out of ordinary code.
9+
10+
Contribution and License Agreement
11+
If you contribute code to this project, you are implicitly allowing your
12+
code to be distributed under the BSD license.
13+
14+
Your ideas have no limits.
15+
Surprisingly powerful.
16+
Why let programming tools shackle your mind?
17+
XOC was designed for extensibility.
18+
Tailoring and retargeting the compiler is easy, and fun.
19+
20+
Truly open.
21+
XOC is not just open-source, it is open from end to end.
22+
You can tune its syntax, add new instructions, integrate arbitrary system
23+
capabilities, enforce custom policies, add specific optimizations ...
24+
25+
XOC is a compiler infrastructure that provides multi-level operations,
26+
flexibility, and the capability of representing almost all popular languages.
27+
There are two level IR representations used throughout all phases of the
28+
compilation.
29+
30+
Build:
31+
cd xoc
32+
make all

Roadmap.txt

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2015 ~ 2016
2+
1. Correctness.
3+
2. New analysis module: Induction Variable Recognization
4+
3. Enable the support to JavaScript.
5+
4. SSA-back translation for exception block.
6+
5. Test environment.

com/agraph.cpp

+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
/*@
2+
XOC Release License
3+
4+
Copyright (c) 2013-2014, Alibaba Group, All rights reserved.
5+
6+
7+
8+
Redistribution and use in source and binary forms, with or without
9+
modification, are permitted provided that the following conditions are met:
10+
11+
* Redistributions of source code must retain the above copyright
12+
notice, this list of conditions and the following disclaimer.
13+
* Redistributions in binary form must reproduce the above copyright
14+
notice, this list of conditions and the following disclaimer in the
15+
documentation and/or other materials provided with the distribution.
16+
* Neither the name of the Su Zhenyu nor the names of its contributors
17+
may be used to endorse or promote products derived from this software
18+
without specific prior written permission.
19+
20+
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
21+
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22+
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
24+
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
26+
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
27+
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28+
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29+
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
30+
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31+
32+
author: Su Zhenyu
33+
@*/
34+
#include "ltype.h"
35+
#include "smempool.h"
36+
#include "sstl.h"
37+
#include "matt.h"
38+
#include "bs.h"
39+
#include "sgraph.h"
40+
#include "agraph.h"
41+
42+
//Build matrix to describe edge-weight.
43+
void AGRAPH::build_adj_matrix(MATRIX<UINT> & adj_mat)
44+
{
45+
IS_TRUE(0, ("Target Dependent Code"));
46+
//Like: adj_mat.set(i, j, EDGE-WEIGHT);
47+
}
48+
49+
50+
/*
51+
Nonrecursive algo to compute the shorest-path.
52+
See <Shortest_Path-Dijkstra.txt>
53+
'infinite': the value indiates infinity.
54+
*/
55+
void AGRAPH::shortest_path(UINT infinite)
56+
{
57+
IS_TRUE(m_pool != NULL, ("not yet initialized."));
58+
MATRIX<UINT> adj_mat;
59+
build_adj_matrix(adj_mat);
60+
UINT row = adj_mat.get_row_size();
61+
UINT col = adj_mat.get_col_size();
62+
UINT i,j,k,min,v1,v2;
63+
if (m_spath_mat != NULL) { delete m_spath_mat; }
64+
m_spath_mat = new MATRIX<UINT>(row, col);
65+
m_spath_mat->set_all(infinite);
66+
67+
//Init path matrix
68+
for (i = 0; i < row; i++) {
69+
for (j = 0; j < col; j++) {
70+
v1 = adj_mat.get(i,j);
71+
if (v1 != infinite) {
72+
m_spath_mat->set(i, j, i);
73+
}
74+
}
75+
}
76+
for (i = 0; i < row; i++) {
77+
min = infinite;
78+
for (j = 0; j < col; j++) {
79+
for (k = 0; k < row; k++) {
80+
v1 = adj_mat.get(k, j);
81+
v2 = adj_mat.get(i, k);
82+
if ((v1 != infinite) && (v2 != infinite)) {
83+
if (min > (v1 + v2)) {
84+
min = v1 + v2;
85+
m_spath_mat->set(i, j, k);
86+
}
87+
}
88+
}
89+
IS_TRUE(min <= infinite, ("exception occur in shortest_path"));
90+
if (min != infinite) {
91+
adj_mat.set(i, j, min);
92+
}
93+
min = infinite;
94+
}
95+
}
96+
}
97+

com/agraph.h

+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
/*@
2+
XOC Release License
3+
4+
Copyright (c) 2013-2014, Alibaba Group, All rights reserved.
5+
6+
7+
8+
Redistribution and use in source and binary forms, with or without
9+
modification, are permitted provided that the following conditions are met:
10+
11+
* Redistributions of source code must retain the above copyright
12+
notice, this list of conditions and the following disclaimer.
13+
* Redistributions in binary form must reproduce the above copyright
14+
notice, this list of conditions and the following disclaimer in the
15+
documentation and/or other materials provided with the distribution.
16+
* Neither the name of the Su Zhenyu nor the names of its contributors
17+
may be used to endorse or promote products derived from this software
18+
without specific prior written permission.
19+
20+
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
21+
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22+
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
24+
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
26+
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
27+
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28+
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29+
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
30+
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31+
32+
author: Su Zhenyu
33+
@*/
34+
#ifndef __A_GRAPH_H_
35+
#define __A_GRAPH_H_
36+
37+
//Alogrithmic Graph.
38+
class AGRAPH : public GRAPH {
39+
protected:
40+
MATRIX<UINT> * m_spath_mat; //record shortest-path.
41+
void build_adj_matrix(MATRIX<UINT> & adj_mat);
42+
public:
43+
AGRAPH(UINT edge_hash_size = 47, UINT vex_hash_size = 47) :
44+
GRAPH(edge_hash_size, vex_hash_size)
45+
{
46+
m_edge_hash_size = edge_hash_size;
47+
m_vex_hash_size = vex_hash_size;
48+
m_spath_mat = NULL;
49+
}
50+
51+
AGRAPH(AGRAPH & g) : GRAPH(g)
52+
{
53+
m_edge_hash_size = g.m_edge_hash_size;
54+
m_vex_hash_size = g.m_vex_hash_size;
55+
clone(g);
56+
}
57+
58+
virtual ~AGRAPH()
59+
{
60+
if (m_spath_mat != NULL) {
61+
delete m_spath_mat;//Delete shortest path matrix
62+
m_spath_mat = NULL;
63+
}
64+
}
65+
66+
bool clone(AGRAPH & src)
67+
{
68+
if (src.m_spath_mat != NULL) {
69+
if (m_spath_mat == NULL) {
70+
m_spath_mat = new MATRIX<UINT>(*src.m_spath_mat);
71+
} else {
72+
m_spath_mat->copy(*src.m_spath_mat);
73+
}
74+
} else {
75+
delete m_spath_mat;
76+
m_spath_mat = NULL;
77+
}
78+
}
79+
80+
UINT count_mem() const
81+
{
82+
UINT count = GRAPH::count_mem();
83+
if (m_spath_mat != NULL) {
84+
count += m_spath_mat->count_mem();
85+
}
86+
}
87+
88+
void shortest_path(UINT infinite);
89+
90+
//Erasing graph, include all nodes and edges,
91+
//except for mempool, freelist.
92+
void erasure()
93+
{
94+
if (m_spath_mat != NULL) {
95+
delete m_spath_mat; //Delete shortest path matrix
96+
m_spath_mat = NULL;
97+
}
98+
GRAPH::erasure();
99+
}
100+
};
101+
#endif
102+

0 commit comments

Comments
 (0)