clover: Use conversion operator to initialize build log from compat::string.
[mesa.git] / src / gallium / state_trackers / clover / core / module.hpp
1 //
2 // Copyright 2012 Francisco Jerez
3 //
4 // Permission is hereby granted, free of charge, to any person obtaining a
5 // copy of this software and associated documentation files (the "Software"),
6 // to deal in the Software without restriction, including without limitation
7 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 // and/or sell copies of the Software, and to permit persons to whom the
9 // Software is furnished to do so, subject to the following conditions:
10 //
11 // The above copyright notice and this permission notice shall be included in
12 // all copies or substantial portions of the Software.
13 //
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 // OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 // OTHER DEALINGS IN THE SOFTWARE.
21 //
22
23 #ifndef CLOVER_CORE_MODULE_HPP
24 #define CLOVER_CORE_MODULE_HPP
25
26 #include "util/compat.hpp"
27
28 namespace clover {
29 struct module {
30 typedef uint32_t resource_id;
31 typedef uint32_t size_t;
32
33 struct section {
34 enum type {
35 text,
36 data_constant,
37 data_global,
38 data_local,
39 data_private
40 };
41
42 section(resource_id id, enum type type, size_t size,
43 const compat::vector<char> &data) :
44 id(id), type(type), size(size), data(data) { }
45 section() : id(0), type(text), size(0), data() { }
46
47 resource_id id;
48 type type;
49 size_t size;
50 compat::vector<char> data;
51 };
52
53 struct argument {
54 enum type {
55 scalar,
56 constant,
57 global,
58 local,
59 image2d_rd,
60 image2d_wr,
61 image3d_rd,
62 image3d_wr,
63 sampler
64 };
65
66 enum ext_type {
67 zero_ext,
68 sign_ext
69 };
70
71 argument(enum type type, size_t size,
72 size_t target_size, size_t target_align,
73 enum ext_type ext_type) :
74 type(type), size(size),
75 target_size(target_size), target_align(target_align),
76 ext_type(ext_type) { }
77
78 argument(enum type type, size_t size) :
79 type(type), size(size),
80 target_size(size), target_align(1),
81 ext_type(zero_ext) { }
82
83 argument() : type(scalar), size(0),
84 target_size(0), target_align(1),
85 ext_type(zero_ext) { }
86
87 type type;
88 size_t size;
89 size_t target_size;
90 size_t target_align;
91 ext_type ext_type;
92 };
93
94 struct symbol {
95 symbol(const compat::vector<char> &name, resource_id section,
96 size_t offset, const compat::vector<argument> &args) :
97 name(name), section(section), offset(offset), args(args) { }
98 symbol() : name(), section(0), offset(0), args() { }
99
100 compat::vector<char> name;
101 resource_id section;
102 size_t offset;
103 compat::vector<argument> args;
104 };
105
106 void serialize(compat::ostream &os) const;
107 static module deserialize(compat::istream &is);
108 size_t size() const;
109
110 compat::vector<symbol> syms;
111 compat::vector<section> secs;
112 };
113 }
114
115 #endif