1 #include "benchmark/benchmark.h"
2 #include "llvm/IR/Intrinsics.h"
5 using namespace Intrinsic
;
7 // Benchmark intrinsic lookup from a variety of targets.
8 static void BM_GetIntrinsicForClangBuiltin(benchmark::State
&state
) {
9 static const char *Builtins
[] = {
10 "__builtin_adjust_trampoline",
12 "__builtin_arm_ttest",
13 "__builtin_amdgcn_cubetc",
14 "__builtin_amdgcn_udot2",
16 "__builtin_bpf_compare",
17 "__builtin_HEXAGON_A2_max",
18 "__builtin_lasx_xvabsd_b",
19 "__builtin_mips_dlsa",
21 "__builtin_altivec_vslb",
22 "__builtin_r600_read_tgid_x",
23 "__builtin_riscv_aes64im",
24 "__builtin_s390_vcksm",
25 "__builtin_ve_vl_pvfmksge_Mvl",
26 "__builtin_ia32_axor64",
29 static const char *Targets
[] = {"", "aarch64", "amdgcn", "mips",
30 "nvvm", "r600", "riscv"};
32 for (auto _
: state
) {
33 for (auto Builtin
: Builtins
)
34 for (auto Target
: Targets
)
35 getIntrinsicForClangBuiltin(Target
, Builtin
);
40 BM_GetIntrinsicForClangBuiltinHexagonFirst(benchmark::State
&state
) {
41 // Exercise the worst case by looking for the first builtin for a target
42 // that has a lot of builtins.
44 getIntrinsicForClangBuiltin("hexagon", "__builtin_HEXAGON_A2_abs");
47 BENCHMARK(BM_GetIntrinsicForClangBuiltin
);
48 BENCHMARK(BM_GetIntrinsicForClangBuiltinHexagonFirst
);