Skip to content

[SYCL] Split build options into separate compile and link options #1087

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 69 additions & 53 deletions clang/test/Driver/clang-offload-wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,52 +5,64 @@
//

// RUN: clang-offload-wrapper --help | FileCheck %s --check-prefix CHECK-HELP
// CHECK-HELP: {{.*}}OVERVIEW: A tool to create a wrapper bitcode for offload target binaries.
// CHECK-HELP: {{.*}}Takes offload target binaries and optional manifest files as input
// CHECK-HELP: {{.*}}and produces bitcode file containing target binaries packaged as data
// CHECK-HELP: {{.*}}and initialization code which registers target binaries in the offload
// CHECK-HELP: {{.*}}runtime. Manifest files format and contents are not restricted and are
// CHECK-HELP: {{.*}}a subject of agreement between the device compiler and the native
// CHECK-HELP: {{.*}}runtime for that device. When present, manifest file name should
// CHECK-HELP: {{.*}}immediately follow the corresponding device image filename on the
// CHECK-HELP: {{.*}}command line. Options annotating a device binary have effect on all
// CHECK-HELP: {{.*}}subsequent input, until redefined. For example:
// CHECK-HELP: {{.*}}$clang-offload-wrapper -host x86_64-pc-linux-gnu \
// CHECK-HELP: {{.*}} -kind=sycl -target=spir64 -format=spirv -build-opts=-g \
// CHECK-HELP: {{.*}} a.spv a_mf.txt \
// CHECK-HELP: {{.*}} -target=xxx -format=native -build-opts="" \
// CHECK-HELP: {{.*}} b.bin b_mf.txt \
// CHECK-HELP: {{.*}} -kind=openmp \
// CHECK-HELP: {{.*}} c.bin
// CHECK-HELP: {{.*}}will generate an x86 wrapper object (.bc) enclosing the following
// CHECK-HELP: {{.*}}tuples describing a single device binary each ('-' means 'none')
// CHECK-HELP: {{.*}}offload kind | target | data format | data | manifest | build options:
// CHECK-HELP: {{.*}}----------------------------------------------------------------------
// CHECK-HELP: {{.*}} sycl | spir64 | spirv | a.spv| a_mf.txt | -g
// CHECK-HELP: {{.*}} sycl | xxx | native | b.bin| b_mf.txt | -
// CHECK-HELP: {{.*}} openmp | xxx | native | c.bin| - | -
// CHECK-HELP: {{.*}}USAGE: clang-offload-wrapper [options] <input files>
// CHECK-HELP: {{.*}}OPTIONS:
// CHECK-HELP: {{.*}}clang-offload-wrapper options:
// CHECK-HELP: {{.*}} --build-opts=<string> - build options passed to the offload runtime
// CHECK-HELP: {{.*}} --desc-name=<name> - Specifies offload descriptor symbol name: '.<offload kind>.<name>', and makes it globally visible
// CHECK-HELP: {{.*}} --emit-reg-funcs - Emit [un-]registration functions
// CHECK-HELP: {{.*}} --entries=<filename> - File listing all offload function entries, SYCL offload only
// CHECK-HELP: {{.*}} --format=<value> - device binary image formats:
// CHECK-HELP: {{.*}} =none - not set
// CHECK-HELP: {{.*}} =native - unknown or native
// CHECK-HELP: {{.*}} =spirv - SPIRV binary
// CHECK-HELP: {{.*}} =llvmbc - LLVMIR bitcode
// CHECK-HELP: {{.*}} --host=<triple> - Target triple for the output module
// CHECK-HELP: {{.*}} --kind=<value> - offload kind:
// CHECK-HELP: {{.*}} =unknown - unknown
// CHECK-HELP: {{.*}} =host - host
// CHECK-HELP: {{.*}} =openmp - OpenMP
// CHECK-HELP: {{.*}} =hip - HIP
// CHECK-HELP: {{.*}} =sycl - SYCL
// CHECK-HELP: {{.*}} -o=<filename> - Output filename
// CHECK-HELP: {{.*}} --target=<string> - offload target triple
// CHECK-HELP: {{.*}} -v - verbose output
// CHECK-HELP: A tool to create a wrapper bitcode for offload target binaries.
// CHECK-HELP: Takes offload target binaries and optional manifest files as input
// CHECK-HELP: and produces bitcode file containing target binaries packaged as data
// CHECK-HELP: and initialization code which registers target binaries in the offload
// CHECK-HELP: runtime. Manifest files format and contents are not restricted and are
// CHECK-HELP: a subject of agreement between the device compiler and the native
// CHECK-HELP: runtime for that device. When present, manifest file name should
// CHECK-HELP: immediately follow the corresponding device image filename on the
// CHECK-HELP: command line. Options annotating a device binary have effect on all
// CHECK-HELP: subsequent input, until redefined.
// CHECK-HELP: For example:
// CHECK-HELP: clang-offload-wrapper
// CHECK-HELP: -host x86_64-pc-linux-gnu
// CHECK-HELP: -kind=sycl
// CHECK-HELP: -target=spir64
// CHECK-HELP: -format=spirv
// CHECK-HELP: -compile-opts=-g
// CHECK-HELP: -link-opts=-cl-denorms-are-zero
// CHECK-HELP: a.spv
// CHECK-HELP: a_mf.txt
// CHECK-HELP: -target=xxx
// CHECK-HELP: -format=native
// CHECK-HELP: -compile-opts=""
// CHECK-HELP: -link-opts=""
// CHECK-HELP: b.bin
// CHECK-HELP: b_mf.txt
// CHECK-HELP: -kind=openmp
// CHECK-HELP: c.bin
// CHECK-HELP: This command generates an x86 wrapper object (.bc) enclosing the
// CHECK-HELP: following tuples describing a single device binary each:
// CHECK-HELP: offload kind | target | data format | data | manifest | build options:
// CHECK-HELP: ----------------------------------------------------------------------
// CHECK-HELP: sycl | spir64 | spirv | a.spv| a_mf.txt | -g
// CHECK-HELP: sycl | xxx | native | b.bin| b_mf.txt | -
// CHECK-HELP: openmp | xxx | native | c.bin| n/a | -
// CHECK-HELP: USAGE: clang-offload-wrapper [options] <input files>
// CHECK-HELP: OPTIONS:
// CHECK-HELP: clang-offload-wrapper options:
// CHECK-HELP: --compile-opts=<string> - compile options passed to the offload runtime
// CHECK-HELP: --desc-name=<name> - Specifies offload descriptor symbol name: '.<offload kind>.<name>', and makes it globally visible
// CHECK-HELP: --emit-reg-funcs - Emit [un-]registration functions
// CHECK-HELP: --entries=<filename> - File listing all offload function entries, SYCL offload only
// CHECK-HELP: --format=<value> - device binary image formats:
// CHECK-HELP: =none - not set
// CHECK-HELP: =native - unknown or native
// CHECK-HELP: =spirv - SPIRV binary
// CHECK-HELP: =llvmbc - LLVMIR bitcode
// CHECK-HELP: --host=<triple> - Target triple for the output module
// CHECK-HELP: --kind=<value> - offload kind:
// CHECK-HELP: =unknown - unknown
// CHECK-HELP: =host - host
// CHECK-HELP: =openmp - OpenMP
// CHECK-HELP: =hip - HIP
// CHECK-HELP: =sycl - SYCL
// CHECK-HELP: --link-opts=<string> - link options passed to the offload runtime
// CHECK-HELP: -o=<filename> - Output filename
// CHECK-HELP: --target=<string> - offload target triple
// CHECK-HELP: -v - verbose output

