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

Method codegen

libchigraph/src/LangModule.cpp:348–365  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

346 }
347
348 Result codegen(
349 size_t /*execInputID*/, const llvm::DebugLoc& nodeLocation,
350 const std::vector<llvm::Value*>& io, llvm::BasicBlock* codegenInto,
351 const std::vector<llvm::BasicBlock*>& outputBlocks,
352 std::unordered_map<std::string, std::shared_ptr<void>>& /*compileCache*/) override {
353 assert(io.size() == 2 && codegenInto != nullptr && outputBlocks.size() == 1);
354
355 llvm::IRBuilder<> builder(codegenInto);
356 builder.SetCurrentDebugLocation(nodeLocation);
357
358 auto casted =
359 builder.CreateCast(llvm::Instruction::CastOps::FPToSI, io[0], builder.getInt32Ty());
360 builder.CreateStore(casted, io[1]);
361
362 builder.CreateBr(outputBlocks[0]);
363
364 return {};
365 }
366
367 std::unique_ptr<NodeType> clone() const override {
368 return std::make_unique<FloatToIntNodeType>(*this);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected