Skip to content

Commit

Permalink
Pass WriteToOutput to backends. (#1066)
Browse files Browse the repository at this point in the history
* Added more code-generation functions to IBackendCodeGenerator.
* Adapted Backends to updated IBackendCodeGenerator.
  • Loading branch information
m4rs-mt authored Aug 31, 2023
1 parent a2461fa commit 89929e8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
10 changes: 8 additions & 2 deletions Src/ILGPU/Backends/IBackendCodeGenerator.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ---------------------------------------------------------------------------------------
// ILGPU
// Copyright (c) 2020-2021 ILGPU Project
// Copyright (c) 2020-2023 ILGPU Project
// www.ilgpu.net
//
// File: IBackendCodeGenerator.cs
Expand Down Expand Up @@ -317,6 +317,12 @@ public interface IBackendCodeGenerator
/// <param name="debug">The node.</param>
void GenerateCode(DebugAssertOperation debug);

/// <summary>
/// Generates code for the output writer.
/// </summary>
/// <param name="writeToOutput">The node.</param>
void GenerateCode(WriteToOutput writeToOutput);

// Terminators

/// <summary>
Expand Down Expand Up @@ -594,7 +600,7 @@ public void Visit(DebugAssertOperation debug) =>

/// <summary cref="IValueVisitor.Visit(WriteToOutput)"/>
public void Visit(WriteToOutput writeToOutput) =>
throw new InvalidCodeGenerationException();
CodeGenerator.GenerateCode(writeToOutput);

/// <summary cref="IValueVisitor.Visit(ReturnTerminator)"/>
public void Visit(ReturnTerminator returnTerminator) =>
Expand Down
5 changes: 5 additions & 0 deletions Src/ILGPU/Backends/OpenCL/CLCodeGenerator.Values.cs
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,11 @@ public void GenerateCode(DebugAssertOperation debug) =>
// Invalid debug node -> should have been removed
debug.Assert(false);

/// <summary cref="IBackendCodeGenerator.GenerateCode(WriteToOutput)"/>
public void GenerateCode(WriteToOutput writeToOutput) =>
// Invalid write node -> should have been removed
writeToOutput.Assert(false);

/// <summary cref="IBackendCodeGenerator.GenerateCode(LanguageEmitValue)"/>
public void GenerateCode(LanguageEmitValue value) =>
// Ignore PTX instructions.
Expand Down
8 changes: 7 additions & 1 deletion Src/ILGPU/Backends/PTX/PTXCodeGenerator.Values.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1231,7 +1231,13 @@ public void GenerateCode(SubWarpShuffle shuffle)

/// <summary cref="IBackendCodeGenerator.GenerateCode(DebugAssertOperation)"/>
public void GenerateCode(DebugAssertOperation debug) =>
Debug.Assert(false, "Invalid debug node -> should have been removed");
// Invalid debug node -> should have been removed
debug.Assert(false);

/// <summary cref="IBackendCodeGenerator.GenerateCode(WriteToOutput)"/>
public void GenerateCode(WriteToOutput writeToOutput) =>
// Invalid write node -> should have been removed
writeToOutput.Assert(false);

/// <summary cref="IBackendCodeGenerator.GenerateCode(LanguageEmitValue)"/>
[SuppressMessage(
Expand Down

0 comments on commit 89929e8

Please sign in to comment.