self.emit("static inline enum svp64_state")
self.emit("svp64_disassemble_operands(struct svp64_ctx *ctx, uint32_t insn) {")
with self:
- condition = " && ".join((
- "(id < (sizeof(ctx->record->operands) / sizeof(*ctx->record->operands)))",
- "ctx->record->operands[id]",
- ))
- self.emit(f"for (size_t id = 0; ({condition}); ++id) {{")
+ self.emit(f"for (size_t id = 0; ((id != SVP64_OPERANDS) && ctx->record->operands[id]); ++id) {{")
with self:
self.emit("enum svp64_state state;")
self.emit("")
SVP64_ERROR_OPERAND_7,
};
+#define SVP64_OPERANDS 8
+
struct svp64_opcode {
uint32_t value;
uint32_t mask;
struct svp64_record {
struct svp64_opcode opcode;
- uint8_t operands[8];
+ uint8_t operands[SVP64_OPERANDS];
char name[16];
};
struct svp64_ctx {
struct svp64_record const *record;
- struct svp64_operand operands[8];
+ struct svp64_operand operands[SVP64_OPERANDS];
};
+#define svp64_foreach_operand(ctx, operand) \
+ for (size_t id = 0; \
+ (((operand = &(ctx)->operands[id]), 1) && \
+ ((id != SVP64_OPERANDS) && (ctx)->record->operands[id])); \
+ operand = &(ctx)->operands[++id])
+
enum svp64_state
svp64_disassemble(struct svp64_ctx *ctx, uint32_t insn);