Commit Graph

119 Commits

Author SHA1 Message Date
Timothy Arceri
4d982ae2c7 gallium/st/clover: remove unused PIPE_SHADER_IR_LLVM
This has been unused since 100796c15c.

Acked-by: Marek Olšák <marek.olsak@amd.com>
2018-02-01 13:56:34 +11:00
Jan Vesely
3115687f9b clover: Fix build after LLVM r313390
v2: pass llvm context reference instead of a pointer

Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
Reviewed-by: Francisco Jerez <currojerez@riseup.net>
2017-09-15 21:39:54 -04:00
Jan Vesely
b295a52836 clover: Fix build since clang r301442
v2: rename default_ik -> ik_opencl

Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
Reviewed-by: Francisco Jerez <currojerez@riseup.net>
2017-04-27 12:52:25 -04:00
Jan Vesely
010fecb853 clover: Dump linked binary to a different file
this allows to pass the generated files directly to llc or bugpoint

v2: add atomic counter ID
v3: remove extra scope operator, constify

Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
Reviewed-by: Francisco Jerez <currojerez@riseup.net>
2017-02-27 16:11:48 -05:00
Vedran Miletić
d9fef848a6 clover: Use Clang's diagnostics
Presently errors from frontend are handled only if they occur in
clang::CompilerInvocation::CreateFromArgs(). This patch uses
clang::DiagnosticsEngine to detect errors such as invalid values for
Clang frontend arguments.

Fixes Piglit's cl/program/build/fail/invalid-version-declaration.cl
test.

v2: fix inconsistent code formatting

Signed-off-by: Vedran Miletić <vedran@miletic.net>
Reviewed-by: Francisco Jerez <currojerez@riseup.net>
Tested-by: Aaron Watry <awatry@gmail.com>
2016-12-24 18:35:09 -08:00
Serge Martin
cc495055cd clover: Add CL_PROGRAM_BINARY_TYPE support (CL1.2).
v3 [Francisco Jerez]: Loosely based on Serge's v1 of this patch in
   order to avoid CL-specific enums in the clover module binary
   format.  In addition to other changes made in v2: Represent the CL
   program binary type as the section type instead of adding a CL
   API-specific enum, check that the binary types of the input objects
   are valid during clLinkProgram(), pass section type as argument to
   build_module_library() instead of using separate function.

Reviewed-by: Francisco Jerez <currojerez@riseup.net>
2016-11-06 15:56:54 +01:00
Niels Ole Salscheider
cfa914a1b4 st/clover: Define __OPENCL_VERSION__ on the device side
This is required by the OpenCL standard.

Signed-off-by: Niels Ole Salscheider <niels_ole@salscheider-online.de>
Reviewed-by: Edward O'Callaghan <funfunctor@folklore1984.net>
Reviewed-by: Vedran Miletić <vedran@miletic.net>
2016-09-10 15:48:54 -07:00
Tom Stellard
106946153f clover: Re-order includes in invocation.cpp to fix build
The build was failing because the official CL headers have a few defines,
like: # define cl_khr_gl_sharing 1

Which have the same name as some class members of clang's OpenCLOptions class.
If we include the cl headers first, this breaks the build because the member
names of this class are replaced by the literal 1.

Reviewed-by: Francisco Jerez <currojerez@riseup.net>
Reviewed-by: Vedran Miletić <vedran@miletic.net>
2016-07-20 21:15:53 +00:00
Tom Stellard
a73bf11a63 clover: Add missing include v2
clang commit r275822 removed unnecessary includes from header files,
so we now need to explicitly include clang/Lex/PreprocessorOptions.h

v2:
  - Use <> instead of "" for the include path.

Reviewed-by: Francisco Jerez <currojerez@riseup.net>
Reviewed-by: Vedran Miletić <vedran@miletic.net>
2016-07-20 21:15:53 +00:00
Francisco Jerez
c2e37fe1f9 clover/llvm: Get rid of compile_program_llvm().
Superseded by compile_program() and link_program().

Reviewed-by: Serge Martin <edb+mesa@sigluy.net>
Tested-by: Jan Vesely <jan.vesely@rutgers.edu>
2016-07-11 20:34:35 -07:00
Francisco Jerez
2a73ae662c clover: Define error subclass to signal build option parse failure.
Reviewed-by: Serge Martin <edb+mesa@sigluy.net>
Tested-by: Jan Vesely <jan.vesely@rutgers.edu>
2016-07-11 20:34:34 -07:00
Francisco Jerez
4ef1c0918d clover: Move back to using build_error to signal compilation failure.
This partially reverts 7e0180d57d.
Having two different exception subclasses for compilation and linking
makes it more difficult to share or move code between the two
codepaths, because the exact same function under the same error
condition would need to throw one exception or the other depending on
what top-level API is being implemented with it.  There is little
benefit anyway because clCompileProgram() and clLinkProgram() can tell
whether they are linking or compiling a program.

Reviewed-by: Serge Martin <edb+mesa@sigluy.net>
Tested-by: Jan Vesely <jan.vesely@rutgers.edu>
2016-07-11 20:34:34 -07:00
Francisco Jerez
fb3eeb1314 clover/llvm: Implement the -create-library linker option.
[ Serge Martin: disable internalize pass when building a library.
  Otherwise some functions may be inlined and removed ]

Reviewed-by: Serge Martin <edb+mesa@sigluy.net>
Tested-by: Jan Vesely <jan.vesely@rutgers.edu>
2016-07-11 20:34:34 -07:00
Francisco Jerez
9de3f4a59f clover/llvm: Implement linkage of multiple clover modules.
Reviewed-by: Serge Martin <edb+mesa@sigluy.net>
Tested-by: Jan Vesely <jan.vesely@rutgers.edu>
2016-07-11 20:34:34 -07:00
Francisco Jerez
132b6ccd4f clover/llvm: Split compilation and linking.
Split the work previously done by compile_program_llvm() into
compile_program() (which simply runs the front-end and serializes the
resulting LLVM IR) and link_program() (which takes care of everything
else down to binary codegen).

[ Serge Martin: allow LLVM IR dump after compilation ]

Reviewed-by: Serge Martin <edb+mesa@sigluy.net>
Tested-by: Jan Vesely <jan.vesely@rutgers.edu>
2016-07-11 20:34:34 -07:00
Francisco Jerez
86100e13ab clover/llvm: Trivial assorted cleanups for invocation.cpp.
Drop a few include and using directives which are no longer necessary.

Reviewed-by: Serge Martin <edb+mesa@sigluy.net>
Tested-by: Jan Vesely <jan.vesely@rutgers.edu>
2016-07-11 20:34:34 -07:00
Francisco Jerez
520cc26859 clover/llvm: Split native codegen into separate file.
Reviewed-by: Serge Martin <edb+mesa@sigluy.net>
Tested-by: Jan Vesely <jan.vesely@rutgers.edu>
2016-07-11 20:34:34 -07:00
Francisco Jerez
8195637363 clover/llvm: Split bitcode codegen into separate file.
Reviewed-by: Serge Martin <edb+mesa@sigluy.net>
Tested-by: Jan Vesely <jan.vesely@rutgers.edu>
2016-07-11 20:34:33 -07:00
Francisco Jerez
71ac9820d6 clover/llvm: Split shared codegen support code into separate file.
This is the common part of the code used to generate a clover::module
from LLVM bitcode, shared between the native and LLVM paths.

Reviewed-by: Serge Martin <edb+mesa@sigluy.net>
Tested-by: Jan Vesely <jan.vesely@rutgers.edu>
2016-07-11 20:34:33 -07:00
Francisco Jerez
26fa9bfd0d clover/llvm: Define function for bitcode print-out.
Reviewed-by: Serge Martin <edb+mesa@sigluy.net>
Tested-by: Jan Vesely <jan.vesely@rutgers.edu>
2016-07-11 20:34:33 -07:00
Francisco Jerez
f0721020ad clover/llvm: Split native codegen and assembly print-out into separate functions.
Reviewed-by: Serge Martin <edb+mesa@sigluy.net>
Tested-by: Jan Vesely <jan.vesely@rutgers.edu>
2016-07-11 20:34:33 -07:00
Francisco Jerez
1d042adc0a clover/llvm: Clean up bitcode codegen.
Reviewed-by: Serge Martin <edb+mesa@sigluy.net>
Tested-by: Jan Vesely <jan.vesely@rutgers.edu>
2016-07-11 20:34:33 -07:00
Francisco Jerez
952d1e6fd6 clover/llvm: Use metadata introspection utils for kernel enumeration.
Reviewed-by: Serge Martin <edb+mesa@sigluy.net>
Tested-by: Jan Vesely <jan.vesely@rutgers.edu>
2016-07-11 20:34:33 -07:00
Francisco Jerez
d37d5842c1 clover/llvm: Use metadata introspection utils for kernel argument set-up.
Reviewed-by: Serge Martin <edb+mesa@sigluy.net>
Tested-by: Jan Vesely <jan.vesely@rutgers.edu>
2016-07-11 20:34:33 -07:00
Francisco Jerez
7da2c1ff0f clover/llvm: Clean up codestyle of get_kernel_args().
Reviewed-by: Serge Martin <edb+mesa@sigluy.net>
Tested-by: Jan Vesely <jan.vesely@rutgers.edu>
2016-07-11 20:22:59 -07:00
Francisco Jerez
0601fe7438 clover/llvm: Fold compile_native() call into build_module_native().
Reviewed-by: Serge Martin <edb+mesa@sigluy.net>
Tested-by: Jan Vesely <jan.vesely@rutgers.edu>
2016-07-11 20:22:56 -07:00
Francisco Jerez
f98422eafd clover/llvm: Factor out duplicated construction of clover::module.
Reviewed-by: Serge Martin <edb+mesa@sigluy.net>
Tested-by: Jan Vesely <jan.vesely@rutgers.edu>
2016-07-11 20:22:53 -07:00
Francisco Jerez
3ce6ab068c clover/llvm: Clean up compile_native().
This switches compile_native() to the C++ API (which the rest of this
file makes use of anyway so there is little benefit from using the C
API), what should get rid of an amount of boilerplate and fix a leak
of the TargetMachine object in the error path.

