public inbox for ~johnnyrichard/olang-devel@lists.sr.ht
 help / color / mirror / code / Atom feed
aa9cfb476fd1cb0e9bdebd177a54f1a0df55d7c3 blob 43062 bytes (raw)

   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
 
/*
 * Copyright (C) 2024 olang maintainers
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */
#include <assert.h>
#include <stdint.h>
#include <stdio.h>

#include "codegen_linux_x86_64.h"
#include "list.h"
#include "map.h"
#include "scope.h"

#define SYS_exit (60)
#define PTR_HEX_CSTR_SIZE (16 + 1)

// The call instruction pushes EIP into stack so the first 8 bytes from stack
// must be preserved else the ret instruction will jump to nowere.
#define X86_CALL_EIP_STACK_OFFSET (8)
#define X86_CALL_ARG_SIZE 6

#define bytes_max(a, b) ((a) > (b) ? (a) : (b))

typedef enum x86_64_register_type {
    REG_ACCUMULATOR,
    REG_BASE,
    REG_COUNTER,
    REG_DATA,
    REG_SRC_IDX,
    REG_DEST_IDX,
    REG_STACK_PTR,
    REG_BASE_PTR,
    REG_R8,
    REG_R9,
    REG_R10,
    REG_R11,
    REG_R12,
    REG_R13,
    REG_R14,
    REG_R15
} x86_64_register_type_t;

/**
 * Arch/ABI      arg1  arg2  arg3  arg4  arg5  arg6  arg7  Notes
 * ──────────────────────────────────────────────────────────────
 * x86-64        rdi   rsi   rdx   r10   r8    r9    -
 */
static int x86_call_args[X86_CALL_ARG_SIZE] = { REG_DEST_IDX, REG_SRC_IDX,
                                                REG_DATA,     REG_R10,
                                                REG_R8,       REG_R9 };

static void
codegen_linux_x86_64_emit_start_entrypoint(codegen_x86_64_t *codegen);

static void
codegen_linux_x86_64_emit_function(
    codegen_x86_64_t *codegen,
    ast_fn_definition_t *fn
);

static void
codegen_linux_x86_64_emit_if(codegen_x86_64_t *codegen, ast_if_stmt_t is_stmt);

static void
codegen_linux_x86_64_put_stack_offset(
    codegen_x86_64_t *codegen,
    symbol_t *symbol,
    size_t offset
);

static size_t
codegen_linux_x86_64_get_stack_offset(
    codegen_x86_64_t *codegen,
    symbol_t *symbol
);

static size_t
type_to_bytes(type_t *type);

static char *
get_reg_for(x86_64_register_type_t type, size_t bytes);

void
codegen_linux_x86_64_init(
    codegen_x86_64_t *codegen,
    arena_t *arena,
    FILE *out
) {
    assert(codegen);
    assert(arena);
    assert(codegen);
    codegen->base_offset = 0;
    codegen->symbols_stack_offset = map_new(arena);
    codegen->out = out;
    codegen->arena = arena;
}

void
codegen_linux_x86_64_emit_translation_unit(
    codegen_x86_64_t *codegen,
    ast_node_t *node
) {
    codegen->label_index = 0;
    codegen_linux_x86_64_emit_start_entrypoint(codegen);

    assert(node->kind == AST_NODE_TRANSLATION_UNIT);
    ast_translation_unit_t translation_unit = node->as_translation_unit;

    list_item_t *item = list_head(translation_unit.decls);

    bool main_found = false;

    while (item != NULL) {
        ast_node_t *decl = (ast_node_t *)item->value;

        if (decl->kind == AST_NODE_FN_DEF) {
            ast_fn_definition_t fn = decl->as_fn_def;
            codegen_linux_x86_64_emit_function(codegen, &fn);

            main_found = main_found || string_view_eq_to_cstr(fn.id, "main");
        } else {
            assert(0 && "translation unit only supports function declarations");
        }

        item = list_next(item);
    }

    assert(main_found && "main function is required.");
}

static void
codegen_linux_x86_64_emit_start_entrypoint(codegen_x86_64_t *codegen) {
    fprintf(codegen->out, ".text\n");
    fprintf(codegen->out, ".globl _start\n\n");

    fprintf(codegen->out, "_start:\n");
    fprintf(codegen->out, "    call main\n");
    fprintf(codegen->out, "    mov %%eax, %%edi\n");
    fprintf(codegen->out, "    mov $%d, %%eax\n", SYS_exit);
    fprintf(codegen->out, "    syscall\n");
}

static size_t
codegen_linux_x86_64_get_next_label(codegen_x86_64_t *codegen) {
    return ++codegen->label_index;
}

typedef size_t size_in_bytes_t;

