Search
lxdream.org :: lxdream :: r1147:e04e4af64626
lxdream 0.9.1
released Jun 29
Download Now
changeset1147:e04e4af64626
parent1146:76c5d1064262
child1148:8e75fab17be8
authornkeynes
dateMon Nov 08 22:10:47 2010 +1000 (9 years ago)
Suggest to the compiler a little more firmly that it inline the x86op
functions (as these are nearly always called with constants, they can
usually be reduced down pretty dramatically)
acinclude.m4
config.h.in
configure
configure.in
src/xlat/x86/x86op.h
1.1 --- a/acinclude.m4 Mon Nov 08 18:56:11 2010 +1000
1.2 +++ b/acinclude.m4 Mon Nov 08 22:10:47 2010 +1000
1.3 @@ -18,6 +18,27 @@
1.4 $2 ])
1.5 ])
1.6
1.7 +# AC_CHECK_FORCEINLINE([if-ok],[if-notok])
1.8 +# Test if the compiler recognizes __attribute__((always_inline))
1.9 +# -----------------------
1.10 +AC_DEFUN([AC_CHECK_FORCEINLINE], [
1.11 +AC_MSG_CHECKING([support for force inlining]);
1.12 +AC_COMPILE_IFELSE([
1.13 + AC_LANG_SOURCE([[
1.14 +static int __attribute__((always_inline)) foo(int a, int b) { return a+b; }
1.15 +
1.16 +int main(int argc, char *argv[])
1.17 +{
1.18 + return foo( 1, 2 ) == 3 ? 0 : 1;
1.19 +}]])], [
1.20 + FORCEINLINE="__attribute__((always_inline))"
1.21 + AC_MSG_RESULT([$FORCEINLINE])
1.22 + $1 ], [
1.23 + FORCEINLINE=""
1.24 + AC_MSG_RESULT([no])
1.25 + $2 ])
1.26 +])
1.27 +
1.28 # AC_CHECK_FRAME_ADDRESS([if-ok],[if-notok])
1.29 # Test if the compiler will let us modify the return address on the stack
1.30 # via __builtin_frame_address()
2.1 --- a/config.h.in Mon Nov 08 18:56:11 2010 +1000
2.2 +++ b/config.h.in Mon Nov 08 22:10:47 2010 +1000
2.3 @@ -25,6 +25,9 @@
2.4 /* Enable watchpoints */
2.5 #undef ENABLE_WATCH
2.6
2.7 +/* Forcibly inline code */
2.8 +#undef FORCEINLINE
2.9 +
2.10 /* translation domain */
2.11 #undef GETTEXT_PACKAGE
2.12
2.13 @@ -76,9 +79,6 @@
2.14 /* Define if your <locale.h> file defines LC_MESSAGES. */
2.15 #undef HAVE_LC_MESSAGES
2.16
2.17 -/* Define to 1 if you have the `GL' library (-lGL). */
2.18 -#undef HAVE_LIBGL
2.19 -
2.20 /* Define to 1 if you have the `OSMesa' library (-lOSMesa). */
2.21 #undef HAVE_LIBOSMESA
2.22
3.1 --- a/configure Mon Nov 08 18:56:11 2010 +1000
3.2 +++ b/configure Mon Nov 08 22:10:47 2010 +1000
3.3 @@ -8124,6 +8124,64 @@
3.4
3.5
3.6
3.7 +{ echo "$as_me:$LINENO: checking support for force inlining" >&5
3.8 +echo $ECHO_N "checking support for force inlining... $ECHO_C" >&6; };
3.9 +cat >conftest.$ac_ext <<_ACEOF
3.10 +
3.11 + /* confdefs.h. */
3.12 +_ACEOF
3.13 +cat confdefs.h >>conftest.$ac_ext
3.14 +cat >>conftest.$ac_ext <<_ACEOF
3.15 +/* end confdefs.h. */
3.16 +
3.17 +static int __attribute__((always_inline)) foo(int a, int b) { return a+b; }
3.18 +
3.19 +int main(int argc, char *argv[])
3.20 +{
3.21 + return foo( 1, 2 ) == 3 ? 0 : 1;
3.22 +}
3.23 +_ACEOF
3.24 +rm -f conftest.$ac_objext
3.25 +if { (ac_try="$ac_compile"
3.26 +case "(($ac_try" in
3.27 + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
3.28 + *) ac_try_echo=$ac_try;;
3.29 +esac
3.30 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
3.31 + (eval "$ac_compile") 2>conftest.er1
3.32 + ac_status=$?
3.33 + grep -v '^ *+' conftest.er1 >conftest.err
3.34 + rm -f conftest.er1
3.35 + cat conftest.err >&5
3.36 + echo "$as_me:$LINENO: \$? = $ac_status" >&5
3.37 + (exit $ac_status); } && {
3.38 + test -z "$ac_c_werror_flag" ||
3.39 + test ! -s conftest.err
3.40 + } && test -s conftest.$ac_objext; then
3.41 +
3.42 + FORCEINLINE="__attribute__((always_inline))"
3.43 + { echo "$as_me:$LINENO: result: $FORCEINLINE" >&5
3.44 +echo "${ECHO_T}$FORCEINLINE" >&6; }
3.45 +
3.46 +else
3.47 + echo "$as_me: failed program was:" >&5
3.48 +sed 's/^/| /' conftest.$ac_ext >&5
3.49 +
3.50 +
3.51 + FORCEINLINE=""
3.52 + { echo "$as_me:$LINENO: result: no" >&5
3.53 +echo "${ECHO_T}no" >&6; }
3.54 +
3.55 +fi
3.56 +
3.57 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
3.58 +
3.59 +
3.60 +cat >>confdefs.h <<_ACEOF
3.61 +#define FORCEINLINE $FORCEINLINE
3.62 +_ACEOF
3.63 +
3.64 +
3.65 { echo "$as_me:$LINENO: checking if we have a working __builtin_frame_address()" >&5
3.66 echo $ECHO_N "checking if we have a working __builtin_frame_address()... $ECHO_C" >&6; };
3.67 if test "$cross_compiling" = yes; then
4.1 --- a/configure.in Mon Nov 08 18:56:11 2010 +1000
4.2 +++ b/configure.in Mon Nov 08 22:10:47 2010 +1000
4.3 @@ -178,6 +178,8 @@
4.4 AC_CHECK_FASTCALL([
4.5 AC_DEFINE(HAVE_FASTCALL, [1], [Use fast register-passing calling conventions])
4.6 ])
4.7 +AC_CHECK_FORCEINLINE()
4.8 +AC_DEFINE_UNQUOTED(FORCEINLINE, [$FORCEINLINE], [Forcibly inline code])
4.9 AC_CHECK_FRAME_ADDRESS( [
4.10 AC_DEFINE(HAVE_FRAME_ADDRESS, [1], [Define if we have a working builtin frame_address])
4.11 ], [ AC_MSG_WARN([Memory exceptions will be slow]) ])
5.1 --- a/src/xlat/x86/x86op.h Mon Nov 08 18:56:11 2010 +1000
5.2 +++ b/src/xlat/x86/x86op.h Mon Nov 08 22:10:47 2010 +1000
5.3 @@ -154,7 +154,7 @@
5.4 /**
5.5 * Encode opcode+reg with no mod/rm (eg MOV imm64, r32)
5.6 */
5.7 -static void x86_encode_opcodereg( int rexw, uint32_t opcode, int reg )
5.8 +static inline void x86_encode_opcodereg( int rexw, uint32_t opcode, int reg )
5.9 {
5.10 int rex = rexw;
5.11 reg &= 0x0F;
5.12 @@ -174,7 +174,7 @@
5.13 * @param rr reg field
5.14 * @param rb r/m field
5.15 */
5.16 -static void x86_encode_reg_rm( int rexw, uint32_t opcode, int rr, int rb )
5.17 +static inline void x86_encode_reg_rm( int rexw, uint32_t opcode, int rr, int rb )
5.18 {
5.19 int rex = rexw;
5.20 rr &= 0x0F;
5.21 @@ -203,7 +203,7 @@
5.22 * @param ss Scale shift (0..3) applied to index register (ignored if no index register)
5.23 * @param disp32 Signed displacement (0 for none)
5.24 */
5.25 -static void x86_encode_modrm( int rexw, uint32_t opcode, int rr, int rb, int rx, int ss, int32_t disp32 )
5.26 +static inline void FORCEINLINE x86_encode_modrm( int rexw, uint32_t opcode, int rr, int rb, int rx, int ss, int32_t disp32 )
5.27 {
5.28 /* Construct the rex prefix where necessary */
5.29 int rex = rexw;
5.30 @@ -290,7 +290,7 @@
5.31 * @param rr mod/rm reg field
5.32 * @param disp32 RIP-relative displacement
5.33 */
5.34 -static void x86_encode_modrm_rip(int rexw, uint32_t opcode, int rr, int32_t disp32)
5.35 +static inline void x86_encode_modrm_rip(int rexw, uint32_t opcode, int rr, int32_t disp32)
5.36 {
5.37 int rex = rexw;
5.38 rr &= 0x0F;
.