v2: Additional fixes for LLVM 3.6.
v3: Update for the latest LLVM SVN changes.

Reviewed-by: Serge Martin <edb+mesa@sigluy.net>
Tested-by: Jan Vesely <jan.vesely@rutgers.edu>
2016-07-11 20:22:50 -07:00
Francisco Jerez
7bcefa5903 clover/llvm: Clean up ELF parsing.
This function was doing three separate things:
 - Initializing and releasing the ELF parsing state (the latter can be
   better done using RAII).
 - Searching for the symbol table in the ELF file.
 - Extraction of kernel symbol offsets from the symbol table.

Split each one into a separate function for clarity and clean up the
result slightly.

Reviewed-by: Serge Martin <edb+mesa@sigluy.net>
Tested-by: Jan Vesely <jan.vesely@rutgers.edu>
2016-07-11 20:22:48 -07:00
Francisco Jerez
574477e599 clover/llvm: Move a bunch of utility functions into separate file.
Some of these will be useful from a different compilation unit in the
same subtree so put them in a publicly accessible header file.

Reviewed-by: Serge Martin <edb+mesa@sigluy.net>
Tested-by: Jan Vesely <jan.vesely@rutgers.edu>
2016-07-11 20:22:43 -07:00
Francisco Jerez
92247cef3f clover/llvm: Tidy debug handling.
Most significant change is debugging flags are now a scoped enum and
all debugging helpers live in the debug namespace.

Reviewed-by: Serge Martin <edb+mesa@sigluy.net>
Tested-by: Jan Vesely <jan.vesely@rutgers.edu>
2016-07-11 20:22:40 -07:00
Francisco Jerez
4614397ac2 clover/llvm: Use helper function to abort compilation with error message.
Reviewed-by: Serge Martin <edb+mesa@sigluy.net>
Tested-by: Jan Vesely <jan.vesely@rutgers.edu>
2016-07-11 20:22:37 -07:00
Francisco Jerez
423eecb76a clover/llvm: Simplify diagnostic_handler().
Reviewed-by: Serge Martin <edb+mesa@sigluy.net>
Tested-by: Jan Vesely <jan.vesely@rutgers.edu>
2016-07-11 20:22:29 -07:00
Francisco Jerez
5884dfbc2a clover/llvm: Trivial codestyle clean-up for optimize().
Reviewed-by: Serge Martin <edb+mesa@sigluy.net>
Tested-by: Jan Vesely <jan.vesely@rutgers.edu>
2016-07-11 20:22:21 -07:00
Francisco Jerez
bdc27f13d5 clover/llvm: Clean up compilation into LLVM IR.
Some assorted and mostly trivial clean-ups for the source to bitcode
compilation path.

Reviewed-by: Serge Martin <edb+mesa@sigluy.net>
Tested-by: Jan Vesely <jan.vesely@rutgers.edu>
2016-07-11 20:21:50 -07:00
Francisco Jerez
714b167f57 clover/llvm: Factor out LLVM context init.
So it can be shared between the compilation and linking codepaths.

Reviewed-by: Serge Martin <edb+mesa@sigluy.net>
Tested-by: Jan Vesely <jan.vesely@rutgers.edu>
2016-07-11 20:21:30 -07:00
Francisco Jerez
fa94055d53 clover/llvm: Declare compiler instance at top level and pass down as argument.
This allows simplifying the interface of compile_llvm() because it no
longer needs to read out and return the optimization level and address
space map from the compiler instance.  Instead declare the compiler
instance at the top level so that both properties are available
directly.

