Please use GitHub pull requests for new patches. Avoid migrating existing patches. Phabricator shutdown timeline
Changeset View
Standalone View
clang/lib/Basic/Targets/RISCV.cpp
Show First 20 Lines • Show All 194 Lines • ▼ Show 20 Lines | void RISCVTargetInfo::getTargetDefines(const LangOptions &Opts, | ||||
if (ISAInfo->hasExtension("c")) | if (ISAInfo->hasExtension("c")) | ||||
Builder.defineMacro("__riscv_compressed"); | Builder.defineMacro("__riscv_compressed"); | ||||
if (ISAInfo->hasExtension("zve32x")) { | if (ISAInfo->hasExtension("zve32x")) { | ||||
Builder.defineMacro("__riscv_vector"); | Builder.defineMacro("__riscv_vector"); | ||||
// Currently we support the v0.11 RISC-V V intrinsics. | // Currently we support the v0.11 RISC-V V intrinsics. | ||||
Builder.defineMacro("__riscv_v_intrinsic", Twine(getVersionValue(0, 11))); | Builder.defineMacro("__riscv_v_intrinsic", Twine(getVersionValue(0, 11))); | ||||
} | } | ||||
auto VScale = getVScaleRange(Opts); | |||||
if (VScale && VScale->first && VScale->first == VScale->second) | |||||
Builder.defineMacro("__riscv_v_fixed_vlen", | |||||
Twine(VScale->first * llvm::RISCV::RVVBitsPerBlock)); | |||||
rjmccall: Is this macro name coming from somewhere specifically? Because it doesn't match the normal… | |||||
I made it up. I'll reconsider it.
The command line is converted to -mvscale-min= and -mvscale-max= options just like SVE. We divide by llvm::RISCV::RVVBitsPerBlock where SVE divides by 128. RISC-V does have a concept of minimum vector length through -march already which is checked by getVScaleRange to deal with any disagreement. There's a special value -mriscv-rvv-vector-bits=zvl to use the minimum value from -march without needing to repeat the value. craig.topper: > Is this macro name coming from somewhere specifically? Because it doesn't match the normal… | |||||
Not Done ReplyInline ActionsOkay. So in principle this could be extended to something like a rule where we statically check only that the value is within the specified range, and then it would be dynamically UB to use a type that's wrong for the actual runtime processor? Maybe that was the idea with SVE but it just never got implemented, which is why the documentation looks the way it does. rjmccall: Okay. So in principle this could be extended to something like a rule where we statically… | |||||
} | } | ||||
static constexpr Builtin::Info BuiltinInfo[] = { | static constexpr Builtin::Info BuiltinInfo[] = { | ||||
#define BUILTIN(ID, TYPE, ATTRS) \ | #define BUILTIN(ID, TYPE, ATTRS) \ | ||||
{#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES}, | {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES}, | ||||
#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \ | #define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \ | ||||
{#ID, TYPE, ATTRS, FEATURE, HeaderDesc::NO_HEADER, ALL_LANGUAGES}, | {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::NO_HEADER, ALL_LANGUAGES}, | ||||
#include "clang/Basic/BuiltinsRISCVVector.def" | #include "clang/Basic/BuiltinsRISCVVector.def" | ||||
▲ Show 20 Lines • Show All 132 Lines • Show Last 20 Lines |
Is this macro name coming from somewhere specifically? Because it doesn't match the normal scheme for RISC-V target macros, which are all lowercase, and it doesn't match the name of the command line argument it reflects.
Also, why is the computation of this thing so complicated when the command-line argument is basically a single number?