| ... | ... | @@ -1,5 +1,24 @@ |
| 1 | const std = @import("std"); |
| 2 | const Io = std.Io; |
| 3 | const assert = std.debug.assert; |
| 4 | const Allocator = std.mem.Allocator; |
| 5 | const DW = std.dwarf; |
| 6 | const Builder = std.zig.llvm.Builder; |
| 1 | 7 | const builtin = @import("builtin"); |
| 8 | const build_options = @import("build_options"); |
| 2 | 9 | |
| 10 | const Air = @import("../Air.zig"); |
| 11 | const codegen = @import("../codegen.zig"); |
| 12 | const Compilation = @import("../Compilation.zig"); |
| 13 | const dev = @import("../dev.zig"); |
| 14 | const InternPool = @import("../InternPool.zig"); |
| 15 | const link = @import("../link.zig"); |
| 16 | const Package = @import("../Package.zig"); |
| 17 | const target_util = @import("../target.zig"); |
| 18 | const Type = @import("../Type.zig"); |
| 19 | const Value = @import("../Value.zig"); |
| 20 | const Zcu = @import("../Zcu.zig"); |
| 21 | const aarch64_c_abi = @import("aarch64/abi.zig"); |
| 3 | 22 | const FuncGen = @import("llvm/FuncGen.zig"); |
| 4 | 23 | const buildAllocaInner = FuncGen.buildAllocaInner; |
| 5 | 24 | const isByRef = FuncGen.isByRef; |
| ... | ... | @@ -7,35 +26,13 @@ const firstParamSRet = FuncGen.firstParamSRet; |
| 7 | 26 | const lowerFnRetTy = FuncGen.lowerFnRetTy; |
| 8 | 27 | const iterateParamTypes = FuncGen.iterateParamTypes; |
| 9 | 28 | const ccAbiPromoteInt = FuncGen.ccAbiPromoteInt; |
| 10 | | const aarch64_c_abi = @import("aarch64/abi.zig"); |
| 11 | 29 | |
| 12 | | const std = @import("std"); |
| 13 | | const Io = std.Io; |
| 14 | | const assert = std.debug.assert; |
| 15 | | const Allocator = std.mem.Allocator; |
| 16 | 30 | const log = std.log.scoped(.codegen); |
| 17 | | const DW = std.dwarf; |
| 18 | | const Builder = std.zig.llvm.Builder; |
| 19 | | |
| 20 | | const build_options = @import("build_options"); |
| 21 | 31 | const bindings = if (build_options.have_llvm) |
| 22 | 32 | @import("llvm/bindings.zig") |
| 23 | 33 | else |
| 24 | 34 | @compileError("LLVM unavailable"); |
| 25 | 35 | |
| 26 | | const link = @import("../link.zig"); |
| 27 | | const Compilation = @import("../Compilation.zig"); |
| 28 | | const Zcu = @import("../Zcu.zig"); |
| 29 | | const InternPool = @import("../InternPool.zig"); |
| 30 | | const Package = @import("../Package.zig"); |
| 31 | | const Air = @import("../Air.zig"); |
| 32 | | const Value = @import("../Value.zig"); |
| 33 | | const Type = @import("../Type.zig"); |
| 34 | | const codegen = @import("../codegen.zig"); |
| 35 | | const dev = @import("../dev.zig"); |
| 36 | | |
| 37 | | const target_util = @import("../target.zig"); |
| 38 | | |
| 39 | 36 | pub fn legalizeFeatures(_: *const std.Target) ?*const Air.Legalize.Features { |
| 40 | 37 | return comptime &.initMany(&.{ |
| 41 | 38 | .expand_int_from_float_safe, |
| ... | ... | @@ -1946,15 +1943,32 @@ pub const Object = struct { |
| 1946 | 1943 | const gop = try o.debug_file_map.getOrPut(gpa, file_index); |
| 1947 | 1944 | errdefer assert(o.debug_file_map.remove(file_index)); |
| 1948 | 1945 | if (gop.found_existing) return gop.value_ptr.*; |
| 1946 | |
| 1947 | const dirs = o.zcu.comp.dirs; |
| 1949 | 1948 | const path = o.zcu.fileByIndex(file_index).path; |
| 1950 | | const abs_path = try path.toAbsolute(o.zcu.comp.dirs, gpa); |
| 1951 | | defer gpa.free(abs_path); |
| 1949 | const root_path: ?[]const u8 = switch (path.root) { |
| 1950 | .zig_lib => dirs.zig_lib.path, |
| 1951 | .global_cache => dirs.global_cache.path, |
| 1952 | .local_cache => dirs.local_cache.path, |
| 1953 | .none => null, |
| 1954 | }; |
| 1952 | 1955 | |
| 1953 | | gop.value_ptr.* = try o.builder.debugFile( |
| 1954 | | try o.builder.metadataString(std.fs.path.basename(abs_path)), |
| 1955 | | try o.builder.metadataString(std.fs.path.dirname(abs_path) orelse ""), |
| 1956 | | ); |
| 1957 | | return gop.value_ptr.*; |
| 1956 | const file = if (root_path) |root| |
| 1957 | try o.builder.debugFile( |
| 1958 | try o.builder.metadataString(path.sub_path), |
| 1959 | try o.builder.metadataString(root), |
| 1960 | ) |
| 1961 | else blk: { |
| 1962 | const relative = try std.fs.path.relative(gpa, dirs.cwd, null, dirs.cwd, path.sub_path); |
| 1963 | defer gpa.free(relative); |
| 1964 | break :blk try o.builder.debugFile( |
| 1965 | try o.builder.metadataString(relative), |
| 1966 | try o.builder.metadataString(dirs.cwd), |
| 1967 | ); |
| 1968 | }; |
| 1969 | |
| 1970 | gop.value_ptr.* = file; |
| 1971 | return file; |
| 1958 | 1972 | } |
| 1959 | 1973 | |
| 1960 | 1974 | pub fn getDebugType(o: *Object, pt: Zcu.PerThread, ty: Type) Allocator.Error!Builder.Metadata { |