Reviewed-by: Serge Martin <edb+mesa@sigluy.net>
Tested-by: Jan Vesely <jan.vesely@rutgers.edu>
2016-07-11 20:21:13 -07:00
Francisco Jerez
a27d4ec3b9 clover/llvm: Refactor compiler instance initialization.
This will be shared between the compiler and linker codepaths.

Reviewed-by: Serge Martin <edb+mesa@sigluy.net>
Tested-by: Jan Vesely <jan.vesely@rutgers.edu>
2016-07-11 20:21:08 -07:00
Francisco Jerez
c2a167ad73 clover/llvm: Factor out compiler option tokenization.
Reviewed-by: Serge Martin <edb+mesa@sigluy.net>
Tested-by: Jan Vesely <jan.vesely@rutgers.edu>
2016-07-11 20:20:47 -07:00
Francisco Jerez
c513cfa747 clover/llvm: Factor out target string parsing.
Reviewed-by: Serge Martin <edb+mesa@sigluy.net>
Tested-by: Jan Vesely <jan.vesely@rutgers.edu>
2016-07-11 20:20:41 -07:00
Francisco Jerez
251054220e clover/llvm: Collect #ifdef mess into a separate file.
This gets rid of most ifdef's from the invocation.cpp code -- Only a
couple of them are left which will be removed differently in the
following commits.

Reviewed-by: Serge Martin <edb+mesa@sigluy.net>
Tested-by: Jan Vesely <jan.vesely@rutgers.edu>
2016-07-11 20:20:12 -07:00
Francisco Jerez
11afde89b8 clover/llvm: Drop dead code.
This ifdef'ed out code was meant to handle compilation into TGSI, but
it doesn't seem likely that it will ever be useful even if the TGSI
back-end is resurrected because the TGSI bitcode can just be plumbed
through in ELF format and dealt with as a regular "native" back-end.

Reviewed-by: Serge Martin <edb+mesa@sigluy.net>
Tested-by: Jan Vesely <jan.vesely@rutgers.edu>
2016-07-11 20:20:05 -07:00
Francisco Jerez
600ac51448 clover/llvm: Drop support for LLVM < 3.6.
Reviewed-by: Serge Martin <edb+mesa@sigluy.net>
Tested-by: Jan Vesely <jan.vesely@rutgers.edu>
2016-07-11 20:19:49 -07:00
Jan Vesely
87787e9079 clover: Fix kernel metadata retrieval after clang r273425
Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
Acked-by: Francisco Jerez <currojerez@riseup.net>
2016-06-27 23:12:37 -07:00
Francisco Jerez
a8a966ddb5 clover/llvm: Fix copyright attribution of invocation.cpp.
This file still only has my name on the copyright notice even though
most of the code (likely more than 90% of it) was authored by various
contributors -- It doesn't seem right to have the whole file
attributed to myself.

Acked-by: Michel Dänzer <michel.daenzer@amd.com>
Acked-by: Serge Martin <edb+mesa@sigluy.net>
2016-06-27 23:12:35 -07:00
Vedran Miletić
82e0bbd01a clover: Fix build against clang SVN >= r273191
setLangDefaults() now requires PreprocessorOptions as an argument.

Reviewed-and-Tested-by: Michel Dänzer <michel.daenzer@amd.com>
2016-06-21 10:08:57 +09:00
Jan Vesely
9525f33164 clover: Handle PIPE_SHADER_IR_NIR in switch
Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
Reviewed-by: Francisco Jerez <currojerez@riseup.net>
2016-05-15 20:05:10 -04:00
Michel Dänzer
860210ccfc clover: Fix build against clang SVN >= r267772
(Re-pushing previous fix for clang SVN r265359, which was reverted in
the meantime)

Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Tom Stellard <thomas.stellard@amd.com>
2016-04-28 12:57:03 +09:00
Michel Dänzer
171a570f38 clover: Fix build against LLVM SVN >= r266163
createInternalizePass now takes a callback instead of a StringSet.

Reviewed-by: Francisco Jerez <currojerez@riseup.net>
2016-04-14 11:53:41 +09:00
Michel Dänzer
715e97e342 Revert "clover: Fix build against clang SVN >= r265359"
This reverts commit 0daab9878d.

The corresponding clang change was reverted.

Trivial.
2016-04-07 17:03:09 +09:00