Skip to content

Commit 1ecdc1b

Browse files
committed
dotnet 9
1 parent fa3e7b8 commit 1ecdc1b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+368
-68
lines changed

ACompiler.sln

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Optimize.Test", "test\Optim
2525
EndProject
2626
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "CodeGen", "src\CodeGen\CodeGen.fsproj", "{6D000D59-F8E4-4732-A315-B6FCE8E41CDC}"
2727
EndProject
28+
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "CodeGen.Test", "test\CodeGen\CodeGen.Test.fsproj", "{74240E09-AD2A-46B4-A844-F2753394DB33}"
29+
EndProject
2830
Global
2931
GlobalSection(SolutionProperties) = preSolution
3032
HideSolutionNode = FALSE
@@ -146,6 +148,18 @@ Global
146148
{6D000D59-F8E4-4732-A315-B6FCE8E41CDC}.Release|x64.Build.0 = Release|Any CPU
147149
{6D000D59-F8E4-4732-A315-B6FCE8E41CDC}.Release|x86.ActiveCfg = Release|Any CPU
148150
{6D000D59-F8E4-4732-A315-B6FCE8E41CDC}.Release|x86.Build.0 = Release|Any CPU
151+
{74240E09-AD2A-46B4-A844-F2753394DB33}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
152+
{74240E09-AD2A-46B4-A844-F2753394DB33}.Debug|Any CPU.Build.0 = Debug|Any CPU
153+
{74240E09-AD2A-46B4-A844-F2753394DB33}.Debug|x64.ActiveCfg = Debug|Any CPU
154+
{74240E09-AD2A-46B4-A844-F2753394DB33}.Debug|x64.Build.0 = Debug|Any CPU
155+
{74240E09-AD2A-46B4-A844-F2753394DB33}.Debug|x86.ActiveCfg = Debug|Any CPU
156+
{74240E09-AD2A-46B4-A844-F2753394DB33}.Debug|x86.Build.0 = Debug|Any CPU
157+
{74240E09-AD2A-46B4-A844-F2753394DB33}.Release|Any CPU.ActiveCfg = Release|Any CPU
158+
{74240E09-AD2A-46B4-A844-F2753394DB33}.Release|Any CPU.Build.0 = Release|Any CPU
159+
{74240E09-AD2A-46B4-A844-F2753394DB33}.Release|x64.ActiveCfg = Release|Any CPU
160+
{74240E09-AD2A-46B4-A844-F2753394DB33}.Release|x64.Build.0 = Release|Any CPU
161+
{74240E09-AD2A-46B4-A844-F2753394DB33}.Release|x86.ActiveCfg = Release|Any CPU
162+
{74240E09-AD2A-46B4-A844-F2753394DB33}.Release|x86.Build.0 = Release|Any CPU
149163
EndGlobalSection
150164
GlobalSection(NestedProjects) = preSolution
151165
{1774273E-38C7-469B-A0B5-E7E8E8C3869A} = {02728C3A-94D7-4744-98C8-759653EF66B8}
@@ -157,5 +171,6 @@ Global
157171
{72B6A517-8523-44C9-9D82-39FDABFF3255} = {02728C3A-94D7-4744-98C8-759653EF66B8}
158172
{6278C3FF-4A53-4912-91FE-00BDD2C96731} = {70D5758D-BB42-4E90-A32E-8247BCD2B6E2}
159173
{6D000D59-F8E4-4732-A315-B6FCE8E41CDC} = {02728C3A-94D7-4744-98C8-759653EF66B8}
174+
{74240E09-AD2A-46B4-A844-F2753394DB33} = {70D5758D-BB42-4E90-A32E-8247BCD2B6E2}
160175
EndGlobalSection
161176
EndGlobal

src/CodeGen/Arch/Wasm.fs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
module Codegen.Arch.Wasm
2+
3+
open System.Collections.Generic
4+
5+
open Optimize
6+
open FLIR
7+
8+
type Type =
9+
| I32
10+
| I64
11+
| F32
12+
| F64
13+
14+
type Var = { Id: int; name: string }
15+
16+
type BinOp =
17+
| Add
18+
| Sub
19+
| Mul
20+
21+
type Instr =
22+
| LocalDecl of Var * Type
23+
| Const of uint64 * Type
24+
| LocalGet of Var
25+
| LocalSet of Var
26+
| Bin of BinOp

src/CodeGen/CodeGen.fsproj

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2-
32
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
3+
<TargetFramework>net9.0</TargetFramework>
54
<GenerateDocumentationFile>true</GenerateDocumentationFile>
65
</PropertyGroup>
7-
86
<ItemGroup>
97
<Compile Include="Library.fs" />
8+
<Compile Include="Arch/Wasm.fs" />
109
</ItemGroup>
11-
1210
<ItemGroup>
1311
<ProjectReference Include="..\Common\Common.fsproj" />
1412
<ProjectReference Include="..\Optimize\Optimize.fsproj" />
1513
</ItemGroup>
16-
1714
</Project>

src/CodeGen/Library.fs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,25 @@
11
module CodeGen.CodeGen
2+
3+
open Common.Span
4+
open Optimize.FLIR
5+
6+
let deSSA (f: Func) =
7+
let block = f.Block
8+
9+
for idx in 0 .. block.Length - 1 do
10+
let phi = block[idx].Phi
11+
12+
if phi.Count > 0 then
13+
for KeyValue(varId, value) in phi do
14+
for (pred, value) in Array.zip f.CFG[idx].Pred value do
15+
block[pred] <-
16+
{ block[pred] with
17+
Instr =
18+
Array.append
19+
block[pred].Instr
20+
[| Assign
21+
{ Target = varId
22+
Value = value
23+
Span = Span.dummy } |] }
24+
25+
{ f with Block = block }

src/Common/Common.fsproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>net8.0</TargetFramework>
3+
<TargetFramework>net9.0</TargetFramework>
44
<GenerateDocumentationFile>true</GenerateDocumentationFile>
55
</PropertyGroup>
66
<ItemGroup>

src/Optimize/Lower/Env.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ type Env() =
277277
|> Seq.map (fun idx -> resolve idx)
278278
|> Array.ofSeq
279279

280-
let f = removeVarAndBlock f varMapping blockMapping
280+
let f = mapVarAndBlock f varMapping blockMapping
281281

282282
block.Clear()
283283
var.Clear()

src/Optimize/Optimize.fsproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>net8.0</TargetFramework>
3+
<TargetFramework>net9.0</TargetFramework>
44
<GenerateDocumentationFile>true</GenerateDocumentationFile>
55
</PropertyGroup>
66
<ItemGroup>

src/Optimize/Pass/ADCE.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,6 @@ let adceImpl (f: Func) =
9595

9696
let varValue = varLive |> Array.indexed |> Array.map mapVarValue
9797

98-
removeVarAndBlock f varValue (removeOnlyMapping blockLive)
98+
mapVarAndBlock f varValue (removeOnlyMapping blockLive)
9999

100100
let adce = transRegional adceImpl

src/Optimize/Pass/SCCP.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,6 @@ let sccpImpl (f: Func) =
320320

321321
let varValue = seq { 0 .. var.Length - 1 } |> Seq.map getVarValue |> Array.ofSeq
322322

323-
removeVarAndBlock f varValue (removeOnlyMapping blockReachable)
323+
mapVarAndBlock f varValue (removeOnlyMapping blockReachable)
324324

325325
let sccp = transRegional sccpImpl

src/Optimize/SSA.fs

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,6 @@ type SSA(f: Func) =
236236

237237
member _.EdgeSplit(block: ResizeArray<Block>) =
238238
let cfg = ResizeArray(f.CFG)
239-
let dedunt = Dictionary()
240239

241240
for idx in 0 .. f.CFG.Length - 1 do
242241
for sIdx in cfg[idx].Succ do
@@ -245,21 +244,17 @@ type SSA(f: Func) =
245244

246245
if node.Succ.Length > 1 && succ.Pred.Length > 1 then
247246
let newBlock =
248-
if dedunt.ContainsKey sIdx then
249-
dedunt[sIdx]
250-
else
251-
let newBlock = block.Count
252-
dedunt.Add(sIdx, newBlock)
247+
let newBlock = block.Count
253248

254-
block.Add(
255-
{ Phi = Map.empty
256-
Instr = [||]
257-
Trans = Jump { Target = sIdx; Span = Span.dummy } }
258-
)
249+
block.Add(
250+
{ Phi = Map.empty
251+
Instr = [||]
252+
Trans = Jump { Target = sIdx; Span = Span.dummy } }
253+
)
259254

260-
cfg.Add { Pred = [||]; Succ = [| sIdx |] }
255+
cfg.Add { Pred = [||]; Succ = [| sIdx |] }
261256

262-
newBlock
257+
newBlock
263258

264259
let mapBlock id = if id = sIdx then newBlock else id
265260

0 commit comments

Comments
 (0)