// -------
// Generate files to wrap.
Expand All @@ -66,8 +78,10 @@
// RUN: clang-offload-wrapper \
// RUN: -host=x86_64-pc-linux-gnu \
// RUN: -kind=openmp -target=tg2 -format=native %t3.tgt %t1_mf.txt \
// RUN: -kind=sycl -target=tg1 -build-opts=-g -format spirv %t1.tgt \
// RUN: -target=tg2 -build-opts= -format native %t2.tgt \
// RUN: -kind=sycl -target=tg1 -compile-opts=-g -link-opts=-cl-denorms-are-zero \
// RUN: -format spirv %t1.tgt \
// RUN: -target=tg2 -compile-opts= -link-opts= \
// RUN: -format native %t2.tgt \
// RUN: -o %t.wrapper.bc
// RUN: llvm-dis %t.wrapper.bc -o - | FileCheck %s --check-prefix CHECK-IR

Expand All @@ -77,7 +91,7 @@
// CHECK-IR-DAG: [[IMAGETY:%.+]] = type { i8*, i8*, [[ENTTY]]*, [[ENTTY]]* }
// CHECK-IR-DAG: [[DESCTY:%.+]] = type { i32, [[IMAGETY]]*, [[ENTTY]]*, [[ENTTY]]* }

// CHECK-IR-DAG: [[SYCL_IMAGETY:%.+]] = type { i16, i8, i8, i8*, i8*, i8*, i8*, i8*, i8*, [[ENTTY]]*, [[ENTTY]]* }
// CHECK-IR-DAG: [[SYCL_IMAGETY:%.+]] = type { i16, i8, i8, i8*, i8*, i8*, i8*, i8*, i8*, i8*, [[ENTTY]]*, [[ENTTY]]* }
// CHECK-IR-DAG: [[SYCL_DESCTY:%.+]] = type { i16, i16, [[SYCL_IMAGETY]]*, [[ENTTY]]*, [[ENTTY]]* }

