aboutgitcodelistschat:MatrixIRC
path: root/cooker/emit.c
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2023-06-07 23:02:23 +0200
committerStefano Brivio <sbrivio@redhat.com>2023-06-07 23:06:32 +0200
commitc38fccbc867019d6c063be1c1d8137edfe52f8de (patch)
treeb3c1b398b4eb40e862263ee084b1dbb7463c1ada /cooker/emit.c
parent1c1a9da7a4f9c4c1990192e14763ebf423d812a9 (diff)
downloadseitan-c38fccbc867019d6c063be1c1d8137edfe52f8de.tar
seitan-c38fccbc867019d6c063be1c1d8137edfe52f8de.tar.gz
seitan-c38fccbc867019d6c063be1c1d8137edfe52f8de.tar.bz2
seitan-c38fccbc867019d6c063be1c1d8137edfe52f8de.tar.lz
seitan-c38fccbc867019d6c063be1c1d8137edfe52f8de.tar.xz
seitan-c38fccbc867019d6c063be1c1d8137edfe52f8de.tar.zst
seitan-c38fccbc867019d6c063be1c1d8137edfe52f8de.zip
mknod/mknodat values, initial support for MASK flag, OP_BITWISE
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'cooker/emit.c')
-rw-r--r--cooker/emit.c56
1 files changed, 35 insertions, 21 deletions
diff --git a/cooker/emit.c b/cooker/emit.c
index 506a561..107b2ce 100644
--- a/cooker/emit.c
+++ b/cooker/emit.c
@@ -198,40 +198,49 @@ void emit_resolvefd(struct gluten_ctx *g, struct gluten_offset fd,
}
/**
- * emit_mask(): Emit OP_MASK instruction: mask and store
+ * emit_bitwise(): Emit OP_BITWISE instruction: bitwise operation and store
* @g: gluten context
* @type: Type of operands
- * @src: gluten pointer to source operand
- * @mask: gluten pointer to mask
+ * @op_type: Type of bitwise operation
+ * @dst: gluten pointer to destination operand, can be OFFSET_NULL
+ * @x: gluten pointer to first source operand
+ * @y: gluten pointer to second source operand
*
- * Return: offset to destination operand, allocated here
+ * Return: offset to destination operand, allocated here if not given
*/
-struct gluten_offset emit_mask(struct gluten_ctx *g, enum type type,
- struct gluten_offset src,
- struct gluten_offset mask)
+struct gluten_offset emit_bitwise(struct gluten_ctx *g, enum type type,
+ enum bitwise_type op_type,
+ struct gluten_offset dst,
+ struct gluten_offset x,
+ struct gluten_offset y)
{
struct op *op = (struct op *)gluten_ptr(&g->g, g->ip);
- struct op_mask *op_mask = &op->op.mask;
+ struct op_bitwise *op_bitwise = &op->op.bitwise;
struct gluten_offset o;
- struct mask_desc *desc;
+ struct bitwise_desc *desc;
- op->type = OP_MASK;
+ op->type = OP_BITWISE;
- o = gluten_ro_alloc(g, sizeof(struct mask_desc));
- desc = (struct mask_desc *)gluten_ptr(&g->g, o);
+ o = gluten_ro_alloc(g, sizeof(struct bitwise_desc));
+ desc = (struct bitwise_desc *)gluten_ptr(&g->g, o);
desc->size = gluten_size[type];
- desc->dst = gluten_rw_alloc(g, desc->size);
- desc->src = src;
- desc->mask = mask;
+ desc->type = op_type;
+ if (dst.type == OFFSET_NULL)
+ desc->dst = gluten_rw_alloc(g, desc->size);
+ else
+ desc->dst = dst;
+ desc->x = x;
+ desc->y = y;
- op_mask->desc = o;
+ op_bitwise->desc = o;
- debug(" %i: OP_MASK: %s: #%lu (size: %lu) := %s: #%lu & %s: #%lu",
+ debug(" %i: OP_BITWISE: %s: #%lu (size: %lu) := %s: #%lu %s %s: #%lu",
g->ip.offset,
- gluten_offset_name[desc->dst.type], desc->dst.offset, desc->size,
- gluten_offset_name[desc->src.type], desc->src.offset,
- gluten_offset_name[desc->mask.type], desc->mask.offset);
+ gluten_offset_name[desc->dst.type], desc->dst.offset, desc->size,
+ gluten_offset_name[desc->x.type], desc->x.offset,
+ bitwise_type_str[op_type],
+ gluten_offset_name[desc->y.type], desc->y.offset);
if (++g->ip.offset > INST_MAX)
die("Too many instructions");
@@ -537,5 +546,10 @@ void link_match(struct gluten_ctx *g)
{
debug(" Linking match...");
gluten_link(g, JUMP_NEXT_MATCH, (struct op *)gluten_ptr(&g->g, g->mr));
- gluten_link(g, JUMP_NEXT_ACTION, (struct op *)gluten_ptr(&g->g, g->mr));
+}
+
+void link_matches(struct gluten_ctx *g)
+{
+ debug(" Linking matches...");
+ gluten_link(g, JUMP_NEXT_ACTION, (struct op *)gluten_ptr(&g->g, g->lr));
}