mirror of
https://github.com/ziglang/zig.git
synced 2026-02-14 05:20:34 +00:00
llvm: fix builds that don't link with libllvm
This commit is contained in:
parent
713a555aa1
commit
48bd0ed7f3
@ -1212,7 +1212,7 @@ pub const Object = struct {
|
||||
try file.writeAll(ptr[0..(bitcode.len * 4)]);
|
||||
}
|
||||
|
||||
if (!self.module.comp.config.use_lib_llvm) {
|
||||
if (!build_options.have_llvm or !self.module.comp.config.use_lib_llvm) {
|
||||
log.err("emitting without libllvm not implemented", .{});
|
||||
return error.FailedToEmit;
|
||||
}
|
||||
@ -1647,7 +1647,7 @@ pub const Object = struct {
|
||||
const is_internal_linkage = decl.val.getExternFunc(zcu) == null and
|
||||
!zcu.decl_exports.contains(decl_index);
|
||||
const noret_bit: u29 = if (fn_info.return_type == .noreturn_type)
|
||||
llvm.DIFlags.NoReturn
|
||||
Builder.DIFlags.NoReturn
|
||||
else
|
||||
0;
|
||||
const debug_decl_type = try o.lowerDebugType(decl.ty);
|
||||
@ -1663,7 +1663,7 @@ pub const Object = struct {
|
||||
.optimized = owner_mod.optimize_mode != .Debug,
|
||||
.definition = true,
|
||||
.local = is_internal_linkage,
|
||||
.debug_info_flags = llvm.DIFlags.StaticMember | noret_bit,
|
||||
.debug_info_flags = Builder.DIFlags.StaticMember | noret_bit,
|
||||
},
|
||||
o.debug_compile_unit,
|
||||
);
|
||||
@ -3372,7 +3372,7 @@ pub const Object = struct {
|
||||
const ty = try o.builder.opaqueType(name);
|
||||
try o.type_map.put(o.gpa, t.toIntern(), ty);
|
||||
|
||||
try o.builder.namedTypeSetBody(
|
||||
o.builder.namedTypeSetBody(
|
||||
ty,
|
||||
try o.builder.structType(struct_kind, llvm_field_types.items),
|
||||
);
|
||||
@ -3483,7 +3483,7 @@ pub const Object = struct {
|
||||
const ty = try o.builder.opaqueType(name);
|
||||
try o.type_map.put(o.gpa, t.toIntern(), ty);
|
||||
|
||||
try o.builder.namedTypeSetBody(
|
||||
o.builder.namedTypeSetBody(
|
||||
ty,
|
||||
try o.builder.structType(.normal, &.{payload_ty}),
|
||||
);
|
||||
@ -3511,7 +3511,7 @@ pub const Object = struct {
|
||||
const ty = try o.builder.opaqueType(name);
|
||||
try o.type_map.put(o.gpa, t.toIntern(), ty);
|
||||
|
||||
try o.builder.namedTypeSetBody(
|
||||
o.builder.namedTypeSetBody(
|
||||
ty,
|
||||
try o.builder.structType(.normal, llvm_fields[0..llvm_fields_len]),
|
||||
);
|
||||
@ -4773,7 +4773,6 @@ pub const FuncGen = struct {
|
||||
|
||||
sync_scope: Builder.SyncScope,
|
||||
|
||||
const DbgState = if (build_options.have_llvm) struct { loc: *llvm.DILocation, scope: *llvm.DIScope, base_line: u32 } else struct {};
|
||||
const BreakList = union {
|
||||
list: std.MultiArrayList(struct {
|
||||
bb: Builder.Function.Block.Index,
|
||||
@ -5760,7 +5759,7 @@ pub const FuncGen = struct {
|
||||
};
|
||||
|
||||
const phi = try self.wip.phi(.i1, "");
|
||||
try phi.finish(
|
||||
phi.finish(
|
||||
&incoming_values,
|
||||
&.{ both_null_block, mixed_block, both_pl_block_end },
|
||||
&self.wip,
|
||||
@ -5827,7 +5826,7 @@ pub const FuncGen = struct {
|
||||
|
||||
parent_bb.ptr(&self.wip).incoming = @intCast(breaks.list.len);
|
||||
const phi = try self.wip.phi(llvm_ty, "");
|
||||
try phi.finish(breaks.list.items(.val), breaks.list.items(.bb), &self.wip);
|
||||
phi.finish(breaks.list.items(.val), breaks.list.items(.bb), &self.wip);
|
||||
return phi.toValue();
|
||||
} else {
|
||||
parent_bb.ptr(&self.wip).incoming = @intCast(breaks.len);
|
||||
@ -6615,7 +6614,7 @@ pub const FuncGen = struct {
|
||||
.optimized = owner_mod.optimize_mode != .Debug,
|
||||
.local = is_internal_linkage,
|
||||
.definition = true,
|
||||
.debug_info_flags = llvm.DIFlags.StaticMember,
|
||||
.debug_info_flags = Builder.DIFlags.StaticMember,
|
||||
},
|
||||
o.debug_compile_unit,
|
||||
);
|
||||
@ -9350,7 +9349,7 @@ pub const FuncGen = struct {
|
||||
_ = try self.wip.br(loop_block);
|
||||
|
||||
self.wip.cursor = .{ .block = end_block };
|
||||
try it_ptr.finish(&.{ next_ptr, dest_ptr }, &.{ body_block, entry_block }, &self.wip);
|
||||
it_ptr.finish(&.{ next_ptr, dest_ptr }, &.{ body_block, entry_block }, &self.wip);
|
||||
return .none;
|
||||
}
|
||||
|
||||
@ -9585,7 +9584,7 @@ pub const FuncGen = struct {
|
||||
|
||||
self.wip.cursor = .{ .block = end_block };
|
||||
const phi = try self.wip.phi(.i1, "");
|
||||
try phi.finish(&.{ .true, .false }, &.{ valid_block, invalid_block }, &self.wip);
|
||||
phi.finish(&.{ .true, .false }, &.{ valid_block, invalid_block }, &self.wip);
|
||||
return phi.toValue();
|
||||
}
|
||||
|
||||
|
||||
@ -4264,7 +4264,7 @@ pub const Function = struct {
|
||||
=> wip.builder.structTypeAssumeCapacity(.normal, &.{
|
||||
wip.extraData(CmpXchg, instruction.data).cmp.typeOfWip(wip),
|
||||
.i1,
|
||||
}) catch unreachable,
|
||||
}),
|
||||
.extractelement => wip.extraData(ExtractElement, instruction.data)
|
||||
.val.typeOfWip(wip).childType(wip.builder),
|
||||
.extractvalue => {
|
||||
@ -4451,7 +4451,7 @@ pub const Function = struct {
|
||||
function.extraData(CmpXchg, instruction.data)
|
||||
.cmp.typeOf(function_index, builder),
|
||||
.i1,
|
||||
}) catch unreachable,
|
||||
}),
|
||||
.extractelement => function.extraData(ExtractElement, instruction.data)
|
||||
.val.typeOf(function_index, builder).childType(builder),
|
||||
.extractvalue => {
|
||||
@ -4840,6 +4840,44 @@ pub const DebugLocation = struct {
|
||||
inlined_at: Metadata,
|
||||
};
|
||||
|
||||
pub const DIFlags = opaque {
|
||||
pub const Zero = 0;
|
||||
pub const Private = 1;
|
||||
pub const Protected = 2;
|
||||
pub const Public = 3;
|
||||
|
||||
pub const FwdDecl = 1 << 2;
|
||||
pub const AppleBlock = 1 << 3;
|
||||
pub const BlockByrefStruct = 1 << 4;
|
||||
pub const Virtual = 1 << 5;
|
||||
pub const Artificial = 1 << 6;
|
||||
pub const Explicit = 1 << 7;
|
||||
pub const Prototyped = 1 << 8;
|
||||
pub const ObjcClassComplete = 1 << 9;
|
||||
pub const ObjectPointer = 1 << 10;
|
||||
pub const Vector = 1 << 11;
|
||||
pub const StaticMember = 1 << 12;
|
||||
pub const LValueReference = 1 << 13;
|
||||
pub const RValueReference = 1 << 14;
|
||||
pub const Reserved = 1 << 15;
|
||||
|
||||
pub const SingleInheritance = 1 << 16;
|
||||
pub const MultipleInheritance = 2 << 16;
|
||||
pub const VirtualInheritance = 3 << 16;
|
||||
|
||||
pub const IntroducedVirtual = 1 << 18;
|
||||
pub const BitField = 1 << 19;
|
||||
pub const NoReturn = 1 << 20;
|
||||
pub const TypePassByValue = 1 << 22;
|
||||
pub const TypePassByReference = 1 << 23;
|
||||
pub const EnumClass = 1 << 24;
|
||||
pub const Thunk = 1 << 25;
|
||||
pub const NonTrivial = 1 << 26;
|
||||
pub const BigEndian = 1 << 27;
|
||||
pub const LittleEndian = 1 << 28;
|
||||
pub const AllCallsDescribed = 1 << 29;
|
||||
};
|
||||
|
||||
pub const WipFunction = struct {
|
||||
builder: *Builder,
|
||||
function: Function.Index,
|
||||
@ -5610,7 +5648,7 @@ pub const WipFunction = struct {
|
||||
vals: []const Value,
|
||||
blocks: []const Block.Index,
|
||||
wip: *WipFunction,
|
||||
) (if (build_options.have_llvm) Allocator.Error else error{})!void {
|
||||
) void {
|
||||
const incoming_len = self.block.ptrConst(wip).incoming;
|
||||
assert(vals.len == incoming_len and blocks.len == incoming_len);
|
||||
const instruction = wip.instructions.get(@intFromEnum(self.instruction));
|
||||
@ -8007,7 +8045,7 @@ pub fn namedTypeSetBody(
|
||||
self: *Builder,
|
||||
named_type: Type,
|
||||
body_type: Type,
|
||||
) (if (build_options.have_llvm) Allocator.Error else error{})!void {
|
||||
) void {
|
||||
const named_item = self.type_items.items[@intFromEnum(named_type)];
|
||||
self.type_extra.items[named_item.data + std.meta.fieldIndex(Type.NamedStructure, "body").?] =
|
||||
@intFromEnum(body_type);
|
||||
@ -9372,7 +9410,7 @@ fn fnTypeAssumeCapacity(
|
||||
ret: Type,
|
||||
params: []const Type,
|
||||
comptime kind: Type.Function.Kind,
|
||||
) (if (build_options.have_llvm) Allocator.Error else error{})!Type {
|
||||
) Type {
|
||||
const tag: Type.Tag = switch (kind) {
|
||||
.normal => .function,
|
||||
.vararg => .vararg_function,
|
||||
@ -9528,7 +9566,7 @@ fn structTypeAssumeCapacity(
|
||||
self: *Builder,
|
||||
comptime kind: Type.Structure.Kind,
|
||||
fields: []const Type,
|
||||
) (if (build_options.have_llvm) Allocator.Error else error{})!Type {
|
||||
) Type {
|
||||
const tag: Type.Tag = switch (kind) {
|
||||
.normal => .structure,
|
||||
.@"packed" => .packed_structure,
|
||||
@ -9739,10 +9777,7 @@ fn bigIntConstAssumeCapacity(
|
||||
assert(type_item.tag == .integer);
|
||||
const bits = type_item.data;
|
||||
|
||||
const ExpectedContents = extern struct {
|
||||
limbs: [64 / @sizeOf(std.math.big.Limb)]std.math.big.Limb,
|
||||
llvm_limbs: if (build_options.have_llvm) [64 / @sizeOf(u64)]u64 else void,
|
||||
};
|
||||
const ExpectedContents = [64 / @sizeOf(std.math.big.Limb)]std.math.big.Limb;
|
||||
var stack align(@alignOf(ExpectedContents)) =
|
||||
std.heap.stackFallback(@sizeOf(ExpectedContents), self.gpa);
|
||||
const allocator = stack.get();
|
||||
@ -9973,11 +10008,7 @@ fn noneConstAssumeCapacity(self: *Builder, ty: Type) Constant {
|
||||
return result.constant;
|
||||
}
|
||||
|
||||
fn structConstAssumeCapacity(
|
||||
self: *Builder,
|
||||
ty: Type,
|
||||
vals: []const Constant,
|
||||
) (if (build_options.have_llvm) Allocator.Error else error{})!Constant {
|
||||
fn structConstAssumeCapacity(self: *Builder, ty: Type, vals: []const Constant) Constant {
|
||||
const type_item = self.type_items.items[@intFromEnum(ty)];
|
||||
var extra = self.typeExtraDataTrail(Type.Structure, switch (type_item.tag) {
|
||||
.structure, .packed_structure => type_item.data,
|
||||
@ -10007,11 +10038,7 @@ fn structConstAssumeCapacity(
|
||||
return result.constant;
|
||||
}
|
||||
|
||||
fn arrayConstAssumeCapacity(
|
||||
self: *Builder,
|
||||
ty: Type,
|
||||
vals: []const Constant,
|
||||
) (if (build_options.have_llvm) Allocator.Error else error{})!Constant {
|
||||
fn arrayConstAssumeCapacity(self: *Builder, ty: Type, vals: []const Constant) Constant {
|
||||
const type_item = self.type_items.items[@intFromEnum(ty)];
|
||||
const type_extra: struct { len: u64, child: Type } = switch (type_item.tag) {
|
||||
inline .small_array, .array => |kind| extra: {
|
||||
@ -10055,11 +10082,7 @@ fn stringNullConstAssumeCapacity(self: *Builder, val: String) Constant {
|
||||
return result.constant;
|
||||
}
|
||||
|
||||
fn vectorConstAssumeCapacity(
|
||||
self: *Builder,
|
||||
ty: Type,
|
||||
vals: []const Constant,
|
||||
) (if (build_options.have_llvm) Allocator.Error else error{})!Constant {
|
||||
fn vectorConstAssumeCapacity(self: *Builder, ty: Type, vals: []const Constant) Constant {
|
||||
assert(ty.isVector(self));
|
||||
assert(ty.vectorLen(self) == vals.len);
|
||||
for (vals) |val| assert(ty.childType(self) == val.typeOf(self));
|
||||
@ -10075,11 +10098,7 @@ fn vectorConstAssumeCapacity(
|
||||
return result.constant;
|
||||
}
|
||||
|
||||
fn splatConstAssumeCapacity(
|
||||
self: *Builder,
|
||||
ty: Type,
|
||||
val: Constant,
|
||||
) (if (build_options.have_llvm) Allocator.Error else error{})!Constant {
|
||||
fn splatConstAssumeCapacity(self: *Builder, ty: Type, val: Constant) Constant {
|
||||
assert(ty.scalarType(self) == val.typeOf(self));
|
||||
|
||||
if (!ty.isVector(self)) return val;
|
||||
@ -10327,7 +10346,7 @@ fn gepConstAssumeCapacity(
|
||||
base: Constant,
|
||||
inrange: ?u16,
|
||||
indices: []const Constant,
|
||||
) (if (build_options.have_llvm) Allocator.Error else error{})!Constant {
|
||||
) Constant {
|
||||
const tag: Constant.Tag = switch (kind) {
|
||||
.normal => .getelementptr,
|
||||
.inbounds => .@"getelementptr inbounds",
|
||||
|
||||
@ -394,41 +394,3 @@ extern fn ZigLLVMWriteImportLibrary(
|
||||
output_lib_path: [*:0]const u8,
|
||||
kill_at: bool,
|
||||
) bool;
|
||||
|
||||
pub const DIFlags = opaque {
|
||||
pub const Zero = 0;
|
||||
pub const Private = 1;
|
||||
pub const Protected = 2;
|
||||
pub const Public = 3;
|
||||
|
||||
pub const FwdDecl = 1 << 2;
|
||||
pub const AppleBlock = 1 << 3;
|
||||
pub const BlockByrefStruct = 1 << 4;
|
||||
pub const Virtual = 1 << 5;
|
||||
pub const Artificial = 1 << 6;
|
||||
pub const Explicit = 1 << 7;
|
||||
pub const Prototyped = 1 << 8;
|
||||
pub const ObjcClassComplete = 1 << 9;
|
||||
pub const ObjectPointer = 1 << 10;
|
||||
pub const Vector = 1 << 11;
|
||||
pub const StaticMember = 1 << 12;
|
||||
pub const LValueReference = 1 << 13;
|
||||
pub const RValueReference = 1 << 14;
|
||||
pub const Reserved = 1 << 15;
|
||||
|
||||
pub const SingleInheritance = 1 << 16;
|
||||
pub const MultipleInheritance = 2 << 16;
|
||||
pub const VirtualInheritance = 3 << 16;
|
||||
|
||||
pub const IntroducedVirtual = 1 << 18;
|
||||
pub const BitField = 1 << 19;
|
||||
pub const NoReturn = 1 << 20;
|
||||
pub const TypePassByValue = 1 << 22;
|
||||
pub const TypePassByReference = 1 << 23;
|
||||
pub const EnumClass = 1 << 24;
|
||||
pub const Thunk = 1 << 25;
|
||||
pub const NonTrivial = 1 << 26;
|
||||
pub const BigEndian = 1 << 27;
|
||||
pub const LittleEndian = 1 << 28;
|
||||
pub const AllCallsDescribed = 1 << 29;
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user