Goose  Diff

Differences From Artifact [6d936f3982]:

  • File bs/builtins/types/runtime/basic.cpp — part of check-in [3c074f1b7d] at 2019-07-30 22:05:49 on branch trunk —
    • Builtin functions are now explicitely marked if they need to be evaluated eagerly.
    • Using errors out if the expression doesn't evaluate to a constant.
    (user: achavasse size: 2824)

To Artifact [c511e53f99]:

  • File bs/builtins/types/runtime/basic.cpp — part of check-in [c7b1aea0a6] at 2019-08-03 14:10:49 on branch trunk — Added support for signed runtime integers and fixed multiple issues with ct_integer to runtime integer conversion. (user: achavasse size: 3120)

9
10
11
12
13
14
15
16
17
18
19
20






21
22
23
24
25
26
27
{
    void SetupRuntimeBasicTypes( Env& e )
    {
        e.storeValue( AppendToVectorTerm( RootIdentity(), TSID( rt_half ) ), ANYTERM( _ ), ValueToIRExpr( ToValue( RTHalf() ) ) );
        e.storeValue( AppendToVectorTerm( RootIdentity(), TSID( rt_float ) ), ANYTERM( _ ), ValueToIRExpr( ToValue( RTFloat() ) ) );
        e.storeValue( AppendToVectorTerm( RootIdentity(), TSID( rt_double ) ), ANYTERM( _ ), ValueToIRExpr( ToValue( RTDouble() ) ) );

        RegisterBuiltinFunc< Eager< Value > ( uint64_t ) >( e, "RTInteger"_sid,
            []( uint64_t numBits )
            {
                return ToValue( RTInteger( numBits ) );
            } );






    }
}

namespace empathy::ir
{
    //// Half
    Value Bridge< RTHalf >::ToValue( const RTHalf& i )







|




>
>
>
>
>
>







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
{
    void SetupRuntimeBasicTypes( Env& e )
    {
        e.storeValue( AppendToVectorTerm( RootIdentity(), TSID( rt_half ) ), ANYTERM( _ ), ValueToIRExpr( ToValue( RTHalf() ) ) );
        e.storeValue( AppendToVectorTerm( RootIdentity(), TSID( rt_float ) ), ANYTERM( _ ), ValueToIRExpr( ToValue( RTFloat() ) ) );
        e.storeValue( AppendToVectorTerm( RootIdentity(), TSID( rt_double ) ), ANYTERM( _ ), ValueToIRExpr( ToValue( RTDouble() ) ) );

        RegisterBuiltinFunc< Eager< Value > ( uint64_t ) >( e, "RTUInt"_sid,
            []( uint64_t numBits )
            {
                return ToValue( RTInteger( numBits ) );
            } );

        RegisterBuiltinFunc< Eager< Value > ( uint64_t ) >( e, "RTSInt"_sid,
            []( uint64_t numBits )
            {
                return ToValue( RTInteger( numBits, true ) );
            } );
    }
}

namespace empathy::ir
{
    //// Half
    Value Bridge< RTHalf >::ToValue( const RTHalf& i )
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
    }

    //// Integer
    Value Bridge< RTInteger >::ToValue( const RTInteger& i )
    {
        return Value( Type(), TVEC( TSID( rt_type ),
            TERM( llvm::IntegerType::get( GetLLVMContext(), i.m_numBits ) ),
            TSID( rt_integer ), TERM( i.m_numBits ) ) );
    }

    optional< RTInteger > Bridge< RTInteger >::FromValue( const Value& v )
    {
        auto result = Decompose( v.val(),
            Vec(
                Lit( "rt_type"_sid ),
                Val< void* >(),
                Lit( "rt_integer"_sid ),

                Val< uint64_t >()
            )
        );

        if( !result )
            return nullopt;

        auto&& [llvmType, numBits] = *result;
        return RTInteger( numBits );
    }
}







|









>







|
|


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
    }

    //// Integer
    Value Bridge< RTInteger >::ToValue( const RTInteger& i )
    {
        return Value( Type(), TVEC( TSID( rt_type ),
            TERM( llvm::IntegerType::get( GetLLVMContext(), i.m_numBits ) ),
            TSID( rt_integer ), TERM( i.m_numBits ), i.m_signed ? TERM( 1ULL ) : TERM( 0ULL ) ) );
    }

    optional< RTInteger > Bridge< RTInteger >::FromValue( const Value& v )
    {
        auto result = Decompose( v.val(),
            Vec(
                Lit( "rt_type"_sid ),
                Val< void* >(),
                Lit( "rt_integer"_sid ),
                Val< uint64_t >(),
                Val< uint64_t >()
            )
        );

        if( !result )
            return nullopt;

        auto&& [llvmType, numBits, signd] = *result;
        return RTInteger( numBits, !!signd );
    }
}