// CHECK-IR: [[ENTBEGIN:@.+]] = external hidden constant [[ENTTY]]
Expand All @@ -92,14 +106,16 @@
// CHECK-IR: [[OMP_DESC:@.+]] = internal constant [[DESCTY]] { i32 1, [[IMAGETY]]* getelementptr inbounds ([1 x [[IMAGETY]]], [1 x [[IMAGETY]]]* [[OMP_IMAGES]], i64 0, i64 0), [[ENTTY]]* [[ENTBEGIN]], [[ENTTY]]* [[ENTEND]] }

// CHECK-IR: [[SYCL_TGT0:@.+]] = internal unnamed_addr constant [4 x i8] c"tg1\00"
// CHECK-IR: [[SYCL_OPTS0:@.+]] = internal unnamed_addr constant [3 x i8] c"-g\00"
// CHECK-IR: [[SYCL_COMPILE_OPTS0:@.+]] = internal unnamed_addr constant [3 x i8] c"-g\00"
// CHECK-IR: [[SYCL_LINK_OPTS0:@.+]] = internal unnamed_addr constant [21 x i8] c"-cl-denorms-are-zero\00"
// CHECK-IR: [[SYCL_BIN0:@.+]] = internal unnamed_addr constant [[SYCL_BIN0TY:\[[0-9]+ x i8\]]] c"Content of device file1{{.+}}"

// CHECK-IR: [[SYCL_TGT1:@.+]] = internal unnamed_addr constant [4 x i8] c"tg2\00"
// CHECK-IR: [[SYCL_OPTS1:@.+]] = internal unnamed_addr constant [1 x i8] zeroinitializer
// CHECK-IR: [[SYCL_COMPILE_OPTS1:@.+]] = internal unnamed_addr constant [1 x i8] zeroinitializer
// CHECK-IR: [[SYCL_LINK_OPTS1:@.+]] = internal unnamed_addr constant [1 x i8] zeroinitializer
// CHECK-IR: [[SYCL_BIN1:@.+]] = internal unnamed_addr constant [[SYCL_BIN1TY:\[[0-9]+ x i8\]]] c"Content of device file2{{.+}}"

