MCPcopy Create free account
hub / github.com/chigraph/chigraph / codegen

Method codegen

libchigraph/src/LangModule.cpp:59–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57 }
58
59 Result codegen(
60 size_t /*inputExecID*/, const llvm::DebugLoc& nodeLocation,
61 const std::vector<llvm::Value*>& io, llvm::BasicBlock* codegenInto,
62 const std::vector<llvm::BasicBlock*>& outputBlocks,
63 std::unordered_map<std::string, std::shared_ptr<void>>& /*compileCache*/) override {
64 assert(io.size() == dataOutputs().size() && codegenInto != nullptr &&
65 outputBlocks.size() == execOutputs().size());
66
67 llvm::IRBuilder<> builder(codegenInto);
68 builder.SetCurrentDebugLocation(nodeLocation);
69
70 // store the arguments
71 auto arg_iter = codegenInto->getParent()->arg_begin();
72 ++arg_iter; // skip the first argument, which is the input exec ID
73 for (const auto& iovalue : io) {
74 builder.CreateStore(&*arg_iter, iovalue);
75
76 ++arg_iter;
77 }
78
79 auto inExecID = &*codegenInto->getParent()->arg_begin();
80 auto switchInst = builder.CreateSwitch(inExecID, outputBlocks[0], execOutputs().size());
81
82 for (auto id = 0ull; id < execOutputs().size(); ++id) {
83 switchInst->addCase(builder.getInt32(id), outputBlocks[id]);
84 }
85 return {};
86 }
87
88 std::unique_ptr<NodeType> clone() const override {
89 return std::make_unique<EntryNodeType>(*this);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected