[CostModel] Templatize EntryCost::Cost to allow custom cost metrics
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Tue, 20 Jul 2021 14:31:24 +0000 (15:31 +0100)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Tue, 20 Jul 2021 14:31:39 +0000 (15:31 +0100)
commit4ffc3c3726e9fd2fd1be80983d7f0fbbf5a7572c
treeda0830b2c9170f2b65801479585dd4c8bf8fa6ce
parentd62bbbebbf709b1eaebaace62c58e759cbd32005
[CostModel] Templatize EntryCost::Cost to allow custom cost metrics

We currently use an unsigned value for our CostTblEntry and TypeConversionCostTblEntry cost tables which is limiting depending on how the target wishes to handle various CostKinds etc.

For instance, targets might wish to store separate instruction count, latency or throughput values etc. On D46276 we have been investigating storing a code snippet to improve latency/throughput cost calculations.

There is a slight problem in that template argument deduction was struggling to match the now templatized Costs[] tables in a ArrayRef constructor - I've added helper wrappers for CostTableLookup/ConvertCostTableLookup which avoids us having to update all existing calls with a template hint.

Differential Revision: https://reviews.llvm.org/D106351
llvm/include/llvm/CodeGen/CostTable.h