-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Code optimizations in implicit codegen (#523)
- Loading branch information
1 parent
3e5f72c
commit e296b4d
Showing
13 changed files
with
96 additions
and
65 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 |
---|---|---|
@@ -1,38 +1,16 @@ | ||
type Visitor struct {} | ||
|
||
type SymbolTable struct {} | ||
|
||
type Visitable interface { | ||
f<bool> accept(Visitor*); | ||
} | ||
|
||
type AstNode struct : Visitable {} | ||
|
||
type AstEntryNode struct : Visitable { | ||
AstNode astNode | ||
SymbolTable* extFunctionScope | ||
bool takesArgs | ||
} | ||
|
||
f<int> main() { | ||
AstEntryNode entryNode; | ||
printf("%d", entryNode.takesArgs); | ||
} | ||
|
||
/*import "bootstrap/util/block-allocator"; | ||
import "bootstrap/util/block-allocator"; | ||
import "bootstrap/util/memory"; | ||
|
||
type ASTNode struct { | ||
int value | ||
} | ||
|
||
p ASTNode.dtor() { | ||
public p ASTNode.dtor() { | ||
printf("Dtor called!"); | ||
} | ||
|
||
f<int> main() { | ||
DefaultMemoryManager defaultMemoryManager; | ||
IMemoryManager* memoryManager = &defaultMemoryManager; | ||
memoryManager.allocate(10l); | ||
//BlockAllocator<ASTNode> allocator = BlockAllocator<ASTNode>(memoryManager, 10l); | ||
}*/ | ||
BlockAllocator<ASTNode> allocator = BlockAllocator<ASTNode>(memoryManager, 10l); | ||
} |
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
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
19 changes: 19 additions & 0 deletions
19
test/test-files/irgenerator/imports/sucess-struct-backwards-dependency/ir-code.ll
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,19 @@ | ||
; ModuleID = 'source.spice' | ||
source_filename = "source.spice" | ||
|
||
%struct.TestStruct = type { %struct.Outer } | ||
%struct.Outer = type { i32 } | ||
|
||
; Function Attrs: noinline nounwind optnone uwtable | ||
define dso_local i32 @main() #0 { | ||
%result = alloca i32, align 4 | ||
%ts = alloca %struct.TestStruct, align 8 | ||
store i32 0, ptr %result, align 4 | ||
call void @_ZN10TestStructI5OuterE4ctorEv(ptr noundef nonnull align 4 dereferenceable(4) %ts) | ||
%1 = load i32, ptr %result, align 4 | ||
ret i32 %1 | ||
} | ||
|
||
declare void @_ZN10TestStructI5OuterE4ctorEv(ptr) | ||
|
||
attributes #0 = { noinline nounwind optnone uwtable } |
9 changes: 9 additions & 0 deletions
9
test/test-files/irgenerator/imports/sucess-struct-backwards-dependency/source.spice
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 @@ | ||
import "source1"; | ||
|
||
type Outer struct { | ||
int i | ||
} | ||
|
||
f<int> main() { | ||
TestStruct<Outer> ts = TestStruct<Outer>(); | ||
} |
13 changes: 13 additions & 0 deletions
13
test/test-files/irgenerator/imports/sucess-struct-backwards-dependency/source1.spice
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,13 @@ | ||
type T dyn; | ||
|
||
type TestStruct<T> struct { | ||
T t | ||
} | ||
|
||
f<int> privateFunction<T>(const T& t) { | ||
return t.i; | ||
} | ||
|
||
public p TestStruct.ctor() { | ||
privateFunction(this.t); | ||
} |