• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

daisytuner / sdfglib / 15133758385

20 May 2025 09:19AM UTC coverage: 60.543% (-3.0%) from 63.542%
15133758385

push

github

web-flow
Merge pull request #22 from daisytuner/normalization

Removes normalization passes

7922 of 13085 relevant lines covered (60.54%)

104.24 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

89.66
/src/builder/function_builder.cpp
1
#include "sdfg/builder/function_builder.h"
2

3
namespace sdfg {
4
namespace builder {
5

6
FunctionBuilder::FunctionBuilder() : element_counter_(1) {};
827✔
7

8
const types::IType& FunctionBuilder::add_container(const std::string& name,
836✔
9
                                                   const types::IType& type, bool is_argument,
10
                                                   bool is_external) const {
11
    if (is_argument && is_external) {
836✔
12
        throw std::invalid_argument("Container cannot be both an argument and an external");
×
13
    }
14

15
    auto res = this->function().containers_.insert({name, type.clone()});
836✔
16
    assert(res.second);
836✔
17

18
    if (is_argument) {
836✔
19
        this->function().arguments_.push_back(name);
219✔
20
    }
219✔
21
    if (is_external) {
836✔
22
        this->function().externals_.push_back(name);
11✔
23
    }
11✔
24
    if (type.is_symbol() && dynamic_cast<const types::Scalar*>(&type)) {
836✔
25
        auto sym = symbolic::symbol(name);
654✔
26
        this->function().assumptions_.insert({sym, symbolic::Assumption::create(sym, type)});
654✔
27
    }
654✔
28

29
    return *(*res.first).second;
836✔
30
};
×
31

32
void FunctionBuilder::remove_container(const std::string& name) const {
6✔
33
    auto& function = this->function();
6✔
34
    if (!function.is_transient(name)) {
6✔
35
        throw std::invalid_argument("Container is not transient");
2✔
36
    }
37

38
    auto& type = function.containers_[name];
4✔
39
    if (type->is_symbol() && dynamic_cast<const types::Scalar*>(type.get())) {
4✔
40
        function.assumptions_.erase(symbolic::symbol(name));
4✔
41
    }
4✔
42

43
    function.containers_.erase(name);
4✔
44
};
4✔
45

46
void FunctionBuilder::change_type(const std::string& name, const types::IType& type) const {
9✔
47
    auto& function = this->function();
9✔
48
    if (!function.is_transient(name)) {
9✔
49
        throw std::invalid_argument("Container is not transient");
×
50
    }
51

52
    function.containers_[name] = type.clone();
9✔
53
};
9✔
54

55
types::StructureDefinition& FunctionBuilder::add_structure(const std::string& name,
20✔
56
                                                           bool is_packed) const {
57
    auto res = this->function().structures_.insert(
20✔
58
        {name, std::make_unique<types::StructureDefinition>(name, is_packed)});
20✔
59
    assert(res.second);
20✔
60

61
    return *(*res.first).second;
20✔
62
};
×
63

64
void FunctionBuilder::make_array(const std::string& name, const symbolic::Expression& size) const {
2✔
65
    auto& function = this->function();
2✔
66
    if (!function.is_transient(name)) {
2✔
67
        throw std::invalid_argument("Container is not transient");
1✔
68
    }
69

70
    auto& old_type = function.containers_[name];
1✔
71

72
    if (old_type->is_symbol()) {
1✔
73
        function.assumptions_.erase(symbolic::symbol(name));
1✔
74
    }
1✔
75

76
    function.containers_[name] = std::make_unique<types::Array>(*old_type, size);
1✔
77
};
1✔
78

79
std::string FunctionBuilder::find_new_name(std::string prefix) const {
4✔
80
    size_t i = 0;
4✔
81
    std::string new_name = prefix + std::to_string(i);
4✔
82
    while (this->function().exists(new_name)) {
4✔
83
        i++;
×
84
        new_name = prefix + std::to_string(i);
×
85
    }
86
    return new_name;
4✔
87
};
4✔
88

89
}  // namespace builder
90
}  // namespace sdfg
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc