@lordcraymen/ir-compiler-passes
v0.1.0
Published
Pass infrastructure for IR transformations
Maintainers
Readme
@lordcraymen/ir-compiler-passes
Pass infrastructure for IR transformations.
Overview
This package provides the foundation for creating IR transformation passes. Passes are pure functions that transform IR programs, allowing you to enrich, validate, or optimize your IR before code generation.
Features
- Pass Interface: Simple
IRProgram → IRProgramtransformation contract - Pass Pipeline: Chain multiple passes together
- Target-Agnostic: Passes work with IR structure, not specific targets
Usage
import { runPasses, type Pass } from '@lordcraymen/ir-compiler-passes';
import type { IRProgram } from '@lordcraymen/ir-core';
// Define a pass
const myPass: Pass = {
name: 'my-transformation',
transform(ir, options) {
// Transform IR and return new IR
return transformedIR;
}
};
// Run passes
const enrichedIR = runPasses(originalIR, [
myPass,
anotherPass
]);Architecture
Passes use metadata on IR nodes to communicate with targets:
const visibilityPass: Pass = {
name: 'visibility',
transform(ir) {
// Add metadata that targets can respect
return addMetadata(ir, { public: true });
}
};License
UNLICENSED
