@@ -378,6 +378,10 @@ void statement_list_typecheckt::typecheck_statement_list_instruction(
378
378
typecheck_statement_list_or (op_code, tia_element);
379
379
else if (ID_statement_list_or_not == statement)
380
380
typecheck_statement_list_or_not (op_code, tia_element);
381
+ else if (ID_statement_list_xor == statement)
382
+ typecheck_statement_list_xor (op_code, tia_element);
383
+ else if (ID_statement_list_xor_not == statement)
384
+ typecheck_statement_list_xor_not (op_code, tia_element);
381
385
else if (ID_statement_list_and_nested == statement)
382
386
typecheck_statement_list_nested_and (op_code);
383
387
else if (ID_statement_list_and_not_nested == statement)
@@ -386,6 +390,10 @@ void statement_list_typecheckt::typecheck_statement_list_instruction(
386
390
typecheck_statement_list_nested_or (op_code);
387
391
else if (ID_statement_list_or_not_nested == statement)
388
392
typecheck_statement_list_nested_or_not (op_code);
393
+ else if (ID_statement_list_xor_nested == statement)
394
+ typecheck_statement_list_nested_xor (op_code);
395
+ else if (ID_statement_list_xor_not_nested == statement)
396
+ typecheck_statement_list_nested_xor_not (op_code);
389
397
else if (ID_statement_list_nesting_closed == statement)
390
398
typecheck_statement_list_nesting_closed (op_code);
391
399
else if (ID_statement_list_assign == statement)
@@ -732,9 +740,8 @@ void statement_list_typecheckt::typecheck_statement_list_and(
732
740
const codet &op_code,
733
741
const symbolt &tia_element)
734
742
{
735
- const symbol_exprt &sym{
736
- typecheck_instruction_with_non_const_operand (op_code)};
737
- const exprt op{typecheck_identifier (tia_element, sym.get_identifier ())};
743
+ exprt op{
744
+ typecheck_simple_boolean_instruction_operand (op_code, tia_element, false )};
738
745
739
746
// If inside of a bit string and if the OR bit is not set, create an 'and'
740
747
// expression with the operand and the current contents of the rlo bit. If
@@ -755,24 +762,22 @@ void statement_list_typecheckt::typecheck_statement_list_and_not(
755
762
const codet &op_code,
756
763
const symbolt &tia_element)
757
764
{
758
- const symbol_exprt &sym{
759
- typecheck_instruction_with_non_const_operand (op_code)};
760
- const exprt op{typecheck_identifier (tia_element, sym.get_identifier ())};
761
- const not_exprt not_op{op};
765
+ exprt op{
766
+ typecheck_simple_boolean_instruction_operand (op_code, tia_element, true )};
762
767
763
768
// If inside of a bit string and if the OR bit is not set, create an 'and'
764
769
// expression with the operand and the current contents of the rlo bit. If
765
770
// the OR bit is set then this instruction is part of an 'and-before-or'
766
771
// block and needs to be added to the rlo in a special way.
767
772
if (or_bit && fc_bit)
768
- add_to_or_rlo_wrapper (not_op );
773
+ add_to_or_rlo_wrapper (op );
769
774
else if (fc_bit)
770
775
{
771
- const and_exprt unsimplified{rlo_bit, not_op };
776
+ const and_exprt unsimplified{rlo_bit, op };
772
777
rlo_bit = simplify_expr (unsimplified, namespacet (symbol_table));
773
778
}
774
779
else
775
- initialize_bit_expression (not_op );
780
+ initialize_bit_expression (op );
776
781
}
777
782
778
783
void statement_list_typecheckt::typecheck_statement_list_or (
@@ -821,6 +826,47 @@ void statement_list_typecheckt::typecheck_statement_list_or_not(
821
826
initialize_bit_expression (not_op);
822
827
}
823
828
829
+ void statement_list_typecheckt::typecheck_statement_list_xor (
830
+ const codet &op_code,
831
+ const symbolt &tia_element)
832
+ {
833
+ const symbol_exprt &sym{
834
+ typecheck_instruction_with_non_const_operand (op_code)};
835
+ const exprt op{typecheck_identifier (tia_element, sym.get_identifier ())};
836
+
837
+ // If inside of a bit string, create an 'xor' expression with the operand and
838
+ // the current contents of the rlo bit.
839
+ if (fc_bit)
840
+ {
841
+ const xor_exprt unsimplified{rlo_bit, op};
842
+ rlo_bit = simplify_expr (unsimplified, namespacet (symbol_table));
843
+ or_bit = false ;
844
+ }
845
+ else
846
+ initialize_bit_expression (op);
847
+ }
848
+
849
+ void statement_list_typecheckt::typecheck_statement_list_xor_not (
850
+ const codet &op_code,
851
+ const symbolt &tia_element)
852
+ {
853
+ const symbol_exprt &sym{
854
+ typecheck_instruction_with_non_const_operand (op_code)};
855
+ const exprt op{typecheck_identifier (tia_element, sym.get_identifier ())};
856
+ const not_exprt not_op{op};
857
+
858
+ // If inside of a bit string, create an 'xor not' expression with the
859
+ // operand and the current contents of the rlo bit.
860
+ if (fc_bit)
861
+ {
862
+ const xor_exprt unsimplified{rlo_bit, not_op};
863
+ rlo_bit = simplify_expr (unsimplified, namespacet (symbol_table));
864
+ or_bit = false ;
865
+ }
866
+ else
867
+ initialize_bit_expression (not_op);
868
+ }
869
+
824
870
void statement_list_typecheckt::typecheck_statement_list_and_before_or ()
825
871
{
826
872
if (fc_bit)
@@ -835,61 +881,49 @@ void statement_list_typecheckt::typecheck_statement_list_and_before_or()
835
881
void statement_list_typecheckt::typecheck_statement_list_nested_and (
836
882
const codet &op_code)
837
883
{
838
- typecheck_instruction_without_operand (op_code);
839
- // If inside of a bit string use the value of the rlo. If this is the first
840
- // expression of a bit string, load the value of the nested operation by
841
- // implicitly setting the rlo to true.
842
- if (!fc_bit)
843
- rlo_bit = true_exprt{};
844
- const nesting_stack_entryt stack_entry{rlo_bit, or_bit, op_code};
845
- nesting_stack.push_back (stack_entry);
846
- fc_bit = false ;
847
- or_bit = false ;
884
+ // Set the rlo to true implicitly so that the value of the AND instruction
885
+ // is being loaded in case of a new bit string.
886
+ typecheck_nested_boolean_instruction (op_code, true_exprt{});
848
887
}
849
888
850
889
void statement_list_typecheckt::typecheck_statement_list_nested_and_not (
851
890
const codet &op_code)
852
891
{
853
- typecheck_instruction_without_operand (op_code);
854
- // If inside of a bit string use the value of the rlo. If this is the first
855
- // expression of a bit string, load the value of the nested operation by
856
- // implicitly setting the rlo to true.
857
- if (!fc_bit)
858
- rlo_bit = true_exprt{};
859
- const nesting_stack_entryt stack_entry{rlo_bit, or_bit, op_code};
860
- nesting_stack.push_back (stack_entry);
861
- fc_bit = false ;
862
- or_bit = false ;
892
+ // Set the rlo to true implicitly so that the value of the AND instruction
893
+ // is being loaded in case of a new bit string.
894
+ typecheck_nested_boolean_instruction (op_code, true_exprt{});
863
895
}
864
896
865
897
void statement_list_typecheckt::typecheck_statement_list_nested_or (
866
898
const codet &op_code)
867
899
{
868
- typecheck_instruction_without_operand (op_code);
869
- // If inside of a bit string use the value of the rlo. If this is the first
870
- // expression of a bit string, load the value of the nested operation by
871
- // implicitly setting the rlo to false.
872
- if (!fc_bit)
873
- rlo_bit = false_exprt{};
874
- const nesting_stack_entryt stack_entry{rlo_bit, or_bit, op_code};
875
- nesting_stack.push_back (stack_entry);
876
- fc_bit = false ;
877
- or_bit = false ;
900
+ // Set the rlo to false implicitly so that the value of the OR instruction
901
+ // is being loaded in case of a new bit string.
902
+ typecheck_nested_boolean_instruction (op_code, false_exprt{});
878
903
}
879
904
880
905
void statement_list_typecheckt::typecheck_statement_list_nested_or_not (
881
906
const codet &op_code)
882
907
{
883
- typecheck_instruction_without_operand (op_code);
884
- // If inside of a bit string use the value of the rlo. If this is the first
885
- // expression of a bit string, load the value of the nested operation by
886
- // implicitly setting the rlo to false.
887
- if (!fc_bit)
888
- rlo_bit = false_exprt{};
889
- const nesting_stack_entryt stack_entry{rlo_bit, or_bit, op_code};
890
- nesting_stack.push_back (stack_entry);
891
- fc_bit = false ;
892
- or_bit = false ;
908
+ // Set the rlo to false implicitly so that the value of the OR instruction
909
+ // is being loaded in case of a new bit string.
910
+ typecheck_nested_boolean_instruction (op_code, false_exprt{});
911
+ }
912
+
913
+ void statement_list_typecheckt::typecheck_statement_list_nested_xor (
914
+ const codet &op_code)
915
+ {
916
+ // Set the rlo to false implicitly so that the value of the XOR instruction
917
+ // is being loaded in case of a new bit string.
918
+ typecheck_nested_boolean_instruction (op_code, false_exprt{});
919
+ }
920
+
921
+ void statement_list_typecheckt::typecheck_statement_list_nested_xor_not (
922
+ const codet &op_code)
923
+ {
924
+ // Set the rlo to false implicitly so that the value of the XOR instruction
925
+ // is being loaded in case of a new bit string.
926
+ typecheck_nested_boolean_instruction (op_code, false_exprt{});
893
927
}
894
928
895
929
void statement_list_typecheckt::typecheck_statement_list_nesting_closed (
@@ -938,6 +972,17 @@ void statement_list_typecheckt::typecheck_statement_list_nesting_closed(
938
972
or_bit = false ;
939
973
rlo_bit = or_exprt{nesting_stack.back ().rlo_bit , not_exprt{rlo_bit}};
940
974
}
975
+ else if (ID_statement_list_xor_nested == statement)
976
+ {
977
+ or_bit = false ;
978
+ rlo_bit = xor_exprt{nesting_stack.back ().rlo_bit , rlo_bit};
979
+ }
980
+ else if (ID_statement_list_xor_not_nested == statement)
981
+ {
982
+ or_bit = false ;
983
+ rlo_bit = xor_exprt{nesting_stack.back ().rlo_bit , not_exprt{rlo_bit}};
984
+ }
985
+ nesting_stack.pop_back ();
941
986
}
942
987
943
988
void statement_list_typecheckt::typecheck_statement_list_assign (
@@ -1129,6 +1174,34 @@ void statement_list_typecheckt::typecheck_binary_accumulator_instruction(
1129
1174
}
1130
1175
}
1131
1176
1177
+ void statement_list_typecheckt::typecheck_nested_boolean_instruction (
1178
+ const codet &op_code,
1179
+ const exprt &rlo_value)
1180
+ {
1181
+ typecheck_instruction_without_operand (op_code);
1182
+ // If inside of a bit string use the value of the rlo. If this is the first
1183
+ // expression of a bit string, load the value of the nested operation by
1184
+ // implicitly setting the rlo to the specified value.
1185
+ if (!fc_bit)
1186
+ rlo_bit = rlo_value;
1187
+ const nesting_stack_entryt stack_entry{rlo_bit, or_bit, op_code};
1188
+ nesting_stack.push_back (stack_entry);
1189
+ fc_bit = false ;
1190
+ or_bit = false ;
1191
+ }
1192
+
1193
+ exprt statement_list_typecheckt::typecheck_simple_boolean_instruction_operand (
1194
+ const codet &op_code,
1195
+ const symbolt &tia_element,
1196
+ bool negate)
1197
+ {
1198
+ const symbol_exprt &sym{
1199
+ typecheck_instruction_with_non_const_operand (op_code)};
1200
+ const exprt op{typecheck_identifier (tia_element, sym.get_identifier ())};
1201
+ const not_exprt not_op{op};
1202
+ return negate ? not_op : op;
1203
+ }
1204
+
1132
1205
exprt statement_list_typecheckt::typecheck_identifier (
1133
1206
const symbolt &tia_element,
1134
1207
const irep_idt &identifier)
0 commit comments