https://github.com/shader-slang/slang
Raw File
Tip revision: 163d3068e332703cc499446fff37230a7c68e8f2 authored by Tim Foley on 21 April 2018, 00:54:39 UTC
Better diagnostics when compilation is aborted (#517)
Tip revision: 163d306
ir-validate.h
// ir-validate.h
#pragma once

namespace Slang
{
    class CompileRequest;
    class DiagnosticSink;
    struct IRModule;


    // Validate that an IR module obeys the invariants we need to enforce.
    // For example:
    //
    // * Confirm that linked lists for children and for use-def chains are consistent
    //   (e.g., x.next.prev == x)
    //
    // * Confirm that parent/child relationships are correct (e.g., if is `x` is in
    //   `y.children`, then `x.parent == y`
    //
    // * Confirm that every operand of an instruction is valid to reference (i.e., it
    //   must either be defined earlier in the same block, in a different block that
    //   dominates the current one, or in a parent instruction of the block.
    //
    // * Confirm that every block ends with a terminator, and there are no terminators
    //   elsewhere in a block.
    //
    // * Confirm that all the parameters of a block come before any "ordinary" instructions.
    void validateIRModule(IRModule* module, DiagnosticSink* sink);

    // A wrapper that calls `validateIRModule` only when IR validation is enabled
    // for the given compile request.
    void validateIRModuleIfEnabled(
        CompileRequest* compileRequest,
        IRModule*       module);
}
back to top