OptLevel
이 페이지에서

OptLevel

타입, 출력 분류

A named optimization level, spelled like a C compiler's -O flag.

import type { OptLevel } from 'typeshade'

시그니처, 설명, 예제는 커밋 c66579bf의 컴파일러 소스에서 그대로 가져온 영어 원문입니다.

구문

type OptLevel = 'O0' | 'O1' | 'O2';

설명

The distinction that matters to a caller is between 'O1' and 'O2', and it concerns whether computed values can change:

  • 'O0': no pass runs. The module is emitted as authored, which makes it the size baseline to compare the other levels against.
  • 'O1': only the passes that move or remove values without changing which floating-point operations execute (constant and copy propagation, dead-branch removal, common-subexpression elimination, dead-code elimination). Every value an O1 build computes at runtime is bit-identical to the O0 build’s, on every target.
  • 'O2': the full pipeline, and the default for every emit function. Adds constant folding on floats, algebraic simplification and loop-invariant code motion. These passes can reorder or replace floating-point operations, so a computed value is not guaranteed to be bit-identical to the O0 build’s.

Choose 'O1' when a build must be provably value-identical to the unoptimized one, and 'O2' otherwise. Pass a level to emitModuleAt to emit WGSL at it, or to lowerWgsl to get the optimized module without emitting text.

함께 보기

소스

src/core/passes/opt/optimize.ts, 297행, 커밋 c66579bf 기준

이 페이지 편집 문제 보고