Lines Matching +full:1 +full:- +full:3

3  *  Copyright(c) 2019-2023 rev.ng Labs Srl. All Rights Reserved.
14 #include "idef-parser.h"
15 #include "parser-helpers.h"
16 #include "idef-parser.tab.h"
17 #include "idef-parser.yy.h"
26 %lex-param {void *scanner}
27 %parse-param {void *scanner}
28 %parse-param {Context *c}
50 %expect 1
89 %left '-' '+'
114 gen_inst(c, $1);
123 gen_inst_code(c, &@1);
140 track_string(c, $1.var.name);
141 $$ = $1;
164 * is assumed where longs are 64-bit, long longs are then
165 * assumed to also be 64-bit.
169 yyassert(c, &@1, $1.bit_width <= 64,
170 "Variables with size > 64-bit are not supported!");
171 $$ = $1;
196 * assumed to be used in for-loops.
211 gen_varid_allocate(c, &@1, &$2, $1.bit_width, $1.signedness);
215 $$.signedness = $1.signedness;
216 $$.bit_width = $1.bit_width;
223 c->inst.code_begin = c->input_buffer + @2.first_column - 1;
224 c->inst.code_end = c->input_buffer + @2.last_column - 1;
235 emit_arg(c, &@1, &$1);
239 emit_arg(c, &@1, &$1);
241 g_array_append_val(c->inst.init_list, $1);
253 EMIT_SIG(c, ", int %ciV", $1.imm.id);
276 @1.last_column = @3.last_column;
277 gen_assign(c, &@1, &$1, &$3);
278 $$ = $1;
282 @1.last_column = @3.last_column;
283 gen_assign(c, &@1, &$1, &$3);
284 $$ = $1;
288 @1.last_column = @3.last_column;
289 HexValue tmp = gen_bin_op(c, &@1, ADD_OP, &$1, &$3);
290 gen_assign(c, &@1, &$1, &tmp);
291 $$ = $1;
295 @1.last_column = @3.last_column;
296 HexValue tmp = gen_bin_op(c, &@1, SUB_OP, &$1, &$3);
297 gen_assign(c, &@1, &$1, &tmp);
298 $$ = $1;
302 @1.last_column = @3.last_column;
303 HexValue tmp = gen_bin_op(c, &@1, ANDB_OP, &$1, &$3);
304 gen_assign(c, &@1, &$1, &tmp);
305 $$ = $1;
309 @1.last_column = @3.last_column;
310 HexValue tmp = gen_bin_op(c, &@1, ORB_OP, &$1, &$3);
311 gen_assign(c, &@1, &$1, &tmp);
312 $$ = $1;
316 @1.last_column = @3.last_column;
317 HexValue tmp = gen_bin_op(c, &@1, XORB_OP, &$1, &$3);
318 gen_assign(c, &@1, &$1, &tmp);
319 $$ = $1;
323 @1.last_column = @3.last_column;
324 gen_pred_assign(c, &@1, &$1, &$3);
328 @1.last_column = @3.last_column;
329 yyassert(c, &@1, $3.type == IMMEDIATE,
330 "Cannot assign non-immediate to immediate!");
331 yyassert(c, &@1, $1.imm.type == VARIABLE,
332 "Cannot assign to non-variable!");
334 OUT(c, &@1, &$1, " = ", &$3, ";\n");
335 $$ = $1;
339 @1.last_column = @12.last_column;
340 yyassert(c, &@1, !is_inside_ternary(c),
341 "Assignment side-effect not modeled!");
342 yyassert(c, &@1, $3.imm.value == 1,
344 gen_load(c, &@1, &$5, $7, &$9, &$11);
349 @1.last_column = @10.last_column;
350 yyassert(c, &@1, !is_inside_ternary(c),
351 "Assignment side-effect not modeled!");
352 yyassert(c, &@1, $3.imm.value == 1,
354 gen_store(c, &@1, &$5, &$7, &$9);
358 @1.last_column = @3.last_column;
359 yyassert(c, &@1, !is_inside_ternary(c),
360 "Assignment side-effect not modeled!");
361 $3 = gen_rvalue_truncate(c, &@1, &$3);
362 $3 = rvalue_materialize(c, &@1, &$3);
363 OUT(c, &@1, "gen_set_usr_field(ctx, USR_LPCFG, ", &$3, ");\n");
367 @1.last_column = @8.last_column;
368 yyassert(c, &@1, !is_inside_ternary(c),
369 "Assignment side-effect not modeled!");
370 gen_deposit_op(c, &@1, &$5, &$7, &$3, &$1);
374 @1.last_column = @8.last_column;
375 yyassert(c, &@1, !is_inside_ternary(c),
376 "Assignment side-effect not modeled!");
377 gen_sethalf(c, &@1, &$1, &$3, &$5, &$7);
381 @1.last_column = @10.last_column;
382 yyassert(c, &@1, !is_inside_ternary(c),
383 "Assignment side-effect not modeled!");
384 gen_setbits(c, &@1, &$3, &$5, &$7, &$9);
388 @1.last_column = @10.last_column;
389 yyassert(c, &@1, !is_inside_ternary(c),
390 "Assignment side-effect not modeled!");
391 gen_rdeposit_op(c, &@1, &$3, &$9, &$7, &$5);
395 @1.last_column = @4.last_column;
396 $$ = $3;
411 gen_load_cancel(c, &@1);
415 gen_cancel(c, &@1);
423 OUT(c, &@1, "gen_set_label(if_label_", &$1, ");\n");
427 @1.last_column = @2.last_column;
428 $2 = gen_if_else(c, &@1, $1);
432 OUT(c, &@1, "gen_set_label(if_label_", &$2, ");\n");
438 yyassert(c, &@3,
439 $3.imm.type == I &&
443 @1.last_column = @13.last_column;
444 OUT(c, &@1, "for (int ", &$3, " = ", &$5, "; ",
446 OUT(c, &@1, "; ", &$11, "++) {\n");
450 OUT(c, &@1, "}\n");
456 @1.last_column = @3.last_column;
457 $1 = gen_if_cond(c, &@1, &$3);
461 $$ = $1;
467 yyassert(c, &@1, false, "Encountered a FAIL token as rvalue.\n");
472 $$ = $1;
476 $$ = $1;
480 $$ = gen_rvalue_pred(c, &@1, &$1);
505 $$ = gen_rvalue_var(c, &@1, &$1);
509 @1.last_column = @6.last_column;
510 $$ = gen_rvalue_mpy(c, &@1, &$1, &$3, &$5);
514 @1.last_column = @3.last_column;
515 $$ = gen_bin_op(c, &@1, ADD_OP, &$1, &$3);
517 | rvalue '-' rvalue
519 @1.last_column = @3.last_column;
520 $$ = gen_bin_op(c, &@1, SUB_OP, &$1, &$3);
524 @1.last_column = @3.last_column;
525 $$ = gen_bin_op(c, &@1, MUL_OP, &$1, &$3);
529 @1.last_column = @3.last_column;
530 $$ = gen_bin_op(c, &@1, ASL_OP, &$1, &$3);
534 @1.last_column = @3.last_column;
535 assert_signedness(c, &@1, $1.signedness);
536 if ($1.signedness == UNSIGNED) {
537 $$ = gen_bin_op(c, &@1, LSR_OP, &$1, &$3);
538 } else if ($1.signedness == SIGNED) {
539 $$ = gen_bin_op(c, &@1, ASR_OP, &$1, &$3);
544 @1.last_column = @3.last_column;
545 $$ = gen_bin_op(c, &@1, LSR_OP, &$1, &$3);
549 @1.last_column = @3.last_column;
550 $$ = gen_bin_op(c, &@1, ANDB_OP, &$1, &$3);
554 @1.last_column = @3.last_column;
555 $$ = gen_bin_op(c, &@1, ORB_OP, &$1, &$3);
559 @1.last_column = @3.last_column;
560 $$ = gen_bin_op(c, &@1, XORB_OP, &$1, &$3);
564 @1.last_column = @3.last_column;
565 $$ = gen_bin_op(c, &@1, ANDL_OP, &$1, &$3);
569 @1.last_column = @3.last_column;
570 $$ = gen_bin_op(c, &@1, MINI_OP, &$3, &$5);
574 @1.last_column = @3.last_column;
575 $$ = gen_bin_op(c, &@1, MAXI_OP, &$3, &$5);
579 @1.last_column = @2.last_column;
580 $$ = gen_rvalue_not(c, &@1, &$2);
584 @1.last_column = @2.last_column;
585 $$ = gen_rvalue_notl(c, &@1, &$2);
589 @1.last_column = @6.last_column;
590 $$ = gen_rvalue_sat(c, &@1, &$1, &$3, &$5);
594 @1.last_column = @2.last_column;
595 $$ = gen_cast_op(c, &@1, &$2, $1.bit_width, $1.signedness);
599 @1.last_column = @3.last_column;
600 $$ = gen_bin_cmp(c, &@1, TCG_COND_EQ, &$1, &$3);
604 @1.last_column = @3.last_column;
605 $$ = gen_bin_cmp(c, &@1, TCG_COND_NE, &$1, &$3);
609 @1.last_column = @3.last_column;
611 assert_signedness(c, &@1, $1.signedness);
612 assert_signedness(c, &@1, $3.signedness);
613 if ($1.signedness == UNSIGNED || $3.signedness == UNSIGNED) {
614 $$ = gen_bin_cmp(c, &@1, TCG_COND_LTU, &$1, &$3);
616 $$ = gen_bin_cmp(c, &@1, TCG_COND_LT, &$1, &$3);
621 @1.last_column = @3.last_column;
623 assert_signedness(c, &@1, $1.signedness);
624 assert_signedness(c, &@1, $3.signedness);
625 if ($1.signedness == UNSIGNED || $3.signedness == UNSIGNED) {
626 $$ = gen_bin_cmp(c, &@1, TCG_COND_GTU, &$1, &$3);
628 $$ = gen_bin_cmp(c, &@1, TCG_COND_GT, &$1, &$3);
633 @1.last_column = @3.last_column;
635 assert_signedness(c, &@1, $1.signedness);
636 assert_signedness(c, &@1, $3.signedness);
637 if ($1.signedness == UNSIGNED || $3.signedness == UNSIGNED) {
638 $$ = gen_bin_cmp(c, &@1, TCG_COND_LEU, &$1, &$3);
640 $$ = gen_bin_cmp(c, &@1, TCG_COND_LE, &$1, &$3);
645 @1.last_column = @3.last_column;
647 assert_signedness(c, &@1, $1.signedness);
648 assert_signedness(c, &@1, $3.signedness);
649 if ($1.signedness == UNSIGNED || $3.signedness == UNSIGNED) {
650 $$ = gen_bin_cmp(c, &@1, TCG_COND_GEU, &$1, &$3);
652 $$ = gen_bin_cmp(c, &@1, TCG_COND_GE, &$1, &$3);
659 t.cond = $1;
660 g_array_append_val(c->ternary, t);
664 Ternary *t = &g_array_index(c->ternary, Ternary,
665 c->ternary->len - 1);
666 t->state = IN_RIGHT;
670 @1.last_column = @5.last_column;
671 $$ = gen_rvalue_ternary(c, &@1, &$1, &$4, &$7);
675 @1.last_column = @4.last_column;
676 $$ = gen_rvalue_fscr(c, &@1, &$3);
680 @1.last_column = @8.last_column;
681 yyassert(c, &@1, $5.type == IMMEDIATE &&
684 $$ = gen_extend_op(c, &@1, &$3, 64, &$7, SIGNED);
688 @1.last_column = @8.last_column;
689 yyassert(c, &@1, $5.type == IMMEDIATE &&
692 $$ = gen_extend_op(c, &@1, &$3, 64, &$7, UNSIGNED);
700 @1.last_column = @2.last_column;
701 $$ = gen_rvalue_abs(c, &@1, &$2);
705 @1.last_column = @6.last_column;
706 $$ = gen_convround_n(c, &@1, &$3, &$5);
710 @1.last_column = @4.last_column;
711 $$ = gen_convround(c, &@1, &$3);
715 @1.last_column = @6.last_column;
716 $$ = gen_round(c, &@1, &$3, &$5);
718 | '-' rvalue
720 @1.last_column = @2.last_column;
721 $$ = gen_rvalue_neg(c, &@1, &$2);
725 @1.last_column = @6.last_column;
726 $$ = gen_tmp(c, &@1, 32, UNSIGNED);
727 OUT(c, &@1, "gen_read_ireg(", &$$, ", ", &$3, ", ", &$6, ");\n");
731 @1.last_column = @8.last_column;
732 gen_circ_op(c, &@1, &$3, &$5, &$7);
736 @1.last_column = @4.last_column;
738 $$ = gen_locnt_op(c, &@1, &$3);
742 @1.last_column = @4.last_column;
744 $$ = gen_ctpop_op(c, &@1, &$3);
748 @1.last_column = @6.last_column;
749 $$ = gen_extract_op(c, &@1, &$5, &$3, &$1);
753 @1.last_column = @8.last_column;
754 yyassert(c, &@1, $5.type == IMMEDIATE &&
760 &@1,
761 &$3,
763 $5.imm.value - $7.imm.value + 1);
767 @1.last_column = @4.last_column;
768 $$ = gen_rvalue_truncate(c, &@1, &$3);
770 $$ = rvalue_materialize(c, &@1, &$$);
771 $$ = gen_rvalue_extend(c, &@1, &$$);
775 @1.last_column = @4.last_column;
776 $$ = gen_rvalue_brev(c, &@1, &$3);
780 @1.last_column = @6.last_column;
781 $$ = gen_rotl(c, &@1, &$3, &$5);
785 @1.last_column = @8.last_column;
786 gen_addsat64(c, &@1, &$3, &$5, &$7);
790 @1.last_column = @8.last_column;
791 $$ = gen_carry_from_add(c, &@1, &$3, &$5, &$7);
795 @1.last_column = @4.last_column;
796 HexValue one = gen_imm_value(c, &@1, 1, 32, UNSIGNED);
797 $$ = gen_bin_op(c, &@1, ANDB_OP, &$3, &one);
803 yyassert(c, &@1, false, "Encountered a FAIL token as lvalue.\n");
807 $$ = $1;
811 $$ = $1;
825 return 1;
844 fputs("#include \"tcg/tcg-op.h\"\n", output_file);
845 fputs("#include \"exec/helper-gen.h\"\n", output_file);
875 context.input_buffer = (char *) calloc(input_size + 1, sizeof(char));
883 return -1;