static size_in_bytes_t
codegen_linux_x86_64_emit_expression(
    codegen_x86_64_t *codegen,
    ast_node_t *expr_node
) {
    switch (expr_node->kind) {
        case AST_NODE_LITERAL: {
            ast_literal_t literal_u32 = expr_node->as_literal;
            assert(literal_u32.kind == AST_LITERAL_U32);
            uint32_t n = literal_u32.as_u32;

            fprintf(codegen->out, "    mov $%d, %%eax\n", n);
            return 4;
        }
        case AST_NODE_REF: {
            ast_ref_t ref = expr_node->as_ref;

            symbol_t *symbol = scope_lookup(ref.scope, ref.id);
            assert(symbol);

            size_t offset =
                codegen_linux_x86_64_get_stack_offset(codegen, symbol);

            size_t bytes = type_to_bytes(symbol->type);

            fprintf(
                codegen->out,
                "    mov -%ld(%%rbp), %s\n",
                offset,
                get_reg_for(REG_ACCUMULATOR, bytes)
            );
            return bytes;
        }
        case AST_NODE_FN_CALL: {
            ast_fn_call_t fn_call = expr_node->as_fn_call;

            symbol_t *symbol = scope_lookup(fn_call.scope, fn_call.id);
            assert(symbol);

            size_t i = 0;
            for (list_item_t *item = list_head(fn_call.args); item != NULL;
                 item = list_next(item)) {
                // FIXME: add support for more args than X86_CALL_ARG_SIZE
                assert(i < X86_CALL_ARG_SIZE);

                ast_node_t *arg_node = (ast_node_t *)item->value;

                codegen_linux_x86_64_emit_expression(codegen, arg_node);

                fprintf(
                    codegen->out,
                    "    push %s\n",
                    get_reg_for(REG_ACCUMULATOR, 8)
                );
                ++i;
            }

            for (; i > 0; --i) {
                fprintf(
                    codegen->out,
                    "    pop %s\n",
                    get_reg_for(x86_call_args[i - 1], 8)
                );
            }

            fprintf(codegen->out, "    call " SV_FMT "\n", SV_ARG(fn_call.id));

            return type_to_bytes(symbol->type);
        }
        case AST_NODE_BINARY_OP: {
            ast_binary_op_t bin_op = expr_node->as_bin_op;
            switch (bin_op.kind) {
                case AST_BINOP_ADDITION: {
                    fprintf(codegen->out, "    xor %%rax, %%rax\n");
                    size_in_bytes_t rhs_bytes =
                        codegen_linux_x86_64_emit_expression(
                            codegen, bin_op.rhs
                        );
                    fprintf(codegen->out, "    push %%rax\n");

                    fprintf(codegen->out, "    xor %%rax, %%rax\n");
                    size_in_bytes_t lhs_bytes =
                        codegen_linux_x86_64_emit_expression(
                            codegen, bin_op.lhs
                        );

                    size_in_bytes_t expr_bytes =
                        bytes_max(rhs_bytes, lhs_bytes);

                    fprintf(codegen->out, "    pop %%rcx\n");
                    fprintf(
                        codegen->out,
                        "    add %s, %s\n",
                        get_reg_for(REG_COUNTER, expr_bytes),
                        get_reg_for(REG_ACCUMULATOR, expr_bytes)
                    );

                    return expr_bytes;
                }
                case AST_BINOP_MULTIPLICATION: {
                    fprintf(codegen->out, "    xor %%rax, %%rax\n");
                    size_in_bytes_t rhs_bytes =
                        codegen_linux_x86_64_emit_expression(
                            codegen, bin_op.rhs
                        );
                    fprintf(codegen->out, "    push %%rax\n");

                    fprintf(codegen->out, "    xor %%rax, %%rax\n");
                    size_in_bytes_t lhs_bytes =
                        codegen_linux_x86_64_emit_expression(
                            codegen, bin_op.lhs
                        );

                    size_in_bytes_t expr_bytes =
                        bytes_max(rhs_bytes, lhs_bytes);

                    fprintf(codegen->out, "    pop %%rcx\n");
                    fprintf(
                        codegen->out,
                        "    mul %s\n",
                        get_reg_for(REG_COUNTER, expr_bytes)
                    );

                    return expr_bytes;
                }
                case AST_BINOP_DIVISION: {
                    fprintf(codegen->out, "    xor %%rax, %%rax\n");
                    size_in_bytes_t rhs_bytes =
                        codegen_linux_x86_64_emit_expression(
                            codegen, bin_op.rhs
                        );
                    fprintf(codegen->out, "    push %%rax\n");

                    fprintf(codegen->out, "    xor %%rax, %%rax\n");
                    size_in_bytes_t lhs_bytes =
                        codegen_linux_x86_64_emit_expression(
                            codegen, bin_op.lhs
                        );

                    size_in_bytes_t expr_bytes =
                        bytes_max(rhs_bytes, lhs_bytes);

                    fprintf(codegen->out, "    pop %%rcx\n");
                    fprintf(codegen->out, "    xor %%rdx, %%rdx\n");
                    fprintf(
                        codegen->out,
                        "    div %s\n",
                        get_reg_for(REG_COUNTER, expr_bytes)
                    );

                    return expr_bytes;
                }
                case AST_BINOP_REMINDER: {
                    fprintf(codegen->out, "    xor %%rax, %%rax\n");
                    size_in_bytes_t rhs_bytes =
                        codegen_linux_x86_64_emit_expression(
                            codegen, bin_op.rhs
                        );
                    fprintf(codegen->out, "    push %%rax\n");

                    fprintf(codegen->out, "    xor %%rax, %%rax\n");
                    size_in_bytes_t lhs_bytes =
                        codegen_linux_x86_64_emit_expression(
                            codegen, bin_op.lhs
                        );

                    size_in_bytes_t expr_bytes =
                        bytes_max(rhs_bytes, lhs_bytes);

                    fprintf(codegen->out, "    pop %%rcx\n");
                    fprintf(codegen->out, "    xor %%rdx, %%rdx\n");
                    fprintf(
                        codegen->out,
                        "    div %s\n",
                        get_reg_for(REG_COUNTER, expr_bytes)
                    );
                    fprintf(
                        codegen->out,
                        "    mov %s, %s\n",
                        get_reg_for(REG_DATA, expr_bytes),
                        get_reg_for(REG_ACCUMULATOR, expr_bytes)
                    );

                    return expr_bytes;
                }
                case AST_BINOP_SUBTRACTION: {
                    fprintf(codegen->out, "    xor %%rax, %%rax\n");
                    size_in_bytes_t rhs_bytes =
                        codegen_linux_x86_64_emit_expression(
                            codegen, bin_op.rhs
                        );
                    fprintf(codegen->out, "    push %%rax\n");

                    fprintf(codegen->out, "    xor %%rax, %%rax\n");
                    size_in_bytes_t lhs_bytes =
                        codegen_linux_x86_64_emit_expression(
                            codegen, bin_op.lhs
                        );

                    size_in_bytes_t expr_bytes =
                        bytes_max(rhs_bytes, lhs_bytes);

                    fprintf(codegen->out, "    pop %%rcx\n");
                    fprintf(
                        codegen->out,
                        "    sub %s, %s\n",
                        get_reg_for(REG_COUNTER, expr_bytes),
                        get_reg_for(REG_ACCUMULATOR, expr_bytes)
                    );

                    return expr_bytes;
                }
                case AST_BINOP_CMP_EQ: {
                    fprintf(codegen->out, "    xor %%rax, %%rax\n");
                    size_in_bytes_t rhs_bytes =
                        codegen_linux_x86_64_emit_expression(
                            codegen, bin_op.rhs
                        );
                    fprintf(codegen->out, "    push %%rax\n");

                    fprintf(codegen->out, "    xor %%rax, %%rax\n");
                    size_in_bytes_t lhs_bytes =
                        codegen_linux_x86_64_emit_expression(
                            codegen, bin_op.lhs
                        );

                    size_in_bytes_t expr_bytes =
                        bytes_max(rhs_bytes, lhs_bytes);

                    fprintf(codegen->out, "    pop %%rcx\n");
                    fprintf(
                        codegen->out,
                        "    cmp %s, %s\n",
                        get_reg_for(REG_COUNTER, expr_bytes),
                        get_reg_for(REG_ACCUMULATOR, expr_bytes)
                    );
                    fprintf(codegen->out, "    sete %%al\n");
                    fprintf(
                        codegen->out,
                        "    movzb %%al, %s\n",
                        get_reg_for(REG_ACCUMULATOR, expr_bytes)
                    );

                    return expr_bytes;
                }
                case AST_BINOP_CMP_LT: {
                    fprintf(codegen->out, "    xor %%rax, %%rax\n");
                    size_in_bytes_t rhs_bytes =
                        codegen_linux_x86_64_emit_expression(
                            codegen, bin_op.rhs
                        );
                    fprintf(codegen->out, "    push %%rax\n");

                    fprintf(codegen->out, "    xor %%rax, %%rax\n");
                    size_in_bytes_t lhs_bytes =
                        codegen_linux_x86_64_emit_expression(
                            codegen, bin_op.lhs
                        );

                    size_in_bytes_t expr_bytes =
                        bytes_max(rhs_bytes, lhs_bytes);

                    fprintf(codegen->out, "    pop %%rcx\n");
                    fprintf(
                        codegen->out,
                        "    cmp %s, %s\n",
                        get_reg_for(REG_COUNTER, expr_bytes),
                        get_reg_for(REG_ACCUMULATOR, expr_bytes)
                    );
                    fprintf(codegen->out, "    setl %%al\n");
                    fprintf(
                        codegen->out,
                        "    movzb %%al, %s\n",
                        get_reg_for(REG_ACCUMULATOR, expr_bytes)
                    );

                    return expr_bytes;
                }
                case AST_BINOP_CMP_GT: {
                    fprintf(codegen->out, "    xor %%rax, %%rax\n");
                    size_in_bytes_t rhs_bytes =
                        codegen_linux_x86_64_emit_expression(
                            codegen, bin_op.rhs
                        );
                    fprintf(codegen->out, "    push %%rax\n");

                    fprintf(codegen->out, "    xor %%rax, %%rax\n");
                    size_in_bytes_t lhs_bytes =
                        codegen_linux_x86_64_emit_expression(
                            codegen, bin_op.lhs
                        );

                    size_in_bytes_t expr_bytes =
                        bytes_max(rhs_bytes, lhs_bytes);

                    fprintf(codegen->out, "    pop %%rcx\n");
                    fprintf(
                        codegen->out,
                        "    cmp %s, %s\n",
                        get_reg_for(REG_COUNTER, expr_bytes),
                        get_reg_for(REG_ACCUMULATOR, expr_bytes)
                    );
                    fprintf(codegen->out, "    setg %%al\n");
                    fprintf(
                        codegen->out,
                        "    movzb %%al, %s\n",
                        get_reg_for(REG_ACCUMULATOR, expr_bytes)
                    );

                    return expr_bytes;
                }
                case AST_BINOP_CMP_NEQ: {
                    fprintf(codegen->out, "    xor %%rax, %%rax\n");
                    size_in_bytes_t rhs_bytes =
                        codegen_linux_x86_64_emit_expression(
                            codegen, bin_op.rhs
                        );
                    fprintf(codegen->out, "    push %%rax\n");

                    fprintf(codegen->out, "    xor %%rax, %%rax\n");
                    size_in_bytes_t lhs_bytes =
                        codegen_linux_x86_64_emit_expression(
                            codegen, bin_op.lhs
                        );

                    size_in_bytes_t expr_bytes =
                        bytes_max(rhs_bytes, lhs_bytes);

                    fprintf(codegen->out, "    pop %%rcx\n");
                    fprintf(
                        codegen->out,
                        "    cmp %s, %s\n",
                        get_reg_for(REG_COUNTER, expr_bytes),
                        get_reg_for(REG_ACCUMULATOR, expr_bytes)
                    );
                    fprintf(codegen->out, "    setne %%al\n");
                    fprintf(
                        codegen->out,
                        "    movzb %%al, %s\n",
                        get_reg_for(REG_ACCUMULATOR, expr_bytes)
                    );

                    return expr_bytes;
                }
                case AST_BINOP_CMP_LEQ: {
                    fprintf(codegen->out, "    xor %%rax, %%rax\n");
                    size_in_bytes_t rhs_bytes =
                        codegen_linux_x86_64_emit_expression(
                            codegen, bin_op.rhs
                        );
                    fprintf(codegen->out, "    push %%rax\n");

                    fprintf(codegen->out, "    xor %%rax, %%rax\n");
                    size_in_bytes_t lhs_bytes =
                        codegen_linux_x86_64_emit_expression(
                            codegen, bin_op.lhs
                        );

                    size_in_bytes_t expr_bytes =
                        bytes_max(rhs_bytes, lhs_bytes);

                    fprintf(codegen->out, "    pop %%rcx\n");
                    fprintf(
                        codegen->out,
                        "    cmp %s, %s\n",
                        get_reg_for(REG_COUNTER, expr_bytes),
                        get_reg_for(REG_ACCUMULATOR, expr_bytes)
                    );
                    fprintf(codegen->out, "    setle %%al\n");
                    fprintf(
                        codegen->out,
                        "    movzb %%al, %s\n",
                        get_reg_for(REG_ACCUMULATOR, expr_bytes)
                    );

                    return expr_bytes;
                }
                case AST_BINOP_CMP_GEQ: {
                    fprintf(codegen->out, "    xor %%rax, %%rax\n");
                    size_in_bytes_t rhs_bytes =
                        codegen_linux_x86_64_emit_expression(
                            codegen, bin_op.rhs
                        );
                    fprintf(codegen->out, "    push %%rax\n");

                    fprintf(codegen->out, "    xor %%rax, %%rax\n");
                    size_in_bytes_t lhs_bytes =
                        codegen_linux_x86_64_emit_expression(
                            codegen, bin_op.lhs
                        );

                    size_in_bytes_t expr_bytes =
                        bytes_max(rhs_bytes, lhs_bytes);

                    fprintf(codegen->out, "    pop %%rcx\n");
                    fprintf(
                        codegen->out,
                        "    cmp %s, %s\n",
                        get_reg_for(REG_COUNTER, expr_bytes),
                        get_reg_for(REG_ACCUMULATOR, expr_bytes)
                    );
                    fprintf(codegen->out, "    setge %%al\n");
                    fprintf(
                        codegen->out,
                        "    movzb %%al, %s\n",
                        get_reg_for(REG_ACCUMULATOR, expr_bytes)
                    );

                    return expr_bytes;
                }
                case AST_BINOP_BITWISE_LSHIFT: {
                    fprintf(codegen->out, "    xor %%rax, %%rax\n");
                    codegen_linux_x86_64_emit_expression(codegen, bin_op.rhs);
                    fprintf(codegen->out, "    push %%rax\n");

                    fprintf(codegen->out, "    xor %%rax, %%rax\n");
                    size_in_bytes_t lhs_bytes =
                        codegen_linux_x86_64_emit_expression(
                            codegen, bin_op.lhs
                        );

                    fprintf(codegen->out, "    pop %%rcx\n");
                    fprintf(
                        codegen->out,
                        "    shl %%cl, %s\n",
                        get_reg_for(REG_ACCUMULATOR, lhs_bytes)
                    );

                    return lhs_bytes;
                }
                case AST_BINOP_BITWISE_RSHIFT: {
                    fprintf(codegen->out, "    xor %%rax, %%rax\n");
                    codegen_linux_x86_64_emit_expression(codegen, bin_op.rhs);
                    fprintf(codegen->out, "    push %%rax\n");

                    fprintf(codegen->out, "    xor %%rax, %%rax\n");
                    size_in_bytes_t lhs_bytes =
                        codegen_linux_x86_64_emit_expression(
                            codegen, bin_op.lhs
                        );

                    fprintf(codegen->out, "    pop %%rcx\n");
                    fprintf(
                        codegen->out,
                        "    shr %%cl, %s\n",
                        get_reg_for(REG_ACCUMULATOR, lhs_bytes)
                    );

                    return lhs_bytes;
                }
                case AST_BINOP_BITWISE_XOR: {
                    fprintf(codegen->out, "    xor %%rax, %%rax\n");
                    size_in_bytes_t rhs_bytes =
                        codegen_linux_x86_64_emit_expression(
                            codegen, bin_op.rhs
                        );
                    fprintf(codegen->out, "    push %%rax\n");

                    fprintf(codegen->out, "    xor %%rax, %%rax\n");
                    size_in_bytes_t lhs_bytes =
                        codegen_linux_x86_64_emit_expression(
                            codegen, bin_op.lhs
                        );

                    size_in_bytes_t expr_bytes =
                        bytes_max(rhs_bytes, lhs_bytes);

                    fprintf(codegen->out, "    pop %%rcx\n");
                    fprintf(
                        codegen->out,
                        "    xor %s, %s\n",
                        get_reg_for(REG_COUNTER, expr_bytes),
                        get_reg_for(REG_ACCUMULATOR, expr_bytes)
                    );

                    return expr_bytes;
                }
                case AST_BINOP_BITWISE_AND: {
                    fprintf(codegen->out, "    xor %%rax, %%rax\n");
                    size_in_bytes_t rhs_bytes =
                        codegen_linux_x86_64_emit_expression(
                            codegen, bin_op.rhs
                        );
                    fprintf(codegen->out, "    push %%rax\n");

                    fprintf(codegen->out, "    xor %%rax, %%rax\n");
                    size_in_bytes_t lhs_bytes =
                        codegen_linux_x86_64_emit_expression(
                            codegen, bin_op.lhs
                        );

                    size_in_bytes_t expr_bytes =
                        bytes_max(rhs_bytes, lhs_bytes);

                    fprintf(codegen->out, "    pop %%rcx\n");
                    fprintf(
                        codegen->out,
                        "    and %s, %s\n",
                        get_reg_for(REG_COUNTER, expr_bytes),
                        get_reg_for(REG_ACCUMULATOR, expr_bytes)
                    );

                    return expr_bytes;
                }
                case AST_BINOP_BITWISE_OR: {
                    fprintf(codegen->out, "    xor %%rax, %%rax\n");
                    size_in_bytes_t rhs_bytes =
                        codegen_linux_x86_64_emit_expression(
                            codegen, bin_op.rhs
                        );
                    fprintf(codegen->out, "    push %%rax\n");

                    fprintf(codegen->out, "    xor %%rax, %%rax\n");
                    size_in_bytes_t lhs_bytes =
                        codegen_linux_x86_64_emit_expression(
                            codegen, bin_op.lhs
                        );

                    size_in_bytes_t expr_bytes =
                        bytes_max(rhs_bytes, lhs_bytes);

                    fprintf(codegen->out, "    pop %%rcx\n");
                    fprintf(
                        codegen->out,
                        "    or %s, %s\n",
                        get_reg_for(REG_COUNTER, expr_bytes),
                        get_reg_for(REG_ACCUMULATOR, expr_bytes)
                    );

                    return expr_bytes;
                }
                case AST_BINOP_LOGICAL_AND: {
                    size_t label_exit =
                        codegen_linux_x86_64_get_next_label(codegen);

                    fprintf(codegen->out, "    xor %%rax, %%rax\n");
                    size_in_bytes_t lhs_bytes =
                        codegen_linux_x86_64_emit_expression(
                            codegen, bin_op.lhs
                        );
                    fprintf(
                        codegen->out,
                        "    cmp $0, %s\n",
                        get_reg_for(REG_ACCUMULATOR, lhs_bytes)
                    );
                    fprintf(codegen->out, "    je .L%ld\n", label_exit);

                    fprintf(codegen->out, "    xor %%rax, %%rax\n");
                    size_in_bytes_t rhs_bytes =
                        codegen_linux_x86_64_emit_expression(
                            codegen, bin_op.rhs
                        );
                    fprintf(
                        codegen->out,
                        "    cmp $0, %s\n",
                        get_reg_for(REG_ACCUMULATOR, rhs_bytes)
                    );
                    fprintf(codegen->out, "    je .L%ld\n", label_exit);
                    fprintf(codegen->out, "    mov $1, %%rax\n");
                    fprintf(codegen->out, ".L%ld:\n", label_exit);

                    return 1;
                }
                case AST_BINOP_LOGICAL_OR: {
                    size_t label_t =
                        codegen_linux_x86_64_get_next_label(codegen);
                    size_t label_f =
                        codegen_linux_x86_64_get_next_label(codegen);

                    fprintf(codegen->out, "    xor %%rax, %%rax\n");
                    size_in_bytes_t lhs_bytes =
                        codegen_linux_x86_64_emit_expression(
                            codegen, bin_op.lhs
                        );
                    fprintf(
                        codegen->out,
                        "    cmp $0, %s\n",
                        get_reg_for(REG_ACCUMULATOR, lhs_bytes)
                    );
                    fprintf(codegen->out, "    jne .L%ld\n", label_t);

                    fprintf(codegen->out, "    xor %%rax, %%rax\n");
                    size_in_bytes_t rhs_bytes =
                        codegen_linux_x86_64_emit_expression(
                            codegen, bin_op.rhs
                        );
                    fprintf(
                        codegen->out,
                        "    cmp $0, %s\n",
                        get_reg_for(REG_ACCUMULATOR, rhs_bytes)
                    );
                    fprintf(codegen->out, "    je .L%ld\n", label_f);

                    fprintf(codegen->out, ".L%ld:\n", label_t);
                    fprintf(codegen->out, "    mov $1, %%rax\n");
                    fprintf(codegen->out, ".L%ld:\n", label_f);

                    return 1;
                }
                default: {
                    assert(0 && "unsupported binary operation");
                    return 0;
                }
            }
        }

        case AST_NODE_UNARY_OP: {
            ast_unary_op_t unary_op = expr_node->as_unary_op;
            switch (unary_op.kind) {
                case AST_UNARY_BITWISE_NOT: {
                    size_in_bytes_t expr_bytes =
                        codegen_linux_x86_64_emit_expression(
                            codegen, unary_op.expr
                        );

                    fprintf(
                        codegen->out,
                        "    not %s\n",
                        get_reg_for(REG_ACCUMULATOR, expr_bytes)
                    );

                    return expr_bytes;
                }
                default: {
                    assert(0 && "unsupported unary operation");
                    return 0;
                }
            }
        }

        default:
            assert(0 && "unsupported expression");
    }
}
static void
codegen_linux_x86_64_emit_block(codegen_x86_64_t *codegen, ast_block_t *block) {
    size_t block_offset = codegen->base_offset;
    size_t nodes_len = list_size(block->nodes);

    for (size_t i = 0; i < nodes_len; ++i) {
        ast_node_t *node = list_get(block->nodes, i)->value;
        switch (node->kind) {
            case AST_NODE_RETURN_STMT: {
                ast_return_stmt_t return_stmt = node->as_return_stmt;

                ast_node_t *expr = return_stmt.expr;

                codegen_linux_x86_64_emit_expression(codegen, expr);

                fprintf(codegen->out, "    mov %%rbp, %%rsp\n");
                fprintf(codegen->out, "    pop %%rbp\n");
                fprintf(codegen->out, "    ret\n");

                break;
            }

            case AST_NODE_VAR_DEF: {
                ast_var_definition_t var_def = node->as_var_def;
                scope_t *scope = var_def.scope;

                symbol_t *symbol = scope_lookup(scope, var_def.id);
                assert(symbol);

                codegen_linux_x86_64_put_stack_offset(
                    codegen, symbol, codegen->base_offset
                );

                if (var_def.value) {
                    codegen_linux_x86_64_emit_expression(
                        codegen, var_def.value
                    );
                }

                size_t type_size = type_to_bytes(symbol->type);

                fprintf(
                    codegen->out,
                    "    mov %s, -%ld(%%rbp)\n",
                    get_reg_for(REG_ACCUMULATOR, type_size),
                    codegen->base_offset
                );
                codegen->base_offset += type_size;

                break;
            }

            case AST_NODE_VAR_ASSIGN_STMT: {
                ast_var_assign_stmt_t var_assign = node->as_var_assign_stmt;
                ast_ref_t ref = var_assign.ref->as_ref;
                scope_t *scope = ref.scope;

                symbol_t *symbol = scope_lookup(scope, ref.id);
                assert(symbol);

                size_t offset =
                    codegen_linux_x86_64_get_stack_offset(codegen, symbol);

                codegen_linux_x86_64_emit_expression(codegen, var_assign.expr);

                size_t type_size = type_to_bytes(symbol->type);
                fprintf(
                    codegen->out,
                    "    mov %s, -%ld(%%rbp)\n",
                    get_reg_for(REG_ACCUMULATOR, type_size),
                    offset
                );

                break;
            }

            case AST_NODE_IF_STMT: {
                codegen_linux_x86_64_emit_if(codegen, node->as_if_stmt);
                break;
            }

            case AST_NODE_WHILE_STMT: {
                ast_while_stmt_t while_stmt = node->as_while_stmt;

                ast_node_t *cond = while_stmt.cond;
                ast_node_t *then = while_stmt.then;

                size_t begin_label =
                    codegen_linux_x86_64_get_next_label(codegen);
                size_t end_label = codegen_linux_x86_64_get_next_label(codegen);

                fprintf(codegen->out, ".L%ld:\n", begin_label);
                codegen_linux_x86_64_emit_expression(codegen, cond);
                fprintf(codegen->out, "    cmp $1, %%rax\n");
                fprintf(codegen->out, "    jnz .L%ld\n", end_label);

                assert(
                    then->kind == AST_NODE_BLOCK && "invalid while-then block"
                );
                ast_block_t then_block = then->as_block;

                codegen_linux_x86_64_emit_block(codegen, &then_block);

                fprintf(codegen->out, "    jmp .L%ld\n", begin_label);
                fprintf(codegen->out, ".L%ld:\n", end_label);

                break;
            }
            default: {
                // FIXME: improve error: replace the node->kind to a string
                // representation
                fprintf(stderr, "node kind %d not supported\n", node->kind);
                assert(0 && "unsupported block statement");
                break;
            }
        }
    }

    codegen->base_offset = block_offset;
}

static void
codegen_linux_x86_64_emit_if(codegen_x86_64_t *codegen, ast_if_stmt_t if_stmt) {
    ast_node_t *cond = if_stmt.cond;
    ast_node_t *then = if_stmt.then;
    ast_node_t *_else = if_stmt._else;

    size_t end_if_label = codegen_linux_x86_64_get_next_label(codegen);
    size_t end_else_label = codegen_linux_x86_64_get_next_label(codegen);

    codegen_linux_x86_64_emit_expression(codegen, cond);
    fprintf(codegen->out, "    cmp $1, %%rax\n");
    fprintf(codegen->out, "    jnz .L%ld\n", end_if_label);

    assert(then->kind == AST_NODE_BLOCK && "invalid if-then block");
    ast_block_t then_block = then->as_block;

    codegen_linux_x86_64_emit_block(codegen, &then_block);
    fprintf(codegen->out, "    jmp .L%ld\n", end_else_label);

    fprintf(codegen->out, ".L%ld:\n", end_if_label);

    if (_else != NULL) {
        if (_else->kind == AST_NODE_IF_STMT) {
            ast_if_stmt_t else_if = _else->as_if_stmt;
            codegen_linux_x86_64_emit_if(codegen, else_if);
        } else {
            ast_block_t else_block = _else->as_block;
            codegen_linux_x86_64_emit_block(codegen, &else_block);
        }
    }

    fprintf(codegen->out, ".L%ld:\n", end_else_label);
}

