Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
2
2022fall-Compiler_CMinus
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
6
Merge Requests
6
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李晓奇
2022fall-Compiler_CMinus
Commits
b1f2b21d
You need to sign in or sign up before continuing.
Commit
b1f2b21d
authored
Dec 05, 2022
by
李晓奇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
finish part
parent
f26d91aa
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
160 additions
and
110 deletions
+160
-110
.gitignore
.gitignore
+1
-0
include/optimization/GVN.h
include/optimization/GVN.h
+21
-10
src/optimization/GVN.cpp
src/optimization/GVN.cpp
+131
-100
tests/4-ir-opt/testcases/GVN/functional/clear.sh
tests/4-ir-opt/testcases/GVN/functional/clear.sh
+4
-0
tests/4-ir-opt/testcases/GVN/performance/clear.sh
tests/4-ir-opt/testcases/GVN/performance/clear.sh
+3
-0
No files found.
.gitignore
View file @
b1f2b21d
...
@@ -2,6 +2,7 @@ build
...
@@ -2,6 +2,7 @@ build
Documentations/1-parser/*.pdf
Documentations/1-parser/*.pdf
compile_commands.json
compile_commands.json
.cache
.cache
.vscode
todo.txt
todo.txt
tmp.cminus
tmp.cminus
include/optimization/GVN.h
View file @
b1f2b21d
...
@@ -204,13 +204,15 @@ class UniqueExpression : public Expression {
...
@@ -204,13 +204,15 @@ class UniqueExpression : public Expression {
}
}
virtual
std
::
string
print
()
{
return
"(UNIQUE "
+
instr_
->
print
()
+
")"
;
}
virtual
std
::
string
print
()
{
return
"(UNIQUE "
+
instr_
->
print
()
+
")"
;
}
bool
equiv
(
const
UniqueExpression
*
other
)
const
{
return
false
;
}
bool
equiv
(
const
UniqueExpression
*
other
)
const
{
return
instr_
==
other
->
instr_
;
}
UniqueExpression
(
Instruction
*
instr
)
UniqueExpression
(
Instruction
*
instr
)
:
Expression
(
e_unique
),
instr_
(
instr
)
{}
:
Expression
(
e_unique
),
instr_
(
instr
)
{}
private:
private:
std
::
shared_ptr
<
Instruction
>
instr_
;
Instruction
*
instr_
;
};
};
}
// namespace GVNExpression
}
// namespace GVNExpression
...
@@ -277,7 +279,7 @@ class GVN : public Pass {
...
@@ -277,7 +279,7 @@ class GVN : public Pass {
BasicBlock
*
bb
);
BasicBlock
*
bb
);
std
::
shared_ptr
<
GVNExpression
::
Expression
>
valueExpr
(
std
::
shared_ptr
<
GVNExpression
::
Expression
>
valueExpr
(
Instruction
*
instr
,
Instruction
*
instr
,
partitions
*
part
=
nullptr
);
const
partitions
&
part
);
std
::
shared_ptr
<
GVNExpression
::
Expression
>
getVN
(
std
::
shared_ptr
<
GVNExpression
::
Expression
>
getVN
(
const
partitions
&
pout
,
const
partitions
&
pout
,
std
::
shared_ptr
<
GVNExpression
::
Expression
>
ve
);
std
::
shared_ptr
<
GVNExpression
::
Expression
>
ve
);
...
@@ -293,11 +295,6 @@ class GVN : public Pass {
...
@@ -293,11 +295,6 @@ class GVN : public Pass {
return
std
::
make_shared
<
CongruenceClass
>
(
index
);
return
std
::
make_shared
<
CongruenceClass
>
(
index
);
}
}
// self add
//
std
::
uint64_t
new_number
()
{
return
next_value_number_
++
;
}
static
int
pretend_copy_stmt
(
Instruction
*
inst
,
BasicBlock
*
bb
);
private:
private:
bool
dump_json_
;
bool
dump_json_
;
std
::
uint64_t
next_value_number_
=
1
;
std
::
uint64_t
next_value_number_
=
1
;
...
@@ -307,10 +304,24 @@ class GVN : public Pass {
...
@@ -307,10 +304,24 @@ class GVN : public Pass {
std
::
unique_ptr
<
GVNExpression
::
ConstFolder
>
folder_
;
std
::
unique_ptr
<
GVNExpression
::
ConstFolder
>
folder_
;
std
::
unique_ptr
<
DeadCode
>
dce_
;
std
::
unique_ptr
<
DeadCode
>
dce_
;
// self add
// self add
member
std
::
map
<
BasicBlock
*
,
bool
>
_TOP
;
std
::
map
<
BasicBlock
*
,
bool
>
_TOP
;
partitions
join_helper
(
BasicBlock
*
pre1
,
BasicBlock
*
pre2
);
partitions
join_helper
(
BasicBlock
*
pre1
,
BasicBlock
*
pre2
);
BasicBlock
*
curr_bb
;
BasicBlock
*
curr_bb
;
//
// self add function
//
std
::
uint64_t
new_number
()
{
return
next_value_number_
++
;
}
static
int
pretend_copy_stmt
(
Instruction
*
inst
,
BasicBlock
*
bb
);
std
::
shared_ptr
<
GVNExpression
::
Expression
>
search_ve
(
Value
*
v
,
const
partitions
&
part
);
std
::
vector
<
std
::
shared_ptr
<
GVNExpression
::
Expression
>>
core_
(
Instruction
*
instr
,
const
partitions
&
part
,
size_t
count
,
bool
fold_
=
true
);
};
};
bool
operator
==
(
const
GVN
::
partitions
&
p1
,
const
GVN
::
partitions
&
p2
);
bool
operator
==
(
const
GVN
::
partitions
&
p1
,
const
GVN
::
partitions
&
p2
);
src/optimization/GVN.cpp
View file @
b1f2b21d
This diff is collapsed.
Click to expand it.
tests/4-ir-opt/testcases/GVN/functional/clear.sh
0 → 100755
View file @
b1f2b21d
rm
-rf
*
.ll
rm
-rf
gvn.json
rm
-rf
`
ls
|
grep
-v
"
\.
"
`
tests/4-ir-opt/testcases/GVN/performance/clear.sh
0 → 100755
View file @
b1f2b21d
rm
-rf
const-prop
rm
-rf
transpose
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment