[PATCH] D123964: CodeGen: Replace some uses of LLVMTargetMachine with TargetMachine

Matthias Braun via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 27 10:56:42 PDT 2022


MatzeB added a comment.

> This sounds backwards to me. LLVMTargetMachine extends with pieces frontends need to use the target (e.g. createMCStreamer). TargetMachine is the base target info class codegen does use. What you're saying would make more sense if the relationship was inverted?

I remember spending quite a while wondering about this myself; I couldn't find anyone who could actually explain the `TargetMachine` / `LLVMTargetMachine` split to me.

So my reading is mostly based on the fact that the `TargetRegistry` API that frontends need to use to construct a target and especially the `createTargetMachine()` call there returns a `TargetMachine` and not an `LLVMTargetMachine`. So it seemed to me like `LLVMTargetMachine` was intended as an implementation detail for `lib/CodeGen`. You can also see `clang` code only dealing with `llvm::TargetMachine` but not `LLVMTargetMachine`.

I agree that this is all convoluted and not consistent and becomes in no way clear given the class names. I'm currently not aware of any code implementing a `TargetMachine` but not `LLVMTargetMachine`. So maybe we should just kill this whole discussion and merge the two classes into just `TargetMachine`?

It seems I actually discussed this before in https://lists.llvm.org/pipermail/llvm-dev/2017-October/thread.html#117907 and we had no opposition for moving the two classes. Seems I just never got around to actually do it...


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D123964/new/

https://reviews.llvm.org/D123964



More information about the llvm-commits mailing list