blob: cb7677a424ed5c83301f8e9da08f93a8419fd441 (
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
52
53
54
55
56
57
58
|
#include "node.h"
#include "byteorder.h"
#include "data.h"
#include "minicc.h"
#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)
{
return Data{DataType::Int, std::make_shared<Constant>(endian::to_little(uint32_t(i)))};
}
Data FlowGraph::MakeLocalInt(std::shared_ptr<FlowGraph::LocalScope> scope, const std::string& name)
{
Data data{DataType::Int, std::make_shared<LocalStorage>(name)};
scope->push_back(std::make_shared<Data>(data));
return data;
}
Data FlowGraph::MakeLocalPointer(std::shared_ptr<FlowGraph::LocalScope> scope, const std::string& name)
{
Data data{DataType::Pointer, std::make_shared<LocalStorage>(name)};
scope->push_back(std::make_shared<Data>(data));
return data;
}
Data FlowGraph::MakeTemporaryInt(std::shared_ptr<FlowGraph::LocalScope> scope)
{
Data data{DataType::Int, std::make_shared<TemporaryStorage>()};
scope->push_back(std::make_shared<Data>(data));
return data;
}
FlowGraph::CreateScopeOp::CreateScopeOp(): m_scope(std::make_shared<LocalScope>())
{
}
std::shared_ptr<LocalScope> FlowGraph::CreateScopeOp::scope()
{
return m_scope;
}
FlowGraph::DestroyScopeOp::DestroyScopeOp(std::shared_ptr<LocalScope> scope): m_scope(std::make_shared<LocalScope>())
{
}
|