Skip to content

Commit ae6dd2f

Browse files
committed
Add support for STL NOT instruction
Extends the language subset of Statement List by the NOT instruction, used for simply negating the current state of the rlo.
1 parent e01c4b5 commit ae6dd2f

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

src/statement-list/scanner.l

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ void statement_list_scanner_init()
116116
CLR { loc(); return TOK_CLR_RLO; }
117117
S { loc(); return TOK_SET; }
118118
R { loc(); return TOK_RESET; }
119+
NOT { loc(); return TOK_NOT; }
119120
A { loc(); return TOK_AND; }
120121
AN { loc(); return TOK_AND_NOT; }
121122
O { loc(); return TOK_OR; }

src/statement-list/statement_list_typecheck.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,8 @@ void statement_list_typecheckt::typecheck_statement_list_instruction(
387387
typecheck_statement_list_accu_real_lte(op_code);
388388
else if(ID_statement_list_accu_real_gte == statement)
389389
typecheck_statement_list_accu_real_gte(op_code);
390+
else if(ID_statement_list_not == statement)
391+
typecheck_statement_list_not(op_code);
390392
else if(ID_statement_list_and == statement)
391393
typecheck_statement_list_and(op_code, tia_element);
392394
else if(ID_statement_list_and_not == statement)
@@ -753,6 +755,20 @@ void statement_list_typecheckt::typecheck_statement_list_accu_real_gte(
753755
typecheck_accumulator_compare_instruction(ID_ge);
754756
}
755757

758+
void statement_list_typecheckt::typecheck_statement_list_not(
759+
const codet &op_code)
760+
{
761+
typecheck_instruction_without_operand(op_code);
762+
if(fc_bit)
763+
{
764+
const not_exprt unsimplified{rlo_bit};
765+
rlo_bit = simplify_expr(unsimplified, namespacet(symbol_table));
766+
or_bit = false;
767+
}
768+
else
769+
initialize_bit_expression(false_exprt{});
770+
}
771+
756772
void statement_list_typecheckt::typecheck_statement_list_and(
757773
const codet &op_code,
758774
const symbolt &tia_element)

src/statement-list/statement_list_typecheck.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,11 @@ class statement_list_typecheckt : public typecheckt
364364

365365
// Bit Logic instructions
366366

367+
/// Performs a typecheck on a STL boolean NOT instruction. Reads and modifies
368+
/// the RLO, OR and FC bit.
369+
/// \param op_code: OP code of the instruction.
370+
void typecheck_statement_list_not(const codet &op_code);
371+
367372
/// Performs a typecheck on a STL boolean And instruction. Reads and modifies
368373
/// the RLO, OR and FC bit.
369374
/// \param op_code: OP code of the instruction.

0 commit comments

Comments
 (0)