[SYCL] Add clang front-end option to enable SYCL device compilation flow.

Patch by Mariya Podchishchaeva <mariya.podchishchaeva@intel.com>

llvm-svn: 354773
This commit is contained in:
Alexey Bader 2019-02-25 11:48:48 +00:00
parent 478cd32bcb
commit 3f62fa69a7
5 changed files with 22 additions and 1 deletions

View File

@ -217,6 +217,8 @@ LANGOPT(CUDAHostDeviceConstexpr, 1, 1, "treating unattributed constexpr function
LANGOPT(CUDADeviceApproxTranscendentals, 1, 0, "using approximate transcendental functions")
LANGOPT(GPURelocatableDeviceCode, 1, 0, "generate relocatable device code")
LANGOPT(SYCLIsDevice , 1, 0, "Generate code for SYCL device")
LANGOPT(SizedDeallocation , 1, 0, "sized deallocation")
LANGOPT(AlignedAllocation , 1, 0, "aligned allocation")
LANGOPT(AlignedAllocationUnavailable, 1, 0, "aligned allocation functions are unavailable")

View File

@ -836,8 +836,14 @@ def fopenmp_is_device : Flag<["-"], "fopenmp-is-device">,
def fopenmp_host_ir_file_path : Separate<["-"], "fopenmp-host-ir-file-path">,
HelpText<"Path to the IR file produced by the frontend for the host.">;
} // let Flags = [CC1Option]
//===----------------------------------------------------------------------===//
// SYCL Options
//===----------------------------------------------------------------------===//
def fsycl_is_device : Flag<["-"], "fsycl-is-device">,
HelpText<"Generate code for SYCL device.">;
} // let Flags = [CC1Option]
//===----------------------------------------------------------------------===//
// cc1as-only Options

View File

@ -2879,6 +2879,8 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
<< Opts.OMPHostIRFile;
}
Opts.SYCLIsDevice = Args.hasArg(options::OPT_fsycl_is_device);
// Set CUDA mode for OpenMP target NVPTX if specified in options
Opts.OpenMPCUDAMode = Opts.OpenMPIsDevice && T.isNVPTX() &&
Args.hasArg(options::OPT_fopenmp_cuda_mode);

View File

@ -1057,6 +1057,12 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
Builder.defineMacro("__CLANG_CUDA_APPROX_TRANSCENDENTALS__");
}
// Define a macro indicating that the source file is being compiled with a
// SYCL device compiler which doesn't produce host binary.
if (LangOpts.SYCLIsDevice) {
Builder.defineMacro("__SYCL_DEVICE_ONLY__", "1");
}
// OpenCL definitions.
if (LangOpts.OpenCL) {
#define OPENCLEXT(Ext) \

View File

@ -0,0 +1,5 @@
// RUN: %clang_cc1 %s -E -dM | FileCheck %s
// RUN: %clang_cc1 %s -fsycl-is-device -E -dM | FileCheck --check-prefix=CHECK-SYCL %s
// CHECK-NOT:#define __SYCL_DEVICE_ONLY__ 1
// CHECK-SYCL:#define __SYCL_DEVICE_ONLY__ 1