size access with unit
authorGötz Lindenmaier <goetz@ipd.info.uni-karlsruhe.de>
Fri, 28 Mar 2003 09:31:16 +0000 (09:31 +0000)
committerGötz Lindenmaier <goetz@ipd.info.uni-karlsruhe.de>
Fri, 28 Mar 2003 09:31:16 +0000 (09:31 +0000)
[r1003]

ir/ir/irmode.c
ir/ir/irmode.h

index 2937497..20b1bcf 100644 (file)
@@ -20,6 +20,7 @@
 # include "array.h"
 
 #if 0
+static long long count = 0;
 #  define ANNOUNCE() printf(__FILE__": call no. %lld (%s)\n", count++, __FUNCTION__)
 #else
 #  define ANNOUNCE() ((void)0)
@@ -29,7 +30,6 @@
  * local values
  * * */
 
-static long long count = 0;
 
 /* dynamic array to hold all modes */
 static ir_mode * modes;
@@ -226,13 +226,20 @@ get_mode_sort(ir_mode* mode)
   return mode->sort;
 }
 
-int
-get_mode_size(ir_mode *mode)
+INLINE int
+get_mode_size_bits(ir_mode *mode)
 {
   ANNOUNCE();
   return mode->size;
 }
 
+int get_mode_size_bytes(ir_mode *mode) {
+  ANNOUNCE();
+  int size = get_mode_size_bits(mode);
+  if ((size % 8) != 0) return -1;
+  return size / 8;
+}
+
 int
 get_mode_align (ir_mode *mode)
 {
index 6e38611..91984b5 100644 (file)
@@ -148,8 +148,11 @@ const char *get_mode_name(ir_mode *mode);
 /* A coarse classification of the mode */
 mode_sort get_mode_sort(ir_mode *mode);
 
-/* The size of values of the mode in bits. */
-int get_mode_size(ir_mode *mode);
+/** The size of values of the mode in bits. */
+int get_mode_size_bits(ir_mode *mode);
+/** The size of values of the mode in bytes.  If the size is not
+    dividable by 8 returns -1. */
+int get_mode_size_bytes(ir_mode *mode);
 
 /* The alignment of values of the mode in bytes. */
 int get_mode_align(ir_mode *mode);