-
-
Notifications
You must be signed in to change notification settings - Fork 71
fix: improve runtime ternary support by refining side-effect detection #2615
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
base: main
Are you sure you want to change the base?
Changes from all commits
fed3aa2
89e4f5d
59ebd23
faee545
5bc6920
6538f87
0d6d656
3b6467e
69aee8b
97f3455
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -16,20 +16,23 @@ export const workgroupBarrier = dualImpl({ | |||||||||||||||||||||
| normalImpl: 'workgroupBarrier is a no-op outside of CODEGEN mode.', | ||||||||||||||||||||||
| signature: { argTypes: [], returnType: Void }, | ||||||||||||||||||||||
| codegenImpl: () => 'workgroupBarrier()', | ||||||||||||||||||||||
| sideEffects: true, | ||||||||||||||||||||||
| }); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| export const storageBarrier = dualImpl({ | ||||||||||||||||||||||
| name: 'storageBarrier', | ||||||||||||||||||||||
| normalImpl: 'storageBarrier is a no-op outside of CODEGEN mode.', | ||||||||||||||||||||||
| signature: { argTypes: [], returnType: Void }, | ||||||||||||||||||||||
| codegenImpl: () => 'storageBarrier()', | ||||||||||||||||||||||
| sideEffects: true, | ||||||||||||||||||||||
| }); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| export const textureBarrier = dualImpl({ | ||||||||||||||||||||||
| name: 'textureBarrier', | ||||||||||||||||||||||
| normalImpl: 'textureBarrier is a no-op outside of CODEGEN mode.', | ||||||||||||||||||||||
| signature: { argTypes: [], returnType: Void }, | ||||||||||||||||||||||
| codegenImpl: () => 'textureBarrier()', | ||||||||||||||||||||||
| sideEffects: true, | ||||||||||||||||||||||
| }); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const atomicNormalError = 'Atomic operations are not supported outside of CODEGEN mode.'; | ||||||||||||||||||||||
|
|
@@ -44,6 +47,7 @@ export const atomicLoad = dualImpl<<T extends AnyAtomic>(a: T) => number>({ | |||||||||||||||||||||
| return { argTypes: [a], returnType: a.inner }; | ||||||||||||||||||||||
| }, | ||||||||||||||||||||||
| codegenImpl: (_ctx, [a]) => stitch`atomicLoad(&${a})`, | ||||||||||||||||||||||
| sideEffects: false, | ||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can't get how Based on the main use case of this being the ternary operator, I suggest
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The definition that distinguishes them: As for renaming — I considered
|
||||||||||||||||||||||
| }); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const atomicActionSignature = (a: BaseData) => { | ||||||||||||||||||||||
|
|
@@ -72,53 +76,61 @@ export const atomicStore = dualImpl<<T extends AnyAtomic>(a: T, value: number) = | |||||||||||||||||||||
| normalImpl: atomicNormalError, | ||||||||||||||||||||||
| signature: atomicActionSignature, | ||||||||||||||||||||||
| codegenImpl: (_ctx, [a, value]) => stitch`atomicStore(&${a}, ${value})`, | ||||||||||||||||||||||
| sideEffects: true, | ||||||||||||||||||||||
| }); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| export const atomicAdd = dualImpl<<T extends AnyAtomic>(a: T, value: number) => number>({ | ||||||||||||||||||||||
| name: 'atomicAdd', | ||||||||||||||||||||||
| normalImpl: atomicNormalError, | ||||||||||||||||||||||
| signature: atomicOpSignature, | ||||||||||||||||||||||
| codegenImpl: (_ctx, [a, value]) => stitch`atomicAdd(&${a}, ${value})`, | ||||||||||||||||||||||
| sideEffects: true, | ||||||||||||||||||||||
| }); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| export const atomicSub = dualImpl<<T extends AnyAtomic>(a: T, value: number) => number>({ | ||||||||||||||||||||||
| name: 'atomicSub', | ||||||||||||||||||||||
| normalImpl: atomicNormalError, | ||||||||||||||||||||||
| signature: atomicOpSignature, | ||||||||||||||||||||||
| codegenImpl: (_ctx, [a, value]) => stitch`atomicSub(&${a}, ${value})`, | ||||||||||||||||||||||
| sideEffects: true, | ||||||||||||||||||||||
| }); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| export const atomicMax = dualImpl<<T extends AnyAtomic>(a: T, value: number) => number>({ | ||||||||||||||||||||||
| name: 'atomicMax', | ||||||||||||||||||||||
| normalImpl: atomicNormalError, | ||||||||||||||||||||||
| signature: atomicOpSignature, | ||||||||||||||||||||||
| codegenImpl: (_ctx, [a, value]) => stitch`atomicMax(&${a}, ${value})`, | ||||||||||||||||||||||
| sideEffects: true, | ||||||||||||||||||||||
| }); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| export const atomicMin = dualImpl<<T extends AnyAtomic>(a: T, value: number) => number>({ | ||||||||||||||||||||||
| name: 'atomicMin', | ||||||||||||||||||||||
| normalImpl: atomicNormalError, | ||||||||||||||||||||||
| signature: atomicOpSignature, | ||||||||||||||||||||||
| codegenImpl: (_ctx, [a, value]) => stitch`atomicMin(&${a}, ${value})`, | ||||||||||||||||||||||
| sideEffects: true, | ||||||||||||||||||||||
| }); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| export const atomicAnd = dualImpl<<T extends AnyAtomic>(a: T, value: number) => number>({ | ||||||||||||||||||||||
| name: 'atomicAnd', | ||||||||||||||||||||||
| normalImpl: atomicNormalError, | ||||||||||||||||||||||
| signature: atomicOpSignature, | ||||||||||||||||||||||
| codegenImpl: (_ctx, [a, value]) => stitch`atomicAnd(&${a}, ${value})`, | ||||||||||||||||||||||
| sideEffects: true, | ||||||||||||||||||||||
| }); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| export const atomicOr = dualImpl<<T extends AnyAtomic>(a: T, value: number) => number>({ | ||||||||||||||||||||||
| name: 'atomicOr', | ||||||||||||||||||||||
| normalImpl: atomicNormalError, | ||||||||||||||||||||||
| signature: atomicOpSignature, | ||||||||||||||||||||||
| codegenImpl: (_ctx, [a, value]) => stitch`atomicOr(&${a}, ${value})`, | ||||||||||||||||||||||
| sideEffects: true, | ||||||||||||||||||||||
| }); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| export const atomicXor = dualImpl<<T extends AnyAtomic>(a: T, value: number) => number>({ | ||||||||||||||||||||||
| name: 'atomicXor', | ||||||||||||||||||||||
| normalImpl: atomicNormalError, | ||||||||||||||||||||||
| signature: atomicOpSignature, | ||||||||||||||||||||||
| codegenImpl: (_ctx, [a, value]) => stitch`atomicXor(&${a}, ${value})`, | ||||||||||||||||||||||
| sideEffects: true, | ||||||||||||||||||||||
| }); | ||||||||||||||||||||||

Uh oh!
There was an error while loading. Please reload this page.