Goose  Diff

Differences From Artifact [a6d7f234ad]:

  • File bs/g0api/compiler.cpp — part of check-in [99c630bf0a] at 2024-04-09 22:55:56 on branch cir-ssa-refactor — Here we go again. Life is pain. Life is suffering (user: zlodo size: 11391)

To Artifact [3c3ff322fd]:

  • File bs/g0api/compiler.cpp — part of check-in [57d4d0c79e] at 2024-09-13 21:05:40 on branch cir-ssa-refactor — Drop in the most apocalyptic changes: new CIR instruction structure, new sequence builder, new compile time address representation, do almost just the bare minimum to compile again. A few simple things are still working somehow (user: achavasse size: 11838)

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
// TODO_SSA reenable
//#include "g0api/g0api.h"
#include "parse/parse.h"
#include "verify/verify.h"
#include "execute/execute.h"
#include "compile/compiler.h"

using namespace goose;
using namespace goose::compile;

namespace goose::g0api
{
    void SetupApiCompiler( Env& e )
    {
        DefineConstant( e, "TargetOSName"_sid, ValueToEIR( ToValue( string( TARGET_OS_NAME ) ) ) );

        wptr< Env > pEnv = e.shared_from_this();








        RegisterBuiltinFunc< Intrinsic< void ( bool ) > >( e, "#VerificationTraceMode"_sid,
            []( auto&& c, const Value& enable )
            {
                if( !enable.isConstant() )
                {
                    DiagnosticsManager::GetInstance().emitErrorMessage( enable.locationId(),
                        "this doesn't evaluate to a constant." );
                    return;
<
|
















>
>
>
>
>
>
>
|








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

#include "g0api/g0api.h"
#include "parse/parse.h"
#include "verify/verify.h"
#include "execute/execute.h"
#include "compile/compiler.h"

using namespace goose;
using namespace goose::compile;

namespace goose::g0api
{
    void SetupApiCompiler( Env& e )
    {
        DefineConstant( e, "TargetOSName"_sid, ValueToEIR( ToValue( string( TARGET_OS_NAME ) ) ) );

        wptr< Env > pEnv = e.shared_from_this();

        RegisterBuiltinFunc< void ( bool ) >( e, "DiagnosticsForceColors"_sid,
            []( bool enable )
            {
                DiagnosticsManager::GetInstance().setForceColors( enable );
            } );

        // TODO_SSA_VERIFICATION reenable
        /*RegisterBuiltinFunc< Intrinsic< void ( bool ) > >( e, "#VerificationTraceMode"_sid,
            []( auto&& c, const Value& enable )
            {
                if( !enable.isConstant() )
                {
                    DiagnosticsManager::GetInstance().emitErrorMessage( enable.locationId(),
                        "this doesn't evaluate to a constant." );
                    return;
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
                {
                    DiagnosticsManager::GetInstance().emitErrorMessage( enable.locationId(),
                        "this doesn't evaluate to a constant." );
                    return;
                }

                verify::Func::SetDumpSolverOnSuccess( *FromValue< bool >( enable ) );
            } );

        RegisterBuiltinFunc< Intrinsic< void ( CustomPattern< Value, FuncPattern >, string ) > >( e, "#DumpFunctionCFG"_sid,
            []( auto&& c, const Value& funcVal, const Value& filename )
            {
                if( !funcVal.isConstant() )
                {
                    DiagnosticsManager::GetInstance().emitErrorMessage( funcVal.locationId(),







|







68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
                {
                    DiagnosticsManager::GetInstance().emitErrorMessage( enable.locationId(),
                        "this doesn't evaluate to a constant." );
                    return;
                }

                verify::Func::SetDumpSolverOnSuccess( *FromValue< bool >( enable ) );
            } );*/

        RegisterBuiltinFunc< Intrinsic< void ( CustomPattern< Value, FuncPattern >, string ) > >( e, "#DumpFunctionCFG"_sid,
            []( auto&& c, const Value& funcVal, const Value& filename )
            {
                if( !funcVal.isConstant() )
                {
                    DiagnosticsManager::GetInstance().emitErrorMessage( funcVal.locationId(),
93
94
95
96
97
98
99






100
101
102
103
104
105
106
                auto f = *FromValue< builtins::Func >( func );
                if( !f.cir() )
                    return;

                ofstream out( name.c_str() );
                out << *f.cir();
            } );







        RegisterBuiltinFunc< Intrinsic< void ( uint32_t ) > >( e, "#SetExecutionBudget"_sid,
            []( auto&& c, const Value& budget )
            {
                static bool used = false;

                if( !budget.isConstant() )







>
>
>
>
>
>







99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
                auto f = *FromValue< builtins::Func >( func );
                if( !f.cir() )
                    return;

                ofstream out( name.c_str() );
                out << *f.cir();
            } );

        RegisterBuiltinFunc< Eager< void > ( CustomPattern< Value, ValuePatternT > ) >( e, "#DumpValue"_sid,
            []( const auto& v )
            {
                G_TRACE_VAL( v );
            } );

        RegisterBuiltinFunc< Intrinsic< void ( uint32_t ) > >( e, "#SetExecutionBudget"_sid,
            []( auto&& c, const Value& budget )
            {
                static bool used = false;

                if( !budget.isConstant() )