-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgcc_8.2.0_flare32.patch
3167 lines (3167 loc) · 77.8 KB
/
gcc_8.2.0_flare32.patch
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
diff -x build-x86_64-pc-linux-gnu -x host-x86_64-pc-linux-gnu -x config.log -x config.status -x flare32-elf -x '*.taghl' -x tags -x Makefile -Nur gcc-8.2.0/config.sub gcc-8.2.0-flare32/config.sub
--- gcc-8.2.0/config.sub 2018-01-02 23:25:18.000000000 -0500
+++ gcc-8.2.0-flare32/config.sub 2018-12-02 08:24:57.914953797 -0500
@@ -258,6 +258,7 @@
| d10v | d30v | dlx | dsp16xx \
| e2k | epiphany \
| fido | fr30 | frv | ft32 \
+ | flare32 \
| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
| hexagon \
| i370 | i860 | i960 | ia16 | ia64 \
diff -x build-x86_64-pc-linux-gnu -x host-x86_64-pc-linux-gnu -x config.log -x config.status -x flare32-elf -x '*.taghl' -x tags -x Makefile -Nur gcc-8.2.0/gcc/config/flare32/flare32_actual.hpp gcc-8.2.0-flare32/gcc/config/flare32/flare32_actual.hpp
--- gcc-8.2.0/gcc/config/flare32/flare32_actual.hpp 1969-12-31 19:00:00.000000000 -0500
+++ gcc-8.2.0-flare32/gcc/config/flare32/flare32_actual.hpp 2018-12-05 09:17:05.795321685 -0500
@@ -0,0 +1,1302 @@
+#define IN_TARGET_CODE 1
+
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "backend.h"
+#include "target.h"
+#include "rtl.h"
+#include "tree.h"
+#include "stringpool.h"
+#include "attribs.h"
+#include "df.h"
+#include "regs.h"
+#include "memmodel.h"
+#include "emit-rtl.h"
+#include "diagnostic-core.h"
+#include "output.h"
+#include "stor-layout.h"
+#include "varasm.h"
+#include "calls.h"
+#include "expr.h"
+#include "builtins.h"
+
+#include "flare32-protos.h"
+
+/* This file should be included last. */
+#include "target-def.h"
+
+
+// Per-function machine data.
+struct GTY(()) machine_function
+{
+ static constexpr int STACK_ALIGNMENT = STACK_BOUNDARY / BITS_PER_UNIT;
+
+ // Number of bytes saved on the stack for callee saved registers.
+ int callee_saved_reg_size;
+
+ // Number of bytes saved on the stack for local variables.
+ int local_vars_size;
+
+ // Number of bytes of arguments passed onto the stack.
+ int stack_args_size;
+
+ // The sum of 2 sizes: locals vars and padding byte for saving the
+ // registers. Used in expand_prologue () and expand_epilogue().
+ int size_for_adjusting_sp;
+
+
+ // Padding for alignment
+ int padding_stack_args, padding_locals;
+
+ void update_stack_args_size()
+ {
+ // Padding needed for each element of the frame.
+ stack_args_size = crtl->args.pretend_args_size;
+
+ // Arguments on the stack should already be aligned?
+ //// Align to the stack alignment
+ //padding_stack_args = stack_args_size % STACK_ALIGNMENT;
+
+ //if (padding_stack_args)
+ //{
+ // padding_stack_args = STACK_ALIGNMENT - padding_stack_args;
+ //}
+
+ //stack_args_size += padding_stack_args;
+ }
+
+ void update_local_vars_size()
+ {
+ // Padding needed for each element of the frame.
+ local_vars_size = get_frame_size();
+
+ // Align to the stack alignment
+ padding_locals = local_vars_size % STACK_ALIGNMENT;
+
+ if (padding_locals)
+ {
+ padding_locals = STACK_ALIGNMENT - padding_locals;
+ }
+
+ local_vars_size += padding_locals;
+ }
+
+ void update_callee_saved_reg_size()
+ {
+ callee_saved_reg_size = 0;
+
+
+ //fprintf(stderr, "\nmachine_function::update_callee_saved_reg_size"
+ // "()\n");
+ // Save callee-saved registers
+ for (int regno=0; regno<FIRST_PSEUDO_REGISTER; ++regno)
+ {
+ if (flare32_regno_actually_callee_saved(regno))
+ {
+ callee_saved_reg_size += UNITS_PER_WORD;
+ }
+ }
+ }
+
+ void update_size_for_adjusting_sp()
+ {
+ //machine.size_for_adjusting_sp = crtl->args.pretend_args_size
+ // + machine.local_vars_size
+ // + (ACCUMULATE_OUTGOING_ARGS
+ // ? static_cast<HOST_WIDE_INT>(crtl->outgoing_args_size) : 0);
+
+ //size_for_adjusting_sp = stack_args_size + UNITS_PER_WORD
+ // + callee_saved_reg_size
+ // + local_vars_size
+ // + (ACCUMULATE_OUTGOING_ARGS
+ // ? static_cast<HOST_WIDE_INT>(crtl->outgoing_args_size) : 0);
+ size_for_adjusting_sp = local_vars_size
+ + (ACCUMULATE_OUTGOING_ARGS
+ ? static_cast<HOST_WIDE_INT>(crtl->outgoing_args_size) : 0);
+ }
+
+ //inline int fp_offset_from_old_sp() const
+ //{
+ // return (-stack_args_size);
+ //}
+
+ inline int ap_offset_from_fp() const
+ {
+ return (stack_args_size + UNITS_PER_WORD);
+ }
+
+
+};
+
+
+#define LOSE_AND_RETURN(msgid, x) \
+do \
+{ \
+ flare32_operand_lossage(msgid, x); \
+ return; \
+} while (0)
+
+static constexpr int MIN_SIMM18 = -131072;
+static constexpr int MAX_SIMM18 = 131071;
+
+// Define how to find the value returned by a function.
+// VALTYPE is the data type of the value (as a tree).
+// If the precise function being called is known, FUNC is its
+// FUNCTION_DECL; otherwise, FUNC is 0.
+//
+// We always return values in register $r0 for flare32.
+
+static rtx flare32_function_value(const_tree valtype,
+ const_tree fntype_or_decl ATTRIBUTE_UNUSED,
+ bool outgoing ATTRIBUTE_UNUSED)
+{
+ return gen_rtx_REG(TYPE_MODE(valtype), FLARE32_R0);
+}
+
+// Define how to find the value returned by a library function.
+//
+// We always return values in register r0 for flare32.
+
+static rtx flare32_libcall_value(machine_mode mode,
+ const_rtx fun ATTRIBUTE_UNUSED)
+{
+ return gen_rtx_REG(mode, FLARE32_R0);
+}
+
+// Handle TARGET_FUNCTION_VALUE_REGNO_P.
+//
+// We always return values in register r0 for flare32.
+
+static bool flare32_function_value_regno_p(const unsigned int regno)
+{
+ return (regno == FLARE32_R0);
+}
+
+// Emit an error message when we're in an asm, and a fatal error for
+// "normal" insns. Formatted output isn't easily implemented, since we
+// use output_operand_lossage to output the actual message and handle the
+// categorization of the error.
+
+static void flare32_operand_lossage(const char *msgid, rtx op)
+{
+ debug_rtx(op);
+ output_operand_lossage("%s", msgid);
+}
+
+
+static bool flare32_regno_ok_for_base_p(const_rtx reg, bool strict_p)
+{
+ const int regno = REGNO(reg);
+
+ if (strict_p)
+ {
+ return (HARD_REGNO_OK_FOR_BASE_P(regno)
+ || HARD_REGNO_OK_FOR_BASE_P(reg_renumber[regno]));
+ }
+ else
+ {
+ return ((!HARD_REGISTER_NUM_P(regno))
+ || HARD_REGNO_OK_FOR_BASE_P(regno));
+ }
+}
+static bool flare32_regno_ok_for_index_p(const_rtx reg, bool strict_p)
+{
+ const int regno = REGNO(reg);
+
+ if (strict_p)
+ {
+ return (HARD_REGNO_OK_FOR_INDEX_P(regno)
+ || HARD_REGNO_OK_FOR_INDEX_P(reg_renumber[regno]));
+ }
+ else
+ {
+ return ((!HARD_REGISTER_NUM_P(regno))
+ || HARD_REGNO_OK_FOR_INDEX_P(regno));
+ }
+}
+
+static bool flare32_legitimate_address_p(machine_mode mode, rtx x,
+ bool strict_p, addr_space_t as)
+{
+ gcc_assert(ADDR_SPACE_GENERIC_P(as));
+
+ //auto handle_inner_plus = [&](rtx tmp) -> bool
+ //{
+ // const bool ret = (REG_P(XEXP(tmp, 0))
+ // && flare32_regno_ok_for_index_p(tmp, strict_p)
+ // && CONSTANT_P(XEXP(tmp, 1)));
+ // fprintf(stderr, "flare32_legitimate_address_p()::%s: %i\n",
+ // "handle_inner_plus", ret);
+ // return ret;
+ //};
+
+ //if (GET_CODE(x) == PLUS)
+ //{
+ // //handle_inner_plus(tmp);
+ // fprintf(stderr, "flare32_legitimate_address_p(): %ld\n",
+ // (GET_CODE(XEXP(x, 0)) == PLUS));
+ //}
+
+ //if ((GET_CODE(x) == PLUS)
+ // && REG_P(XEXP(x, 0))
+ // && flare32_regno_ok_for_base_p(XEXP(x, 0), strict_p))
+ if (GET_CODE(x) == PLUS)
+ {
+ // SImode, DImode
+ if (GET_MODE_SIZE(mode) >= UNITS_PER_WORD)
+ {
+ //auto tmp = XEXP(x, 1);
+
+ //
+ //if (REG_P(tmp) && flare32_regno_ok_for_index_p(tmp, strict_p))
+ //{
+ // return true;
+ //}
+
+ //switch (GET_CODE(tmp))
+ //{
+ //case PLUS:
+ // {
+ // return handle_inner_plus(tmp);
+ // }
+ // break;
+
+ //case CONST_INT:
+ //case SYMBOL_REF:
+ //case LABEL_REF:
+ // return true;
+ // break;
+
+ //default:
+ // return false;
+ //}
+
+ // plus(plus(reg, reg), immediate)
+ if (GET_CODE(XEXP(x, 0)) == PLUS)
+ {
+ auto reg_plus_reg = XEXP(x, 0);
+ auto base = XEXP(reg_plus_reg, 0);
+ auto index = XEXP(reg_plus_reg, 1);
+ return (REG_P(base)
+ && flare32_regno_ok_for_base_p(base, strict_p)
+ && REG_P(index)
+ && flare32_regno_ok_for_index_p(index, strict_p)
+ && CONSTANT_P(XEXP(x, 1)));
+ }
+
+ if (REG_P(XEXP(x, 0))
+ && flare32_regno_ok_for_base_p(XEXP(x, 0), strict_p))
+ {
+ auto some_index = XEXP(x, 1);
+
+ if (REG_P(some_index)
+ && flare32_regno_ok_for_index_p(some_index, strict_p))
+ {
+ return true;
+ }
+
+ if (CONSTANT_P(some_index))
+ {
+ return true;
+ }
+ }
+
+ }
+
+ // QImode, HImode
+ else // if (GET_MODE_SIZE(mode) < UNITS_PER_WORD)
+ {
+ return (REG_P(XEXP(x, 0))
+ && flare32_regno_ok_for_base_p(XEXP(x, 0), strict_p)
+ && REG_P(XEXP(x, 1))
+ && flare32_regno_ok_for_index_p(XEXP(x, 1), strict_p));
+ }
+ }
+ // All simple integer modes support this.
+ if (REG_P(x) && flare32_regno_ok_for_base_p(x, strict_p))
+ {
+ return true;
+ }
+
+
+ //// Might need this later...
+ //if (GET_CODE(x) == SYMBOL_REF
+ // || GET_CODE(x) == LABEL_REF
+ // || GET_CODE(x) == CONST)
+ //{
+ // return true;
+ //}
+
+ return false;
+}
+
+static reg_class_t flare32_secondary_reload(bool in_p, rtx x,
+ reg_class_t reload_class_as_t, machine_mode reload_mode,
+ secondary_reload_info* sri)
+{
+ const reg_class reload_class = reg_class(reload_class_as_t);
+
+ const auto regno = true_regnum(x);
+
+ sri->icode = CODE_FOR_nothing;
+ sri->extra_cost = 0;
+
+ if (flare32_reg_class_cpyspec(reload_class)
+ || (reload_class == HILO_REGS))
+ {
+ if ((regno != -1) && ((GET_CODE(x) == REG)
+ || (GET_CODE(x) == SUBREG))
+ && (REGNO_REG_CLASS(regno) == GENERAL_REGS))
+ {
+ return NO_REGS;
+ }
+
+ sri->extra_cost = 1;
+ return GENERAL_REGS;
+ }
+ //else if (((GET_CODE(x) == REG) || (GET_CODE(x) == SUBREG))
+ // && flare32_reg_class_cpyspec(REGNO_REG_CLASS(regno)))
+ //{
+ // if (reload_class != GENERAL_REGS)
+ // {
+ // return GENERAL_REGS;
+ // }
+ // return NO_REGS;
+ //}
+ //if (((GET_CODE(x) == REG) || (GET_CODE(x) == SUBREG))
+ // && flare32_reg_class_cpyspec(REGNO_REG_CLASS(regno)))
+ //{
+ //}
+
+ return NO_REGS;
+}
+
+
+static bool flare32_fixed_condition_code_regs(unsigned int *p1,
+ unsigned int *p2)
+{
+ *p1 = FLARE32_FLAGS;
+ *p2 = INVALID_REGNUM;
+ return true;
+}
+
+//static reg_class_t flare32_target_spill_class(reg_class_t rc,
+// machine_mode mode)
+//{
+// return reg_class_t(GENERAL_REGS);
+// //return NO_REGS;
+//}
+
+
+// The PRINT_OPERAND worker.
+
+static void flare32_print_operand(FILE *file, rtx x, int code)
+{
+ auto operand = x;
+
+ int rgoff = 0;
+ int the_regno = 0;
+ switch (code)
+ {
+ case 0:
+ // No code, print as usual
+ break;
+
+ case 'L':
+ // Higher of two registers, print one up
+ rgoff = 1;
+ break;
+
+ case 'R':
+ case 'H':
+ // Higher of a register pair, print normal
+ rgoff = 0;
+ break;
+
+ default:
+ LOSE_AND_RETURN ("invalid operand modifier letter", x);
+ break;
+ }
+
+ /* Print an operand as without a modifier letter. */
+ switch (GET_CODE(operand))
+ {
+ case REG:
+ the_regno = REGNO(operand) + rgoff;
+ if (the_regno >= FIRST_PSEUDO_REGISTER)
+ {
+ internal_error("internal error: bad register: %d",
+ the_regno);
+ }
+ fprintf(file, "%s", reg_names[the_regno]);
+ break;
+
+ case MEM:
+ output_address(GET_MODE(XEXP(operand, 0)), XEXP(operand, 0));
+ break;
+
+ default:
+ // No need to handle all strange variants, let
+ // output_addr_const do it for us.
+ if (CONSTANT_P(operand))
+ {
+ fprintf(file, "#");
+ output_addr_const(file, operand);
+ return;
+ }
+
+ LOSE_AND_RETURN("unexpected operand", x);
+ }
+}
+
+static void flare32_print_operand_address(FILE* file, machine_mode mode,
+ rtx x)
+{
+ rtx left, right;
+ switch (GET_CODE(x))
+ {
+ case REG:
+ fprintf(file, "%s", reg_names[REGNO(x)]);
+ break;
+
+ case PLUS:
+ left = XEXP(x, 0);
+ right = XEXP(x, 1);
+
+ // plus(plus(reg, reg), immediate)
+ if (GET_CODE(left) == PLUS)
+ {
+ auto base = XEXP(left, 0);
+ auto index = XEXP(left, 1);
+ fprintf(file, "%s, %s, ", reg_names[REGNO(base)],
+ reg_names[REGNO(index)]);
+ if (CONST_INT_P(right))
+ {
+ fprintf(file, "#%ld", INTVAL(right));
+ }
+ else if (CONSTANT_P(right))
+ {
+ fprintf(file, "#");
+ output_addr_const(file, right);
+ }
+ else
+ {
+ gcc_unreachable();
+ }
+ }
+ else
+ {
+ fprintf(file, "%s, ", reg_names[REGNO(left)]);
+
+ if (GET_CODE(right) == REG)
+ {
+ fprintf(file, "%s", reg_names[REGNO(right)]);
+ }
+ else if (CONST_INT_P(right))
+ {
+ fprintf(file, "#%ld", INTVAL(right));
+ }
+ else if (CONSTANT_P(right))
+ {
+ fprintf(file, "#");
+ output_addr_const(file, right);
+ }
+ else
+ {
+ gcc_unreachable();
+ }
+ }
+
+ //switch (GET_CODE(right))
+ //{
+ //case CONST_INT:
+ // fprintf(file, "%s, %ld", reg_names[REGNO(left)],
+ // INTVAL(right));
+ // break;
+
+
+ //case REG:
+ // fprintf(file, "%s, %s", reg_names[REGNO(left)],
+ // reg_names[REGNO(right)]);
+ // break;
+
+ //case PLUS:
+ // fprintf(file, "%s, %s + ", reg_names[REGNO(left)],
+ // reg_names[REGNO(XEXP(right, 0))]);
+ // if (CONST_INT_P(XEXP(right, 1)))
+ // {
+ // fprintf(file, "%ld", INTVAL(XEXP(right, 1)));
+ // }
+ // else if (CONSTANT_P(XEXP(right, 1)))
+ // {
+ // output_addr_const(file, XEXP(right, 1));
+ // }
+ // else
+ // {
+ // gcc_unreachable();
+ // }
+ // break;
+
+ //default:
+ // if (CONSTANT_P(right))
+ // {
+ // fprintf(file, "%s, ", reg_names[REGNO(left)]);
+ // output_addr_const(file, right);
+ // }
+ // else
+ // {
+ // gcc_unreachable();
+ // }
+ // break;
+ //}
+ break;
+
+ //case LABEL_REF:
+ // fprintf(file, "<some_label_ref>");
+ // break;
+
+ case LABEL_REF:
+ case SYMBOL_REF:
+ case CONST:
+ //fprintf(file, "<some_symbol_ref>");
+
+ fprintf(file, "#");
+ output_addr_const(file, x);
+ break;
+
+ //case CONST:
+ // fprintf(file, "<some_const>");
+ // break;
+
+ default:
+ gcc_unreachable();
+ break;
+ }
+}
+
+bool flare32_32_bit_offset_address_p(rtx x)
+{
+ // Inside the "MEM"
+ x = XEXP(x, 0);
+
+ switch (GET_CODE(x))
+ {
+ case PLUS:
+
+ //if (REG_P(XEXP(x, 0)) && (REG_P(XEXP(x, 1))
+ // || CONST_INT_P(XEXP(x, 1))))
+ if (REG_P(XEXP(x, 0)) && (REG_P(XEXP(x, 1))
+ || CONSTANT_P(XEXP(x, 1))))
+ {
+ return true;
+ }
+
+ //if (REG_P(XEXP(x, 0)) && (GET_CODE(XEXP(x, 1)) == PLUS))
+ //{
+ // auto tmp = XEXP(x, 1);
+
+ // //if (REG_P(XEXP(tmp, 0)) && CONST_INT_P(XEXP(tmp, 1)))
+ // if (REG_P(XEXP(tmp, 0)) && CONSTANT_P(XEXP(tmp, 1)))
+ // {
+ // return true;
+ // }
+ //}
+
+ if (GET_CODE(XEXP(x, 0)) == PLUS)
+ {
+ auto reg_plus_reg = XEXP(x, 0);
+
+ return (REG_P(XEXP(reg_plus_reg, 0))
+ && REG_P(XEXP(reg_plus_reg, 1))
+ && CONSTANT_P(XEXP(x, 1)));
+ }
+
+
+ break;
+
+ //case SYMBOL_REF:
+ ////case LABEL_REF:
+ //case CONST:
+ // return true;
+ default:
+ break;
+ }
+
+ return false;
+}
+
+bool flare32_non_32_bit_offset_address_p(rtx x)
+{
+ // Inside the "MEM"
+ x = XEXP(x, 0);
+
+ if (REG_P(x))
+ {
+ return true;
+ }
+
+ if (GET_CODE(x) == PLUS)
+ {
+ // Register + register indexing is allowed for 8-bit and 16-bit
+ // loads and stores.
+ return (REG_P(XEXP(x, 0)) && REG_P(XEXP(x, 1)));
+ }
+
+ return false;
+}
+
+//bool flare32_non_offset_address_p(rtx x)
+//{
+//}
+
+// Compute the size of the local area and the size to be adjusted by the
+// prologue and epilogue.
+
+
+// Implements the macro INITIAL_ELIMINATION_OFFSET, return the OFFSET.
+
+int flare32_initial_elimination_offset(int from, int to)
+{
+ int ret = 0;
+
+ //ret = 0;
+
+ if (((from) == FRAME_POINTER_REGNUM)
+ && ((to) == HARD_FRAME_POINTER_REGNUM))
+ {
+ flare32_compute_frame();
+
+ // There's technically a "push fp", but the compiler perhaps
+ // doesn't need to really know about the "push fp".
+ // The hard frame pointer is ABOVE the callee-saved registers
+ // preservation area (actually points at the very first
+ // location in the callee-saved registers preservation area).
+
+ // (fake_fp - fp) == -(callee_saved_reg_size - UNITS_PER_WORD)
+ ret = -(cfun->machine->callee_saved_reg_size - UNITS_PER_WORD);
+ }
+ else if ((from) == ARG_POINTER_REGNUM
+ && (to) == HARD_FRAME_POINTER_REGNUM)
+ {
+ // account for the "push fp"
+ // arguments start two addresses above the hard frame pointer
+
+ // (fake_ap - fp) == (UNITS_PER_WORD * 2) == 8;
+ ret = (UNITS_PER_WORD * 2);
+ }
+ //if (((from) == ARG_POINTER_REGNUM)
+ // && ((to) == FRAME_POINTER_REGNUM))
+ //{
+ // ret = 0x00;
+ //}
+ //if ((((from) == FRAME_POINTER_REGNUM)
+ // || ((from) == ARG_POINTER_REGNUM)))
+ //{
+ // //ret = 0x0;
+ //}
+ else
+ {
+ abort ();
+ }
+
+ return ret;
+}
+
+static bool flare32_return_in_memory(const_tree type,
+ const_tree fntype ATTRIBUTE_UNUSED)
+{
+ const HOST_WIDE_INT size = int_size_in_bytes(type);
+ return ((size == -1) || (size > (2 * UNITS_PER_WORD)));
+ //return ((size == -1) || (size > UNITS_PER_WORD));
+}
+
+static unsigned HOST_WIDE_INT flare32_size_of_type(machine_mode mode,
+ const_tree type)
+{
+ unsigned HOST_WIDE_INT size;
+
+ if (type)
+ {
+ //if (AGGREGATE_TYPE_P(type))
+ //{
+ // return true;
+ //}
+ size = int_size_in_bytes(type);
+ }
+ else
+ {
+ size = GET_MODE_SIZE(mode);
+ }
+
+ return size;
+}
+
+static bool flare32_must_pass_in_stack(machine_mode mode,
+ const_tree type)
+{
+ if (type && AGGREGATE_TYPE_P(type))
+ {
+ return true;
+ }
+ return (flare32_size_of_type(mode, type) > (2 * UNITS_PER_WORD));
+ //return (flare32_size_of_type(mode, type) > UNITS_PER_WORD);
+}
+
+
+// Return non-zero if the function argument described by TYPE is to be
+// passed by reference.
+static bool flare32_pass_by_reference
+ (cumulative_args_t cum ATTRIBUTE_UNUSED, machine_mode mode,
+ const_tree type, bool named ATTRIBUTE_UNUSED)
+{
+ //unsigned HOST_WIDE_INT size;
+
+ //if (type)
+ //{
+ // if (AGGREGATE_TYPE_P(type))
+ // {
+ // return true;
+ // }
+ // size = int_size_in_bytes(type);
+ //}
+ //else
+ //{
+ // size = GET_MODE_SIZE(mode);
+ //}
+
+ ////return (size > (4 * (FLARE32_LAST_REG_FUNC_ARG + 1)));
+ //return (size > UNITS_PER_WORD);
+
+ if (type && AGGREGATE_TYPE_P(type))
+ {
+ return true;
+ }
+ return (flare32_size_of_type(mode, type) > (2 * UNITS_PER_WORD));
+}
+
+static int flare32_arg_partial_bytes(cumulative_args_t cum_v,
+ machine_mode mode, tree type, bool named)
+{
+ return 0;
+}
+
+// Return the next register to be used to hold a function argument or
+// NULL_RTX if there's no more space.
+static rtx flare32_function_arg(cumulative_args_t cum_v,
+ machine_mode mode, const_tree type ATTRIBUTE_UNUSED,
+ bool named ATTRIBUTE_UNUSED)
+{
+ //if (!named)
+ //{
+ // return NULL_RTX;
+ //}
+
+ CUMULATIVE_ARGS* cum = get_cumulative_args(cum_v);
+
+ if ((*cum) <= FLARE32_LAST_REG_FUNC_ARG)
+ {
+ const auto temp = (*cum);
+ //fprintf(stderr, "\nflare32_function_arg REG: %d\n", temp);
+ return gen_rtx_REG(mode, temp);
+ }
+ else
+ {
+ //fprintf(stderr, "\nflare32_function_arg NULL_RTX\n");
+ return NULL_RTX;
+ }
+}
+
+#define FLARE32_FUNCTION_ARG_SIZE(MODE, TYPE) \
+ ((MODE) != BLKmode ? GET_MODE_SIZE (MODE) \
+ : (unsigned) int_size_in_bytes (TYPE))
+
+// This hook need not do anything if the argument in question was passed on
+// the stack.
+static void
+flare32_function_arg_advance(cumulative_args_t cum_v, machine_mode mode,
+ const_tree type, bool named ATTRIBUTE_UNUSED)
+{
+ CUMULATIVE_ARGS* cum = get_cumulative_args(cum_v);
+
+ *cum = ((*cum <= FLARE32_R5)
+ ? *cum + ((3 + FLARE32_FUNCTION_ARG_SIZE(mode, type)) / 4)
+ : *cum);
+}
+
+//// This hook need not do anything if the argument in question was passed on
+//// the stack.
+//static void flare32_function_arg_advance(cumulative_args_t cum_v,
+// machine_mode mode, const_tree type, bool named ATTRIBUTE_UNUSED)
+//{
+// CUMULATIVE_ARGS* cum = get_cumulative_args(cum_v);
+//
+// //*cum = ((*cum <= FLARE32_R5)
+// // ? *cum + ((3 + FLARE32_FUNCTION_ARG_SIZE(mode, type)) / 4)
+// // : *cum);
+// //fprintf(stderr, "flare32_function_arg_advance: %d\n", *cum);
+//
+// if ((*cum) <= FLARE32_LAST_REG_FUNC_ARG)
+// {
+// //*cum += (3 + FLARE32_FUNCTION_ARG_SIZE(mode, type)) / 4;
+//
+// //// AFAIK we don't have any BLKmode instructions....
+// //if (mode == BLKmode)
+// //{
+// // abort();
+// //}
+//
+// const auto size = (mode != BLKmode) ? GET_MODE_SIZE(mode)
+// : static_cast<unsigned>(int_size_in_bytes(type));
+//
+// //fprintf(stderr, "flare32_function_arg_advance size: %d\n", size);
+//
+// // Small operands
+// if ((size / 4) == 0)
+// {
+// *cum += 1;
+// }
+// else
+// {
+// *cum += size / 4;
+// }
+// }
+// //else
+// //{
+// // *cum = FLARE32_LAST_REG_FUNC_ARG + 1;
+// //}
+//
+// //fprintf(stderr, "flare32_function_arg_advance: %d\n\n", *cum);
+//}
+
+bool flare32_absolute(rtx x)
+{
+ return ((GET_CODE(x) == SYMBOL_REF) || (GET_CODE(x) == LABEL_REF)
+ || (GET_CODE(x) == CONST) || CONST_INT_P(x));
+}
+bool flare32_reg_cpyspec(rtx x)
+{
+ return (REG_P(x)
+ && flare32_reg_class_cpyspec(REGNO_REG_CLASS(REGNO(x))));
+}
+bool flare32_reg_class_cpyspec(reg_class x)
+{
+ return ((x == CC_REGS) || (x == HI_REGS) || (x == LO_REGS));
+ //return ((x == HI_REGS) || (x == LO_REGS));
+}
+bool flare32_reg_general(rtx x)
+{
+ return (REG_P(x)
+ && flare32_reg_class_general(REGNO_REG_CLASS(REGNO(x))));
+}
+bool flare32_reg_class_general(reg_class x)
+{
+ return (x == GENERAL_REGS);
+}
+
+
+
+
+// Zero initialization is OK for all current fields.
+static machine_function* flare32_init_machine_status()
+{
+ return ggc_cleared_alloc<machine_function>();
+}
+
+static bool flare32_target_rtx_costs(rtx x,
+ machine_mode mode, int outer_code ATTRIBUTE_UNUSED,
+ int opno ATTRIBUTE_UNUSED, int* total, bool speed)
+{
+ if (speed)
+ {
+ switch (GET_CODE(x))
+ {
+ case PLUS:
+ case MINUS:
+ if (mode == DImode)
+ {
+ *total = COSTS_N_INSNS(2);
+ }
+ break;
+ case MULT:
+ if (mode == SImode)
+ {
+ *total = COSTS_N_INSNS(4);
+ }
+ else if (mode == DImode)
+ {
+ *total = COSTS_N_INSNS(6);
+ }
+ break;
+
+ case DIV:
+ case UDIV:
+ case MOD:
+ case UMOD:
+ if (mode == SImode)
+ {
+ // Assume 4 bits computed per cycle.
+ *total = COSTS_N_INSNS(8);
+ }
+ else if (mode == DImode)
+ {
+ // Assume 2 bits computed per cycle.
+ *total = COSTS_N_INSNS(32);
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+ //else
+ //{
+ //}
+
+ return true;
+}
+
+static int flare32_target_memory_move_cost(machine_mode mode,
+ reg_class_t rclass_as_t, bool in)
+{
+ const reg_class rclass = reg_class(rclass_as_t);
+
+ int ret = 2;
+
+ if (rclass != GENERAL_REGS)
+ {
+ ret *= 2;
+ }
+
+
+ if (mode == DImode)
+ {
+ ret *= 2;
+ }
+ return ret;
+}
+
+static void flare32_option_override()
+{
+ // Set the per-function-data initializer.
+ init_machine_status = flare32_init_machine_status;
+}
+
+bool flare32_regno_actually_callee_saved(int regno)