I’m looking at the clang frontend, especially to put some POC patches up that show how we can do fun things with LLVM/offload. I want nice and clean patches but there is an issue. Often, the offloading languages (CUDA, OpenMP, HIP*, SYCL, …) seem to simply copy flags and language options from the others and then rename them. That’s very unfortunate for interoperability and code sharing in Clang.
Let’s look at an example:
def fcuda_is_device : Flag<["-"], "fcuda-is-device">
def fopenmp_is_target_device : Flag<["-"], "fopenmp-is-target-device">
def : Flag<["-"], "fopenmp-is-device">, Alias< fopenmp_is_target_device >;
def fsycl_is_device : Flag<["-"], "fsycl-is-device">,
and
LANGOPT(CUDAIsDevice , 1, 0, "compiling for CUDA device")
LANGOPT(OpenMPIsTargetDevice , 1, 0, "Generate code only for OpenMP target device")
LANGOPT(SYCLIsDevice , 1, 0, "Generate code for SYCL device")
So, 1 concept, 4 flags, 3 language options.
Do we really need this? I understand the flags might now be (semi) permanent but can we eliminate the language options at least?
Of course the solution to too many is another one:
def offload_is_device : Flag<["-"], "offload-is-device">,
LANGOPT(OffloadIsDevice, 1, 0, "generate code only for an offload device.")
with all options aliasing this one and all LangOpts uses replaced by OffloadIsDevice.
There are more such opportunities but I wanted to see what people think before I start making patches.
Maybe I overlooked an intrinsic reason we need the complexity.
~ J
* HIP reuses a lot of CUDA flags, which is weird but somehow better I guess.