Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[compiler] Remove phi type, infer phi.id.type #30795

Merged
merged 1 commit into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading