Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
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
0
Merge Requests
0
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
efbf4233
Commit
efbf4233
authored
Dec 02, 2022
by
李晓奇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
follow update
parent
f0f0bb81
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
399 additions
and
187 deletions
+399
-187
.clang-format
.clang-format
+2
-1
Documentations/4.2-gvn/README.md
Documentations/4.2-gvn/README.md
+117
-108
Documentations/4.2-gvn/gvn.pdf
Documentations/4.2-gvn/gvn.pdf
+0
-0
include/lightir/Instruction.h
include/lightir/Instruction.h
+3
-4
include/optimization/GVN.h
include/optimization/GVN.h
+8
-0
src/optimization/.gitignore
src/optimization/.gitignore
+1
-0
src/optimization/GVN.cpp
src/optimization/GVN.cpp
+268
-74
No files found.
.clang-format
View file @
efbf4233
...
...
@@ -6,7 +6,7 @@ AlwaysBreakTemplateDeclarations: true
BinPackArguments: false
BinPackParameters: false
BreakConstructorInitializers: BeforeComma
ColumnLimit:
12
0
ColumnLimit:
8
0
CommentPragmas: '^(!|NOLINT)'
ConstructorInitializerAllOnOneLineOrOnePerLine: true
IncludeBlocks: Regroup
...
...
@@ -23,4 +23,5 @@ PenaltyReturnTypeOnItsOwnLine: 200
SpacesBeforeTrailingComments: 1
TabWidth: 4
UseTab: Never
AlwaysBreakAfterReturnType: TopLevelDefinitions
...
Documentations/4.2-gvn/README.md
View file @
efbf4233
This diff is collapsed.
Click to expand it.
Documentations/4.2-gvn/gvn.pdf
View file @
efbf4233
No preview for this file type
include/lightir/Instruction.h
View file @
efbf4233
...
...
@@ -56,6 +56,7 @@ class Instruction : public User, public llvm::ilist_node<Instruction>
Module
*
get_module
();
OpID
get_instr_type
()
const
{
return
op_id_
;
}
// clang-format off
static
std
::
string
get_instr_op_name
(
OpID
id
)
{
switch
(
id
)
{
case
ret
:
return
"ret"
;
break
;
...
...
@@ -79,12 +80,10 @@ class Instruction : public User, public llvm::ilist_node<Instruction>
case
zext
:
return
"zext"
;
break
;
case
fptosi
:
return
"fptosi"
;
break
;
case
sitofp
:
return
"sitofp"
;
break
;
default:
return
""
;
break
;
default:
return
""
;
break
;
}
}
// clang-format on
std
::
string
get_instr_op_name
()
{
return
get_instr_op_name
(
op_id_
);
}
bool
is_void
()
...
...
include/optimization/GVN.h
View file @
efbf4233
...
...
@@ -159,6 +159,7 @@ class GVN : public Pass {
partitions
join
(
const
partitions
&
P1
,
const
partitions
&
P2
);
std
::
shared_ptr
<
CongruenceClass
>
intersect
(
std
::
shared_ptr
<
CongruenceClass
>
,
std
::
shared_ptr
<
CongruenceClass
>
);
partitions
transferFunction
(
Instruction
*
x
,
Value
*
e
,
partitions
pin
);
partitions
transferFunction
(
BasicBlock
*
bb
);
std
::
shared_ptr
<
GVNExpression
::
PhiExpression
>
valuePhiFunc
(
std
::
shared_ptr
<
GVNExpression
::
Expression
>
,
const
partitions
&
);
std
::
shared_ptr
<
GVNExpression
::
Expression
>
valueExpr
(
Instruction
*
instr
);
...
...
@@ -176,6 +177,10 @@ class GVN : public Pass {
return
std
::
make_shared
<
CongruenceClass
>
(
index
);
}
// self add
//
std
::
uint64_t
new_number
()
{
return
next_value_number_
++
;
}
private:
bool
dump_json_
;
std
::
uint64_t
next_value_number_
=
1
;
...
...
@@ -184,6 +189,9 @@ class GVN : public Pass {
std
::
unique_ptr
<
FuncInfo
>
func_info_
;
std
::
unique_ptr
<
GVNExpression
::
ConstFolder
>
folder_
;
std
::
unique_ptr
<
DeadCode
>
dce_
;
// self add
std
::
map
<
Instruction
*
,
bool
>
_TOP
;
};
bool
operator
==
(
const
GVN
::
partitions
&
p1
,
const
GVN
::
partitions
&
p2
);
src/optimization/.gitignore
0 → 100644
View file @
efbf4233
todo
src/optimization/GVN.cpp
View file @
efbf4233
This diff is collapsed.
Click to expand it.
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