[llvm] Overhaul the TargetMachine and LLVMTargetMachine Classes (PR #111234)

Matin Raayai via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 9 11:12:30 PDT 2024


================
@@ -0,0 +1,92 @@
+//===-- CodeGenCommonTMImpl.h -----------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file This file describes the CodeGenCommonTMImpl class, which
+/// implements a set of functionality used by \c TargetMachine classes in
+/// LLVM that make use of the target-independent code generator.
+//===----------------------------------------------------------------------===//
+#ifndef LLVM_CODEGEN_CODEGENCOMMONTMIMPL_H
+#define LLVM_CODEGEN_CODEGENCOMMONTMIMPL_H
+#include "llvm/Target/TargetMachine.h"
+
+namespace llvm {
+
+/// \brief implements a set of functionality in the \c TargetMachine class
+/// for targets that make use of the independent code generator (CodeGen)
+/// library. Must not be used directly in code unless to inherit its
+/// implementation.
+class CodeGenCommonTMImpl : public TargetMachine {
+protected: // Can only create subclasses.
+  CodeGenCommonTMImpl(const Target &T, StringRef DataLayoutString,
+                      const Triple &TT, StringRef CPU, StringRef FS,
+                      const TargetOptions &Options, Reloc::Model RM,
+                      CodeModel::Model CM, CodeGenOptLevel OL);
+
+  void initAsmInfo();
+
+public:
+  /// Get a TargetTransformInfo implementation for the target.
+  ///
+  /// The TTI returned uses the common code generator to answer queries about
+  /// the IR.
+  TargetTransformInfo getTargetTransformInfo(const Function &F) const override;
----------------
matinraayai wrote:

It's because it's already in the `TargetMachine` interface:

https://github.com/matinraayai/llvm-project/blob/b52f940b385cabf51c96004a5d17e3bf0b1cd2e1/llvm/include/llvm/Target/TargetMachine.h#L368

There's no function in `CodeGenTargetMachine` that is not inherited  in `TargetMachine`; `CodeGenTargetMachine` is only a collection of `TargetMachine` interface implementations commonly shared among all targets in LLVM, where all use the target-independent code generator.

https://github.com/llvm/llvm-project/pull/111234


More information about the llvm-commits mailing list