blob: 2d757f9d6c8d9411fe8ab4ce1d5f54f3ec97917d (
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
|
#include "node.h"
#include "data.h"
#include <boost/endian/conversion.hpp>
#include <memory>
using namespace FlowGraph;
FlowGraph::Data& Node::destination()
{
if (mOperands.size() < 1)
throw std::runtime_error("ICE: No destination operand available");
return mOperands[0];
}
// 4 byte for now
Data FlowGraph::MakeConstantInt(int i)
{
std::vector<uint8_t> value(size_t(4), uint8_t(0));
*(reinterpret_cast<int32_t*>(value.data())) = boost::endian::native_to_little(static_cast<int32_t>(i));
return Data{DataType::Int, std::make_shared<Constant>(value)};
}
Data FlowGraph::MakeLocalPointer(FlowGraph::LocalScope& scope, const std::string& name)
{
Data data{DataType::Pointer, std::make_shared<LocalStorage>(scope, name)};
scope.push_back(std::make_shared<Data>(data));
return data;
}
Data FlowGraph::MakeLocalSize(FlowGraph::LocalScope& scope, const std::string& name)
{
Data data{DataType::Size, std::make_shared<LocalStorage>(scope, name)};
scope.push_back(std::make_shared<Data>(data));
return data;
}
Data FlowGraph::MakeTemporaryInt(FlowGraph::LocalScope& scope)
{
Data data{DataType::Int, std::make_shared<TemporaryStorage>(scope)};
scope.push_back(std::make_shared<Data>(data));
return data;
}
LocalScope& CreateScopeOp::scope()
{
return m_scope;
}
|