Skip to content

Commit 8b79dfd

Browse files
authored
[REFACTOR][TARGET] Cleanup backend target registration (#19759)
The backend reorg leaves target-kind and op registration behind generic register.cc shims, which makes the new layout harder to navigate and keeps a few obsolete target paths alive. This change keeps backend registration beside the backend definitions while preserving the existing static initialization behavior. Backend target-kind registration units now use semantic target_kind.cc names, target builtin registration is colocated with the CUDA, Metal, and Trainium builtin definitions, the NVPTX intrinsic rules live with CUDA LLVM codegen, and the unused target/opt placeholder is removed.
1 parent e43555f commit 8b79dfd

17 files changed

Lines changed: 21 additions & 115 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ tvm_file_glob(GLOB CODEGEN_SRCS
348348
src/backend/trn/codegen/*.cc
349349
src/backend/trn/op/*.cc
350350
src/backend/trn/transform/*.cc
351-
src/backend/vulkan/codegen/register.cc
351+
src/backend/vulkan/codegen/target_kind.cc
352352
src/backend/vulkan/codegen/vulkan_fallback_module.cc
353353
src/backend/webgpu/codegen/*.cc
354354
)
File renamed without changes.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
/*!
21-
* \file register.cc
21+
* \file target_kind.cc
2222
* \brief CUDA compiler backend static registration.
2323
*/
2424
#include <dlpack/dlpack.h>

src/backend/cuda/op/register.cc

Lines changed: 0 additions & 35 deletions
This file was deleted.

src/backend/cuda/op/target_builtin.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
*
2323
* builtin intrinsic operators specific to CUDA target.
2424
*/
25+
#include <tvm/ffi/function.h>
26+
#include <tvm/runtime/base.h>
2527
#include <tvm/tirx/builtin.h>
2628
#include <tvm/tirx/op.h>
2729
#include <tvm/tirx/op_attr_types.h>
@@ -597,6 +599,8 @@ void RegisterDeviceIntrinsicAliases() {
597599

598600
#undef TIRX_DEFINE_BUILTIN_FUNC
599601

602+
TVM_FFI_STATIC_INIT_BLOCK() { RegisterCudaTargetBuiltins(); }
603+
600604
} // namespace builtin
601605
} // namespace tirx
602606
} // namespace tvm

src/backend/hexagon/codegen/register.cc renamed to src/backend/hexagon/codegen/target_kind.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
/*!
21-
* \file register.cc
21+
* \file target_kind.cc
2222
* \brief Hexagon compiler backend static registration.
2323
*/
2424
#include <dlpack/dlpack.h>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
/*!
21-
* \file register.cc
21+
* \file target_kind.cc
2222
* \brief Metal compiler backend static registration.
2323
*/
2424
#include <dlpack/dlpack.h>

src/backend/metal/op/register.cc

Lines changed: 0 additions & 35 deletions
This file was deleted.

src/backend/metal/op/target_builtin.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
*
2323
* builtin intrinsic operators specific to Metal target.
2424
*/
25+
#include <tvm/ffi/function.h>
26+
#include <tvm/runtime/base.h>
2527
#include <tvm/tirx/op.h>
2628
#include <tvm/tirx/op_attr_types.h>
2729

@@ -57,6 +59,8 @@ TIRX_DEFINE_BUILTIN_FUNC(simdgroup_multiply_accumulate)
5759

5860
#undef TIRX_DEFINE_BUILTIN_FUNC
5961

62+
TVM_FFI_STATIC_INIT_BLOCK() { RegisterMetalTargetBuiltins(); }
63+
6064
} // namespace builtin
6165
} // namespace tirx
6266
} // namespace tvm
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
/*!
21-
* \file register.cc
21+
* \file target_kind.cc
2222
* \brief OpenCL compiler backend static registration.
2323
*/
2424
#include <dlpack/dlpack.h>

0 commit comments

Comments
 (0)