[MC][NFC] Replace MCAsmInfo::evaluateAsRelocatableImpl with func ptr (#246744)
Avoid a virtual function by using a function pointer for evaluating
specifier exprs. Saves ~400B of .data.rel.ro.
[Clang][AMDGPU] Remove R600 target support
Remove the r600 triple from the clang frontend, driver and CodeGen,
together with the `__R600__` macro and the `__builtin_r600_*` builtins.
AMDGPUTargetInfo now only handles amdgcn, so the R600 branches are gone.
```
$ clang --target=r600 -S test.cl
error: unknown target triple 'r600'
```
RFC: https://discourse.llvm.org/t/rfc-amdgpu-deprecating-and-removing-llvm-s-r600-terascale-backend/92840
[Clang][AMDGPU] Remove redundant isAMDGCN checks. NFC
After the r600 target removal, AMDGPUTargetInfo is only created for
the amdgcn triple, so every `isAMDGCN()` check in it is always true.
Drop those checks and the helpers that only wrapped them.
```
if (hasFMAF())
Builder.defineMacro("__HAS_FMAF__");
-->
Builder.defineMacro("__HAS_FMAF__");
```
RFC: https://discourse.llvm.org/t/rfc-amdgpu-deprecating-and-removing-llvm-s-r600-terascale-backend/92840
[clang-diff] Switch to OptTable (#246766)
Parse the command line with OptTable instead of cl::opt, as part of
removing cl::opt from clang/. Help output uses the OptTable format, and
LLVM's global options (e.g. -debug-only, --version) are no longer
accepted.
LLM-aided
[docs] Document signature of builtin functions more consistently (#246637)
This greatly increases the consistency in how the signature of builtin
functions is documented. Historically, only some of the intrinsics had a
proper pseudo-C++ declaration, only some provided a documented return
type, etc. Also, the formatting (west-pointer vs. east-pointer) was
inconsistent, and some declarations used `type` to express generics
while others use `T`.
This patch also fixes some more severe documentation issues:
- `__builtin_unpredictable` was documented to operate on `long long`,
but actually operates on `long`.
- `__builtin_bitreverseg` is undocumented.
---------
Co-authored-by: Timm Baeder <tbaeder at redhat.com>
[docs] Fix incomplete list of `constexpr` elementwise intrinsics (#246615)
The current list is missing several intrinsics that can be used in
constant expressions, such as `__builtin_elementwise_clmul`.
[SPARC] Emit relocations for symbolic immediates of sethi, unimp, Tcc, movr and movcc (#245946)
The immediate operands of sethi, unimp, Tcc, movr and movcc had no
encoder
method, so a symbolic operand reached getMachineOpValue() and hit
llvm_unreachable("Unhandled expression!"). This also happened for values
that are only known after encoding, such as a label difference or a
later
.set.
Give these operands encoder methods that emit a fixup for the field, as
GNU as does: R_SPARC_22 for sethi and unimp, R_SPARC_10 for movr and
R_SPARC_11 for movcc. GNU as uses R_SPARC_13 for a trap number, but on
V9
bits 12-11 of that field are the condition code, so use R_SPARC_7, which
covers just the trap number.
Fold the simm5/simm13 encoders into the same helper.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[Driver] Merge CSKY bare-metal toolchain into BareMetal (#240290)
CSKYToolChain is only used for csky targets that are not Linux;
csky-*-linux-* is already handled by the generic Linux toolchain.
Fold the bare-metal handling into the BareMetal toolchain, as was
done for RISCVToolChain, and remove CSKYToolChain.
- Route csky in the default switch to BareMetal and add csky with an
unknown OS to BareMetal::handlesTarget().
- Use the "cskyelf" linker emulation for non-Linux csky targets.
- With a GCC installation, use libgcc/libstdc++ and no unwind library,
do not warn about multilibs, and apply the selected multilib's OS
suffix to the GCC install and sysroot library paths when the
multilib set does not provide a file paths callback.
- Add sysroot/include and sysroot/sys-include, link crti.o/crtn.o and
-lnosys (or -lsemi with -msim) instead of -lgloss.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[Sparc][MC] Make register names case-sensitive (#245945)
matchRegisterName lowercased the name before calling the generated
matchers, so "%G1", "%SP" and "%R14" were accepted, but the hand-written
checks such as "%xcc", "%gsr" and "%tick" were case-sensitive, so "%XCC"
and "%GSR" were rejected.
GNU as only accepts lowercase register names. Do the same and stop
lowercasing the name.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[clang][RISCV] Added RTEMS OS target info for RISC-V (#241839)
Use RTEMSTargetInfo for riscv32-*-rtems and riscv64-*-rtems triples,
this is already done for ARM, SPARC and other architectures.
It makes clang emit __rtems__ macro when triples are used.
Add RISC-V RTEMS triples to predefined-macros-no-warnings.c
Add rtems-init.c test checking macros for all RTEMS targets.
[lld][Hexagon] Set copyRel to R_HEX_COPY (#245243)
copyRel was never initialized for Hexagon, so non-PIE copy relocations
were emitted as R_HEX_NONE and the linux musl loader left the copied
data zeroed, e.g. BusyBox's stdout.
[clang] Fix crash on trailing comma in vectorize_width
With `#pragma clang loop vectorize_width(4, )`, the token after the comma
is the end marker for the loop hint. The parser diagnoses the missing
argument, then lexes past the marker. Error recovery consumes the
following loop and crashes at the end of the file.
```text
Stack dump:
1. <eof> parser at end of file
2. <stdin>:1:10: parsing function body 'f'
3. <stdin>:1:10: in compound statement ('{}')
```
Leave the end marker for the existing recovery path so parsing resumes
at the following loop. Clang now emits only the malformed hint error.
```text
<stdin>:2:40: error: vectorize_width loop hint malformed; use vectorize_width(X, fixed) or vectorize_width(X, scalable) where X is an integer, or vectorize_width('fixed' or 'scalable')
[6 lines not shown]
[LICM] Don't reassociate an nsw add that only feeds sign extensions
hoistBOAssociation rewrites "(LV + C1) + C2" as "LV + (C1 + C2)" and
drops nsw unless C1 + C2 provably cannot overflow or both adds are also
nuw. When the sum only feeds sign extensions, as in an array index such
as i * S0 + j * S1 + k * S2, the dropped nsw means the extensions no
longer distribute over the adds. Leave such adds alone.
In llvm-test-suite at -O3 on x86-64, 4 programs change. lencod and
ldecod (MultiSource/Applications/JM) shrink by 64 and 81 instructions,
and miniGMG (MultiSource/Benchmarks/DOE-ProxyApps-C/miniGMG) by 2.
tramp3d-v4 (MultiSource/Benchmarks/tramp3d-v4) grows by 398
instructions, but a run executes 3.2% fewer instructions (898M -> 869M,
counted by callgrind); its run time is within noise (median +1.1% over
31 runs, interquartile ranges overlapping).
Assisted-by: Claude Code
Xtensa: Use LastSubtargetCache in getSubtargetImpl (#242853)
Migrate to the new common target pattern.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
Revert "[Clang][OpenMP] Allow array shaping as the base of array sections in target update" (#246790)
Reverts llvm/llvm-project#244591
asserts on test case attached in :
https://github.com/llvm/llvm-project/pull/244591
[SystemZ] Use VFTCI*/WFTCIXB for llvm.is.fpclass on vector and f128 types
Lower ISD::IS_FPCLASS on <2 x double> and <4 x float> to VFTCIDB/VFTCISB
(one instruction) instead of the 3-instruction comparison sequence currently
produced by generic expansion. Lower IS_FPCLASS on fp128 on z14+ to WFTCIXB
instead of TCXB, keeping the value in a single VR128 and avoiding the vrepg
split and the GroupAlone dispatch restriction of TCXB.
For vectors, register IS_FPCLASS as Custom for v2f64 (z13+) and v4f32 (z14+),
emit SystemZISD::VFTCI with the TDC 12-bit mask as a TargetConstant, and
return the all-ones/all-zeros element result directly as the boolean mask.
For f128 on z14+, add a new SystemZISD::WFTCIXB node and wire it to the
existing WFTCIXB instruction. Extract the boolean from the i128 result
with vlgvg + srlg 63.
Assisted by: IBM Bob