compiler: intrinsify some math/bits functions
Let the Go frontend recognize some math/bits functions and turn
them into intrinsics.
Corresponding change in the GCC backend:
Index: gcc/go/go-gcc.cc
===================================================================
--- gcc/go/go-gcc.cc (revision 272290)
+++ gcc/go/go-gcc.cc (working copy)
@@ -613,7 +613,7 @@
NULL_TREE),
false, false);
- // Used by runtime/internal/sys.
+ // Used by runtime/internal/sys and math/bits.
this->define_builtin(BUILT_IN_CTZ, "__builtin_ctz", "ctz",
build_function_type_list(integer_type_node,
unsigned_type_node,
@@ -624,6 +624,31 @@
long_long_unsigned_type_node,
NULL_TREE),
true, false);
+ this->define_builtin(BUILT_IN_CLZ, "__builtin_clz", "clz",
+ build_function_type_list(integer_type_node,
+ unsigned_type_node,
+ NULL_TREE),
+ true, false);
+ this->define_builtin(BUILT_IN_CLZLL, "__builtin_clzll", "clzll",
+ build_function_type_list(integer_type_node,
+ long_long_unsigned_type_node,
+ NULL_TREE),
+ true, false);
+ this->define_builtin(BUILT_IN_POPCOUNT, "__builtin_popcount", "popcount",
+ build_function_type_list(integer_type_node,
+ unsigned_type_node,
+ NULL_TREE),
+ true, false);
+ this->define_builtin(BUILT_IN_POPCOUNTLL, "__builtin_popcountll", "popcountll",
+ build_function_type_list(integer_type_node,
+ long_long_unsigned_type_node,
+ NULL_TREE),
+ true, false);
+ this->define_builtin(BUILT_IN_BSWAP16, "__builtin_bswap16", "bswap16",
+ build_function_type_list(uint16_type_node,
+ uint16_type_node,
+ NULL_TREE),
+ true, false);
this->define_builtin(BUILT_IN_BSWAP32, "__builtin_bswap32", "bswap32",
build_function_type_list(uint32_type_node,
uint32_type_node,
Change-Id: If44b18882c885f1c93d4682890f176b89cbc5b1a
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/183266
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 files changed