static size_t
type_to_bytes(type_t *type) {
    switch (type->kind) {
        case TYPE_PRIMITIVE: {
            return type->as_primitive.size;
        }
        case TYPE_PTR: {
            return 8;
        }
        case TYPE_UNKNOWN: {
            assert(
                0 && "cannot calculate size of an unknown type: probably a "
                     "parser issue."
            );
        }
    }

    assert(0 && "unreachable");
}

static size_t
calculate_fn_local_size(scope_t *scope) {
    assert(scope);

    // The local_size starts with 8 bytes since the first 8 bytes from the
    // stack are reserved to store RBP during the prelude
    size_t local_size = 8;

    map_kv_t *kvs[scope->symbols->size];

    map_get_kvs(scope->symbols, kvs);

    for (size_t i = 0; i < scope->symbols->size; ++i) {
        symbol_t *symbol = (symbol_t *)kvs[i]->value;
        local_size += type_to_bytes(symbol->type);
    }

    size_t max_child_local_size = 0;

    list_item_t *item = list_head(scope->children);

    while (item != NULL) {
        size_t child_local_size =
            calculate_fn_local_size((scope_t *)item->value);

        if (child_local_size > max_child_local_size) {
            max_child_local_size = child_local_size;
        }

        item = list_next(item);
    }

    return local_size + max_child_local_size;
}

