| 1198 | return res; |
| 1199 | } |
| 1200 | id define_function(const location &loc, function &info) override |
| 1201 | { |
| 1202 | assert(!is_in_function()); |
| 1203 | |
| 1204 | function_blocks &func = _functions_blocks.emplace_back(); |
| 1205 | func.return_type = info.return_type; |
| 1206 | |
| 1207 | for (const member_type ¶m : info.parameter_list) |
| 1208 | func.param_types.push_back(param.type); |
| 1209 | |
| 1210 | add_location(loc, func.declaration); |
| 1211 | |
| 1212 | // https://www.khronos.org/registry/spir-v/specs/unified1/SPIRV.html#OpFunction |
| 1213 | const id res = info.id = |
| 1214 | add_instruction(spv::OpFunction, convert_type(info.return_type), func.declaration) |
| 1215 | .add(spv::FunctionControlMaskNone) |
| 1216 | .add(convert_type(func)); |
| 1217 | |
| 1218 | if (!info.name.empty()) |
| 1219 | add_name(res, info.name.c_str()); |
| 1220 | |
| 1221 | for (member_type ¶m : info.parameter_list) |
| 1222 | { |
| 1223 | add_location(param.location, func.declaration); |
| 1224 | |
| 1225 | param.id = add_instruction(spv::OpFunctionParameter, convert_type(param.type, true), func.declaration); |
| 1226 | |
| 1227 | add_name(param.id, param.name.c_str()); |
| 1228 | } |
| 1229 | |
| 1230 | _functions.push_back(std::make_unique<function>(info)); |
| 1231 | _current_function = _functions.back().get(); |
| 1232 | _current_function_blocks = &func; |
| 1233 | |
| 1234 | return res; |
| 1235 | } |
| 1236 | |
| 1237 | void define_entry_point(function &func) override |
| 1238 | { |
nothing calls this directly
no test coverage detected