<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/106669>106669</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [RISCV][SiFive7Model] Best way to provide custom VCIX latencies?
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          michalt
      </td>
    </tr>
</table>

<pre>
    I'm not sure if this belongs to a bug, but I wanted to open the conversation about the best approach to dealing with scheduling of VCIX instructions. What I'd like to be able to do is to:

- Be able to provide accurate latencies of VCIX instructions in our internal LLVM build. (NB: These latencies would not be upstreamed)
- But reuse the upstream `SiFive7Model`.
- Make it reasonably easy to keep up with the upstream changes of `SiFive7Model` (e.g., manually copy & paste of the VCIX latencies would be ok, but it'd be nice to avoid anything more complicated).

What would be the best approach to achieve this?

Idea 1:

- Create a copy of `RISCVSchedSiFive7.td` (let's call it `RISCVSchedSiFive7Foobar.td`).
- But this leads to name conflicts since everything is just included in `RISCV.td`.
- So one could run `sed s/SiFive7/SiFive7Foobar/g` over the file. This is not quite enough (`VLDSX0Pred` conflicts); perhaps we could try to use the `SiFive7` prefix for all definitions in that file? Would that be acceptable?
- The above should be mostly mechanical (could be automated by a script). Then it would be a matter of (semi-)manually adjusting the VCIX scheduling information.

Idea 2:

- Perhaps we could refactor `RISCVSchedSiFive7.td` to have something like `SiFive7ModelTemplate` that would be a multiclass and could be instantiated with different VCIX scheduling information? (i.e., we would just instantiate it to create the current  `SiFive7Model`)
- This seems like a cleaner approach where `RISCVSchedSiFive7Foobar.td` would not have to be a copy (with all the `sed` renaming), it would just instantiate the model and provide the custom VCIX latencies.
- But I'm not sure if this is even feasible? (not a TableGen expert!) Would we run into some issues with this? Would it significantly increase the maintenance burden of `RISCVSchedSiFive7.td`?

@topperc @michaelmaitland What are your thoughts? Any better ideas would be appreciated! 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