static void
codegen_linux_x86_64_emit_function(
    codegen_x86_64_t *codegen,
    ast_fn_definition_t *fn_def
) {
    codegen->base_offset = X86_CALL_EIP_STACK_OFFSET;

    ast_node_t *block_node = fn_def->block;
    fprintf(codegen->out, "" SV_FMT ":\n", SV_ARG(fn_def->id));

    fprintf(codegen->out, "    push %%rbp\n");
    fprintf(codegen->out, "    mov %%rsp, %%rbp\n");

    size_t i = 0;
    for (list_item_t *item = list_head(fn_def->params); item != NULL;
         item = list_next(item)) {
        assert(i < X86_CALL_ARG_SIZE);

        ast_fn_param_t *param = item->value;

        symbol_t *symbol = scope_lookup(fn_def->scope, param->id);
        assert(symbol);

        size_t offset = codegen->base_offset;

        codegen_linux_x86_64_put_stack_offset(
            codegen, symbol, codegen->base_offset
        );

        fprintf(
            codegen->out,
            "    mov %s, -%ld(%%rbp)\n",
            // FIXME: Type may not be an as_primitive
            get_reg_for(x86_call_args[i], symbol->type->as_primitive.size),
            offset
        );

        // FIXME: add offset according to the param size
        codegen->base_offset += 8;
        ++i;
    }

    size_t local_size = calculate_fn_local_size(fn_def->scope);

    if (local_size != 0) {
        fprintf(codegen->out, "    sub $%ld, %%rsp\n", local_size);
    }

    assert(block_node->kind == AST_NODE_BLOCK);
    ast_block_t block = block_node->as_block;

    codegen_linux_x86_64_emit_block(codegen, &block);
}

static void
codegen_linux_x86_64_put_stack_offset(
    codegen_x86_64_t *codegen,
    symbol_t *symbol,
    size_t offset
) {
    size_t *stack_offset = arena_alloc(codegen->arena, sizeof(size_t));
    *stack_offset = offset;

    char symbol_ptr[PTR_HEX_CSTR_SIZE];
    sprintf(symbol_ptr, "%lx", (uintptr_t)symbol);

    map_put(codegen->symbols_stack_offset, symbol_ptr, stack_offset);
}

static size_t
codegen_linux_x86_64_get_stack_offset(
    codegen_x86_64_t *codegen,
    symbol_t *symbol
) {
    char symbol_ptr[PTR_HEX_CSTR_SIZE];
    sprintf(symbol_ptr, "%lx", (uintptr_t)symbol);

    return *(size_t *)map_get(codegen->symbols_stack_offset, symbol_ptr);
}

static char *
get_reg_for(x86_64_register_type_t type, size_t bytes) {
    switch (type) {
        case REG_ACCUMULATOR: {
            if (bytes <= 1) {
                return "%ah";
            } else if (bytes <= 2) {
                return "%ax";
            } else if (bytes <= 4) {
                return "%eax";
            }
            return "%rax";
        }
        case REG_BASE: {
            if (bytes <= 1) {
                return "%bh";
            } else if (bytes <= 2) {
                return "%bx";
            } else if (bytes <= 4) {
                return "%ebx";
            }
            return "%rbx";
        }
        case REG_COUNTER: {
            if (bytes <= 1) {
                return "%ch";
            } else if (bytes <= 2) {
                return "%cx";
            } else if (bytes <= 4) {
                return "%ecx";
            }
            return "%rcx";
        }
        case REG_DATA: {
            if (bytes <= 1) {
                return "%dh";
            } else if (bytes <= 2) {
                return "%dx";
            } else if (bytes <= 4) {
                return "%edx";
            }
            return "%rdx";
        }
        case REG_SRC_IDX: {
            if (bytes <= 1) {
                return "%sil";
            } else if (bytes <= 2) {
                return "%si";
            } else if (bytes <= 4) {
                return "%esi";
            }
            return "%rsi";
        }
        case REG_DEST_IDX: {
            if (bytes <= 1) {
                return "%sil";
            } else if (bytes <= 2) {
                return "%di";
            } else if (bytes <= 4) {
                return "%edi";
            }
            return "%rdi";
        }
        case REG_STACK_PTR: {
            if (bytes <= 1) {
                return "%spl";
            } else if (bytes <= 2) {
                return "%sp";
            } else if (bytes <= 4) {
                return "%esp";
            }
            return "%rsp";
        }
        case REG_BASE_PTR: {
            if (bytes <= 1) {
                return "%bpl";
            } else if (bytes <= 2) {
                return "%bp";
            } else if (bytes <= 4) {
                return "%ebp";
            }
            return "%rbp";
        }
        case REG_R8: {
            if (bytes <= 1) {
                return "%r8b";
            } else if (bytes <= 2) {
                return "%r8w";
            } else if (bytes <= 4) {
                return "%r8d";
            }
            return "%r8";
        }
        case REG_R9: {
            if (bytes <= 1) {
                return "%r9b";
            } else if (bytes <= 2) {
                return "%r9w";
            } else if (bytes <= 4) {
                return "%r9d";
            }
            return "%r9";
        }
        case REG_R10: {
            if (bytes <= 1) {
                return "%r10b";
            } else if (bytes <= 2) {
                return "%r10w";
            } else if (bytes <= 4) {
                return "%r10d";
            }
            return "%r10";
        }
        case REG_R11: {
            if (bytes <= 1) {
                return "%r11b";
            } else if (bytes <= 2) {
                return "%r11w";
            } else if (bytes <= 4) {
                return "%r11d";
            }
            return "%r11";
        }
        case REG_R12: {
            if (bytes <= 1) {
                return "%r12b";
            } else if (bytes <= 2) {
                return "%r12w";
            } else if (bytes <= 4) {
                return "%r12d";
            }
            return "%r12";
        }
        case REG_R13: {
            if (bytes <= 1) {
                return "%r13b";
            } else if (bytes <= 2) {
                return "%r13w";
            } else if (bytes <= 4) {
                return "%r13d";
            }
            return "%r13";
        }
        case REG_R14: {
            if (bytes <= 1) {
                return "%r14b";
            } else if (bytes <= 2) {
                return "%r14w";
            } else if (bytes <= 4) {
                return "%r14d";
            }
            return "%r14";
        }
        case REG_R15: {
            if (bytes <= 1) {
                return "%r15b";
            } else if (bytes <= 2) {
                return "%r15w";
            } else if (bytes <= 4) {
                return "%r15d";
            }
            return "%r15";
        }
    }
    assert(0 && "invalid register");
    return NULL;
}
debug log:

solving aa9cfb4 ...
found aa9cfb4 in http://lists.johnnyrichard.com/olang/20241010013318.222905-7-carlos@maniero.me/
found c0b7326 in http://lists.johnnyrichard.com/olang/20241010013318.222905-3-carlos@maniero.me/
found 9a8d76e in http://lists.johnnyrichard.com/olang/20241010013318.222905-2-carlos@maniero.me/
found ae28aa5 in https://git.johnnyrichard.com/olang.git
preparing index
index prepared:
100644 ae28aa52330ce1eb38c1d3e1fd595f0d0af4ab40	src/codegen_linux_x86_64.c

applying [1/3] http://lists.johnnyrichard.com/olang/20241010013318.222905-2-carlos@maniero.me/
diff --git a/src/codegen_linux_x86_64.c b/src/codegen_linux_x86_64.c
index ae28aa5..9a8d76e 100644


applying [2/3] http://lists.johnnyrichard.com/olang/20241010013318.222905-3-carlos@maniero.me/
diff --git a/src/codegen_linux_x86_64.c b/src/codegen_linux_x86_64.c
index 9a8d76e..c0b7326 100644


applying [3/3] http://lists.johnnyrichard.com/olang/20241010013318.222905-7-carlos@maniero.me/
diff --git a/src/codegen_linux_x86_64.c b/src/codegen_linux_x86_64.c
index c0b7326..aa9cfb4 100644

Checking patch src/codegen_linux_x86_64.c...
Applied patch src/codegen_linux_x86_64.c cleanly.
Checking patch src/codegen_linux_x86_64.c...
Applied patch src/codegen_linux_x86_64.c cleanly.
Checking patch src/codegen_linux_x86_64.c...
Applied patch src/codegen_linux_x86_64.c cleanly.

index at:
100644 aa9cfb476fd1cb0e9bdebd177a54f1a0df55d7c3	src/codegen_linux_x86_64.c

Code repositories for project(s) associated with this public inbox

	https://git.johnnyrichard.com/olang.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox