diff --git a/compiler/forget/packages/playground/components/Editor/HIRTabContent.tsx b/compiler/forget/packages/playground/components/Editor/HIRTabContent.tsx
new file mode 100644
index 0000000000..e164fde0e4
--- /dev/null
+++ b/compiler/forget/packages/playground/components/Editor/HIRTabContent.tsx
@@ -0,0 +1,149 @@
+/**
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ */
+
+import clsx from "clsx";
+
+import { HIR } from "babel-plugin-react-forget";
+import { useState } from "react";
+
+const {
+ parseFunctions,
+ Environment,
+ enterSSA,
+ eliminateRedundantPhi,
+ inferReferenceEffects,
+ inferMutableRanges,
+ leaveSSA,
+ lower,
+ printHIR,
+} = HIR;
+
+export default function HIRTabContent({ source }: { source: string }) {
+ const astFunctions = parseFunctions(source);
+
+ const [flags, setFlags] = useState({
+ eliminateRedundantPhi: true,
+ inferReferenceEffects: true,
+ inferMutableRanges: true,
+ leaveSSA: true,
+ });
+
+ return (
+
+
+ {astFunctions.map((func, index): React.ReactNode => {
+ let body;
+ try {
+ const env = new Environment();
+ const ir = lower(func, env);
+ enterSSA(ir, env);
+ if (flags.eliminateRedundantPhi) {
+ eliminateRedundantPhi(ir);
+ }
+ if (flags.inferReferenceEffects) {
+ inferReferenceEffects(ir);
+ }
+ if (flags.inferMutableRanges) {
+ inferMutableRanges(ir);
+ }
+ if (flags.leaveSSA) {
+ leaveSSA(ir);
+ }
+ const textHIR = printHIR(ir.body);
+ body =
{textHIR};
+ } catch (e: any) {
+ body =
error: ${e.toString()}
;
+ }
+ const name = func.node.id?.name ?? "anonymous";
+ return (
+
+
Function: {name}
+ {body}
+
+ );
+ })}
+
+
+
+ );
+}
+
+type Flags = {
+ eliminateRedundantPhi: boolean;
+ inferReferenceEffects: boolean;
+ inferMutableRanges: boolean;
+ leaveSSA: boolean;
+};
+
+function CompilerFlagsEditor({
+ flags,
+ setFlags,
+}: {
+ flags: Flags;
+ setFlags: (flags: Flags) => void;
+}) {
+ return (
+
+
Compiler Options
+
+ {
+ setFlags({ ...flags, eliminateRedundantPhi });
+ }}
+ />
+ {
+ setFlags({ ...flags, inferReferenceEffects });
+ }}
+ />
+ {
+ setFlags({ ...flags, inferMutableRanges });
+ }}
+ />
+ {
+ setFlags({ ...flags, leaveSSA });
+ }}
+ />
+
+
+ );
+}
+
+function LabeledCheckbox({
+ label,
+ value,
+ onChange,
+}: {
+ label: string;
+ value: boolean;
+ onChange: (value: boolean) => void;
+}) {
+ return (
+
+ );
+}
diff --git a/compiler/forget/packages/playground/components/Editor/Output.tsx b/compiler/forget/packages/playground/components/Editor/Output.tsx
index 11d40cfbbc..efc8125eeb 100644
--- a/compiler/forget/packages/playground/components/Editor/Output.tsx
+++ b/compiler/forget/packages/playground/components/Editor/Output.tsx
@@ -19,6 +19,7 @@ import { getSelectedFile, type Store } from "../../lib/stores";
import GraphView from "../GraphView";
import Preview from "../Preview";
import { monacoOptions } from "./monacoOptions";
+import HIRTabContent from "./HIRTabContent";
const MemoizedOutput = memo(Output);
@@ -43,7 +44,7 @@ function Output({ store, updateDiagnostics }: Props) {
tabs={{
Preview: ,
IR: ,
- HIR: ,
+ HIR: ,
CFG: ,
ValGraph: (
diff --git a/compiler/forget/packages/playground/components/Editor/index.tsx b/compiler/forget/packages/playground/components/Editor/index.tsx
index 1e45c80a5d..be4657098f 100644
--- a/compiler/forget/packages/playground/components/Editor/index.tsx
+++ b/compiler/forget/packages/playground/components/Editor/index.tsx
@@ -1,5 +1,8 @@
-/*
- * Copyright (c) Facebook, Inc. and its affiliates.
+/**
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
*/
import { useDrag } from "@use-gesture/react";
@@ -89,7 +92,6 @@ export default function Editor() {
})}
>
-