// CHECK-IR: [[SYCL_IMAGES:@.+]] = internal unnamed_addr constant [2 x [[SYCL_IMAGETY]]] [{{.+}} { i16 1, i8 4, i8 2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* [[SYCL_TGT0]], i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* [[SYCL_OPTS0]], i64 0, i64 0), i8* null, i8* null, i8* getelementptr inbounds ([[SYCL_BIN0TY]], [[SYCL_BIN0TY]]* [[SYCL_BIN0]], i64 0, i64 0), i8* getelementptr inbounds ([[SYCL_BIN0TY]], [[SYCL_BIN0TY]]* [[SYCL_BIN0]], i64 1, i64 0), [[ENTTY]]* null, [[ENTTY]]* null }, [[SYCL_IMAGETY]] { i16 1, i8 4, i8 1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* [[SYCL_TGT1]], i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* [[SYCL_OPTS1]], i64 0, i64 0), i8* null, i8* null, i8* getelementptr inbounds ([[SYCL_BIN1TY]], [[SYCL_BIN1TY]]* [[SYCL_BIN1]], i64 0, i64 0), i8* getelementptr inbounds ([[SYCL_BIN1TY]], [[SYCL_BIN1TY]]* [[SYCL_BIN1]], i64 1, i64 0), [[ENTTY]]* null, [[ENTTY]]* null }]
// CHECK-IR: [[SYCL_IMAGES:@.+]] = internal unnamed_addr constant [2 x [[SYCL_IMAGETY]]] [{{.+}} { i16 1, i8 4, i8 2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* [[SYCL_TGT0]], i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* [[SYCL_COMPILE_OPTS0]], i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* [[SYCL_LINK_OPTS0]], i64 0, i64 0), i8* null, i8* null, i8* getelementptr inbounds ([[SYCL_BIN0TY]], [[SYCL_BIN0TY]]* [[SYCL_BIN0]], i64 0, i64 0), i8* getelementptr inbounds ([[SYCL_BIN0TY]], [[SYCL_BIN0TY]]* [[SYCL_BIN0]], i64 1, i64 0), [[ENTTY]]* null, [[ENTTY]]* null }, [[SYCL_IMAGETY]] { i16 1, i8 4, i8 1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* [[SYCL_TGT1]], i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* [[SYCL_COMPILE_OPTS1]], i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* [[SYCL_LINK_OPTS1]], i64 0, i64 0), i8* null, i8* null, i8* getelementptr inbounds ([[SYCL_BIN1TY]], [[SYCL_BIN1TY]]* [[SYCL_BIN1]], i64 0, i64 0), i8* getelementptr inbounds ([[SYCL_BIN1TY]], [[SYCL_BIN1TY]]* [[SYCL_BIN1]], i64 1, i64 0), [[ENTTY]]* null, [[ENTTY]]* null }]

// CHECK-IR: [[SYCL_DESC:@.+]] = internal constant [[SYCL_DESCTY]] { i16 1, i16 2, [[SYCL_IMAGETY]]* getelementptr inbounds ([2 x [[SYCL_IMAGETY]]], [2 x [[SYCL_IMAGETY]]]* [[SYCL_IMAGES]], i64 0, i64 0), [[ENTTY]]* null, [[ENTTY]]* null }

Expand Down Expand Up @@ -138,7 +154,7 @@
//
// RUN: clang-offload-wrapper -kind sycl -host=x86_64-pc-linux-gnu -emit-reg-funcs=0 -desc-name=lalala -o - %t.tgt | llvm-dis | FileCheck %s --check-prefix CHECK-IR1
// CHECK-IR1: source_filename = "offload.wrapper.object"
// CHECK-IR1: [[IMAGETY:%.+]] = type { i16, i8, i8, i8*, i8*, i8*, i8*, i8*, i8*, %__tgt_offload_entry*, %__tgt_offload_entry* }
// CHECK-IR1: [[IMAGETY:%.+]] = type { i16, i8, i8, i8*, i8*, i8*, i8*, i8*, i8*, i8*, %__tgt_offload_entry*, %__tgt_offload_entry* }
// CHECK-IR1: [[ENTTY:%.+]] = type { i8*, i8*, i64, i32, i32 }
// CHECK-IR1: [[DESCTY:%.+]] = type { i16, i16, [[IMAGETY]]*, [[ENTTY]]*, [[ENTTY]]* }
// CHECK-IR1-NOT: @llvm.global_ctors
Expand Down
Loading