summaryrefslogtreecommitdiff
path: root/compiler_and_linker/unsorted/CodeGenOptPPC.c
blob: cdf34e7e3efbc9d878b9e847fa5fd7cc675c1b90 (plain)
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
#include "compiler/CodeGenOptPPC.h"
#include "compiler/InstrSelection.h"
#include "compiler/CCompiler.h"
#include "pref_structs.h"
#include "compiler/CParser.h"

static short pref_versions;

void CodeGen_InitCompiler(void) {
    init_cgdispatch();
}

void CodeGen_TermCompiler(void) {
    // empty!
}

void CodeGen_InitBackEndOptions(void) {
    Handle handle;
    PBackEnd pb;
    PMachOLinker pmol;

    CWSecretGetNamedPreferences(cparams.context, "PPC CodeGen Mach-O", &handle);
    pb = *((PBackEnd *) *handle);
    pref_versions = pb.version;

    CWSecretGetNamedPreferences(cparams.context, "PPC Mach-O Linker", &handle);
    pmol = *((PMachOLinker *) *handle);

    copts.function_align = 16;
    copts.misaligned_mem_access = 1;
    copts.switch_tables = 1;
    copts.prepare_compress = 0;
    copts.min_struct_alignment = 4;
    copts.altivec_model = 0;
    copts.altivec_vrsave = 1;
    copts.codegen_pic = pb.pic;
    copts.codegen_dynamic = pb.dynamic;
    if (!copts.codegen_dynamic)
        copts.codegen_pic = 0;
    copts.no_common = !pb.common;
    copts.no_implicit_templates = 0;
    copts.absolutepath = pmol.symfullpath;
    copts.x06 = pmol.exports;
    copts.schedule_factor = 2;
    copts.altivec_model = pb.altivec;
    copts.readonly_strings = pb.readonlystrings;
    if (pb.schedule)
        copts.schedule_factor = 2;
    else
        copts.schedule_factor = 0;

    switch (pb.processor) {
        case 1:
            copts.processor = CPU_PPC601;
            copts.scheduling = 1;
            break;
        case 2:
            copts.processor = CPU_PPC603;
            copts.scheduling = 2;
            break;
        case 3:
            copts.processor = CPU_PPC603e;
            copts.scheduling = 5;
            break;
        case 4:
            copts.processor = CPU_PPC604;
            copts.scheduling = 3;
            break;
        case 5:
            copts.processor = CPU_PPC604e;
            copts.scheduling = 6;
            break;
        case 6:
            copts.processor = CPU_PPC750;
            copts.scheduling = 4;
            break;
        case 7:
            copts.processor = CPU_PPC7400;
            copts.scheduling = 7;
            break;
        case 8:
            copts.processor = CPU_PPC7450;
            copts.scheduling = 10;
            break;
        default:
            copts.processor = CPU_Generic;
            copts.scheduling = 8;
            break;
    }

    copts.peephole = pb.peephole;
    copts.structalignment = pb.structalignment;
    copts.profile = pb.profiler;
    copts.fp_contract = pb.fpcontract;
    copts.traceback = pb.tracebacktables > 0;
    copts.x1D = pb.tracebacktables == 2;
    copts.gen_isel = 0;
    if (pb.processorspecific && copts.processor >= CPU_PPC603)
        copts.gen_fsel = 10;
    else
        copts.gen_fsel = 0;
    if (pb.vrsave)
        copts.altivec_vrsave = 1;
    else
        copts.altivec_vrsave = 0;
    copts.unroll_speculative = 1;
    copts.unroll_instr_limit = 70;
    copts.unroll_factor_limit = 10;
    copts.opt_bcc_lr_ctr = 1;
    copts.use_lmw_stmw = 1;
    if (copts.optimizationlevel > 2)
        copts.optimizewithasm = 1;
    else
        copts.optimizewithasm = 0;
    copts.strengthreductionstrict = 1;
}

void Test_Version_Numbers(void) {
    // empty!
}