aboutsummaryrefslogtreecommitdiff
path: root/sim/common/cgen-sim.h
diff options
context:
space:
mode:
authorDavid Edelsohn <dje.gcc@gmail.com>1997-05-01 17:45:25 +0000
committerDavid Edelsohn <dje.gcc@gmail.com>1997-05-01 17:45:25 +0000
commit2c8f0de695ce97cd6c09eca707e1a216c8b69943 (patch)
treed1f26648ab4545e72724ce2461c4f9186990a9b2 /sim/common/cgen-sim.h
parent9f4b686cb5b5377bc70b9b0b2392bef7d7628301 (diff)
downloadgdb-2c8f0de695ce97cd6c09eca707e1a216c8b69943.zip
gdb-2c8f0de695ce97cd6c09eca707e1a216c8b69943.tar.gz
gdb-2c8f0de695ce97cd6c09eca707e1a216c8b69943.tar.bz2
(EXTRACT_SIGNED,EXTRACT_UNSIGNED,HOST_LONGS_FOR_BITS): Move from
cgen-types.h to cgen-sim.h.
Diffstat (limited to 'sim/common/cgen-sim.h')
-rw-r--r--sim/common/cgen-sim.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/sim/common/cgen-sim.h b/sim/common/cgen-sim.h
index 4cfc7d2..7df7d3f 100644
--- a/sim/common/cgen-sim.h
+++ b/sim/common/cgen-sim.h
@@ -42,6 +42,20 @@ enum sim_signal_type {
void engine_halt PARAMS ((struct _sim_cpu *, enum exec_state, int));
void engine_signal PARAMS ((struct _sim_cpu *, enum sim_signal_type));
+/* Instruction field support macros. */
+
+#define EXTRACT_SIGNED(val, total, start, length) \
+(((((val) >> ((total) - ((start) + (length)))) & ((1 << (length)) - 1)) \
+ ^ (1 << ((length) - 1))) \
+ - (1 << ((length) - 1)))
+
+#define EXTRACT_UNSIGNED(val, total, start, length) \
+(((val) >> ((total) - ((start) + (length)))) & ((1 << (length)) - 1))
+
+/* Compute number of longs required to hold N bits. */
+#define HOST_LONGS_FOR_BITS(n) \
+ (((n) + sizeof (long) * 8 - 1) / sizeof (long) * 8)
+
/* Decode,extract,semantics. */
typedef void (EXTRACT_FN) PARAMS ((SIM_CPU *, PCADDR, insn_t, struct argbuf *));