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
|
{
return ToValue( IntegerType( numBits, true ) );
} );
}
const Term& IntegerType::Pattern::GetPattern()
{
static auto pattern = ValueToEIR( Value( TypeType(), MkStdRTType( TSID( integer ),
nullptr,
VEC( HOLE( "size"_sid ), HOLE( "signedness"_sid ) ) ) ) );
return pattern;
}
const Term& IntegerType::PatternSigned::GetPattern()
{
static auto pattern = ValueToEIR( Value( TypeType(), MkStdRTType( TSID( integer ),
nullptr,
VEC( HOLE( "size"_sid ), TERM( 1U ) ) ) ) );
return pattern;
}
const Term& IntegerType::PatternUnsigned::GetPattern()
{
static auto pattern = ValueToEIR( Value( TypeType(), MkStdRTType( TSID( integer ),
nullptr,
VEC( HOLE( "size"_sid ), TERM( 0U ) ) ) ) );
return pattern;
}
const Term& IntegerType::PatternUnsigned32::GetPattern()
{
static auto pattern = ValueToEIR( Value( TypeType(), MkStdRTType( TSID( integer ),
nullptr,
VEC( TERM( 32U ), TERM( 0U ) ) ) ) );
return pattern;
}
llvm::Type* GetLLVMType( const HalfFloatType& t )
{
|
|
|
|
|
|
|
|
|
|
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
|
{
return ToValue( IntegerType( numBits, true ) );
} );
}
const Term& IntegerType::Pattern::GetPattern()
{
static auto pattern = ValueToEIR( Value( TypeType(), MkStdRTType( TSID( rt_type ),
nullptr, TSID( integer ),
VEC( HOLE( "size"_sid ), HOLE( "signedness"_sid ) ) ) ) );
return pattern;
}
const Term& IntegerType::PatternSigned::GetPattern()
{
static auto pattern = ValueToEIR( Value( TypeType(), MkStdRTType( TSID( rt_type ),
nullptr, TSID( integer ),
VEC( HOLE( "size"_sid ), TERM( 1U ) ) ) ) );
return pattern;
}
const Term& IntegerType::PatternUnsigned::GetPattern()
{
static auto pattern = ValueToEIR( Value( TypeType(), MkStdRTType( TSID( rt_type ),
nullptr, TSID( integer ),
VEC( HOLE( "size"_sid ), TERM( 0U ) ) ) ) );
return pattern;
}
const Term& IntegerType::PatternUnsigned32::GetPattern()
{
static auto pattern = ValueToEIR( Value( TypeType(), MkStdRTType( TSID( rt_type ),
nullptr, TSID( integer ),
VEC( TERM( 32U ), TERM( 0U ) ) ) ) );
return pattern;
}
llvm::Type* GetLLVMType( const HalfFloatType& t )
{
|
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
}
namespace goose::eir
{
//// Half
Value Bridge< HalfFloatType >::ToValue( const HalfFloatType& t )
{
return Value( Type(), MkStdRTType( TSID( half ), GetLLVMType( t ) ) );
}
optional< HalfFloatType > Bridge< HalfFloatType >::FromValue( const Value& v )
{
if( v != ToValue( HalfFloatType() ) )
return nullopt;
return {};
}
//// Float
Value Bridge< FloatType >::ToValue( const FloatType& t )
{
return Value( Type(), MkStdRTType( TSID( float ), GetLLVMType( t ) ) );
}
optional< FloatType > Bridge< FloatType >::FromValue( const Value& v )
{
if( v != ToValue( FloatType() ) )
return nullopt;
return {};
}
//// Double
Value Bridge< DoubleFloatType >::ToValue( const DoubleFloatType& t )
{
return Value( Type(), MkStdRTType( TSID( double ), GetLLVMType( t ) ) );
}
optional< DoubleFloatType > Bridge< DoubleFloatType >::FromValue( const Value& v )
{
if( v != ToValue( DoubleFloatType() ) )
return nullopt;
return {};
}
//// Integer
Value Bridge< IntegerType >::ToValue( const IntegerType& t )
{
return Value( Type(), MkStdRTType( TSID( integer ), GetLLVMType( t ),
VEC( TERM( t.m_numBits ), t.m_signed ? TERM( 1U ) : TERM( 0U ) ) ) );
}
optional< IntegerType > Bridge< IntegerType >::FromValue( const Value& v )
{
auto result = Decompose( v.val(),
Vec(
Lit( "integer"_sid ),
SubTerm(),
Val< void* >(),
Vec(
Val< uint32_t >(),
Val< uint32_t >()
)
)
);
|
|
|
|
|
|
>
|
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
}
namespace goose::eir
{
//// Half
Value Bridge< HalfFloatType >::ToValue( const HalfFloatType& t )
{
return Value( Type(), MkStdRTType( TSID( rt_type ), GetLLVMType( t ), TSID( half ) ) );
}
optional< HalfFloatType > Bridge< HalfFloatType >::FromValue( const Value& v )
{
if( v != ToValue( HalfFloatType() ) )
return nullopt;
return {};
}
//// Float
Value Bridge< FloatType >::ToValue( const FloatType& t )
{
return Value( Type(), MkStdRTType( TSID( rt_type ), GetLLVMType( t ), TSID( float ) ) );
}
optional< FloatType > Bridge< FloatType >::FromValue( const Value& v )
{
if( v != ToValue( FloatType() ) )
return nullopt;
return {};
}
//// Double
Value Bridge< DoubleFloatType >::ToValue( const DoubleFloatType& t )
{
return Value( Type(), MkStdRTType( TSID( rt_type ), GetLLVMType( t ), TSID( double ) ) );
}
optional< DoubleFloatType > Bridge< DoubleFloatType >::FromValue( const Value& v )
{
if( v != ToValue( DoubleFloatType() ) )
return nullopt;
return {};
}
//// Integer
Value Bridge< IntegerType >::ToValue( const IntegerType& t )
{
return Value( Type(), MkStdRTType( TSID( rt_type ), GetLLVMType( t ), TSID( integer ),
VEC( TERM( t.m_numBits ), t.m_signed ? TERM( 1U ) : TERM( 0U ) ) ) );
}
optional< IntegerType > Bridge< IntegerType >::FromValue( const Value& v )
{
auto result = Decompose( v.val(),
Vec(
Lit( "rt_type"_sid ),
SubTerm(),
Val< void* >(),
Lit( "integer"_sid ),
Vec(
Val< uint32_t >(),
Val< uint32_t >()
)
)
);
|