Skip to content
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

Changes for Llvm14 #11374

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
1 change: 1 addition & 0 deletions src/codegen/llvm.zig
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,7 @@ pub const Object = struct {
} else {
_ = self.llvm_module.addAlias(
llvm_global.typeOf(),
0, // TODO(gwenzek) addrSpace
llvm_global,
exp_name_z,
);
Expand Down
5 changes: 4 additions & 1 deletion src/codegen/llvm/bindings.zig
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,10 @@ pub const Builder = opaque {
pub const buildStore = LLVMBuildStore;
extern fn LLVMBuildStore(*const Builder, Val: *const Value, Ptr: *const Value) *const Value;

pub const buildLoad = LLVMBuildLoad2;
pub const buildLoad = LLVMBuildLoad;
extern fn LLVMBuildLoad(*const Builder, PointerVal: *const Value, Name: [*:0]const u8) *const Value;
// TODO(gwenzek): replace buildLoad with buildLoad2
pub const buildLoad2 = LLVMBuildLoad2;
extern fn LLVMBuildLoad2(*const Builder, Ty: *const Type, PointerVal: *const Value, Name: [*:0]const u8) *const Value;

pub const buildNeg = LLVMBuildNeg;
Expand Down
6 changes: 3 additions & 3 deletions src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -4129,11 +4129,11 @@ pub fn punt_to_lld(arena: Allocator, args: []const []const u8) error{OutOfMemory
const llvm = @import("codegen/llvm/bindings.zig");
const argc = @intCast(c_int, argv.len);
if (mem.eql(u8, args[1], "ld.lld")) {
break :rc llvm.LinkELF(argc, argv.ptr, true);
break :rc llvm.LinkELF(argc, argv.ptr, true, false);
} else if (mem.eql(u8, args[1], "lld-link")) {
break :rc llvm.LinkCOFF(argc, argv.ptr, true);
break :rc llvm.LinkCOFF(argc, argv.ptr, true, false);
} else if (mem.eql(u8, args[1], "wasm-ld")) {
break :rc llvm.LinkWasm(argc, argv.ptr, true);
break :rc llvm.LinkWasm(argc, argv.ptr, true, false);
} else {
unreachable;
}
Expand Down
140 changes: 90 additions & 50 deletions src/stage1/codegen.cpp

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions src/stage1/target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,7 @@ uint32_t target_arch_pointer_bit_width(ZigLLVM_ArchType arch) {
case ZigLLVM_amdil:
case ZigLLVM_hsail:
case ZigLLVM_spir:
case ZigLLVM_spirv32:
case ZigLLVM_kalimba:
case ZigLLVM_lanai:
case ZigLLVM_shave:
Expand Down Expand Up @@ -551,6 +552,7 @@ uint32_t target_arch_pointer_bit_width(ZigLLVM_ArchType arch) {
case ZigLLVM_amdil64:
case ZigLLVM_hsail64:
case ZigLLVM_spir64:
case ZigLLVM_spirv64:
case ZigLLVM_wasm64:
case ZigLLVM_renderscript64:
case ZigLLVM_ve:
Expand Down Expand Up @@ -592,6 +594,7 @@ uint32_t target_arch_largest_atomic_bits(ZigLLVM_ArchType arch) {
case ZigLLVM_amdil:
case ZigLLVM_hsail:
case ZigLLVM_spir:
case ZigLLVM_spirv32:
case ZigLLVM_kalimba:
case ZigLLVM_lanai:
case ZigLLVM_shave:
Expand All @@ -618,6 +621,7 @@ uint32_t target_arch_largest_atomic_bits(ZigLLVM_ArchType arch) {
case ZigLLVM_amdil64:
case ZigLLVM_hsail64:
case ZigLLVM_spir64:
case ZigLLVM_spirv64:
case ZigLLVM_wasm64:
case ZigLLVM_renderscript64:
case ZigLLVM_ve:
Expand Down Expand Up @@ -849,6 +853,8 @@ const char *arch_stack_pointer_register_name(ZigLLVM_ArchType arch) {
case ZigLLVM_sparcv9:
case ZigLLVM_spir:
case ZigLLVM_spir64:
case ZigLLVM_spirv32:
case ZigLLVM_spirv64:
case ZigLLVM_systemz:
case ZigLLVM_tce:
case ZigLLVM_tcele:
Expand Down Expand Up @@ -909,6 +915,8 @@ bool target_is_arm(const ZigTarget *target) {
case ZigLLVM_sparcv9:
case ZigLLVM_spir:
case ZigLLVM_spir64:
case ZigLLVM_spirv32:
case ZigLLVM_spirv64:
case ZigLLVM_systemz:
case ZigLLVM_tce:
case ZigLLVM_tcele:
Expand Down
2 changes: 1 addition & 1 deletion src/translate_c.zig
Original file line number Diff line number Diff line change
Expand Up @@ -4788,7 +4788,7 @@ fn transType(c: *Context, scope: *Scope, ty: *const clang.Type, source_loc: clan
.rhs = try transQualType(c, scope, element_qt, source_loc),
});
},
.ExtInt, .ExtVector => {
.BitInt, .ExtVector => {
const type_name = c.str(ty.getTypeClassName());
return fail(c, error.UnsupportedType, source_loc, "TODO implement translation of type: '{s}'", .{type_name});
},
Expand Down
6 changes: 2 additions & 4 deletions src/zig_llvm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -980,10 +980,8 @@ void ZigLLVMAddByValAttr(LLVMValueRef fn_ref, unsigned ArgNo, LLVMTypeRef type_v

void ZigLLVMAddSretAttr(LLVMValueRef fn_ref, unsigned ArgNo, LLVMTypeRef type_val) {
Function *func = unwrap<Function>(fn_ref);
AttrBuilder attr_builder(func->getContext());
Type *llvm_type = unwrap<Type>(type_val);
attr_builder.addStructRetAttr(llvm_type);
func->addParamAttrs(ArgNo + 1, attr_builder);
func->addParamAttr(ArgNo, Attribute::getWithStructRetType(func->getContext(), llvm_type));
}

void ZigLLVMAddFunctionAttr(LLVMValueRef fn_ref, const char *attr_name, const char *attr_value) {
Expand Down Expand Up @@ -1088,7 +1086,7 @@ void ZigLLVMSetTailCall(LLVMValueRef Call) {
void ZigLLVMSetCallSret(LLVMValueRef Call, LLVMTypeRef return_type) {
CallInst *call_inst = unwrap<CallInst>(Call);
Type *llvm_type = unwrap<Type>(return_type);
call_inst->addParamAttr(1, Attribute::getWithStructRetType(call_inst->getContext(), llvm_type));
call_inst->addParamAttr(0, Attribute::getWithStructRetType(call_inst->getContext(), llvm_type));
}

void ZigLLVMFunctionSetPrefixData(LLVMValueRef function, LLVMValueRef data) {
Expand Down