<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/54146>54146</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
RISCV should support the "generic" cpu
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
andreas-schwab
</td>
</tr>
</table>
<pre>
Software that uses llvm as backend does not know, and should not need to know, that it needs to use "generic-rv64" instead of "generic" as the cpu for createTargetMachine when the target machine happens to be RISCV. Instead, RISCVSubtarget::initializeSubtargetDependencies and createRISCVMCSubtargetInfo should automatically select the appropriate cpu in place of "generic" based on the target bitness.
Otherweise, software like <https://github.com/apache/tvm> will have to add super special code just for RISCV, see GetLLVMTargetMachine in <https://github.com/apache/tvm/blob/main/src/target/llvm/llvm_common.cc>, to avoid errors like this:
https://build.opensuse.org/package/live_build_log/openSUSE:Factory:RISCV/tvm/standard/riscv64
112/176 Test #109: Runtime.ZeroCopy .................................................Subprocess aborted***Exception: 2.45 sec
Running main() from /home/abuild/rpmbuild/BUILD/googletest-release-1.11.0/googletest/src/gtest_main.cc
Note: Google Test filter = Runtime.ZeroCopy
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from Runtime
[ RUN ] Runtime.ZeroCopy
LLVM ERROR: CPU 'generic' is not supported. Use generic-rv64
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyVVU1v2zgQ_TXyZWBBohx_HHRInTgIkLSFU_ewl4CixhIbihRIym721--Qcrw2ulugAmFRHHLmzZvHcWXq9_LF7P2RWwTfcg-DQwdKHTrgDiou3lDXUBta1MbDmzbHhK2B06JrzaDquKwRa_DmbI6e5LjugoG8QsJYgxqtFFN7mM_oE6R2HnkNZn9hDQaK7VsE0Q-wNxaERe7xG7cN-mcuWqkRji3quMnHZehO6y3ve9QxaoWwfXxZf08BHsdIAVxcehmq8VxS3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