| 392 | }; |
| 393 | |
| 394 | struct MakeStructNodeType : public NodeType { |
| 395 | MakeStructNodeType(GraphStruct& ty) : NodeType(ty.module()), mStruct{&ty} { |
| 396 | setName("_make_" + ty.name()); |
| 397 | setDescription("Make a " + ty.name() + " structure"); |
| 398 | makePure(); |
| 399 | |
| 400 | // set inputs |
| 401 | setDataInputs(ty.types()); |
| 402 | |
| 403 | // set output to just be the struct |
| 404 | setDataOutputs({{"", ty.dataType()}}); |
| 405 | } |
| 406 | |
| 407 | Result codegen(size_t /*execInputID*/, const llvm::DebugLoc& nodeLocation, |
| 408 | const std::vector<llvm::Value*>& io, llvm::BasicBlock* codegenInto, |
| 409 | const std::vector<llvm::BasicBlock*>& outputBlocks, |
| 410 | std::unordered_map<std::string, std::shared_ptr<void>>& compileCache) override { |
| 411 | llvm::IRBuilder<> builder{codegenInto}; |
| 412 | builder.SetCurrentDebugLocation(nodeLocation); |
| 413 | |
| 414 | llvm::Value* out = io[io.size() - 1]; // output goes last |
| 415 | for (auto id = 0; id < io.size() - 1; ++id) { |
| 416 | auto ptr = builder.CreateStructGEP( |
| 417 | #if LLVM_VERSION_AT_LEAST(3, 7) |
| 418 | mStruct->dataType().llvmType(), |
| 419 | #endif |
| 420 | out, id); |
| 421 | builder.CreateStore(io[id], ptr); |
| 422 | } |
| 423 | |
| 424 | builder.CreateBr(outputBlocks[0]); |
| 425 | |
| 426 | return {}; |
| 427 | } |
| 428 | |
| 429 | nlohmann::json toJSON() const override { return {}; } |
| 430 | std::unique_ptr<NodeType> clone() const override { |
| 431 | return std::make_unique<MakeStructNodeType>(*mStruct); |
| 432 | } |
| 433 | |
| 434 | GraphStruct* mStruct; |
| 435 | }; |
| 436 | |
| 437 | struct BreakStructNodeType : public NodeType { |
| 438 | BreakStructNodeType(GraphStruct& ty) : NodeType(ty.module()), mStruct{&ty} { |
nothing calls this directly
no outgoing calls
no test coverage detected