Merge remote-tracking branch 'origin/master' into llvm14
This commit is contained in:
1908
src/codegen/c.zig
1908
src/codegen/c.zig
File diff suppressed because it is too large
Load Diff
6558
src/codegen/llvm.zig
6558
src/codegen/llvm.zig
File diff suppressed because it is too large
Load Diff
@@ -60,7 +60,7 @@ pub const Context = opaque {
|
||||
Packed: Bool,
|
||||
) *const Type;
|
||||
|
||||
const structCreateNamed = LLVMStructCreateNamed;
|
||||
pub const structCreateNamed = LLVMStructCreateNamed;
|
||||
extern fn LLVMStructCreateNamed(C: *const Context, Name: [*:0]const u8) *const Type;
|
||||
|
||||
pub const constString = LLVMConstStringInContext;
|
||||
@@ -117,9 +117,15 @@ pub const Value = opaque {
|
||||
pub const setLinkage = LLVMSetLinkage;
|
||||
extern fn LLVMSetLinkage(Global: *const Value, Linkage: Linkage) void;
|
||||
|
||||
pub const setVisibility = LLVMSetVisibility;
|
||||
extern fn LLVMSetVisibility(Global: *const Value, Linkage: Visibility) void;
|
||||
|
||||
pub const setUnnamedAddr = LLVMSetUnnamedAddr;
|
||||
extern fn LLVMSetUnnamedAddr(Global: *const Value, HasUnnamedAddr: Bool) void;
|
||||
|
||||
pub const setThreadLocalMode = LLVMSetThreadLocalMode;
|
||||
extern fn LLVMSetThreadLocalMode(Global: *const Value, Mode: ThreadLocalMode) void;
|
||||
|
||||
pub const deleteGlobal = LLVMDeleteGlobal;
|
||||
extern fn LLVMDeleteGlobal(GlobalVar: *const Value) void;
|
||||
|
||||
@@ -157,6 +163,9 @@ pub const Value = opaque {
|
||||
pub const constZExt = LLVMConstZExt;
|
||||
extern fn LLVMConstZExt(ConstantVal: *const Value, ToType: *const Type) *const Value;
|
||||
|
||||
pub const constZExtOrBitCast = LLVMConstZExtOrBitCast;
|
||||
extern fn LLVMConstZExtOrBitCast(ConstantVal: *const Value, ToType: *const Type) *const Value;
|
||||
|
||||
pub const constNot = LLVMConstNot;
|
||||
extern fn LLVMConstNot(ConstantVal: *const Value) *const Value;
|
||||
|
||||
@@ -178,12 +187,18 @@ pub const Value = opaque {
|
||||
pub const setFunctionCallConv = LLVMSetFunctionCallConv;
|
||||
extern fn LLVMSetFunctionCallConv(Fn: *const Value, CC: CallConv) void;
|
||||
|
||||
pub const fnSetSubprogram = ZigLLVMFnSetSubprogram;
|
||||
extern fn ZigLLVMFnSetSubprogram(f: *const Value, subprogram: *DISubprogram) void;
|
||||
|
||||
pub const setValueName = LLVMSetValueName;
|
||||
extern fn LLVMSetValueName(Val: *const Value, Name: [*:0]const u8) void;
|
||||
|
||||
pub const setValueName2 = LLVMSetValueName2;
|
||||
extern fn LLVMSetValueName2(Val: *const Value, Name: [*]const u8, NameLen: usize) void;
|
||||
|
||||
pub const getValueName = LLVMGetValueName;
|
||||
extern fn LLVMGetValueName(Val: *const Value) [*:0]const u8;
|
||||
|
||||
pub const takeName = ZigLLVMTakeName;
|
||||
extern fn ZigLLVMTakeName(new_owner: *const Value, victim: *const Value) void;
|
||||
|
||||
@@ -224,6 +239,9 @@ pub const Value = opaque {
|
||||
|
||||
pub const getAlignment = LLVMGetAlignment;
|
||||
extern fn LLVMGetAlignment(V: *const Value) c_uint;
|
||||
|
||||
pub const addFunctionAttr = ZigLLVMAddFunctionAttr;
|
||||
extern fn ZigLLVMAddFunctionAttr(Fn: *const Value, attr_name: [*:0]const u8, attr_value: [*:0]const u8) void;
|
||||
};
|
||||
|
||||
pub const Type = opaque {
|
||||
@@ -298,6 +316,15 @@ pub const Module = opaque {
|
||||
pub const setModuleDataLayout = LLVMSetModuleDataLayout;
|
||||
extern fn LLVMSetModuleDataLayout(*const Module, *const TargetData) void;
|
||||
|
||||
pub const setModulePICLevel = ZigLLVMSetModulePICLevel;
|
||||
extern fn ZigLLVMSetModulePICLevel(module: *const Module) void;
|
||||
|
||||
pub const setModulePIELevel = ZigLLVMSetModulePIELevel;
|
||||
extern fn ZigLLVMSetModulePIELevel(module: *const Module) void;
|
||||
|
||||
pub const setModuleCodeModel = ZigLLVMSetModuleCodeModel;
|
||||
extern fn ZigLLVMSetModuleCodeModel(module: *const Module, code_model: CodeModel) void;
|
||||
|
||||
pub const addFunction = LLVMAddFunction;
|
||||
extern fn LLVMAddFunction(*const Module, Name: [*:0]const u8, FunctionTy: *const Type) *const Value;
|
||||
|
||||
@@ -308,7 +335,7 @@ pub const Module = opaque {
|
||||
extern fn LLVMGetNamedFunction(*const Module, Name: [*:0]const u8) ?*const Value;
|
||||
|
||||
pub const getIntrinsicDeclaration = LLVMGetIntrinsicDeclaration;
|
||||
extern fn LLVMGetIntrinsicDeclaration(Mod: *const Module, ID: c_uint, ParamTypes: ?[*]*const Type, ParamCount: usize) *const Value;
|
||||
extern fn LLVMGetIntrinsicDeclaration(Mod: *const Module, ID: c_uint, ParamTypes: ?[*]const *const Type, ParamCount: usize) *const Value;
|
||||
|
||||
pub const printToString = LLVMPrintModuleToString;
|
||||
extern fn LLVMPrintModuleToString(*const Module) [*:0]const u8;
|
||||
@@ -349,6 +376,24 @@ pub const Module = opaque {
|
||||
Name: [*:0]const u8,
|
||||
NameLen: usize,
|
||||
) ?*const Value;
|
||||
|
||||
pub const setTarget = LLVMSetTarget;
|
||||
extern fn LLVMSetTarget(M: *const Module, Triple: [*:0]const u8) void;
|
||||
|
||||
pub const addModuleDebugInfoFlag = ZigLLVMAddModuleDebugInfoFlag;
|
||||
extern fn ZigLLVMAddModuleDebugInfoFlag(module: *const Module) void;
|
||||
|
||||
pub const addModuleCodeViewFlag = ZigLLVMAddModuleCodeViewFlag;
|
||||
extern fn ZigLLVMAddModuleCodeViewFlag(module: *const Module) void;
|
||||
|
||||
pub const createDIBuilder = ZigLLVMCreateDIBuilder;
|
||||
extern fn ZigLLVMCreateDIBuilder(module: *const Module, allow_unresolved: bool) *DIBuilder;
|
||||
|
||||
pub const setModuleInlineAsm2 = LLVMSetModuleInlineAsm2;
|
||||
extern fn LLVMSetModuleInlineAsm2(M: *const Module, Asm: [*]const u8, Len: usize) void;
|
||||
|
||||
pub const printModuleToFile = LLVMPrintModuleToFile;
|
||||
extern fn LLVMPrintModuleToFile(M: *const Module, Filename: [*:0]const u8, ErrorMessage: *[*:0]const u8) Bool;
|
||||
};
|
||||
|
||||
pub const lookupIntrinsicID = LLVMLookupIntrinsicID;
|
||||
@@ -425,6 +470,14 @@ pub const Builder = opaque {
|
||||
Name: [*:0]const u8,
|
||||
) *const Value;
|
||||
|
||||
pub const buildZExtOrBitCast = LLVMBuildZExtOrBitCast;
|
||||
extern fn LLVMBuildZExtOrBitCast(
|
||||
*const Builder,
|
||||
Val: *const Value,
|
||||
DestTy: *const Type,
|
||||
Name: [*:0]const u8,
|
||||
) *const Value;
|
||||
|
||||
pub const buildSExt = LLVMBuildSExt;
|
||||
extern fn LLVMBuildSExt(
|
||||
*const Builder,
|
||||
@@ -433,6 +486,14 @@ pub const Builder = opaque {
|
||||
Name: [*:0]const u8,
|
||||
) *const Value;
|
||||
|
||||
pub const buildSExtOrBitCast = LLVMBuildSExtOrBitCast;
|
||||
extern fn LLVMBuildSExtOrBitCast(
|
||||
*const Builder,
|
||||
Val: *const Value,
|
||||
DestTy: *const Type,
|
||||
Name: [*:0]const u8,
|
||||
) *const Value;
|
||||
|
||||
pub const buildCall = ZigLLVMBuildCall;
|
||||
extern fn ZigLLVMBuildCall(
|
||||
*const Builder,
|
||||
@@ -489,6 +550,9 @@ pub const Builder = opaque {
|
||||
pub const buildFSub = LLVMBuildFSub;
|
||||
extern fn LLVMBuildFSub(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
|
||||
|
||||
pub const buildFNeg = LLVMBuildFNeg;
|
||||
extern fn LLVMBuildFNeg(*const Builder, V: *const Value, Name: [*:0]const u8) *const Value;
|
||||
|
||||
pub const buildSub = LLVMBuildSub;
|
||||
extern fn LLVMBuildSub(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
|
||||
|
||||
@@ -644,6 +708,14 @@ pub const Builder = opaque {
|
||||
Name: [*:0]const u8,
|
||||
) *const Value;
|
||||
|
||||
pub const buildVectorSplat = LLVMBuildVectorSplat;
|
||||
extern fn LLVMBuildVectorSplat(
|
||||
*const Builder,
|
||||
ElementCount: c_uint,
|
||||
EltVal: *const Value,
|
||||
Name: [*:0]const u8,
|
||||
) *const Value;
|
||||
|
||||
pub const buildPtrToInt = LLVMBuildPtrToInt;
|
||||
extern fn LLVMBuildPtrToInt(
|
||||
*const Builder,
|
||||
@@ -816,8 +888,8 @@ pub const Builder = opaque {
|
||||
pub const buildExactSDiv = LLVMBuildExactSDiv;
|
||||
extern fn LLVMBuildExactSDiv(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
|
||||
|
||||
pub const zigSetCurrentDebugLocation = ZigLLVMSetCurrentDebugLocation;
|
||||
extern fn ZigLLVMSetCurrentDebugLocation(builder: *const Builder, line: c_int, column: c_int, scope: *DIScope) void;
|
||||
pub const setCurrentDebugLocation = ZigLLVMSetCurrentDebugLocation2;
|
||||
extern fn ZigLLVMSetCurrentDebugLocation2(builder: *const Builder, line: c_uint, column: c_uint, scope: *DIScope, inlined_at: ?*DILocation) void;
|
||||
|
||||
pub const clearCurrentDebugLocation = ZigLLVMClearCurrentDebugLocation;
|
||||
extern fn ZigLLVMClearCurrentDebugLocation(builder: *const Builder) void;
|
||||
@@ -830,9 +902,52 @@ pub const Builder = opaque {
|
||||
|
||||
pub const buildShuffleVector = LLVMBuildShuffleVector;
|
||||
extern fn LLVMBuildShuffleVector(*const Builder, V1: *const Value, V2: *const Value, Mask: *const Value, Name: [*:0]const u8) *const Value;
|
||||
|
||||
pub const buildAndReduce = ZigLLVMBuildAndReduce;
|
||||
extern fn ZigLLVMBuildAndReduce(B: *const Builder, Val: *const Value) *const Value;
|
||||
|
||||
pub const buildOrReduce = ZigLLVMBuildOrReduce;
|
||||
extern fn ZigLLVMBuildOrReduce(B: *const Builder, Val: *const Value) *const Value;
|
||||
|
||||
pub const buildXorReduce = ZigLLVMBuildXorReduce;
|
||||
extern fn ZigLLVMBuildXorReduce(B: *const Builder, Val: *const Value) *const Value;
|
||||
|
||||
pub const buildIntMaxReduce = ZigLLVMBuildIntMaxReduce;
|
||||
extern fn ZigLLVMBuildIntMaxReduce(B: *const Builder, Val: *const Value, is_signed: bool) *const Value;
|
||||
|
||||
pub const buildIntMinReduce = ZigLLVMBuildIntMinReduce;
|
||||
extern fn ZigLLVMBuildIntMinReduce(B: *const Builder, Val: *const Value, is_signed: bool) *const Value;
|
||||
|
||||
pub const buildFPMaxReduce = ZigLLVMBuildFPMaxReduce;
|
||||
extern fn ZigLLVMBuildFPMaxReduce(B: *const Builder, Val: *const Value) *const Value;
|
||||
|
||||
pub const buildFPMinReduce = ZigLLVMBuildFPMinReduce;
|
||||
extern fn ZigLLVMBuildFPMinReduce(B: *const Builder, Val: *const Value) *const Value;
|
||||
|
||||
pub const buildAddReduce = ZigLLVMBuildAddReduce;
|
||||
extern fn ZigLLVMBuildAddReduce(B: *const Builder, Val: *const Value) *const Value;
|
||||
|
||||
pub const buildMulReduce = ZigLLVMBuildMulReduce;
|
||||
extern fn ZigLLVMBuildMulReduce(B: *const Builder, Val: *const Value) *const Value;
|
||||
|
||||
pub const buildFPAddReduce = ZigLLVMBuildFPAddReduce;
|
||||
extern fn ZigLLVMBuildFPAddReduce(B: *const Builder, Acc: *const Value, Val: *const Value) *const Value;
|
||||
|
||||
pub const buildFPMulReduce = ZigLLVMBuildFPMulReduce;
|
||||
extern fn ZigLLVMBuildFPMulReduce(B: *const Builder, Acc: *const Value, Val: *const Value) *const Value;
|
||||
};
|
||||
|
||||
pub const DIScope = opaque {};
|
||||
pub const MDString = opaque {
|
||||
pub const get = LLVMMDStringInContext2;
|
||||
extern fn LLVMMDStringInContext2(C: *const Context, Str: [*]const u8, SLen: usize) *MDString;
|
||||
};
|
||||
|
||||
pub const DIScope = opaque {
|
||||
pub const toNode = ZigLLVMScopeToNode;
|
||||
extern fn ZigLLVMScopeToNode(scope: *DIScope) *DINode;
|
||||
};
|
||||
|
||||
pub const DINode = opaque {};
|
||||
pub const Metadata = opaque {};
|
||||
|
||||
pub const IntPredicate = enum(c_uint) {
|
||||
@@ -914,6 +1029,9 @@ pub const TargetMachine = opaque {
|
||||
pub const TargetData = opaque {
|
||||
pub const dispose = LLVMDisposeTargetData;
|
||||
extern fn LLVMDisposeTargetData(*const TargetData) void;
|
||||
|
||||
pub const abiAlignmentOfType = LLVMABIAlignmentOfType;
|
||||
extern fn LLVMABIAlignmentOfType(TD: *const TargetData, Ty: *const Type) c_uint;
|
||||
};
|
||||
|
||||
pub const CodeModel = enum(c_int) {
|
||||
@@ -1198,7 +1316,7 @@ pub const WriteImportLibrary = ZigLLVMWriteImportLibrary;
|
||||
extern fn ZigLLVMWriteImportLibrary(
|
||||
def_path: [*:0]const u8,
|
||||
arch: ArchType,
|
||||
output_lib_path: [*c]const u8,
|
||||
output_lib_path: [*:0]const u8,
|
||||
kill_at: bool,
|
||||
) bool;
|
||||
|
||||
@@ -1222,6 +1340,20 @@ pub const Linkage = enum(c_uint) {
|
||||
LinkerPrivateWeak,
|
||||
};
|
||||
|
||||
pub const Visibility = enum(c_uint) {
|
||||
Default,
|
||||
Hidden,
|
||||
Protected,
|
||||
};
|
||||
|
||||
pub const ThreadLocalMode = enum(c_uint) {
|
||||
NotThreadLocal,
|
||||
GeneralDynamicTLSModel,
|
||||
LocalDynamicTLSModel,
|
||||
InitialExecTLSModel,
|
||||
LocalExecTLSModel,
|
||||
};
|
||||
|
||||
pub const AtomicOrdering = enum(c_uint) {
|
||||
NotAtomic = 0,
|
||||
Unordered = 1,
|
||||
@@ -1387,3 +1519,357 @@ pub const address_space = struct {
|
||||
pub const constant_buffer_15: c_uint = 23;
|
||||
};
|
||||
};
|
||||
|
||||
pub const DIEnumerator = opaque {};
|
||||
pub const DILocalVariable = opaque {};
|
||||
pub const DILocation = opaque {};
|
||||
|
||||
pub const DIGlobalVariable = opaque {
|
||||
pub const toNode = ZigLLVMGlobalVariableToNode;
|
||||
extern fn ZigLLVMGlobalVariableToNode(global_variable: *DIGlobalVariable) *DINode;
|
||||
|
||||
pub const replaceLinkageName = ZigLLVMGlobalVariableReplaceLinkageName;
|
||||
extern fn ZigLLVMGlobalVariableReplaceLinkageName(global_variable: *DIGlobalVariable, linkage_name: *MDString) void;
|
||||
};
|
||||
pub const DIType = opaque {
|
||||
pub const toScope = ZigLLVMTypeToScope;
|
||||
extern fn ZigLLVMTypeToScope(ty: *DIType) *DIScope;
|
||||
|
||||
pub const toNode = ZigLLVMTypeToNode;
|
||||
extern fn ZigLLVMTypeToNode(ty: *DIType) *DINode;
|
||||
};
|
||||
pub const DIFile = opaque {
|
||||
pub const toScope = ZigLLVMFileToScope;
|
||||
extern fn ZigLLVMFileToScope(difile: *DIFile) *DIScope;
|
||||
|
||||
pub const toNode = ZigLLVMFileToNode;
|
||||
extern fn ZigLLVMFileToNode(difile: *DIFile) *DINode;
|
||||
};
|
||||
pub const DILexicalBlock = opaque {
|
||||
pub const toScope = ZigLLVMLexicalBlockToScope;
|
||||
extern fn ZigLLVMLexicalBlockToScope(lexical_block: *DILexicalBlock) *DIScope;
|
||||
|
||||
pub const toNode = ZigLLVMLexicalBlockToNode;
|
||||
extern fn ZigLLVMLexicalBlockToNode(lexical_block: *DILexicalBlock) *DINode;
|
||||
};
|
||||
pub const DICompileUnit = opaque {
|
||||
pub const toScope = ZigLLVMCompileUnitToScope;
|
||||
extern fn ZigLLVMCompileUnitToScope(compile_unit: *DICompileUnit) *DIScope;
|
||||
|
||||
pub const toNode = ZigLLVMCompileUnitToNode;
|
||||
extern fn ZigLLVMCompileUnitToNode(compile_unit: *DICompileUnit) *DINode;
|
||||
};
|
||||
pub const DISubprogram = opaque {
|
||||
pub const toScope = ZigLLVMSubprogramToScope;
|
||||
extern fn ZigLLVMSubprogramToScope(subprogram: *DISubprogram) *DIScope;
|
||||
|
||||
pub const toNode = ZigLLVMSubprogramToNode;
|
||||
extern fn ZigLLVMSubprogramToNode(subprogram: *DISubprogram) *DINode;
|
||||
|
||||
pub const replaceLinkageName = ZigLLVMSubprogramReplaceLinkageName;
|
||||
extern fn ZigLLVMSubprogramReplaceLinkageName(subprogram: *DISubprogram, linkage_name: *MDString) void;
|
||||
};
|
||||
|
||||
pub const getDebugLoc = ZigLLVMGetDebugLoc2;
|
||||
extern fn ZigLLVMGetDebugLoc2(line: c_uint, col: c_uint, scope: *DIScope, inlined_at: ?*DILocation) *DILocation;
|
||||
|
||||
pub const DIBuilder = opaque {
|
||||
pub const dispose = ZigLLVMDisposeDIBuilder;
|
||||
extern fn ZigLLVMDisposeDIBuilder(dib: *DIBuilder) void;
|
||||
|
||||
pub const finalize = ZigLLVMDIBuilderFinalize;
|
||||
extern fn ZigLLVMDIBuilderFinalize(dib: *DIBuilder) void;
|
||||
|
||||
pub const createPointerType = ZigLLVMCreateDebugPointerType;
|
||||
extern fn ZigLLVMCreateDebugPointerType(
|
||||
dib: *DIBuilder,
|
||||
pointee_type: *DIType,
|
||||
size_in_bits: u64,
|
||||
align_in_bits: u64,
|
||||
name: [*:0]const u8,
|
||||
) *DIType;
|
||||
|
||||
pub const createBasicType = ZigLLVMCreateDebugBasicType;
|
||||
extern fn ZigLLVMCreateDebugBasicType(
|
||||
dib: *DIBuilder,
|
||||
name: [*:0]const u8,
|
||||
size_in_bits: u64,
|
||||
encoding: c_uint,
|
||||
) *DIType;
|
||||
|
||||
pub const createArrayType = ZigLLVMCreateDebugArrayType;
|
||||
extern fn ZigLLVMCreateDebugArrayType(
|
||||
dib: *DIBuilder,
|
||||
size_in_bits: u64,
|
||||
align_in_bits: u64,
|
||||
elem_type: *DIType,
|
||||
elem_count: c_int,
|
||||
) *DIType;
|
||||
|
||||
pub const createEnumerator = ZigLLVMCreateDebugEnumerator;
|
||||
extern fn ZigLLVMCreateDebugEnumerator(
|
||||
dib: *DIBuilder,
|
||||
name: [*:0]const u8,
|
||||
val: i64,
|
||||
) *DIEnumerator;
|
||||
|
||||
pub const createEnumerationType = ZigLLVMCreateDebugEnumerationType;
|
||||
extern fn ZigLLVMCreateDebugEnumerationType(
|
||||
dib: *DIBuilder,
|
||||
scope: *DIScope,
|
||||
name: [*:0]const u8,
|
||||
file: *DIFile,
|
||||
line_number: c_uint,
|
||||
size_in_bits: u64,
|
||||
align_in_bits: u64,
|
||||
enumerator_array: [*]const *DIEnumerator,
|
||||
enumerator_array_len: c_int,
|
||||
underlying_type: *DIType,
|
||||
unique_id: [*:0]const u8,
|
||||
) *DIType;
|
||||
|
||||
pub const createStructType = ZigLLVMCreateDebugStructType;
|
||||
extern fn ZigLLVMCreateDebugStructType(
|
||||
dib: *DIBuilder,
|
||||
scope: *DIScope,
|
||||
name: [*:0]const u8,
|
||||
file: ?*DIFile,
|
||||
line_number: c_uint,
|
||||
size_in_bits: u64,
|
||||
align_in_bits: u64,
|
||||
flags: c_uint,
|
||||
derived_from: ?*DIType,
|
||||
types_array: [*]const *DIType,
|
||||
types_array_len: c_int,
|
||||
run_time_lang: c_uint,
|
||||
vtable_holder: ?*DIType,
|
||||
unique_id: [*:0]const u8,
|
||||
) *DIType;
|
||||
|
||||
pub const createUnionType = ZigLLVMCreateDebugUnionType;
|
||||
extern fn ZigLLVMCreateDebugUnionType(
|
||||
dib: *DIBuilder,
|
||||
scope: *DIScope,
|
||||
name: [*:0]const u8,
|
||||
file: ?*DIFile,
|
||||
line_number: c_uint,
|
||||
size_in_bits: u64,
|
||||
align_in_bits: u64,
|
||||
flags: c_uint,
|
||||
types_array: [*]const *DIType,
|
||||
types_array_len: c_int,
|
||||
run_time_lang: c_uint,
|
||||
unique_id: [*:0]const u8,
|
||||
) *DIType;
|
||||
|
||||
pub const createMemberType = ZigLLVMCreateDebugMemberType;
|
||||
extern fn ZigLLVMCreateDebugMemberType(
|
||||
dib: *DIBuilder,
|
||||
scope: *DIScope,
|
||||
name: [*:0]const u8,
|
||||
file: ?*DIFile,
|
||||
line: c_uint,
|
||||
size_in_bits: u64,
|
||||
align_in_bits: u64,
|
||||
offset_in_bits: u64,
|
||||
flags: c_uint,
|
||||
ty: *DIType,
|
||||
) *DIType;
|
||||
|
||||
pub const createReplaceableCompositeType = ZigLLVMCreateReplaceableCompositeType;
|
||||
extern fn ZigLLVMCreateReplaceableCompositeType(
|
||||
dib: *DIBuilder,
|
||||
tag: c_uint,
|
||||
name: [*:0]const u8,
|
||||
scope: *DIScope,
|
||||
file: ?*DIFile,
|
||||
line: c_uint,
|
||||
) *DIType;
|
||||
|
||||
pub const createForwardDeclType = ZigLLVMCreateDebugForwardDeclType;
|
||||
extern fn ZigLLVMCreateDebugForwardDeclType(
|
||||
dib: *DIBuilder,
|
||||
tag: c_uint,
|
||||
name: [*:0]const u8,
|
||||
scope: *DIScope,
|
||||
file: *DIFile,
|
||||
line: c_uint,
|
||||
) *DIType;
|
||||
|
||||
pub const replaceTemporary = ZigLLVMReplaceTemporary;
|
||||
extern fn ZigLLVMReplaceTemporary(dib: *DIBuilder, ty: *DIType, replacement: *DIType) void;
|
||||
|
||||
pub const replaceDebugArrays = ZigLLVMReplaceDebugArrays;
|
||||
extern fn ZigLLVMReplaceDebugArrays(
|
||||
dib: *DIBuilder,
|
||||
ty: *DIType,
|
||||
types_array: [*]const *DIType,
|
||||
types_array_len: c_int,
|
||||
) void;
|
||||
|
||||
pub const createSubroutineType = ZigLLVMCreateSubroutineType;
|
||||
extern fn ZigLLVMCreateSubroutineType(
|
||||
dib: *DIBuilder,
|
||||
types_array: [*]const *DIType,
|
||||
types_array_len: c_int,
|
||||
flags: c_uint,
|
||||
) *DIType;
|
||||
|
||||
pub const createAutoVariable = ZigLLVMCreateAutoVariable;
|
||||
extern fn ZigLLVMCreateAutoVariable(
|
||||
dib: *DIBuilder,
|
||||
scope: *DIScope,
|
||||
name: [*:0]const u8,
|
||||
file: *DIFile,
|
||||
line_no: c_uint,
|
||||
ty: *DIType,
|
||||
always_preserve: bool,
|
||||
flags: c_uint,
|
||||
) *DILocalVariable;
|
||||
|
||||
pub const createGlobalVariable = ZigLLVMCreateGlobalVariable;
|
||||
extern fn ZigLLVMCreateGlobalVariable(
|
||||
dib: *DIBuilder,
|
||||
scope: *DIScope,
|
||||
name: [*:0]const u8,
|
||||
linkage_name: [*:0]const u8,
|
||||
file: *DIFile,
|
||||
line_no: c_uint,
|
||||
di_type: *DIType,
|
||||
is_local_to_unit: bool,
|
||||
) *DIGlobalVariable;
|
||||
|
||||
pub const createParameterVariable = ZigLLVMCreateParameterVariable;
|
||||
extern fn ZigLLVMCreateParameterVariable(
|
||||
dib: *DIBuilder,
|
||||
scope: *DIScope,
|
||||
name: [*:0]const u8,
|
||||
file: *DIFile,
|
||||
line_no: c_uint,
|
||||
ty: *DIType,
|
||||
always_preserve: bool,
|
||||
flags: c_uint,
|
||||
arg_no: c_uint,
|
||||
) *DILocalVariable;
|
||||
|
||||
pub const createLexicalBlock = ZigLLVMCreateLexicalBlock;
|
||||
extern fn ZigLLVMCreateLexicalBlock(
|
||||
dib: *DIBuilder,
|
||||
scope: *DIScope,
|
||||
file: *DIFile,
|
||||
line: c_uint,
|
||||
col: c_uint,
|
||||
) *DILexicalBlock;
|
||||
|
||||
pub const createCompileUnit = ZigLLVMCreateCompileUnit;
|
||||
extern fn ZigLLVMCreateCompileUnit(
|
||||
dib: *DIBuilder,
|
||||
lang: c_uint,
|
||||
difile: *DIFile,
|
||||
producer: [*:0]const u8,
|
||||
is_optimized: bool,
|
||||
flags: [*:0]const u8,
|
||||
runtime_version: c_uint,
|
||||
split_name: [*:0]const u8,
|
||||
dwo_id: u64,
|
||||
emit_debug_info: bool,
|
||||
) *DICompileUnit;
|
||||
|
||||
pub const createFile = ZigLLVMCreateFile;
|
||||
extern fn ZigLLVMCreateFile(
|
||||
dib: *DIBuilder,
|
||||
filename: [*:0]const u8,
|
||||
directory: [*:0]const u8,
|
||||
) *DIFile;
|
||||
|
||||
pub const createFunction = ZigLLVMCreateFunction;
|
||||
extern fn ZigLLVMCreateFunction(
|
||||
dib: *DIBuilder,
|
||||
scope: *DIScope,
|
||||
name: [*:0]const u8,
|
||||
linkage_name: [*:0]const u8,
|
||||
file: *DIFile,
|
||||
lineno: c_uint,
|
||||
fn_di_type: *DIType,
|
||||
is_local_to_unit: bool,
|
||||
is_definition: bool,
|
||||
scope_line: c_uint,
|
||||
flags: c_uint,
|
||||
is_optimized: bool,
|
||||
decl_subprogram: ?*DISubprogram,
|
||||
) *DISubprogram;
|
||||
|
||||
pub const createVectorType = ZigLLVMDIBuilderCreateVectorType;
|
||||
extern fn ZigLLVMDIBuilderCreateVectorType(
|
||||
dib: *DIBuilder,
|
||||
SizeInBits: u64,
|
||||
AlignInBits: u32,
|
||||
Ty: *DIType,
|
||||
elem_count: u32,
|
||||
) *DIType;
|
||||
|
||||
pub const insertDeclareAtEnd = ZigLLVMInsertDeclareAtEnd;
|
||||
extern fn ZigLLVMInsertDeclareAtEnd(
|
||||
dib: *DIBuilder,
|
||||
storage: *const Value,
|
||||
var_info: *DILocalVariable,
|
||||
debug_loc: *DILocation,
|
||||
basic_block_ref: *const BasicBlock,
|
||||
) *const Value;
|
||||
|
||||
pub const insertDeclare = ZigLLVMInsertDeclare;
|
||||
extern fn ZigLLVMInsertDeclare(
|
||||
dib: *DIBuilder,
|
||||
storage: *const Value,
|
||||
var_info: *DILocalVariable,
|
||||
debug_loc: *DILocation,
|
||||
insert_before_instr: *const Value,
|
||||
) *const Value;
|
||||
|
||||
pub const insertDbgValueIntrinsicAtEnd = ZigLLVMInsertDbgValueIntrinsicAtEnd;
|
||||
extern fn ZigLLVMInsertDbgValueIntrinsicAtEnd(
|
||||
dib: *DIBuilder,
|
||||
val: *const Value,
|
||||
var_info: *DILocalVariable,
|
||||
debug_loc: *DILocation,
|
||||
basic_block_ref: *const BasicBlock,
|
||||
) *const Value;
|
||||
};
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
@@ -184,7 +184,7 @@ pub const DeclGen = struct {
|
||||
|
||||
fn fail(self: *DeclGen, comptime format: []const u8, args: anytype) Error {
|
||||
@setCold(true);
|
||||
const src: LazySrcLoc = .{ .node_offset = 0 };
|
||||
const src = LazySrcLoc.nodeOffset(0);
|
||||
const src_loc = src.toSrcLoc(self.decl);
|
||||
assert(self.error_msg == null);
|
||||
self.error_msg = try Module.ErrorMsg.create(self.module.gpa, src_loc, format, args);
|
||||
@@ -193,7 +193,7 @@ pub const DeclGen = struct {
|
||||
|
||||
fn todo(self: *DeclGen, comptime format: []const u8, args: anytype) Error {
|
||||
@setCold(true);
|
||||
const src: LazySrcLoc = .{ .node_offset = 0 };
|
||||
const src = LazySrcLoc.nodeOffset(0);
|
||||
const src_loc = src.toSrcLoc(self.decl);
|
||||
assert(self.error_msg == null);
|
||||
self.error_msg = try Module.ErrorMsg.create(self.module.gpa, src_loc, "TODO (SPIR-V): " ++ format, args);
|
||||
@@ -313,7 +313,7 @@ pub const DeclGen = struct {
|
||||
// As of yet, there is no vector support in the self-hosted compiler.
|
||||
.Vector => self.todo("implement arithmeticTypeInfo for Vector", .{}),
|
||||
// TODO: For which types is this the case?
|
||||
else => self.todo("implement arithmeticTypeInfo for {}", .{ty}),
|
||||
else => self.todo("implement arithmeticTypeInfo for {}", .{ty.fmtDebug()}),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -335,17 +335,17 @@ pub const DeclGen = struct {
|
||||
const int_info = ty.intInfo(target);
|
||||
const backing_bits = self.backingIntBits(int_info.bits) orelse {
|
||||
// Integers too big for any native type are represented as "composite integers": An array of largestSupportedIntBits.
|
||||
return self.todo("implement composite int constants for {}", .{ty});
|
||||
return self.todo("implement composite int constants for {}", .{ty.fmtDebug()});
|
||||
};
|
||||
|
||||
// We can just use toSignedInt/toUnsignedInt here as it returns u64 - a type large enough to hold any
|
||||
// SPIR-V native type (up to i/u64 with Int64). If SPIR-V ever supports native ints of a larger size, this
|
||||
// might need to be updated.
|
||||
assert(self.largestSupportedIntBits() <= std.meta.bitCount(u64));
|
||||
assert(self.largestSupportedIntBits() <= @bitSizeOf(u64));
|
||||
|
||||
// Note, value is required to be sign-extended, so we don't need to mask off the upper bits.
|
||||
// See https://www.khronos.org/registry/SPIR-V/specs/unified1/SPIRV.html#Literal
|
||||
var int_bits = if (ty.isSignedInt()) @bitCast(u64, val.toSignedInt()) else val.toUnsignedInt();
|
||||
var int_bits = if (ty.isSignedInt()) @bitCast(u64, val.toSignedInt()) else val.toUnsignedInt(target);
|
||||
|
||||
const value: spec.LiteralContextDependentNumber = switch (backing_bits) {
|
||||
1...32 => .{ .uint32 = @truncate(u32, int_bits) },
|
||||
@@ -388,7 +388,7 @@ pub const DeclGen = struct {
|
||||
});
|
||||
},
|
||||
.Void => unreachable,
|
||||
else => return self.todo("constant generation of type {}", .{ty}),
|
||||
else => return self.todo("constant generation of type {}", .{ty.fmtDebug()}),
|
||||
}
|
||||
|
||||
return result_id.toRef();
|
||||
@@ -414,7 +414,7 @@ pub const DeclGen = struct {
|
||||
const backing_bits = self.backingIntBits(int_info.bits) orelse {
|
||||
// TODO: Integers too big for any native type are represented as "composite integers":
|
||||
// An array of largestSupportedIntBits.
|
||||
return self.todo("Implement composite int type {}", .{ty});
|
||||
return self.todo("Implement composite int type {}", .{ty.fmtDebug()});
|
||||
};
|
||||
|
||||
const payload = try self.spv.arena.create(SpvType.Payload.Int);
|
||||
@@ -633,7 +633,13 @@ pub const DeclGen = struct {
|
||||
return result_id.toRef();
|
||||
}
|
||||
|
||||
fn airArithOp(self: *DeclGen, inst: Air.Inst.Index, comptime fop: Opcode, comptime sop: Opcode, comptime uop: Opcode) !IdRef {
|
||||
fn airArithOp(
|
||||
self: *DeclGen,
|
||||
inst: Air.Inst.Index,
|
||||
comptime fop: Opcode,
|
||||
comptime sop: Opcode,
|
||||
comptime uop: Opcode,
|
||||
) !IdRef {
|
||||
// LHS and RHS are guaranteed to have the same type, and AIR guarantees
|
||||
// the result to be the same as the LHS and RHS, which matches SPIR-V.
|
||||
const ty = self.air.typeOfIndex(inst);
|
||||
@@ -644,8 +650,8 @@ pub const DeclGen = struct {
|
||||
const result_id = self.spv.allocId();
|
||||
const result_type_id = try self.resolveTypeId(ty);
|
||||
|
||||
assert(self.air.typeOf(bin_op.lhs).eql(ty));
|
||||
assert(self.air.typeOf(bin_op.rhs).eql(ty));
|
||||
assert(self.air.typeOf(bin_op.lhs).eql(ty, self.module));
|
||||
assert(self.air.typeOf(bin_op.rhs).eql(ty, self.module));
|
||||
|
||||
// Binary operations are generally applicable to both scalar and vector operations
|
||||
// in SPIR-V, but int and float versions of operations require different opcodes.
|
||||
@@ -692,7 +698,7 @@ pub const DeclGen = struct {
|
||||
const result_id = self.spv.allocId();
|
||||
const result_type_id = try self.resolveTypeId(Type.initTag(.bool));
|
||||
const op_ty = self.air.typeOf(bin_op.lhs);
|
||||
assert(op_ty.eql(self.air.typeOf(bin_op.rhs)));
|
||||
assert(op_ty.eql(self.air.typeOf(bin_op.rhs), self.module));
|
||||
|
||||
// Comparisons are generally applicable to both scalar and vector operations in SPIR-V,
|
||||
// but int and float versions of operations require different opcodes.
|
||||
|
||||
@@ -170,7 +170,7 @@ fn writeString(section: *Section, str: []const u8) void {
|
||||
|
||||
var j: usize = 0;
|
||||
while (j < @sizeOf(Word) and i + j < str.len) : (j += 1) {
|
||||
word |= @as(Word, str[i + j]) << @intCast(Log2Word, j * std.meta.bitCount(u8));
|
||||
word |= @as(Word, str[i + j]) << @intCast(Log2Word, j * @bitSizeOf(u8));
|
||||
}
|
||||
|
||||
section.instructions.appendAssumeCapacity(word);
|
||||
|
||||
@@ -1206,7 +1206,7 @@ pub const Opcode = enum(u16) {
|
||||
}
|
||||
};
|
||||
pub const ImageOperands = packed struct {
|
||||
Bias: bool align(@alignOf(u32)) = false,
|
||||
Bias: bool = false,
|
||||
Lod: bool = false,
|
||||
Grad: bool = false,
|
||||
ConstOffset: bool = false,
|
||||
@@ -1280,7 +1280,7 @@ pub const ImageOperands = packed struct {
|
||||
};
|
||||
};
|
||||
pub const FPFastMathMode = packed struct {
|
||||
NotNaN: bool align(@alignOf(u32)) = false,
|
||||
NotNaN: bool = false,
|
||||
NotInf: bool = false,
|
||||
NSZ: bool = false,
|
||||
AllowRecip: bool = false,
|
||||
@@ -1314,7 +1314,7 @@ pub const FPFastMathMode = packed struct {
|
||||
_reserved_bit_31: bool = false,
|
||||
};
|
||||
pub const SelectionControl = packed struct {
|
||||
Flatten: bool align(@alignOf(u32)) = false,
|
||||
Flatten: bool = false,
|
||||
DontFlatten: bool = false,
|
||||
_reserved_bit_2: bool = false,
|
||||
_reserved_bit_3: bool = false,
|
||||
@@ -1348,7 +1348,7 @@ pub const SelectionControl = packed struct {
|
||||
_reserved_bit_31: bool = false,
|
||||
};
|
||||
pub const LoopControl = packed struct {
|
||||
Unroll: bool align(@alignOf(u32)) = false,
|
||||
Unroll: bool = false,
|
||||
DontUnroll: bool = false,
|
||||
DependencyInfinite: bool = false,
|
||||
DependencyLength: bool = false,
|
||||
@@ -1417,7 +1417,7 @@ pub const LoopControl = packed struct {
|
||||
};
|
||||
};
|
||||
pub const FunctionControl = packed struct {
|
||||
Inline: bool align(@alignOf(u32)) = false,
|
||||
Inline: bool = false,
|
||||
DontInline: bool = false,
|
||||
Pure: bool = false,
|
||||
Const: bool = false,
|
||||
@@ -1451,7 +1451,7 @@ pub const FunctionControl = packed struct {
|
||||
_reserved_bit_31: bool = false,
|
||||
};
|
||||
pub const MemorySemantics = packed struct {
|
||||
_reserved_bit_0: bool align(@alignOf(u32)) = false,
|
||||
_reserved_bit_0: bool = false,
|
||||
Acquire: bool = false,
|
||||
Release: bool = false,
|
||||
AcquireRelease: bool = false,
|
||||
@@ -1489,7 +1489,7 @@ pub const MemorySemantics = packed struct {
|
||||
pub const MakeVisibleKHR: MemorySemantics = .{ .MakeVisible = true };
|
||||
};
|
||||
pub const MemoryAccess = packed struct {
|
||||
Volatile: bool align(@alignOf(u32)) = false,
|
||||
Volatile: bool = false,
|
||||
Aligned: bool = false,
|
||||
Nontemporal: bool = false,
|
||||
MakePointerAvailable: bool = false,
|
||||
@@ -1562,7 +1562,7 @@ pub const MemoryAccess = packed struct {
|
||||
};
|
||||
};
|
||||
pub const KernelProfilingInfo = packed struct {
|
||||
CmdExecTime: bool align(@alignOf(u32)) = false,
|
||||
CmdExecTime: bool = false,
|
||||
_reserved_bit_1: bool = false,
|
||||
_reserved_bit_2: bool = false,
|
||||
_reserved_bit_3: bool = false,
|
||||
@@ -1596,7 +1596,7 @@ pub const KernelProfilingInfo = packed struct {
|
||||
_reserved_bit_31: bool = false,
|
||||
};
|
||||
pub const RayFlags = packed struct {
|
||||
OpaqueKHR: bool align(@alignOf(u32)) = false,
|
||||
OpaqueKHR: bool = false,
|
||||
NoOpaqueKHR: bool = false,
|
||||
TerminateOnFirstHitKHR: bool = false,
|
||||
SkipClosestHitShaderKHR: bool = false,
|
||||
@@ -1630,7 +1630,7 @@ pub const RayFlags = packed struct {
|
||||
_reserved_bit_31: bool = false,
|
||||
};
|
||||
pub const FragmentShadingRate = packed struct {
|
||||
Vertical2Pixels: bool align(@alignOf(u32)) = false,
|
||||
Vertical2Pixels: bool = false,
|
||||
Vertical4Pixels: bool = false,
|
||||
Horizontal2Pixels: bool = false,
|
||||
Horizontal4Pixels: bool = false,
|
||||
|
||||
Reference in New Issue
Block a user