summaryrefslogtreecommitdiff
path: root/compiler_and_linker/unsorted/CodeGenOptPPC.c
blob: 4964435769d82dee0dda7d6a640e57cd0e977e27 (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.code_alignment = 16;
    copts.misaligned_mem_access = 1;
    copts.switch_tables = 1;
    copts.prepare_compress = 0;
    copts.some_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_mode = 2;
    copts.altivec_model = pb.altivec;
    copts.readonly_strings = pb.readonlystrings;
    if (pb.schedule)
        copts.schedule_mode = 2;
    else
        copts.schedule_mode = 0;

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

    copts.peephole = pb.peephole;
    copts.align_mode = pb.structalignment;
    copts.profile = pb.profiler;
    copts.fp_contract = pb.fpcontract;
    copts.traceback = pb.tracebacktables > 0;
    copts.x1D = pb.tracebacktables == 2;
    copts.x1E = 0;
    if (pb.processorspecific && copts.cpu >= CPU_PPC603)
        copts.gen_fsel = 10;
    else
        copts.gen_fsel = 0;
    if (pb.vrsave)
        copts.altivec_vrsave = 1;
    else
        copts.altivec_vrsave = 0;
    copts.ppc_unroll_speculative = 1;
    copts.ppc_unroll_instructions_limit = 70;
    copts.ppc_unroll_factor_limit = 10;
    copts.ppc_opt_bclr_bcctr = 1;
    copts.use_lmw_stmw = 1;
    if (copts.optimizationlevel > 2)
        copts.optimizewithasm = 1;
    else
        copts.optimizewithasm = 0;
    copts.opt_strength_reduction_strict = 1;
}

void Test_Version_Numbers(void) {
    // empty!
}