This is an archive of the discontinued LLVM Phabricator instance.

[RISCV][NFC] Move RISCVISAInfo back to Support
ClosedPublic

Authored by pcwang-thead on Dec 22 2022, 12:09 AM.

Details

Summary

So that there is no cyclic dependency if we want to use it in
tablegen.

Diff Detail

Event Timeline

pcwang-thead requested review of this revision.Dec 22 2022, 12:09 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 22 2022, 12:09 AM

@pcwang-thead - could you please explain the cycling dependency you are mentioning, in the commit message? I am missing where the cyclic dependency is.

Francesco

@pcwang-thead - could you please explain the cycling dependency you are mentioning, in the commit message? I am missing where the cyclic dependency is.

Francesco

There would be a cyclic dependency if RISCVISAInfo.cpp is used in RISCVTargetDefEmitter.cpp as suggested in a recent comment from @pcwang-thead

@craig.topper Thanks!

If we want to use RISCVISAInfo in RISCVTargetDefEmitter.cpp, we need to add TargetParser component to llvm/utils/TableGen/CMakeLists.txt:

diff --git a/llvm/utils/TableGen/CMakeLists.txt b/llvm/utils/TableGen/CMakeLists.txt
index aa16e7e894ac..987b955655e3 100644
--- a/llvm/utils/TableGen/CMakeLists.txt
+++ b/llvm/utils/TableGen/CMakeLists.txt
@@ -1,6 +1,6 @@
 add_subdirectory(GlobalISel)

-set(LLVM_LINK_COMPONENTS Support)
+set(LLVM_LINK_COMPONENTS Support TargetParser)

 add_tablegen(llvm-tblgen LLVM
   DESTINATION "${LLVM_TOOLS_INSTALL_DIR}"

This causes CMake errors like:

[cmake] CMake Error: The inter-target dependency graph contains the following strongly connected component (cycle):
[cmake]   "llvm-tblgen" of type EXECUTABLE
[cmake]     depends on "LLVMTargetParser" (weak)
[cmake]   "RISCVTargetParserTableGen" of type UTILITY
[cmake]     depends on "llvm-tblgen" (strong)
[cmake]   "LLVMTargetParser" of type STATIC_LIBRARY
[cmake]     depends on "RISCVTargetParserTableGen" (strong)
[cmake] At least one of these targets is not a STATIC_LIBRARY.  Cyclic dependencies are allowed only among static libraries.

So I move RISCVISAInfo.cpp back to Support component to avoid this cyclic dependency.
@fpetrogalli

From my PoV (which no longer relates to RISC-V in particular), I do not wish for TargetParser to be a dependency of TableGen, specifically because I want to be able to table-generate parts of TargetParser. If this means that I was wrong to move RISCVISAInfo into the TargetParser library (very likely), then by all means move it back.

fpetrogalli accepted this revision.Dec 29 2022, 12:17 AM

Thank you all for the explanation. I am OK with this change.

Francesco

This revision is now accepted and ready to land.Dec 29 2022, 12:17 AM
This revision was automatically updated to reflect the committed changes.
llvm/include/llvm/Support/RISCVISAInfo.h