Pass 'global'
All checks were successful
CI / ci (Release, ubuntu-latest) (pull_request) Successful in 1m11s
CI / ci (MinSizeRel, ubuntu-latest) (pull_request) Successful in 1m16s
CI / ci (RelWithDebInfo, ubuntu-latest) (pull_request) Successful in 1m14s
CI / ci (Debug, ubuntu-latest) (pull_request) Successful in 6m26s
CI / ci (Release, ubuntu-latest) (push) Successful in 1m15s
CI / ci (MinSizeRel, ubuntu-latest) (push) Successful in 1m20s
CI / ci (RelWithDebInfo, ubuntu-latest) (push) Successful in 1m19s
CI / ci (Debug, ubuntu-latest) (push) Successful in 6m29s
All checks were successful
CI / ci (Release, ubuntu-latest) (pull_request) Successful in 1m11s
CI / ci (MinSizeRel, ubuntu-latest) (pull_request) Successful in 1m16s
CI / ci (RelWithDebInfo, ubuntu-latest) (pull_request) Successful in 1m14s
CI / ci (Debug, ubuntu-latest) (pull_request) Successful in 6m26s
CI / ci (Release, ubuntu-latest) (push) Successful in 1m15s
CI / ci (MinSizeRel, ubuntu-latest) (push) Successful in 1m20s
CI / ci (RelWithDebInfo, ubuntu-latest) (push) Successful in 1m19s
CI / ci (Debug, ubuntu-latest) (push) Successful in 6m29s
This commit is contained in:
parent
7f5d0834ae
commit
101a3332cd
@ -2326,6 +2326,9 @@ LLVMICmpPredicate = enum u32
|
|||||||
[extern] LLVMDIBuilderCreateFunction = fn [cc(c)] (di_builder: &LLVMDIBuilder, scope: &LLVMMetadata, name_pointer: &u8, name_length: u64, linkage_name_pointer: &u8, linkage_name_length: u64, file: &LLVMMetadata, line: u32, type: &LLVMMetadata, is_local_to_unit: s32, is_definition: s32, scope_line: u32, flags: LLVMDIFlags, is_optimized: s32) &LLVMMetadata;
|
[extern] LLVMDIBuilderCreateFunction = fn [cc(c)] (di_builder: &LLVMDIBuilder, scope: &LLVMMetadata, name_pointer: &u8, name_length: u64, linkage_name_pointer: &u8, linkage_name_length: u64, file: &LLVMMetadata, line: u32, type: &LLVMMetadata, is_local_to_unit: s32, is_definition: s32, scope_line: u32, flags: LLVMDIFlags, is_optimized: s32) &LLVMMetadata;
|
||||||
[extern] LLVMDIBuilderFinalizeSubprogram = fn [cc(c)] (di_builder: &LLVMDIBuilder, subprogram: &LLVMMetadata) void;
|
[extern] LLVMDIBuilderFinalizeSubprogram = fn [cc(c)] (di_builder: &LLVMDIBuilder, subprogram: &LLVMMetadata) void;
|
||||||
|
|
||||||
|
[extern] LLVMDIBuilderCreateGlobalVariableExpression = fn [cc(c)] (di_builder: &LLVMDIBuilder, scope: &LLVMMetadata, name_pointer: &u8, name_length: u64, linkage_name_pointer: &u8, linkage_name_length: u64, file: &LLVMMetadata, line: u32, type: &LLVMMetadata, local_to_unit: s32, expression: &LLVMMetadata, declaration: &LLVMMetadata, bit_alignment: u32) &LLVMMetadata;
|
||||||
|
[extern] LLVMGlobalSetMetadata = fn [cc(c)] (global: &LLVMValue, kind: u32, metadata: &LLVMMetadata) void;
|
||||||
|
|
||||||
[extern] LLVMDIBuilderCreateLexicalBlock = fn [cc(c)] (di_builder: &LLVMDIBuilder, scope: &LLVMMetadata, file: &LLVMMetadata, line: u32, column: u32) &LLVMMetadata;
|
[extern] LLVMDIBuilderCreateLexicalBlock = fn [cc(c)] (di_builder: &LLVMDIBuilder, scope: &LLVMMetadata, file: &LLVMMetadata, line: u32, column: u32) &LLVMMetadata;
|
||||||
[extern] LLVMDIBuilderCreateDebugLocation = fn [cc(c)] (context: &LLVMContext, line: u32, column: u32, scope: &LLVMMetadata, inlined_at: &LLVMMetadata) &LLVMMetadata;
|
[extern] LLVMDIBuilderCreateDebugLocation = fn [cc(c)] (context: &LLVMContext, line: u32, column: u32, scope: &LLVMMetadata, inlined_at: &LLVMMetadata) &LLVMMetadata;
|
||||||
[extern] LLVMDIBuilderCreateAutoVariable = fn [cc(c)] (di_builder: &LLVMDIBuilder, scope: &LLVMMetadata, name_pointer: &u8, name_length: u64, file: &LLVMMetadata, line: u32, type: &LLVMMetadata, always_preserve: s32, flags: LLVMDIFlags, bit_alignment: u32) &LLVMMetadata;
|
[extern] LLVMDIBuilderCreateAutoVariable = fn [cc(c)] (di_builder: &LLVMDIBuilder, scope: &LLVMMetadata, name_pointer: &u8, name_length: u64, file: &LLVMMetadata, line: u32, type: &LLVMMetadata, always_preserve: s32, flags: LLVMDIFlags, bit_alignment: u32) &LLVMMetadata;
|
||||||
@ -6238,7 +6241,30 @@ parse = fn (module: &Module) void
|
|||||||
|
|
||||||
if (!is_global_keyword)
|
if (!is_global_keyword)
|
||||||
{
|
{
|
||||||
#trap();
|
>initial_value = parse_value(module, scope, zero);
|
||||||
|
skip_space(module);
|
||||||
|
expect_character(module, ';');
|
||||||
|
|
||||||
|
>global_storage = new_value(module);
|
||||||
|
global_storage.& = {
|
||||||
|
.id = .global,
|
||||||
|
zero,
|
||||||
|
};
|
||||||
|
|
||||||
|
>global = new_global(module);
|
||||||
|
global.& = {
|
||||||
|
.variable = {
|
||||||
|
.storage = global_storage,
|
||||||
|
.type = global_type,
|
||||||
|
.scope = scope,
|
||||||
|
.name = global_name,
|
||||||
|
.line = global_line,
|
||||||
|
.column = global_column,
|
||||||
|
},
|
||||||
|
.initial_value = initial_value,
|
||||||
|
.linkage = .internal, // TODO: linkage
|
||||||
|
zero,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -10829,14 +10855,14 @@ emit = fn (module: &Module) void
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
>global_pointer_type = global.variable.storage.type;
|
|
||||||
assert(global_pointer_type.id == .pointer);
|
|
||||||
>global_value_type = global_pointer_type.content.pointer.element_type;
|
|
||||||
|
|
||||||
switch (global.variable.storage.id)
|
switch (global.variable.storage.id)
|
||||||
{
|
{
|
||||||
.function, .forward_declared_function =>
|
.function, .forward_declared_function =>
|
||||||
{
|
{
|
||||||
|
>global_pointer_type = global.variable.storage.type;
|
||||||
|
assert(global_pointer_type.id == .pointer);
|
||||||
|
>global_value_type = global_pointer_type.content.pointer.element_type;
|
||||||
|
|
||||||
>function_type = &global_value_type.content.function;
|
>function_type = &global_value_type.content.function;
|
||||||
>semantic_argument_types = function_type.base.semantic_argument_types;
|
>semantic_argument_types = function_type.base.semantic_argument_types;
|
||||||
>semantic_return_type = function_type.base.semantic_return_type;
|
>semantic_return_type = function_type.base.semantic_return_type;
|
||||||
@ -11044,7 +11070,51 @@ emit = fn (module: &Module) void
|
|||||||
},
|
},
|
||||||
.global =>
|
.global =>
|
||||||
{
|
{
|
||||||
#trap();
|
assert(!module.current_function);
|
||||||
|
>initial_value = global.initial_value;
|
||||||
|
analyze_value(module, initial_value, global.variable.type, .memory, 1);
|
||||||
|
|
||||||
|
>initial_value_type = initial_value.type;
|
||||||
|
|
||||||
|
if (!global.variable.type)
|
||||||
|
{
|
||||||
|
global.variable.type = initial_value_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
>global_type = global.variable.type;
|
||||||
|
|
||||||
|
if (global_type != initial_value_type)
|
||||||
|
{
|
||||||
|
report_error();
|
||||||
|
}
|
||||||
|
|
||||||
|
resolve_type_in_place(module, global_type);
|
||||||
|
|
||||||
|
>is_constant: u1 = 0;
|
||||||
|
>linkage: LLVMLinkage = undefined;
|
||||||
|
switch (global.linkage)
|
||||||
|
{
|
||||||
|
.internal => { linkage = .internal; },
|
||||||
|
.external => { linkage = .external; },
|
||||||
|
}
|
||||||
|
|
||||||
|
>thread_local_mode: LLVMThreadLocalMode = .none;
|
||||||
|
>externally_initialized: u1 = 0;
|
||||||
|
>alignment = get_byte_alignment(global_type);
|
||||||
|
>unnamed_address: LLVMUnnamedAddress = .none;
|
||||||
|
|
||||||
|
>llvm_global = llvm_create_global_variable(module.llvm.module, global_type.llvm.memory, is_constant, linkage, initial_value.llvm, global.variable.name, thread_local_mode, externally_initialized, alignment, unnamed_address);
|
||||||
|
global.variable.storage.llvm = llvm_global;
|
||||||
|
global.variable.storage.type = get_pointer_type(module, global_type);
|
||||||
|
|
||||||
|
if (module.has_debug_info)
|
||||||
|
{
|
||||||
|
>name = global.variable.name;
|
||||||
|
>linkage_name = name;
|
||||||
|
>local_to_unit = global.linkage == .internal;
|
||||||
|
>global_debug = LLVMDIBuilderCreateGlobalVariableExpression(module.llvm.di_builder, module.scope.llvm, name.pointer, name.length, linkage_name.pointer, linkage_name.length, module.llvm.file, global.variable.line, global_type.llvm.debug, #extend(local_to_unit), null_expression(module), zero, alignment * 8);
|
||||||
|
LLVMGlobalSetMetadata(llvm_global, 0, global_debug);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
else =>
|
else =>
|
||||||
{
|
{
|
||||||
@ -11063,6 +11133,11 @@ emit = fn (module: &Module) void
|
|||||||
assert(!module.current_macro_instantiation);
|
assert(!module.current_macro_instantiation);
|
||||||
assert(!module.current_macro_declaration);
|
assert(!module.current_macro_declaration);
|
||||||
|
|
||||||
|
if (global.emitted)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (global.variable.storage.id == .function)
|
if (global.variable.storage.id == .function)
|
||||||
{
|
{
|
||||||
module.current_function = global;
|
module.current_function = global;
|
||||||
@ -11783,6 +11858,7 @@ names: [_][]u8 = [
|
|||||||
"pointer_cast",
|
"pointer_cast",
|
||||||
"u1_return",
|
"u1_return",
|
||||||
"local_type_inference",
|
"local_type_inference",
|
||||||
|
"global",
|
||||||
];
|
];
|
||||||
|
|
||||||
[export] main = fn [cc(c)] (argument_count: u32, argv: &&u8, envp: &&u8) s32
|
[export] main = fn [cc(c)] (argument_count: u32, argv: &&u8, envp: &&u8) s32
|
||||||
|
@ -9461,7 +9461,6 @@ void emit(Module* module)
|
|||||||
}
|
}
|
||||||
|
|
||||||
LLVMThreadLocalMode thread_local_mode = LLVMNotThreadLocal;
|
LLVMThreadLocalMode thread_local_mode = LLVMNotThreadLocal;
|
||||||
unsigned address_space = 0;
|
|
||||||
bool externally_initialized = false;
|
bool externally_initialized = false;
|
||||||
|
|
||||||
auto alignment = get_byte_alignment(global_type);
|
auto alignment = get_byte_alignment(global_type);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user