Skip to content

Commit

Permalink
use dialect for first thing!
Browse files Browse the repository at this point in the history
  • Loading branch information
vchuravy committed Jan 17, 2024
1 parent c0f5ab2 commit d8b41bb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 20 deletions.
4 changes: 0 additions & 4 deletions src/JuliaDialect.td
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [{}];
}
Expand All @@ -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 = [{}];
}
Expand Down
25 changes: 9 additions & 16 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@
#include <llvm/Bitcode/BitcodeReader.h>
#include <llvm/Linker/Linker.h>

#include "llvm-dialects/Dialect/Builder.h"
#include "JuliaDialect.h"

using namespace llvm;

static bool jl_fpo_disabled(const Triple &TT) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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<jl_code_instance_t*, jl_codegen_call_target_t> call_targets;
Function *f = NULL;
Expand Down Expand Up @@ -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<julia::GetPGCStackOrNew>();
else
ctx.topalloca = ctx.builder.create<julia::GetPGCStack>();

ctx.pgcstack = ctx.topalloca;
ctx.pgcstack->setName("pgcstack");
}
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit d8b41bb

Please sign in to comment.