Fangrui Song 6b3351792c [test] Add {{.*}} to make tests immune to dso_local/dso_preemptable/(none) differences
For a definition (of most linkage types), dso_local is set for ELF -fno-pic/-fpie
and COFF, but not for Mach-O.  This nuance causes unneeded binary format differences.

This patch replaces (function) `define ` with `define{{.*}} `,
(variable/constant/alias) `= ` with `={{.*}} `, or inserts appropriate `{{.*}} `
if there is an explicit linkage.

* Clang will set dso_local for Mach-O, which is currently implied by TargetMachine.cpp. This will make COFF/Mach-O and executable ELF similar.
* Eventually I hope we can make dso_local the textual LLVM IR default (write explicit "dso_preemptable" when applicable) and -fpic ELF will be similar to everything else. This patch helps move toward that goal.
2020-12-30 20:52:01 -08:00

72 lines
2.0 KiB
Common Lisp

// RUN: %clang_cc1 -emit-llvm -o - -triple x86_64-darwin-apple %s | FileCheck %s
#pragma OPENCL EXTENSION cl_khr_fp16 : enable
// CHECK-LABEL: define{{.*}} void @test_half_builtins
void test_half_builtins(half h0, half h1, half h2) {
volatile half res;
// CHECK: call half @llvm.copysign.f16(half %h0, half %h1)
res = __builtin_copysignf16(h0, h1);
// CHECK: call half @llvm.fabs.f16(half %h0)
res = __builtin_fabsf16(h0);
// CHECK: call half @llvm.ceil.f16(half %h0)
res = __builtin_ceilf16(h0);
// CHECK: call half @llvm.cos.f16(half %h0)
res = __builtin_cosf16(h0);
// CHECK: call half @llvm.exp.f16(half %h0)
res = __builtin_expf16(h0);
// CHECK: call half @llvm.exp2.f16(half %h0)
res = __builtin_exp2f16(h0);
// CHECK: call half @llvm.floor.f16(half %h0)
res = __builtin_floorf16(h0);
// CHECK: call half @llvm.fma.f16(half %h0, half %h1, half %h2)
res = __builtin_fmaf16(h0, h1 ,h2);
// CHECK: call half @llvm.maxnum.f16(half %h0, half %h1)
res = __builtin_fmaxf16(h0, h1);
// CHECK: call half @llvm.minnum.f16(half %h0, half %h1)
res = __builtin_fminf16(h0, h1);
// CHECK: frem half %h0, %h1
res = __builtin_fmodf16(h0, h1);
// CHECK: call half @llvm.pow.f16(half %h0, half %h1)
res = __builtin_powf16(h0, h1);
// CHECK: call half @llvm.log10.f16(half %h0)
res = __builtin_log10f16(h0);
// CHECK: call half @llvm.log2.f16(half %h0)
res = __builtin_log2f16(h0);
// CHECK: call half @llvm.log.f16(half %h0)
res = __builtin_logf16(h0);
// CHECK: call half @llvm.rint.f16(half %h0)
res = __builtin_rintf16(h0);
// CHECK: call half @llvm.round.f16(half %h0)
res = __builtin_roundf16(h0);
// CHECK: call half @llvm.sin.f16(half %h0)
res = __builtin_sinf16(h0);
// CHECK: call half @llvm.sqrt.f16(half %h0)
res = __builtin_sqrtf16(h0);
// CHECK: call half @llvm.trunc.f16(half %h0)
res = __builtin_truncf16(h0);
// CHECK: call half @llvm.canonicalize.f16(half %h0)
res = __builtin_canonicalizef16(h0);
}