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
2f5d0fa7
Commit
2f5d0fa7
authored
Nov 16, 2022
by
张栋澈
🤡
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Lab4.1] Publish
parent
45c9bd9c
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
14 additions
and
3 deletions
+14
-3
CMakeLists.txt
CMakeLists.txt
+1
-1
include/lightir/BasicBlock.h
include/lightir/BasicBlock.h
+2
-1
include/lightir/Function.h
include/lightir/Function.h
+1
-0
include/lightir/GlobalVariable.h
include/lightir/GlobalVariable.h
+1
-0
include/lightir/Instruction.h
include/lightir/Instruction.h
+1
-0
src/cminusfc/CMakeLists.txt
src/cminusfc/CMakeLists.txt
+1
-0
src/lightir/BasicBlock.cpp
src/lightir/BasicBlock.cpp
+4
-0
src/lightir/Type.cpp
src/lightir/Type.cpp
+2
-1
src/lightir/Value.cpp
src/lightir/Value.cpp
+1
-0
No files found.
CMakeLists.txt
View file @
2f5d0fa7
...
...
@@ -48,6 +48,6 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
include_directories
(
${
PROJECT_SOURCE_DIR
}
)
include_directories
(
${
PROJECT_BINARY_DIR
}
)
include_directories
(
include/lightir
)
include_directories
(
include/optimization
)
add_subdirectory
(
src
)
add_subdirectory
(
tests
)
include/lightir/BasicBlock.h
View file @
2f5d0fa7
...
...
@@ -49,7 +49,7 @@ class BasicBlock : public Value, public llvm::ilist_node<BasicBlock> {
void
add_instr_begin
(
Instruction
*
instr
);
void
delete_instr
(
Instruction
*
instr
);
void
erase_instr
(
Instruction
*
instr
);
bool
empty
()
{
return
instr_list_
.
empty
();
}
int
get_num_of_instr
()
{
return
instr_list_
.
size
();
}
...
...
@@ -60,6 +60,7 @@ class BasicBlock : public Value, public llvm::ilist_node<BasicBlock> {
virtual
std
::
string
print
()
override
;
private:
BasicBlock
(
const
BasicBlock
&
)
=
delete
;
explicit
BasicBlock
(
Module
*
m
,
const
std
::
string
&
name
,
Function
*
parent
);
std
::
list
<
BasicBlock
*>
pre_bbs_
;
std
::
list
<
BasicBlock
*>
succ_bbs_
;
...
...
include/lightir/Function.h
View file @
2f5d0fa7
...
...
@@ -20,6 +20,7 @@ class FunctionType;
class
Function
:
public
Value
,
public
llvm
::
ilist_node
<
Function
>
{
public:
Function
(
const
Function
&
)
=
delete
;
Function
(
FunctionType
*
ty
,
const
std
::
string
&
name
,
Module
*
parent
);
virtual
~
Function
();
static
Function
*
create
(
FunctionType
*
ty
,
const
std
::
string
&
name
,
Module
*
parent
);
...
...
include/lightir/GlobalVariable.h
View file @
2f5d0fa7
...
...
@@ -17,6 +17,7 @@ class GlobalVariable : public User, public llvm::ilist_node<GlobalVariable> {
GlobalVariable
(
std
::
string
name
,
Module
*
m
,
Type
*
ty
,
bool
is_const
,
Constant
*
init
=
nullptr
);
public:
GlobalVariable
(
const
GlobalVariable
&
)
=
delete
;
static
GlobalVariable
*
create
(
std
::
string
name
,
Module
*
m
,
Type
*
ty
,
bool
is_const
,
Constant
*
init
);
virtual
~
GlobalVariable
()
=
default
;
Constant
*
get_init
()
{
return
init_val_
;
}
...
...
include/lightir/Instruction.h
View file @
2f5d0fa7
...
...
@@ -45,6 +45,7 @@ class Instruction : public User, public llvm::ilist_node<Instruction> {
// ty here is result type
Instruction
(
Type
*
ty
,
OpID
id
,
unsigned
num_ops
,
BasicBlock
*
parent
);
Instruction
(
Type
*
ty
,
OpID
id
,
unsigned
num_ops
);
Instruction
(
const
Instruction
&
)
=
delete
;
virtual
~
Instruction
()
=
default
;
inline
const
BasicBlock
*
get_parent
()
const
{
return
parent_
;
}
inline
BasicBlock
*
get_parent
()
{
return
parent_
;
}
...
...
src/cminusfc/CMakeLists.txt
View file @
2f5d0fa7
...
...
@@ -9,6 +9,7 @@ target_link_libraries(
IR_lib
common
syntax
OP_lib
)
install
(
...
...
src/lightir/BasicBlock.cpp
View file @
2f5d0fa7
...
...
@@ -22,6 +22,10 @@ void BasicBlock::delete_instr(Instruction *instr) {
instr_list_
.
remove
(
instr
);
instr
->
remove_use_of_ops
();
}
void
BasicBlock
::
erase_instr
(
Instruction
*
instr
)
{
instr
->
remove_use_of_ops
();
instr_list_
.
erase
(
instr
);
}
const
Instruction
*
BasicBlock
::
get_terminator
()
const
{
if
(
instr_list_
.
empty
())
{
...
...
src/lightir/Type.cpp
View file @
2f5d0fa7
...
...
@@ -114,7 +114,8 @@ IntegerType *IntegerType::get(unsigned num_bits, Module *m) {
}
else
if
(
num_bits
==
32
)
{
return
m
->
get_int32_type
();
}
else
{
assert
(
"IntegerType::get has error num_bits"
);
assert
(
false
and
"IntegerType::get has error num_bits"
);
return
nullptr
;
}
}
...
...
src/lightir/Value.cpp
View file @
2f5d0fa7
...
...
@@ -17,6 +17,7 @@ void Value::replace_all_use_with(Value *new_val) {
assert
(
val
&&
"new_val is not a user"
);
val
->
set_operand
(
use
.
arg_no_
,
new_val
);
}
use_list_
.
clear
();
}
void
Value
::
remove_use
(
Value
*
val
)
{
...
...
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