[all-commits] [llvm/llvm-project] 0045d0: [SPIR-V] Add a toolchain for SPIR-V in clang

Anastasia Stulova via All-commits all-commits at lists.llvm.org
Thu Dec 23 07:10:37 PST 2021

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 0045d01af96ff56c5b62d133be076020a33867ff
  Author: Anastasia Stulova <anastasia.stulova at arm.com>
  Date:   2021-12-23 (Thu, 23 Dec 2021)

  Changed paths:
    M clang/docs/UsersManual.rst
    M clang/include/clang/Basic/DiagnosticDriverKinds.td
    M clang/include/clang/Driver/Tool.h
    M clang/include/clang/Driver/ToolChain.h
    M clang/lib/Driver/Driver.cpp
    M clang/lib/Driver/ToolChain.cpp
    M clang/lib/Driver/ToolChains/Clang.cpp
    M clang/lib/Driver/ToolChains/Clang.h
    M clang/lib/Driver/ToolChains/SPIRV.cpp
    M clang/lib/Driver/ToolChains/SPIRV.h
    A clang/test/Driver/spirv-toolchain.cl

  Log Message:
  [SPIR-V] Add a toolchain for SPIR-V in clang

This patch adds a toolchain (TC) for SPIR-V along with the
following changes in Driver and base ToolChain and Tool.
This is required to provide a mechanism in clang to bypass
SPIR-V backend in LLVM for SPIR-V until it lands in LLVM and

The SPIR-V code is generated by the SPIRV-LLVM translator tool
named 'llvm-spirv' that is sought in 'PATH'.

The compilation phases/actions should be bound for SPIR-V in
the meantime as following:

    compile -> tools::Clang
    backend -> tools::SPIRV::Translator
    assemble -> tools::SPIRV::Translator

However, Driver’s ToolSelector collapses compile-backend-assemble
and compile-backend sequences to tools::Clang. To prevent this,
added new {use,has}IntegratedBackend properties in ToolChain and
Tool to which the ToolSelector reacts on, and which SPIR-V TC

Linking of multiple input files is currently not supported but
can be added separately.

Differential Revision: https://reviews.llvm.org/D112410

Co-authored-by: Henry Linjamäki <henry.linjamaki at parmance.com>

More information about the All-commits mailing list