Commit Graph

1537 Commits

Author SHA1 Message Date
Hsiangkai Wang 77bb82d068 [Clang][RISCV] Support half-precision floating point for RVV intrinsics.
Use _Float16 as the half-precision floating point type. Define a new
type specifier 'x' for the _Float16 type.

Differential Revision: https://reviews.llvm.org/D105001
2021-07-19 23:17:01 +08:00
Zakk Chen 08cf69c31f [RISCV] Support overloading for RVV miscellaneous functions.
Based on this update to the intrinsic doc
https://github.com/riscv/rvv-intrinsic-doc/pull/103

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D105611
2021-07-13 21:35:37 -07:00
jacquesguan 88326bbce3 [RISCV][clang] Add macro __riscv_zvlsseg for RVV Zvlsseg builtins
Add extension macro __riscv_zvlsseg to enable Zvlsseg builtins only
with target feature Zvlsseg.

Reviewed By: HsiangKai

Differential Revision: https://reviews.llvm.org/D105626
2021-07-09 13:18:42 +08:00
Hsiangkai Wang 593bf9b4de [Clang][RISCV] Implement vlseg and vlsegff.
Differential Revision: https://reviews.llvm.org/D103527
2021-07-07 13:44:40 +08:00
Valeriy Savchenko c818cb96ad [analyzer][satest][NFC] Relax dependencies requirements 2021-06-30 12:50:21 +03:00
Sven van Haastregt ca964b40e6 [OpenCL][NFC] Reorganize ClangOpenCLBuiltinEmitter comments
Since 8866793b4e ("[OpenCL] Add OpenCL builtin test generator",
2021-06-09) there are two emitters in this file, so move the
file-level comment to the appropriate class.
2021-06-11 10:22:59 +01:00
Sven van Haastregt 8866793b4e [OpenCL] Add OpenCL builtin test generator
Add a new clang-tblgen flag `-gen-clang-opencl-builtin-tests` that
generates a .cl file containing calls to every builtin function
defined in the .td input.

This patch does not add any use of the new flag yet, so the only way
to obtain a generated test file is through a manual invocation of
clang-tblgen.  A test making use of this emitter will be added in a
followup commit.

Differential Revision: https://reviews.llvm.org/D97869
2021-06-09 14:03:58 +01:00
Michael Spencer 7defab0820 Reapply "[clang][deps] Support inferred modules"
This reverts commit 76b8754d and ensures the PCM files are created in the correct directory (not in the current working directory).
2021-05-20 12:41:52 +02:00
Frederik Gossen 76b8754d1b Revert "Reapply "[clang][deps] Support inferred modules""
This reverts commit c98833cdaa.
The test `ClangScanDeps/modules-inferred-explicit-build.m` creates files
in the current directory.
2021-05-19 19:19:37 +02:00
Michael Spencer c98833cdaa Reapply "[clang][deps] Support inferred modules"
This reapplies commit 95033eb3 that reverted commit 1d9e8e13.

The tests were failing on Windows due to spaces and backslashes in paths not being handled carefully.
2021-05-19 13:35:51 +02:00
Jan Svoboda ccd485e554 Revert "[clang][deps] Support inferred modules"
This reverts commit 1d9e8e13

Something is off with handling Windows paths: http://45.33.8.238/win/38908/step_7.txt
Most likely introduced in https://reviews.llvm.org/D102491
2021-05-17 13:27:14 +02:00
Jan Svoboda e827d74a97 [clang][deps] Specify Python 3 in shebang
Some build bots don't like plain `python` in the shebang: https://lab.llvm.org/buildbot/#/builders/139/builds/4147.
2021-05-17 13:02:25 +02:00
Michael Spencer 1d9e8e13dd [clang][deps] Support inferred modules
This patch adds support for inferred modules to the dependency scanner.

Effectively a cherry-pick of https://github.com/apple/llvm-project/pull/699 authored by @Bigcheese with libclang and other changes omitted.

Contains following changes:

