From d8b41bbb25a0c7b296a16b18fb49a42efca33542 Mon Sep 17 00:00:00 2001 From: Valentin Churavy Date: Thu, 26 Oct 2023 19:28:44 -0400 Subject: [PATCH] use dialect for first thing! --- src/JuliaDialect.td | 4 ---- src/codegen.cpp | 25 +++++++++---------------- 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/src/JuliaDialect.td b/src/JuliaDialect.td index 4c1d2a64418c5..1c169ab5bfaf3 100644 --- a/src/JuliaDialect.td +++ b/src/JuliaDialect.td @@ -35,8 +35,6 @@ def GetPGCStack : JuliaOp<"get_pgcstack", let results = (outs Ptr:$result); let arguments = (ins); - let defaultBuilderHasExplicitResultType = true; - let summary = "Obtain hidden pgcstack pointer"; let description = [{}]; } @@ -46,8 +44,6 @@ def GetPGCStackOrNew : JuliaOp<"get_pgcstack_or_new", let results = (outs Ptr:$result); let arguments = (ins); - let defaultBuilderHasExplicitResultType = true; - let summary = "Obtain hidden pgcstack pointer"; let description = [{}]; } diff --git a/src/codegen.cpp b/src/codegen.cpp index 824464382cd97..29eaf229eeefa 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -76,6 +76,9 @@ #include #include +#include "llvm-dialects/Dialect/Builder.h" +#include "JuliaDialect.h" + using namespace llvm; static bool jl_fpo_disabled(const Triple &TT) { @@ -777,19 +780,6 @@ static const auto jlboxed_uint8_cache = new JuliaVariable{ [](Type *T_size) -> Type * { return ArrayType::get(get_pjlvalue(T_size->getContext()), 256); }, }; -static const auto jlpgcstack_func = new JuliaFunction<>{ - "julia.get_pgcstack", - [](LLVMContext &C) { return FunctionType::get(PointerType::get(JuliaType::get_ppjlvalue_ty(C), 0), false); }, - nullptr, -}; - -static const auto jladoptthread_func = new JuliaFunction<>{ - "julia.get_pgcstack_or_new", - jlpgcstack_func->_type, - jlpgcstack_func->_attrs, -}; - - // important functions // Symbols are not gc-tracked, but we'll treat them as callee rooted anyway, // because they may come from a gc-rooted location @@ -1838,7 +1828,7 @@ struct jl_varinfo_t { // function and module, and visible local variables and labels. class jl_codectx_t { public: - IRBuilder<> builder; + llvm_dialects::Builder builder; jl_codegen_params_t &emission_context; llvm::MapVector call_targets; Function *f = NULL; @@ -6154,7 +6144,11 @@ static void allocate_gc_frame(jl_codectx_t &ctx, BasicBlock *b0, bool or_new=fal { // allocate a placeholder gc instruction // this will require the runtime, but it gets deleted later if unused - ctx.topalloca = ctx.builder.CreateCall(prepare_call(or_new ? jladoptthread_func : jlpgcstack_func)); + if (or_new) + ctx.topalloca = ctx.builder.create(); + else + ctx.topalloca = ctx.builder.create(); + ctx.pgcstack = ctx.topalloca; ctx.pgcstack->setName("pgcstack"); } @@ -9462,7 +9456,6 @@ static void init_jit_functions(void) global_jlvalue_to_llvm(new JuliaVariable{"jl_undefref_exception", true, size2pjlvalue}, &jl_undefref_exception); add_named_global(jlgetworld_global, &jl_world_counter); add_named_global("__stack_chk_fail", &__stack_chk_fail); - add_named_global(jlpgcstack_func, (void*)NULL); add_named_global(jlerror_func, &jl_error); add_named_global(jlatomicerror_func, &jl_atomic_error); add_named_global(jlthrow_func, &jl_throw);