[clang][RISCV] Set vscale_range attribute based on presence of "v" extension
authorPhilip Reames <preames@rivosinc.com>
Mon, 17 Oct 2022 17:09:58 +0000 (10:09 -0700)
committerPhilip Reames <listmail@philipreames.com>
Mon, 17 Oct 2022 18:33:03 +0000 (11:33 -0700)
commit4467c781d7bbf25a3b89a25ccbc0382731f51322
treec611a2c0f668d59c9a93d4a0f1d1d8d93cf5aea0
parentd0a4741392a3df0fb4083e12bef0cef14af439e1
[clang][RISCV] Set vscale_range attribute based on presence of "v" extension

This follows the path that AArch64 SVE has taken. Doing this via a function attribute set in the frontend is basically a workaround for the fact that several analyzes which need the information (i.e. known bits, lvi, scev) can't easily use TTI without significant amounts of plumbing changes.

This patch hard codes "v" numbers, and directly follows the SVE precedent as a result. In a follow up, I hope to drive this from RISCVISAInfo.h/cpp instead, but the MinVLen number being returned from that interface seemed to always be 0 (which is wrong), and I haven't figured out what's going wrong there.

Differential Revision: https://reviews.llvm.org/D135894
clang/lib/Basic/Targets/RISCV.cpp
clang/lib/Basic/Targets/RISCV.h
clang/test/CodeGen/riscv-vector-bits-vscale-range.c [new file with mode: 0644]