Skip to content

Commit

Permalink
[compiler] Remove phi type, infer phi.id.type
Browse files Browse the repository at this point in the history
[ghstack-poisoned]
  • Loading branch information
josephsavona committed Aug 22, 2024
1 parent 99d76c2 commit 9e8f62c
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,6 @@ export type Phi = {
kind: 'Phi';
id: Identifier;
operands: Map<BlockId, Identifier>;
type: Type;
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export function printPhi(phi: Phi): string {
const items = [];
items.push(printIdentifier(phi.id));
items.push(printMutableRange(phi.id));
items.push(printType(phi.type));
items.push(printType(phi.id.type));
items.push(': phi(');
const phis = [];
for (const [blockId, id] of phi.operands) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ class SSABuilder {
kind: 'Phi',
id: newId,
operands: predDefs,
type: makeType(),
};

block.phis.add(phi);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export function inferTypes(func: HIRFunction): void {
function apply(func: HIRFunction, unifier: Unifier): void {
for (const [_, block] of func.body.blocks) {
for (const phi of block.phis) {
phi.type = unifier.get(phi.type);
phi.id.type = unifier.get(phi.id.type);
}
for (const instr of block.instructions) {
for (const operand of eachInstructionLValue(instr)) {
Expand Down Expand Up @@ -126,7 +126,7 @@ function* generate(
const returnTypes: Array<Type> = [];
for (const [_, block] of func.body.blocks) {
for (const phi of block.phis) {
yield equation(phi.type, {
yield equation(phi.id.type, {
kind: 'Phi',
operands: [...phi.operands.values()].map(id => id.type),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ export function propagatePhiTypes(fn: HIRFunction): void {
}
if (type !== null) {
phi.id.type = type;
phi.type = type;
propagated.add(phi.id.id);
}
}
Expand Down

0 comments on commit 9e8f62c

Please sign in to comment.