[patch 16/24] Immediate Values - Powerpc Optimization

2007-12-20 Thread Mathieu Desnoyers
PowerPC optimization of the immediate values which uses a li instruction,
patched with an immediate value.

Changelog:
- Put imv_set and _imv_set in the architecture independent header.
- Pack the __imv section. Use smallest types required for size (char).
- Remove architecture specific update code : now handled by architecture
  agnostic code.
- Use imv_* instead of immediate_*.

Signed-off-by: Mathieu Desnoyers <[EMAIL PROTECTED]>
CC: Rusty Russell <[EMAIL PROTECTED]>
CC: Christoph Hellwig <[EMAIL PROTECTED]>
CC: Paul Mackerras <[EMAIL PROTECTED]>
---
 arch/powerpc/Kconfig|1 
 include/asm-powerpc/immediate.h |   55 
 2 files changed, 56 insertions(+)

Index: linux-2.6-lttng/include/asm-powerpc/immediate.h
===
--- /dev/null   1970-01-01 00:00:00.0 +
+++ linux-2.6-lttng/include/asm-powerpc/immediate.h 2007-11-19 
12:26:16.0 -0500
@@ -0,0 +1,55 @@
+#ifndef _ASM_POWERPC_IMMEDIATE_H
+#define _ASM_POWERPC_IMMEDIATE_H
+
+/*
+ * Immediate values. PowerPC architecture optimizations.
+ *
+ * (C) Copyright 2006 Mathieu Desnoyers <[EMAIL PROTECTED]>
+ *
+ * This file is released under the GPLv2.
+ * See the file COPYING for more details.
+ */
+
+#include 
+
+/**
+ * imv_read - read immediate variable
+ * @name: immediate value name
+ *
+ * Reads the value of @name.
+ * Optimized version of the immediate.
+ * Do not use in __init and __exit functions. Use _imv_read() instead.
+ */
+#define imv_read(name) \
+   ({  \
+   __typeof__(name##__imv) value;  \
+   BUILD_BUG_ON(sizeof(value) > 8);\
+   switch (sizeof(value)) {\
+   case 1: \
+   asm(".section __imv,\"a\",@progbits\n\t"\
+   PPC_LONG "%c1, ((1f)-1)\n\t"\
+   ".byte 1\n\t"   \
+   ".previous\n\t" \
+   "li %0,0\n\t"   \
+   "1:\n\t"\
+   : "=r" (value)  \
+   : "i" (##__imv));  \
+   break;  \
+   case 2: \
+   asm(".section __imv,\"a\",@progbits\n\t"\
+   PPC_LONG "%c1, ((1f)-2)\n\t"\
+   ".byte 2\n\t"   \
+   ".previous\n\t" \
+   "li %0,0\n\t"   \
+   "1:\n\t"\
+   : "=r" (value)  \
+   : "i" (##__imv));  \
+   break;  \
+   case 4: \
+   case 8: value = name##__imv;\
+   break;  \
+   };  \
+   value;  \
+   })
+
+#endif /* _ASM_POWERPC_IMMEDIATE_H */
Index: linux-2.6-lttng/arch/powerpc/Kconfig
===
--- linux-2.6-lttng.orig/arch/powerpc/Kconfig   2007-11-19 12:25:21.0 
-0500
+++ linux-2.6-lttng/arch/powerpc/Kconfig2007-11-19 12:26:01.0 
-0500
@@ -81,6 +81,7 @@ config PPC
default y
select HAVE_OPROFILE
select HAVE_KPROBES
+   select HAVE_IMMEDIATE
 
 config EARLY_PRINTK
bool

-- 
Mathieu Desnoyers
Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[patch 16/24] Immediate Values - Powerpc Optimization

2007-12-20 Thread Mathieu Desnoyers
PowerPC optimization of the immediate values which uses a li instruction,
patched with an immediate value.

Changelog:
- Put imv_set and _imv_set in the architecture independent header.
- Pack the __imv section. Use smallest types required for size (char).
- Remove architecture specific update code : now handled by architecture
  agnostic code.
- Use imv_* instead of immediate_*.

Signed-off-by: Mathieu Desnoyers [EMAIL PROTECTED]
CC: Rusty Russell [EMAIL PROTECTED]
CC: Christoph Hellwig [EMAIL PROTECTED]
CC: Paul Mackerras [EMAIL PROTECTED]
---
 arch/powerpc/Kconfig|1 
 include/asm-powerpc/immediate.h |   55 
 2 files changed, 56 insertions(+)

Index: linux-2.6-lttng/include/asm-powerpc/immediate.h
===
--- /dev/null   1970-01-01 00:00:00.0 +
+++ linux-2.6-lttng/include/asm-powerpc/immediate.h 2007-11-19 
12:26:16.0 -0500
@@ -0,0 +1,55 @@
+#ifndef _ASM_POWERPC_IMMEDIATE_H
+#define _ASM_POWERPC_IMMEDIATE_H
+
+/*
+ * Immediate values. PowerPC architecture optimizations.
+ *
+ * (C) Copyright 2006 Mathieu Desnoyers [EMAIL PROTECTED]
+ *
+ * This file is released under the GPLv2.
+ * See the file COPYING for more details.
+ */
+
+#include asm/asm-compat.h
+
+/**
+ * imv_read - read immediate variable
+ * @name: immediate value name
+ *
+ * Reads the value of @name.
+ * Optimized version of the immediate.
+ * Do not use in __init and __exit functions. Use _imv_read() instead.
+ */
+#define imv_read(name) \
+   ({  \
+   __typeof__(name##__imv) value;  \
+   BUILD_BUG_ON(sizeof(value)  8);\
+   switch (sizeof(value)) {\
+   case 1: \
+   asm(.section __imv,\a\,@progbits\n\t\
+   PPC_LONG %c1, ((1f)-1)\n\t\
+   .byte 1\n\t   \
+   .previous\n\t \
+   li %0,0\n\t   \
+   1:\n\t\
+   : =r (value)  \
+   : i (name##__imv));  \
+   break;  \
+   case 2: \
+   asm(.section __imv,\a\,@progbits\n\t\
+   PPC_LONG %c1, ((1f)-2)\n\t\
+   .byte 2\n\t   \
+   .previous\n\t \
+   li %0,0\n\t   \
+   1:\n\t\
+   : =r (value)  \
+   : i (name##__imv));  \
+   break;  \
+   case 4: \
+   case 8: value = name##__imv;\
+   break;  \
+   };  \
+   value;  \
+   })
+
+#endif /* _ASM_POWERPC_IMMEDIATE_H */
Index: linux-2.6-lttng/arch/powerpc/Kconfig
===
--- linux-2.6-lttng.orig/arch/powerpc/Kconfig   2007-11-19 12:25:21.0 
-0500
+++ linux-2.6-lttng/arch/powerpc/Kconfig2007-11-19 12:26:01.0 
-0500
@@ -81,6 +81,7 @@ config PPC
default y
select HAVE_OPROFILE
select HAVE_KPROBES
+   select HAVE_IMMEDIATE
 
 config EARLY_PRINTK
bool

-- 
Mathieu Desnoyers
Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/