|
@ -1,8 +1,9 @@ |
|
|
import { expect } from "chai" |
|
|
import { expect } from "chai" |
|
|
|
|
|
import { edgeConnects } from "../lib/data/graph" |
|
|
|
|
|
|
|
|
import { Loc } from "../lib/ir/loc" |
|
|
import { Loc } from "../lib/ir/loc" |
|
|
import type { SSA } from "../lib/ir/ssa" |
|
|
import type { SSA } from "../lib/ir/ssa" |
|
|
import { liveness } from "../lib/live" |
|
|
|
|
|
|
|
|
import { interference, liveness } from "../lib/regalloc" |
|
|
|
|
|
|
|
|
describe("liveness", () => { |
|
|
describe("liveness", () => { |
|
|
it("computes liveness", () => { |
|
|
it("computes liveness", () => { |
|
@ -26,3 +27,18 @@ describe("liveness", () => { |
|
|
expect(info[4]).to.deep.equal(new Set([y[0], x[2]])) |
|
|
expect(info[4]).to.deep.equal(new Set([y[0], x[2]])) |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
describe("interference", () => { |
|
|
|
|
|
it("computes interference", () => { |
|
|
|
|
|
const block: Array<SSA> = [ |
|
|
|
|
|
{ dest: Loc.vari("a"), source: 7 }, |
|
|
|
|
|
{ dest: Loc.vari("b"), source: 3 }, |
|
|
|
|
|
{ dest: Loc.vari("x"), source: Loc.vari("a") } |
|
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
|
|
const info = liveness(block) |
|
|
|
|
|
const g = interference(block, info) |
|
|
|
|
|
|
|
|
|
|
|
expect(edgeConnects(g, "a", "b")).to.be.true |
|
|
|
|
|
}) |
|
|
|
|
|
}) |