diff --git a/clang/lib/Headers/riscv_ntlh.h b/clang/lib/Headers/riscv_ntlh.h --- a/clang/lib/Headers/riscv_ntlh.h +++ b/clang/lib/Headers/riscv_ntlh.h @@ -21,8 +21,23 @@ __RISCV_NTLH_ALL }; -#define __riscv_ntl_load(PTR, DOMAIN) __builtin_riscv_ntl_load((PTR), (DOMAIN)) -#define __riscv_ntl_store(PTR, VAL, DOMAIN) \ +#define __riscv_ntl_load_with_domain(PTR, DOMAIN) \ + __builtin_riscv_ntl_load((PTR), (DOMAIN)) +#define __riscv_ntl_load_without_domain(PTR) \ + __builtin_riscv_ntl_load((PTR), __RISCV_NTLH_ALL) +#define __riscv_SELECT_NTL_LOAD(_1, _2, NAME, ...) NAME + +#define __riscv_ntl_load(...) \ + __riscv_SELECT_NTL_LOAD(__VA_ARGS__, __riscv_ntl_load_with_domain, \ + __riscv_ntl_load_without_domain)(__VA_ARGS__) + +#define __riscv_ntl_store_with_domain(PTR, VAL, DOMAIN) \ __builtin_riscv_ntl_store((PTR), (VAL), (DOMAIN)) +#define __riscv_ntl_store_without_domain(PTR, VAL) \ + __builtin_riscv_ntl_store((PTR), (VAL), __RISCV_NTLH_ALL) +#define __riscv_SELECT_NTL_STORE(_1, _2, _3, NAME, ...) NAME +#define __riscv_ntl_store(...) \ + __riscv_SELECT_NTL_STORE(__VA_ARGS__, __riscv_ntl_store_with_domain, \ + __riscv_ntl_store_without_domain)(__VA_ARGS__) #endif \ No newline at end of file diff --git a/clang/test/CodeGen/RISCV/ntlh-intrinsics/riscv32-zihintntl.c b/clang/test/CodeGen/RISCV/ntlh-intrinsics/riscv32-zihintntl.c --- a/clang/test/CodeGen/RISCV/ntlh-intrinsics/riscv32-zihintntl.c +++ b/clang/test/CodeGen/RISCV/ntlh-intrinsics/riscv32-zihintntl.c @@ -100,6 +100,24 @@ *scvs1 = __riscv_ntl_load(scvs2, __RISCV_NTLH_ALL); // CHECK: load {{.*}}align 8, !nontemporal !4, !riscv-nontemporal-domain !8 *scvc1 = __riscv_ntl_load(scvc2, __RISCV_NTLH_ALL); // CHECK: load {{.*}}align 8, !nontemporal !4, !riscv-nontemporal-domain !8 + uc = __riscv_ntl_load(&sc); // CHECK: load i8{{.*}}align 1, !nontemporal !4, !riscv-nontemporal-domain !8 + sc = __riscv_ntl_load(&uc); // CHECK: load i8{{.*}}align 1, !nontemporal !4, !riscv-nontemporal-domain !8 + us = __riscv_ntl_load(&ss); // CHECK: load i16{{.*}}align 2, !nontemporal !4, !riscv-nontemporal-domain !8 + ss = __riscv_ntl_load(&us); // CHECK: load i16{{.*}}align 2, !nontemporal !4, !riscv-nontemporal-domain !8 + ui = __riscv_ntl_load(&si); // CHECK: load i32{{.*}}align 4, !nontemporal !4, !riscv-nontemporal-domain !8 + si = __riscv_ntl_load(&ui); // CHECK: load i32{{.*}}align 4, !nontemporal !4, !riscv-nontemporal-domain !8 + ull = __riscv_ntl_load(&sll); // CHECK: load i64{{.*}}align 8, !nontemporal !4, !riscv-nontemporal-domain !8 + sll = __riscv_ntl_load(&ull); // CHECK: load i64{{.*}}align 8, !nontemporal !4, !riscv-nontemporal-domain !8 + h1 = __riscv_ntl_load(&h2); // CHECK: load half{{.*}}align 2, !nontemporal !4, !riscv-nontemporal-domain !8 + f1 = __riscv_ntl_load(&f2); // CHECK: load float{{.*}}align 4, !nontemporal !4, !riscv-nontemporal-domain !8 + d1 = __riscv_ntl_load(&d2); // CHECK: load double{{.*}}align 8, !nontemporal !4, !riscv-nontemporal-domain !8 + v4si1 = __riscv_ntl_load(&v4si2); // CHECK: load <4 x i32>{{.*}}align 16, !nontemporal !4, !riscv-nontemporal-domain !8 + v8ss1 = __riscv_ntl_load(&v8ss2); // CHECK: load <8 x i16>{{.*}}align 16, !nontemporal !4, !riscv-nontemporal-domain !8 + v16sc1 = __riscv_ntl_load(&v16sc2); // CHECK: load <16 x i8>{{.*}}align 16, !nontemporal !4, !riscv-nontemporal-domain !8 + *scvi1 = __riscv_ntl_load(scvi2); // CHECK: load {{.*}}align 8, !nontemporal !4, !riscv-nontemporal-domain !8 + *scvs1 = __riscv_ntl_load(scvs2); // CHECK: load {{.*}}align 8, !nontemporal !4, !riscv-nontemporal-domain !8 + *scvc1 = __riscv_ntl_load(scvc2); // CHECK: load {{.*}}align 8, !nontemporal !4, !riscv-nontemporal-domain !8 + __riscv_ntl_store(&uc, 1, __RISCV_NTLH_INNERMOST_PRIVATE); // CHECK: store i8{{.*}}align 1, !nontemporal !4, !riscv-nontemporal-domain !5 __riscv_ntl_store(&sc, 1, __RISCV_NTLH_INNERMOST_PRIVATE); // CHECK: store i8{{.*}}align 1, !nontemporal !4, !riscv-nontemporal-domain !5 __riscv_ntl_store(&us, 1, __RISCV_NTLH_INNERMOST_PRIVATE); // CHECK: store i16{{.*}}align 2, !nontemporal !4, !riscv-nontemporal-domain !5 @@ -172,6 +190,23 @@ __riscv_ntl_store(scvs2, *scvs1, __RISCV_NTLH_ALL); // CHECK: store {{.*}}align 8, !nontemporal !4, !riscv-nontemporal-domain !8 __riscv_ntl_store(scvc2, *scvc1, __RISCV_NTLH_ALL); // CHECK: store {{.*}}align 8, !nontemporal !4, !riscv-nontemporal-domain !8 + __riscv_ntl_store(&uc, 1); // CHECK: store i8{{.*}}align 1, !nontemporal !4, !riscv-nontemporal-domain !8 + __riscv_ntl_store(&sc, 1); // CHECK: store i8{{.*}}align 1, !nontemporal !4, !riscv-nontemporal-domain !8 + __riscv_ntl_store(&us, 1); // CHECK: store i16{{.*}}align 2, !nontemporal !4, !riscv-nontemporal-domain !8 + __riscv_ntl_store(&ss, 1); // CHECK: store i16{{.*}}align 2, !nontemporal !4, !riscv-nontemporal-domain !8 + __riscv_ntl_store(&ui, 1); // CHECK: store i32{{.*}}align 4, !nontemporal !4, !riscv-nontemporal-domain !8 + __riscv_ntl_store(&si, 1); // CHECK: store i32{{.*}}align 4, !nontemporal !4, !riscv-nontemporal-domain !8 + __riscv_ntl_store(&ull, 1); // CHECK: store i64{{.*}}align 8, !nontemporal !4, !riscv-nontemporal-domain !8 + __riscv_ntl_store(&sll, 1); // CHECK: store i64{{.*}}align 8, !nontemporal !4, !riscv-nontemporal-domain !8 + __riscv_ntl_store(&h1, 1.0); // CHECK: store half{{.*}}align 2, !nontemporal !4, !riscv-nontemporal-domain !8 + __riscv_ntl_store(&f1, 1.0); // CHECK: store float{{.*}}align 4, !nontemporal !4, !riscv-nontemporal-domain !8 + __riscv_ntl_store(&d1, 1.0); // CHECK: store double{{.*}}align 8, !nontemporal !4, !riscv-nontemporal-domain !8 + __riscv_ntl_store(&v4si1, v4si2); // CHECK: store <4 x i32>{{.*}}align 16, !nontemporal !4, !riscv-nontemporal-domain !8 + __riscv_ntl_store(&v8ss1, v8ss2); // CHECK: store <8 x i16>{{.*}}align 16, !nontemporal !4, !riscv-nontemporal-domain !8 + __riscv_ntl_store(&v16sc1, v16sc2); // CHECK: store <16 x i8>{{.*}}align 16, !nontemporal !4, !riscv-nontemporal-domain !8 + __riscv_ntl_store(scvi2, *scvi1); // CHECK: store {{.*}}align 8, !nontemporal !4, !riscv-nontemporal-domain !8 + __riscv_ntl_store(scvs2, *scvs1); // CHECK: store {{.*}}align 8, !nontemporal !4, !riscv-nontemporal-domain !8 + __riscv_ntl_store(scvc2, *scvc1); // CHECK: store {{.*}}align 8, !nontemporal !4, !riscv-nontemporal-domain !8 } // clang-format on