1. [Clang][ScanDeps] Ignore __inferred_module.map dependency.
  * This shows up with inferred modules, but it doesn't exist on disk, so don't report it as a dependency.

2. [Clang][ScanDeps] Use the module map a module was inferred from for inferred modules.

Also includes a smoke test that uses clang-scan-deps output to perform an explicit build. There's no intention to duplicate whatever `test/Modules` contains, just to verify the produced command-line does "work" (with very loose definition of work).

Split from D100934.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D102495
2021-05-17 11:41:54 +02:00
Hsiangkai Wang c04c66d705 [RISCV] Consider scalar types for required extensions.
We have vector operations on double vector and float scalar. For
example, vfwadd.wf is such a instruction.

vfloat64m1_t vfwadd_wf(vfloat64m1_t op0, float op1, size_t op2);

We should specify F and D extensions for it.

Differential Revision: https://reviews.llvm.org/D102051
2021-05-08 04:06:45 +08:00
Craig Topper cfe3b0005f [RISCV] Reorder masked builtin operands. Use clang_builtin_alias for all overloaded vector builtins.
This patch makes the builtin operand order match the C operand order
for all intrinsics. With this we can use clang_builtin_alias for
all overloaded intrinsics.

This should further reduce the test time for vector intrinsics.

Differential Revision: https://reviews.llvm.org/D101700
2021-05-02 10:57:25 -07:00
Sven van Haastregt 37bc1dc987 [NFC] Workaround MSVC2019 32-bit compiler crash
As reported on D100492, this restructuring should stop the internal
compiler error from happening.

Fixes PR50128.
2021-04-27 11:15:47 +01:00
Hsiangkai Wang d8fa5ef6a2 [RISCV] Apply clang_builtin_alias to overloaded builtins.
We only apply `clang_builtin_alias` to non-masked builtins.
Masked builtins could not use `clang_builtin_alias` because the
operand order is different between overloaded intrinsics and builtins.

A bunch of test cases need to be updated.

Differential Revision: https://reviews.llvm.org/D100658
2021-04-25 18:12:19 +08:00
Hsiangkai Wang 14cc1cb222 [RISCV] Implement the vneg.v builtin.
Differential Revision: https://reviews.llvm.org/D100819
2021-04-23 11:40:18 +08:00
Sven van Haastregt e2b3b89bf1 [OpenCL] Do not add builtins with unavailable types
Add functionality to assign extensions to types in OpenCLBuiltins.td
and use that information to filter candidates that should not be
exposed if a type is not available.

Differential Revision: https://reviews.llvm.org/D100209
2021-04-21 11:59:29 +01:00
ShihPo Hung 11072a0bdb [RISCV][Clang] Add RVV AMO builtins
Add vamo[swap/add/xor/and/or/min/max/minu/maxu] builtins.

Reviewed By: khchen

Differential Revision: https://reviews.llvm.org/D100448
2021-04-21 01:48:02 -07:00
Sven van Haastregt 6cb7631df3 [OpenCL] Change OpenCL builtin version encoding
Instead of using a MinVersion and MaxVersion field, encode the version
of a builtin using a mask that aligns better with version handling in
OpenCLOptions.h.  In addition, this saves a field in the BuiltinTable.

This change allows a finer-grained control over the OpenCL versions in
which a builtin is available: instead of a range, we can now toggle
each version individually.

The fine-grained version control is not yet exposed on the TableGen
definitions side, as changes for OpenCL 3 feature optionality still
need to be defined and will affect how we want to expose these.

Differential Revision: https://reviews.llvm.org/D100492
2021-04-19 10:23:13 +01:00
Zakk Chen 8f683366af [RISCV][Clang] Add RVV miscellaneous intrinsic functions.
1. vreinterpret
2. vundefined
3. LMUL truncation and extension.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D100391
2021-04-16 09:41:19 -07:00
Zakk Chen ea5d33dbc1 [RISCV][Clang] Add vmv and vfmv series intrinsic functions.
Authored-by: Roger Ferrer Ibanez <rofirrim@gmail.com>
Co-Authored-by: Zakk Chen <zakk.chen@sifive.com>

