Goose  Diff

Differences From Artifact [25409ea40b]:

  • File bs/builtins/types/runtime/basic.cpp — part of check-in [a67a742689] at 2019-08-07 01:56:03 on branch trunk —
    • Implemented some missing compile time instruction execution for unsigned ints.
    • C++ integer types are now mapped to fixed size integer types, rather than BigInt, now that the former are available at compile time.
    • The binary shift operators for ct_int now take an uint32 as their right hand side operand, rather than a ct_int.
    (user: achavasse size: 5501)

To Artifact [5af76bd3ca]:

  • File bs/builtins/types/runtime/basic.cpp — part of check-in [aee388d9c0] at 2019-08-09 19:54:22 on branch trunk — Cleanup: got rid of the half-assed location and poisoning systems in ir::Terms. (user: achavasse size: 5493)

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
{
    void SetupRuntimeBasicTypes( Env& e )
    {
        e.storeValue( AppendToVectorTerm( RootIdentity(), TSID( half ) ), ANYTERM( _ ), ValueToIRExpr( ToValue( HalfFloatType() ) ) );
        e.storeValue( AppendToVectorTerm( RootIdentity(), TSID( float ) ), ANYTERM( _ ), ValueToIRExpr( ToValue( FloatType() ) ) );
        e.storeValue( AppendToVectorTerm( RootIdentity(), TSID( double ) ), ANYTERM( _ ), ValueToIRExpr( ToValue( DoubleFloatType() ) ) );

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

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

    const Term& IntegerType::Pattern::GetPattern()
    {
        static auto pattern = ValueToIRExpr( Value( TypeType(), TVEC( TSID( rt_type ),
            MkHole( "llvmType"_sid ),
            TSID( integer ), MkHole( "size"_sid ), MkHole( "signedness"_sid ) ) ) );

        return pattern;
    }

    const Term& IntegerType::PatternSigned::GetPattern()
    {
        static auto pattern = ValueToIRExpr( Value( TypeType(), TVEC( TSID( rt_type ),
            MkHole( "llvmType"_sid ),
            TSID( integer ), MkHole( "size"_sid ), TERM( 1ULL ) ) ) );

        return pattern;
    }

    const Term& IntegerType::PatternUnsigned::GetPattern()
    {
        static auto pattern = ValueToIRExpr( Value( TypeType(), TVEC( TSID( rt_type ),
            MkHole( "llvmType"_sid ),
            TSID( integer ), MkHole( "size"_sid ), TERM( 0ULL ) ) ) );

        return pattern;
    }
}

namespace empathy::ir
{







|
|




|
|


















|








|







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
{
    void SetupRuntimeBasicTypes( Env& e )
    {
        e.storeValue( AppendToVectorTerm( RootIdentity(), TSID( half ) ), ANYTERM( _ ), ValueToIRExpr( ToValue( HalfFloatType() ) ) );
        e.storeValue( AppendToVectorTerm( RootIdentity(), TSID( float ) ), ANYTERM( _ ), ValueToIRExpr( ToValue( FloatType() ) ) );
        e.storeValue( AppendToVectorTerm( RootIdentity(), TSID( double ) ), ANYTERM( _ ), ValueToIRExpr( ToValue( DoubleFloatType() ) ) );

        RegisterBuiltinFunc< Eager< Value > ( uint32_t ) >( e, "uint"_sid,
            []( uint32_t numBits )
            {
                return ToValue( IntegerType( numBits ) );
            } );

        RegisterBuiltinFunc< Eager< Value > ( uint32_t ) >( e, "sint"_sid,
            []( uint32_t numBits )
            {
                return ToValue( IntegerType( numBits, true ) );
            } );
    }

    const Term& IntegerType::Pattern::GetPattern()
    {
        static auto pattern = ValueToIRExpr( Value( TypeType(), TVEC( TSID( rt_type ),
            MkHole( "llvmType"_sid ),
            TSID( integer ), MkHole( "size"_sid ), MkHole( "signedness"_sid ) ) ) );

        return pattern;
    }

    const Term& IntegerType::PatternSigned::GetPattern()
    {
        static auto pattern = ValueToIRExpr( Value( TypeType(), TVEC( TSID( rt_type ),
            MkHole( "llvmType"_sid ),
            TSID( integer ), MkHole( "size"_sid ), TERM( 1U ) ) ) );

        return pattern;
    }

    const Term& IntegerType::PatternUnsigned::GetPattern()
    {
        static auto pattern = ValueToIRExpr( Value( TypeType(), TVEC( TSID( rt_type ),
            MkHole( "llvmType"_sid ),
            TSID( integer ), MkHole( "size"_sid ), TERM( 0U ) ) ) );

        return pattern;
    }
}

namespace empathy::ir
{
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
    }

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

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

        if( !result )
            return nullopt;

        auto&& [llvmType, numBits, signd] = *result;







|









|
|







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
    }

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

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

        if( !result )
            return nullopt;

        auto&& [llvmType, numBits, signd] = *result;