Skip to content

Add GCC backend using libgccjit #22812

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,8 @@ set(ZIG_STAGE2_SOURCES
src/codegen/spirv/Module.zig
src/codegen/spirv/Section.zig
src/codegen/spirv/spec.zig
src/codegen/gccjit.zig
src/codegen/gccjit/bindings.zig
src/crash_report.zig
src/dev.zig
src/glibc.zig
Expand Down
1 change: 1 addition & 0 deletions src/Compilation/Config.zig
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ pub const Options = struct {
use_lib_llvm: ?bool = null,
use_lld: ?bool = null,
use_clang: ?bool = null,
use_gccjit: ?bool = null,
lto: ?LtoMode = null,
/// WASI-only. Type of WASI execution model ("command" or "reactor").
wasi_exec_model: ?std.builtin.WasiExecModel = null,
Expand Down
40 changes: 40 additions & 0 deletions src/codegen/gccjit.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Mostly copied from llvm.zig
const std = @import("std");
const builtin = @import("builtin");
const assert = std.debug.assert;
const Allocator = std.mem.Allocator;
const log = std.log.scoped(.codegen);
const math = std.math;
const DW = std.dwarf;

//const Builder = @import("llvm/Builder.zig");
const gccjit = @import("gccjit/bindings.zig");
const link = @import("../link.zig");
const Compilation = @import("../Compilation.zig");
const build_options = @import("build_options");
const Zcu = @import("../Zcu.zig");
const InternPool = @import("../InternPool.zig");
const Package = @import("../Package.zig");
const Air = @import("../Air.zig");
const Liveness = @import("../Liveness.zig");
const Value = @import("../Value.zig");
const Type = @import("../Type.zig");
const x86_64_abi = @import("../arch/x86_64/abi.zig");
const wasm_c_abi = @import("../arch/wasm/abi.zig");
const aarch64_c_abi = @import("../arch/aarch64/abi.zig");
const arm_c_abi = @import("../arch/arm/abi.zig");
const riscv_c_abi = @import("../arch/riscv64/abi.zig");
const mips_c_abi = @import("../arch/mips/abi.zig");
const dev = @import("../dev.zig");

const Error = error{ OutOfMemory, CodegenFail };

pub fn getGCCJIT_Type_FromInst(inst: Air.Inst.Ref) c_int {
switch (inst) {
.c_long_type => {
return gccjit.GCC_JIT_TYPE_LONG;
},

else => return 9,
}
}
Loading