[hir] Move inference passes to separate folder
Sathya Gunasekaran committed
Jan 4, 2023 at 21:11 UTC
b8fd4680b1fc89f08ffb2bb8ded3000c516e1d90
10 files changed
+38
-21
compiler/forget/src/CompilerPipeline.ts
+2
-7
@@ -6,13 +6,8 @@
6
*/
7
import { NodePath } from "@babel/traverse";
8
import * as t from "@babel/types";
9
-import {
10
- Environment,
11
- HIRFunction,
12
- inferMutableRanges,
13
- inferReferenceEffects,
14
- lower,
15
-} from "./HIR";
9
+import { inferMutableRanges, inferReferenceEffects } from "./Inference";
10
+import { Environment, HIRFunction, lower } from "./HIR";
11
import { ReactiveFunction } from "./HIR/HIR";
12
import {
13
buildReactiveFunction,
compiler/forget/src/HIR/index.ts
-2
@@ -8,6 +8,4 @@
8
export { lower } from "./BuildHIR";
9
export { HIRFunction } from "./HIR";
10
export { Environment } from "./HIRBuilder";
11
-export { inferMutableRanges } from "./InferMutableRanges";
12
-export { default as inferReferenceEffects } from "./InferReferenceEffects";
11
export { printFunction } from "./PrintHIR";
compiler/forget/src/Inference/InferAlias.ts
renamed
+7
-1
@@ -1,5 +1,11 @@
1
import DisjointSet from "../Utils/DisjointSet";
2
-import { HIRFunction, Identifier, Instruction, LValue, Place } from "./HIR";
2
+import {
3
+ HIRFunction,
4
+ Identifier,
5
+ Instruction,
6
+ LValue,
7
+ Place,
8
+} from "../HIR/HIR";
9
10
export type AliasSet = Set<Identifier>;
11
compiler/forget/src/Inference/InferAliasForStores.ts
renamed
+7
-1
@@ -5,7 +5,13 @@
5
* LICENSE file in the root directory of this source tree.
6
*/
7
import DisjointSet from "../Utils/DisjointSet";
8
-import { Effect, HIRFunction, Identifier, InstructionId, Place } from "./HIR";
8
+import {
9
+ Effect,
10
+ HIRFunction,
11
+ Identifier,
12
+ InstructionId,
13
+ Place,
14
+} from "../HIR/HIR";
15
16
export function inferAliasForStores(
17
func: HIRFunction,
compiler/forget/src/Inference/InferMutableLifetimes.ts
renamed
+3
-3
@@ -13,9 +13,9 @@ import {
13
Instruction,
14
makeInstructionId,
15
Place,
16
-} from "./HIR";
17
-import { printInstruction, printPlace } from "./PrintHIR";
18
-import { eachInstructionOperand } from "./visitors";
16
+} from "../HIR/HIR";
17
+import { printInstruction, printPlace } from "../HIR/PrintHIR";
18
+import { eachInstructionOperand } from "../HIR/visitors";
19
20
/**
21
* For each usage of a value in the given function, determines if the usage
compiler/forget/src/Inference/InferMutableRanges.ts
renamed
+1
-1
@@ -5,7 +5,7 @@
5
* LICENSE file in the root directory of this source tree.
6
*/
7
8
-import { HIRFunction } from "./HIR";
8
+import { HIRFunction } from "../HIR/HIR";
9
import { inferAliases } from "./InferAlias";
10
import { inferAliasForStores } from "./InferAliasForStores";
11
import { inferMutableLifetimes } from "./InferMutableLifetimes";
compiler/forget/src/Inference/InferMutableRangesForAlias.ts
renamed
+1
-1
@@ -1,5 +1,5 @@
1
import DisjointSet from "../Utils/DisjointSet";
2
-import { Identifier, InstructionId } from "./HIR";
2
+import { Identifier, InstructionId } from "../HIR/HIR";
3
4
export function inferMutableRangesForAlias(aliases: DisjointSet<Identifier>) {
5
const aliasSets = aliases.buildSets();
compiler/forget/src/Inference/InferReferenceEffects.ts
renamed
+7
-3
@@ -18,13 +18,17 @@ import {
18
Phi,
19
Place,
20
ValueKind,
21
-} from "./HIR";
22
-import { printMixedHIR, printPlace, printSourceLocation } from "./PrintHIR";
21
+} from "../HIR/HIR";
22
+import {
23
+ printMixedHIR,
24
+ printPlace,
25
+ printSourceLocation,
26
+} from "../HIR/PrintHIR";
27
import {
28
eachInstructionOperand,
29
eachTerminalOperand,
30
eachTerminalSuccessor,
27
-} from "./visitors";
31
+} from "../HIR/visitors";
32
33
/**
34
* For every usage of a value in the given function, infers the effect or action
compiler/forget/src/Inference/index.ts
new
+9
@@ -0,0 +1,9 @@
1
+/**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+export { inferMutableRanges } from "./InferMutableRanges";
9
+export { default as inferReferenceEffects } from "./InferReferenceEffects";
compiler/forget/src/index.ts
+1
-2
@@ -17,8 +17,7 @@ import * as t from "@babel/types";
17
import { lower } from "./HIR/BuildHIR";
18
import codegen from "./HIR/Codegen";
19
import { Environment } from "./HIR/HIRBuilder";
20
-import { inferMutableRanges } from "./HIR/InferMutableRanges";
21
-import inferReferenceEffects from "./HIR/InferReferenceEffects";
20
+import { inferMutableRanges, inferReferenceEffects } from "./Inference";
21
import { inferTypes } from "./TypeInference";
22
import printHIR, { printFunction } from "./HIR/PrintHIR";
23
import { buildReactiveFunction } from "./ReactiveScopes/BuildReactiveFunction";