From 09d884737da7f0edd2cf0244765cd234954d25b8 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 25 Jun 2024 11:13:25 -0400 Subject: [PATCH] xo-jit: + MachPipeline::codegen_type() --- include/xo/jit/MachPipeline.hpp | 17 +++++++++++++++++ src/jit/MachPipeline.cpp | 5 +++++ 2 files changed, 22 insertions(+) diff --git a/include/xo/jit/MachPipeline.hpp b/include/xo/jit/MachPipeline.hpp index 0dc5a6a8..49be235d 100644 --- a/include/xo/jit/MachPipeline.hpp +++ b/include/xo/jit/MachPipeline.hpp @@ -86,6 +86,23 @@ namespace xo { // ----- code generation ----- + /** establish llvm IR corresponding to a c++ type. + * Handles + * T := bool|char|short|int|long|float|double + * | T1(*)(T2..Tn) + * | struct{T1,..,Tn} + * + * Not supported yet: + * - vector + * - string + * - map + * - unions + * - pointers (except function pointers) + * + * Idempotent: multiple calls with the same @p td produce the same @c llvm::Type pointer. + * @c llvm::Type instances are *immortal* (llvm interns them into opaque global lookup tables) + **/ + llvm::Type * codegen_type(TypeDescr td); llvm::Value * codegen_constant(ref::brw expr); llvm::Function * codegen_primitive(ref::brw expr); llvm::Value * codegen_apply(ref::brw expr, llvm::IRBuilder<> & ir_builder); diff --git a/src/jit/MachPipeline.cpp b/src/jit/MachPipeline.cpp index bf2d76e2..88037393 100644 --- a/src/jit/MachPipeline.cpp +++ b/src/jit/MachPipeline.cpp @@ -311,6 +311,11 @@ namespace xo { } } + llvm::Type * + MachPipeline::codegen_type(TypeDescr td) { + return td_to_llvm_type(llvm_cx_.borrow(), td); + } + llvm::Function * MachPipeline::codegen_primitive(ref::brw expr) {