Reviewed By: craig.topper, Jim

Differential Revision: https://reviews.llvm.org/D100266
2021-04-14 22:22:39 -07:00
Sander de Smalen 204aaf8795 [AArch64][SVE] Always use overloaded methods instead of preprocessor macro.
This fixes a subtle issue where:

  svprf(pg, ptr, SV_ALL /*is sv_pattern instead of sv_prfop*/)

would be quietly accepted. With this change, the function declaration
guards that the third parameter is a `enum sv_prfop`. Previously `svprf`
would map directly to `__builtin_sve_svprfb`, which accepts the enum
operand as a signed integer and only checks that the incoming range is
valid, meaning that SV_ALL would be discarded as being outside the valid
immediate range, but would have allowed SV_VL1 without issuing a warning
(C) or error (C++).

Reviewed By: c-rhodes

Differential Revision: https://reviews.llvm.org/D100297
2021-04-13 21:12:53 +01:00
Aaron Ballman c058a71227 Correct the tablegen for checking mutually exclusive stmt attrs
The previous implementation was insufficient for checking statement
attribute mutual exclusion because attributed statements do not collect
their attributes one-at-a-time in the same way that declarations do. So
the design that was attempting to check for mutual exclusion as each
attribute was processed would not ever catch a mutual exclusion in a
statement. This was missed due to insufficient test coverage, which has
now been added for the [[likely]] and [[unlikely]] attributes.

The new approach is to check all of attributes that are to be applied
to the attributed statement in a group. This required generating
another DiagnoseMutualExclusions() function into AttrParsedAttrImpl.inc.
2021-04-13 15:20:30 -04:00
Sander de Smalen fa936b610f [AArch64][SVE] Fix dup/dupq intrinsics for C++.
This patch changes the builtin prototype to use 'b' (boolean) instead
of the default integer element type. That fixes the dup/dupq intrinsics
when compiling with C++.

This patch also fixes one of the defines for __ARM_FEATURE_SVE2_BITPERM.

Reviewed By: kmclaughlin

Differential Revision: https://reviews.llvm.org/D100294
2021-04-13 10:55:20 +01:00
Zakk Chen a8fc0e445c [RISCV][Clang] Add all RVV Mask intrinsic functions.
1. Redefine vpopc and vfirst IR intrinsic so it could adapt on
clang tablegen generator which always appends a type for vl
in IntrinsicType of clang codegen.
2. Remove `c` type transformer and add `u` and `l` for unsigned long
and long type.

Authored-by: Roger Ferrer Ibanez <rofirrim@gmail.com>
Co-Authored-by: Zakk Chen <zakk.chen@sifive.com>

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D100120
2021-04-11 19:19:02 -07:00
Zakk Chen 01fa222b6d [RISCV][Clang] Add RVV Type-Convert intrinsic functions.
Fix extension macro condition.

Support below instructions:
1. Single-Width Floating-Point/Integer Type-Convert Instructions
2. Widening Floating-Point/Integer Type-Convert Instructions
3. Narrowing Floating-Point/Integer Type-Convert Instructions

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D99742
2021-04-11 19:19:01 -07:00
Hsiangkai Wang 471ae42c04 [RISCV][Clang] Add RVV vleff intrinsic functions.
Reviewed By: craig.topper, liaolucy, jrtc27, khchen

Differential Revision: https://reviews.llvm.org/D99151
2021-04-10 17:10:19 +08:00
Aaron Ballman 028092eb61 Correct the tablegen logic for MutualExclusions attribute checking.
Just because an attribute is a statement attribute doesn't mean it's
not also a declaration attribute. In Clang, there are not currently any
DeclOrStmtAttr attributes that require mutual exclusion checking, but
downstream clients discovered this issue.
2021-04-07 14:04:08 -04:00
Aaron Ballman 65c22acfa4 Silence -Woverloaded-virtual warnings from generated code; NFC 2021-04-06 07:19:07 -04:00
David Blaikie 2458aa0b91 Add missing override to clang tblgen AttrEmitter 2021-04-02 20:47:49 -07:00
Aaron Ballman 4be8a26951 Use tablegen to diagnose mutually exclusive attributes
Currently, when one or more attributes are mutually exclusive, the
developer adding the attribute has to manually emit diagnostics. In
practice, this is highly error prone, especially for declaration
attributes, because such checking is not trivial. Redeclarations
require you to write a "merge" function to diagnose mutually exclusive
attributes and most attributes get this wrong.

This patch introduces a table-generated way to specify that a group of
two or more attributes are mutually exclusive:

def : MutualExclusions<[Attr1, Attr2, Attr3]>;

This works for both statement and declaration attributes (but not type
attributes) and the checking is done either from the common attribute
diagnostic checking code or from within mergeDeclAttribute() when
merging redeclarations.
2021-04-02 16:34:42 -04:00
Richard Smith c23ee7718e [www] List both the regular and expanded form of %diff in the
diagnostics reference.

In passing, properly validate and diagnose errors in %diff format
specifiers.
2021-03-30 17:25:01 -07:00
Zakk Chen 821547cabb [RISCV][Clang] Update new overloading rules for RVV intrinsics.
RVV intrinsics has new overloading rule, please see
82aac7dad4

Changed:
1. Rename `generic` to `overloaded` because the new rule is not using C11 generic.
2. Change HasGeneric to HasNoMaskedOverloaded because all masked operations
   support overloading api.
3. Add more overloaded tests due to overloading rule changed.

Differential Revision: https://reviews.llvm.org/D99189
2021-03-28 09:04:35 -07:00
Zakk Chen 88c2d4c8eb [RISCV][Clang] Add RVV Vector Indexed Load intrinsic functions.
Support Complex type transformer to define more complexity legal type.

Overall our downstream implementation there are only four instructions need to
use complex type transformer, it's not a common case.
I still feel using a string for prototypes is simple and clear.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D98848
2021-03-23 19:18:50 -07:00
Paul C. Anagnostopoulos a9fc44c557 [TableGen] Improve handling of template arguments
This requires changes to TableGen files and some C++ files due to
incompatible multiclass template arguments that slipped through
before the improved handling.
2021-03-19 09:57:53 -04:00
Aaron Ballman fa4e72971e Automate common diagnostic checking for statement attributes
Clang currently automates a fair amount of diagnostic checking for
declaration attributes based on the declarations in Attr.td. It checks
for things like subject appertainment, number of arguments, language
options, etc. This patch uses the same machinery to perform diagnostic
checking on statement attributes.
2021-03-19 08:35:38 -04:00
Zakk Chen be947aded0 [RISCV][Clang] Add RVV vle/vse intrinsic functions.
Add new field PermuteOperands to mapping different operand order between
C/C++ API and clang builtin.

Reviewed By: craig.topper, rogfer01

Authored-by: Roger Ferrer Ibanez <rofirrim@gmail.com>
Co-Authored-by: Hsiangkai Wang <kai.wang@sifive.com>
Co-Authored-by: Zakk Chen <zakk.chen@sifive.com>

Differential Revision: https://reviews.llvm.org/D98388
2021-03-17 20:31:25 -07:00
Zakk Chen 95c0125f2b [Clang][RISCV] Add rvv vsetvl and vsetvlmax intrinsic functions.
Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D96843
2021-03-17 20:26:06 -07:00
Jim Lin 678241795c [RISCV] Don't emit #undef BUILTIN from RISCVVEmitter.cpp
In BuiltinsRISCV.def, other extension 's intrinsics need to be defined by using macro BUILTIN.
So, it shouldn't undefine macro BUILTIN in the end of declaration for V intrinsics.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D98682
2021-03-16 14:57:45 +08:00
Simon Pilgrim d53866ff47 Fix MSVC "result of 32-bit shift implicitly converted to 64 bits" warnings. NFCI. 2021-03-11 10:29:14 +00:00
Craig Topper 9773cad519 [RISCV] Add additional checking to tablgen RISCVVEmitter requested in D95016.
This errors, but doesn't give source location. We'd need to pass
the Record through several layers to get to the location.

Reviewed By: jrtc27

Differential Revision: https://reviews.llvm.org/D98379
2021-03-10 19:46:25 -08:00
Zakk Chen d6a0560bf2 [Clang][RISCV] Add custom TableGen backend for riscv-vector intrinsics.
Demonstrate how to generate vadd/vfadd intrinsic functions

1. add -gen-riscv-vector-builtins for clang builtins.
2. add -gen-riscv-vector-builtin-codegen for clang codegen.
3. add -gen-riscv-vector-header for riscv_vector.h. It also generates
ifdef directives with extension checking, base on D94403.
4. add -gen-riscv-vector-generic-header for riscv_vector_generic.h.
Generate overloading version Header for generic api.
https://github.com/riscv/rvv-intrinsic-doc/blob/master/rvv-intrinsic-rfc.md#c11-generic-interface
5. update tblgen doc for riscv related options.

riscv_vector.td also defines some unused type transformers for vadd,
because I think it could demonstrate how tranfer type work and we need
them for the whole intrinsic functions implementation in the future.

Authored-by: Roger Ferrer Ibanez <rofirrim@gmail.com>
Co-Authored-by: Zakk Chen <zakk.chen@sifive.com>

Reviewed By: jrtc27, craig.topper, HsiangKai, Jim, Paul-C-Anagnostopoulos

Differential Revision: https://reviews.llvm.org/D95016
2021-03-10 18:43:43 -08:00
Sven van Haastregt 3fa0e79372 [OpenCL] Use StringMap instead of std::map
As the LLVM Programmer's Manual suggests, use a StringMap instead of
an std::map with a StringRef key.
2021-03-02 09:37:26 +00:00
Jessica Clarke 9e0d55024d [clang][NFC] Clean up whitespace in ClangOpcodesEmitter output
This should now be about as style-conforming as TableGen'ed code ever
can reasonably be.
2021-02-27 01:28:56 +00:00
Harmen Stoppels a54f160b3a Prefer /usr/bin/env xxx over /usr/bin/xxx where xxx = perl, python, awk
Allow users to use a non-system version of perl, python and awk, which is useful
in certain package managers.

Reviewed By: JDevlieghere, MaskRay

Differential Revision: https://reviews.llvm.org/D95119
2021-02-25 11:32:27 +01:00
Zequan Wu b380699416 [Utils] Add an option to specify number of cores to use in creduce-clang-crash.py
Differential Revision: https://reviews.llvm.org/D97098
2021-02-22 12:43:09 -08:00
Ryan Santhiraraja 2c25efcbd3 [AArch64] Adding SHA3 Intrinsics support
This patch adds the following SHA3 Intrinsics:
        vsha512hq_u64,
        vsha512h2q_u64,
        vsha512su0q_u64,
        vsha512su1q_u64
        veor3q_u8
        veor3q_u16
        veor3q_u32
        veor3q_u64
        veor3q_s8
        veor3q_s16
        veor3q_s32
        veor3q_s64
        vrax1q_u64
        vxarq_u64
        vbcaxq_u8
        vbcaxq_u16
        vbcaxq_u32
        vbcaxq_u64
        vbcaxq_s8
        vbcaxq_s16
        vbcaxq_s32
        vbcaxq_s64

    Note need to include +sha3 and +crypto when building from the front-end

Reviewed By: DavidSpickett

Differential Revision: https://reviews.llvm.org/D96381
2021-02-22 12:09:20 +00:00
Richard Smith 3cd70fc59d Detect diagnostic groups that are defined in multiple 'def's.
Remove the three such groups that we've accumulated. These were causing
duplicated output to appear in generated the diagnostic reference.
2021-02-18 17:19:01 -08:00