-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/jiweixing/bit-minic-compiler
- Loading branch information
Showing
45 changed files
with
974 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="lib" path="lib/jdom.jar"/> | ||
<classpathentry kind="lib" path="lib/codegen.jar"/> | ||
<classpathentry kind="lib" path="lib/icgen.jar"/> | ||
<classpathentry kind="lib" path="lib/opt.jar"/> | ||
<classpathentry kind="lib" path="lib/parser.jar"/> | ||
<classpathentry kind="lib" path="lib/pp.jar"/> | ||
<classpathentry kind="lib" path="lib/scanner.jar"/> | ||
<classpathentry kind="lib" path="lib/semantic.jar"/> | ||
<classpathentry kind="lib" path="lib/simulator.jar"/> | ||
<classpathentry kind="lib" path="lib/util.jar"/> | ||
<classpathentry kind="lib" path="lib/jython.jar"/> | ||
<classpathentry kind="lib" path="lib/antlr-4.6-complete.jar"/> | ||
<classpathentry kind="lib" path="lib/Mars4_5.jar"/> | ||
|
||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"> | ||
<attributes> | ||
<attribute name="owner.project.facets" value="java"/> | ||
</attributes> | ||
</classpathentry> | ||
|
||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>BIT-MiniCC-Clean</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.wst.common.project.facet.core.builder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
<nature>org.eclipse.wst.common.project.facet.core.nature</nature> | ||
</natures> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled | ||
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 | ||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve | ||
org.eclipse.jdt.core.compiler.compliance=1.7 | ||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate | ||
org.eclipse.jdt.core.compiler.debug.localVariable=generate | ||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate | ||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error | ||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error | ||
org.eclipse.jdt.core.compiler.source=1.7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<faceted-project> | ||
<installed facet="java" version="1.7"/> | ||
</faceted-project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# bit-minic-compiler | ||
A C compiler framework in Java | ||
|
||
Weixing Ji ([email protected]) <br> | ||
|
||
Contributor:<br> | ||
Yu Hao, 2017<br> | ||
Shuofu Ning, 2016-2017<br> | ||
YiFan Wu, 2015-2016 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 1 addition & 5 deletions
6
bit-minic-clean/src/bit/minisys/minicc/pp/IMiniCCPreProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,5 @@ | ||
package bit.minisys.minicc.pp; | ||
|
||
public interface IMiniCCPreProcessor { | ||
/* | ||
* @return String the path of the output file | ||
* @param iFile input file path | ||
*/ | ||
public String run(String iFile) throws Exception; | ||
public void run(String iFile, String oFile); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 1 addition & 4 deletions
5
bit-minic-clean/src/bit/minisys/minicc/simulator/IMIPSSimulator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,5 @@ | ||
package bit.minisys.minicc.simulator; | ||
|
||
public interface IMIPSSimulator { | ||
/* | ||
* @param input input file path | ||
*/ | ||
public void run(String input) throws Exception; | ||
public void run(String iFile); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<config name="config.xml"> | ||
<phases> | ||
<phase> | ||
<phase skip="false" type="java" path="" name="pp" /> | ||
<phase skip="false" type="java" path="" name="scanning" /> | ||
<phase skip="false" type="java" path="" name="parsing" /> | ||
<phase skip="false" type="java" path="" name="semantic" /> | ||
<phase skip="true" type="java" path="" name="icgen" /> | ||
<phase skip="true" type="java" path="" name="optimizing" /> | ||
<phase skip="false" type="java" path="bit.minisys.minicc.codegen.MiniCCMIPSCodeGen" name="codegen" /> | ||
<phase skip="false" type="java" path="" name="simulating" /> | ||
</phase> | ||
</phases> | ||
</config> | ||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#define NUM 4 | ||
|
||
/* this is a demo program */ | ||
|
||
int main(){ | ||
int a; | ||
int b; | ||
|
||
a = MARS_SCANF_I(); | ||
b = MARS_SCANF_I(); | ||
|
||
a = a + b; | ||
|
||
MARS_PRINTF_I(a); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
|
||
# Code generated from MiniCCompiler at | ||
# input file:D:\projects\bit-minicc\bit-minic-clean\input\test.ic2.xml | ||
# Please do not change this file! | ||
|
||
.data | ||
.text | ||
__init: | ||
# setup the stack | ||
lui $sp, 0x8000 | ||
addi $sp, $sp, 0x0000 | ||
addiu $sp, $sp, -1024 | ||
|
||
# redirect to main function | ||
jal __main | ||
|
||
# make system call to terminate the program | ||
li $v0, 10 | ||
syscall | ||
|
||
|
||
__MARS_SCANF_I: | ||
li $v0, 5 | ||
syscall | ||
move $t0, $v0 | ||
jr $ra | ||
|
||
|
||
__MARS_PRINTF_I: | ||
li $v0, 1 | ||
syscall | ||
jr $ra | ||
|
||
__main: | ||
|
||
# allocate stack frame for the callee | ||
addiu $fp, $sp, 0 | ||
addiu $sp, $sp, -136 | ||
sw $ra, 0($fp) | ||
|
||
sw $a0, 8($fp) | ||
sw $a1, 12($fp) | ||
sw $a2, 16($fp) | ||
sw $a3, 20($fp) | ||
|
||
|
||
jal __MARS_SCANF_I | ||
|
||
lw $ra, 0($fp) | ||
|
||
lw $a0, 8($sp) | ||
lw $a1, 12($sp) | ||
lw $a2, 16($sp) | ||
lw $a3, 20($sp) | ||
|
||
move $t9, $v0 | ||
sw $ra, 0($fp) | ||
|
||
sw $a0, 8($fp) | ||
sw $a1, 12($fp) | ||
sw $a2, 16($fp) | ||
sw $a3, 20($fp) | ||
|
||
|
||
jal __MARS_SCANF_I | ||
|
||
lw $ra, 0($fp) | ||
|
||
lw $a0, 8($sp) | ||
lw $a1, 12($sp) | ||
lw $a2, 16($sp) | ||
lw $a3, 20($sp) | ||
|
||
move $t8, $v0 | ||
add $t9, $t9, $t8 | ||
sw $ra, 0($fp) | ||
|
||
sw $a0, 8($fp) | ||
sw $a1, 12($fp) | ||
sw $a2, 16($fp) | ||
sw $a3, 20($fp) | ||
|
||
move $a0, $25 | ||
|
||
jal __MARS_PRINTF_I | ||
|
||
lw $ra, 0($fp) | ||
|
||
lw $a0, 8($sp) | ||
lw $a1, 12($sp) | ||
lw $a2, 16($sp) | ||
lw $a3, 20($sp) | ||
|
||
addi $v0, $v0, 0 | ||
addiu $sp, $fp, 0 | ||
addiu $fp, $fp, -136 | ||
jr $ra | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<IC name="test.ic.xml"> | ||
<functions> | ||
<function /> | ||
</functions> | ||
</IC> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<IC name="test.ic.xml"> | ||
<functions> | ||
<function /> | ||
</functions> | ||
</IC> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
|
||
int main ( ) { | ||
int a ; | ||
int b ; | ||
|
||
a = MARS_SCANF_I ( ) ; | ||
b = MARS_SCANF_I ( ) ; | ||
|
||
a = a + b ; | ||
|
||
MARS_PRINTF_I ( a ) ; | ||
|
||
return 0 ; | ||
} |
Oops, something went wrong.