-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
242f31a
commit 8e0446e
Showing
11 changed files
with
171 additions
and
15 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 |
---|---|---|
|
@@ -164,3 +164,5 @@ Thumbs.db | |
output/ | ||
*.bin | ||
*.o | ||
*.ll | ||
/bin/ |
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 |
---|---|---|
|
@@ -6,9 +6,8 @@ public class Darkmatter { | |
public static final String VERSION = "0.1.0"; | ||
|
||
|
||
|
||
|
||
|
||
|
||
public Darkmatter() { | ||
|
||
} | ||
|
||
} |
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
2 changes: 1 addition & 1 deletion
2
...yw/darkmatter/syntax/CompilerMessage.java → .../darkmatter/compiler/CompilerMessage.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,4 +1,4 @@ | ||
package me.anthonyw.darkmatter.syntax; | ||
package me.anthonyw.darkmatter.compiler; | ||
|
||
public enum CompilerMessage { | ||
|
||
|
7 changes: 6 additions & 1 deletion
7
...w/darkmatter/syntax/CompilerSeverity.java → ...darkmatter/compiler/CompilerSeverity.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
11 changes: 11 additions & 0 deletions
11
src/main/java/me/anthonyw/darkmatter/compiler/JvmCompilable.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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package me.anthonyw.darkmatter.compiler; | ||
|
||
public abstract class JvmCompilable { | ||
|
||
/** | ||
* This will generate JVM byte-code | ||
* @return | ||
*/ | ||
public abstract String jvmCodeGen(); | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/me/anthonyw/darkmatter/compiler/LlvmAssembly.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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package me.anthonyw.darkmatter.compiler; | ||
|
||
import me.anthonyw.darkmatter.compiler.llvm.LlvmOpCode; | ||
|
||
public class LlvmAssembly { | ||
|
||
private final LlvmOpCode opcode; | ||
private final Object[] args; | ||
|
||
public LlvmAssembly(final LlvmOpCode opcode, Object...args) { | ||
this.opcode = opcode; | ||
this.args = args; | ||
} | ||
|
||
public LlvmOpCode getOpCode() { | ||
return opcode; | ||
} | ||
|
||
public Object[] getArgs() { | ||
return args; | ||
} | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/me/anthonyw/darkmatter/compiler/LlvmCompilable.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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package me.anthonyw.darkmatter.compiler; | ||
|
||
public abstract class LlvmCompilable { | ||
|
||
public abstract String llvmCodeGen(); | ||
|
||
} |
5 changes: 5 additions & 0 deletions
5
src/main/java/me/anthonyw/darkmatter/compiler/jvm/JvmOpCode.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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package me.anthonyw.darkmatter.compiler.jvm; | ||
|
||
public enum JvmOpCode { | ||
|
||
} |
93 changes: 93 additions & 0 deletions
93
src/main/java/me/anthonyw/darkmatter/compiler/llvm/LlvmOpCode.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 |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package me.anthonyw.darkmatter.compiler.llvm; | ||
|
||
public enum LlvmOpCode { | ||
|
||
COMMENT(";"), | ||
|
||
RETURN("ret"), | ||
|
||
BR("br"), | ||
|
||
SWITCH("switch"), | ||
|
||
INVOKE("invoke"), | ||
|
||
UNWIND("unwind"), | ||
|
||
UNREACHABLE("unreachable"), | ||
|
||
|
||
// BINARY | ||
|
||
|
||
/** | ||
* Addition | ||
* | ||
* Description: | ||
* <p> | ||
* The 'add' instruction returns the sum of its two operands. | ||
* </p> | ||
* | ||
* Example: | ||
* <p> | ||
* {result} = add {type} {var1} {var2} | ||
* {result} = add i32 4, %var | ||
* </p> | ||
*/ | ||
ADD("add"), | ||
|
||
/** | ||
* Subtraction | ||
* | ||
* <p> | ||
* The value produced is the integer or floating point difference of the two operands. | ||
* </p> | ||
* | ||
* <result> = sub <type> <var1> <var2> | ||
* <result> = sub i32 4, %var | ||
*/ | ||
SUBTRACT("sub"), | ||
|
||
/** | ||
* Multiply | ||
* | ||
* <p> | ||
* The value produced is the integer or floating point product of the two operands. | ||
* Because the operands are the same width, the result of an integer multiplication is the same whether the operands should be deemed unsigned or signed. | ||
* </p> | ||
* | ||
* <result> = mul i32 4, %var | ||
*/ | ||
MULTIPLY("mul"), | ||
|
||
/** | ||
* Unsigned division | ||
* | ||
* <result> = udiv <type> <var1>, <var2> | ||
*/ | ||
DIVISION_UNSIGNED("udiv"), | ||
|
||
|
||
/** | ||
* Signed division | ||
* | ||
* <p> | ||
* The value produced is the unsigned integer quotient of the two operands. | ||
* This instruction always performs an unsigned division operation, regardless of whether the arguments are unsigned or not. | ||
* </p> | ||
* | ||
* <result> = sdiv <type> <var1>, <var2> | ||
*/ | ||
DIVISION_SIGNED("sdiv"); | ||
|
||
private final String opcode; | ||
|
||
private LlvmOpCode(final String opcode) { | ||
this.opcode = opcode; | ||
} | ||
|
||
public String getOpCode() { | ||
return opcode; | ||
} | ||
|
||
} |
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