Skip to content

Commit 7d2893e

Browse files
committed
Merge branch 'master' into fbinit
2 parents 782c74c + 80a06be commit 7d2893e

File tree

29 files changed

+121
-111
lines changed

29 files changed

+121
-111
lines changed

src/codegen/debug.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ impl<'ink> Debug<'ink> for DebugBuilder<'ink> {
762762

763763
let variable_key = VariableKey::new(
764764
variable.get_qualified_name(),
765-
Some(function_scope.linking_context.get_call_name()),
765+
Some(&function_scope.linking_context.get_call_name_for_ir()),
766766
);
767767
self.variables.insert(variable_key, debug_variable);
768768
}
@@ -801,7 +801,7 @@ impl<'ink> Debug<'ink> for DebugBuilder<'ink> {
801801

802802
let variable_key = VariableKey::new(
803803
variable.get_qualified_name(),
804-
Some(function_scope.linking_context.get_call_name()),
804+
Some(&function_scope.linking_context.get_call_name_for_ir()),
805805
);
806806
self.variables.insert(variable_key, debug_variable);
807807
}
@@ -819,7 +819,8 @@ impl<'ink> Debug<'ink> for DebugBuilder<'ink> {
819819
.get_subprogram()
820820
.map(|it| it.as_debug_info_scope())
821821
.unwrap_or_else(|| file.as_debug_info_scope());
822-
let variable_key = VariableKey::new(name, Some(function_scope.linking_context.get_call_name()));
822+
let variable_key =
823+
VariableKey::new(name, Some(&function_scope.linking_context.get_call_name_for_ir()));
823824
if let Some(debug_type) = self.types.get(&name.to_lowercase()) {
824825
let debug_type = *debug_type;
825826
let line = function_scope.linking_context.get_location().get_line_plus_one() as u32;
@@ -865,7 +866,7 @@ impl<'ink> Debug<'ink> for DebugBuilder<'ink> {
865866
scope,
866867
None,
867868
);
868-
let key = VariableKey::new(name, Some(function_scope.linking_context.get_call_name()));
869+
let key = VariableKey::new(name, Some(&function_scope.linking_context.get_call_name_for_ir()));
869870
let variable = self.variables.get(&key);
870871
self.debug_info.insert_declare_at_end(value, variable.copied(), None, location, block);
871872
}

src/codegen/generators/expression_generator.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ impl<'ink, 'b> ExpressionCodeGenerator<'ink, 'b> {
497497
.ok_or_else(|| Diagnostic::cannot_generate_call_statement(operator))?;
498498

499499
let parameters_list = parameters.map(flatten_expression_list).unwrap_or_default();
500-
let implementation_name = implementation.get_call_name();
500+
let implementation_name = &implementation.get_call_name();
501501
// if the function is builtin, generate a basic value enum for it
502502
if let Some(builtin) = self.index.get_builtin_function(implementation_name) {
503503
// adr, ref, etc.
@@ -865,7 +865,7 @@ impl<'ink, 'b> ExpressionCodeGenerator<'ink, 'b> {
865865
.ok_or_else(|| Diagnostic::cannot_generate_call_statement(operator))?;
866866

867867
self.generate_stateful_pou_arguments(
868-
implementation.get_call_name(),
868+
&implementation.get_call_name_for_ir(),
869869
None,
870870
call_ptr,
871871
passed_parameters,
@@ -874,7 +874,7 @@ impl<'ink, 'b> ExpressionCodeGenerator<'ink, 'b> {
874874
_ => {
875875
let call_ptr = self.generate_lvalue(operator)?;
876876
self.generate_stateful_pou_arguments(
877-
implementation.get_call_name(),
877+
&implementation.get_call_name_for_ir(),
878878
None,
879879
call_ptr,
880880
passed_parameters,

src/codegen/generators/pou_generator.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ impl<'ink, 'cg> PouGenerator<'ink, 'cg> {
162162
}
163163

164164
fn mangle_function(&self, implementation: &ImplementationIndexEntry) -> Result<String, Diagnostic> {
165-
let ctx = SectionMangler::function(implementation.get_call_name().to_lowercase());
165+
let ctx = SectionMangler::function(implementation.get_call_name_for_ir().to_lowercase());
166166

167167
let params = self.index.get_declared_parameters(implementation.get_call_name());
168168

@@ -279,7 +279,8 @@ impl<'ink, 'cg> PouGenerator<'ink, 'cg> {
279279

280280
let function_declaration = self.create_llvm_function_type(parameters, variadic, return_type_llvm)?;
281281

282-
let curr_f = module.add_function(implementation.get_call_name(), function_declaration, None);
282+
let curr_f: FunctionValue<'_> =
283+
module.add_function(&implementation.get_call_name_for_ir(), function_declaration, None);
283284

284285
let section_name = self.get_section(implementation)?;
285286
curr_f.set_section(section_name.as_deref());

src/codegen/generators/statement_generator.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -805,8 +805,8 @@ impl<'a, 'b> StatementCodeGenerator<'a, 'b> {
805805
//generate return void
806806
self.llvm.builder.build_return(None);
807807
} else {
808-
// renerate return statement
809-
let call_name = self.function_context.linking_context.get_call_name();
808+
// generate return statement
809+
let call_name = &self.function_context.linking_context.get_call_name_for_ir();
810810
let var_name = format!("{call_name}_ret"); // TODO: Naming convention (see plc_util/src/convention.rs)
811811
let ret_name = ret_v.get_qualified_name();
812812
let value_ptr =

src/codegen/tests/code_gen_tests.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,11 +1115,11 @@ fn fb_method_called_locally() {
11151115
define void @foo(%foo* %0) {
11161116
entry:
11171117
%bar = getelementptr inbounds %foo, %foo* %0, i32 0, i32 0
1118-
%call = call i32 @foo.addToBar(%foo* %0, i16 42)
1118+
%call = call i32 @foo_addToBar(%foo* %0, i16 42)
11191119
ret void
11201120
}
11211121
1122-
define i32 @foo.addToBar(%foo* %0, i16 %1) {
1122+
define i32 @foo_addToBar(%foo* %0, i16 %1) {
11231123
entry:
11241124
%bar = getelementptr inbounds %foo, %foo* %0, i32 0, i32 0
11251125
%foo.addToBar = alloca i32, align 4
@@ -1133,8 +1133,8 @@ fn fb_method_called_locally() {
11331133
store i32 %tmpVar, i32* %bar, align 4
11341134
%load_bar1 = load i32, i32* %bar, align 4
11351135
store i32 %load_bar1, i32* %foo.addToBar, align 4
1136-
%foo.addToBar_ret = load i32, i32* %foo.addToBar, align 4
1137-
ret i32 %foo.addToBar_ret
1136+
%foo_addToBar_ret = load i32, i32* %foo.addToBar, align 4
1137+
ret i32 %foo_addToBar_ret
11381138
}
11391139
11401140
define void @main() {
@@ -1144,7 +1144,7 @@ fn fb_method_called_locally() {
11441144
%0 = bitcast %foo* %fb to i8*
11451145
call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %0, i8* align 1 bitcast (%foo* @__foo__init to i8*), i64 ptrtoint (%foo* getelementptr (%foo, %foo* null, i32 1) to i64), i1 false)
11461146
store i32 0, i32* %x, align 4
1147-
%call = call i32 @foo.addToBar(%foo* %fb, i16 3)
1147+
%call = call i32 @foo_addToBar(%foo* %fb, i16 3)
11481148
store i32 %call, i32* %x, align 4
11491149
ret void
11501150
}
@@ -1198,11 +1198,11 @@ fn fb_local_method_var_shadows_parent_var() {
11981198
define void @foo(%foo* %0) {
11991199
entry:
12001200
%bar = getelementptr inbounds %foo, %foo* %0, i32 0, i32 0
1201-
%call = call i32 @foo.addToBar(%foo* %0, i16 42)
1201+
%call = call i32 @foo_addToBar(%foo* %0, i16 42)
12021202
ret void
12031203
}
12041204
1205-
define i32 @foo.addToBar(%foo* %0, i16 %1) {
1205+
define i32 @foo_addToBar(%foo* %0, i16 %1) {
12061206
entry:
12071207
%bar = getelementptr inbounds %foo, %foo* %0, i32 0, i32 0
12081208
%foo.addToBar = alloca i32, align 4
@@ -1218,8 +1218,8 @@ fn fb_local_method_var_shadows_parent_var() {
12181218
store i32 %tmpVar, i32* %bar1, align 4
12191219
%load_bar2 = load i32, i32* %bar1, align 4
12201220
store i32 %load_bar2, i32* %foo.addToBar, align 4
1221-
%foo.addToBar_ret = load i32, i32* %foo.addToBar, align 4
1222-
ret i32 %foo.addToBar_ret
1221+
%foo_addToBar_ret = load i32, i32* %foo.addToBar, align 4
1222+
ret i32 %foo_addToBar_ret
12231223
}
12241224
12251225
define void @main() {
@@ -1229,7 +1229,7 @@ fn fb_local_method_var_shadows_parent_var() {
12291229
%0 = bitcast %foo* %fb to i8*
12301230
call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %0, i8* align 1 bitcast (%foo* @__foo__init to i8*), i64 ptrtoint (%foo* getelementptr (%foo, %foo* null, i32 1) to i64), i1 false)
12311231
store i32 0, i32* %x, align 4
1232-
%call = call i32 @foo.addToBar(%foo* %fb, i16 3)
1232+
%call = call i32 @foo_addToBar(%foo* %fb, i16 3)
12331233
store i32 %call, i32* %x, align 4
12341234
ret void
12351235
}
@@ -1280,11 +1280,11 @@ fn prog_method_called_locally() {
12801280
define void @foo(%foo* %0) {
12811281
entry:
12821282
%bar = getelementptr inbounds %foo, %foo* %0, i32 0, i32 0
1283-
%call = call i32 @foo.addToBar(%foo* %0, i16 42)
1283+
%call = call i32 @foo_addToBar(%foo* %0, i16 42)
12841284
ret void
12851285
}
12861286
1287-
define i32 @foo.addToBar(%foo* %0, i16 %1) {
1287+
define i32 @foo_addToBar(%foo* %0, i16 %1) {
12881288
entry:
12891289
%bar = getelementptr inbounds %foo, %foo* %0, i32 0, i32 0
12901290
%foo.addToBar = alloca i32, align 4
@@ -1298,15 +1298,15 @@ fn prog_method_called_locally() {
12981298
store i32 %tmpVar, i32* %bar, align 4
12991299
%load_bar1 = load i32, i32* %bar, align 4
13001300
store i32 %load_bar1, i32* %foo.addToBar, align 4
1301-
%foo.addToBar_ret = load i32, i32* %foo.addToBar, align 4
1302-
ret i32 %foo.addToBar_ret
1301+
%foo_addToBar_ret = load i32, i32* %foo.addToBar, align 4
1302+
ret i32 %foo_addToBar_ret
13031303
}
13041304
13051305
define void @main() {
13061306
entry:
13071307
%x = alloca i32, align 4
13081308
store i32 0, i32* %x, align 4
1309-
%call = call i32 @foo.addToBar(%foo* @foo_instance, i16 3)
1309+
%call = call i32 @foo_addToBar(%foo* @foo_instance, i16 3)
13101310
store i32 %call, i32* %x, align 4
13111311
ret void
13121312
}
@@ -1354,11 +1354,11 @@ fn prog_local_method_var_shadows_parent_var() {
13541354
define void @foo(%foo* %0) {
13551355
entry:
13561356
%bar = getelementptr inbounds %foo, %foo* %0, i32 0, i32 0
1357-
%call = call i32 @foo.addToBar(%foo* %0, i16 42)
1357+
%call = call i32 @foo_addToBar(%foo* %0, i16 42)
13581358
ret void
13591359
}
13601360
1361-
define i32 @foo.addToBar(%foo* %0, i16 %1) {
1361+
define i32 @foo_addToBar(%foo* %0, i16 %1) {
13621362
entry:
13631363
%bar = getelementptr inbounds %foo, %foo* %0, i32 0, i32 0
13641364
%foo.addToBar = alloca i32, align 4
@@ -1374,15 +1374,15 @@ fn prog_local_method_var_shadows_parent_var() {
13741374
store i32 %tmpVar, i32* %bar1, align 4
13751375
%load_bar2 = load i32, i32* %bar1, align 4
13761376
store i32 %load_bar2, i32* %foo.addToBar, align 4
1377-
%foo.addToBar_ret = load i32, i32* %foo.addToBar, align 4
1378-
ret i32 %foo.addToBar_ret
1377+
%foo_addToBar_ret = load i32, i32* %foo.addToBar, align 4
1378+
ret i32 %foo_addToBar_ret
13791379
}
13801380
13811381
define void @main() {
13821382
entry:
13831383
%x = alloca i32, align 4
13841384
store i32 0, i32* %x, align 4
1385-
%call = call i32 @foo.addToBar(%foo* @foo_instance, i16 3)
1385+
%call = call i32 @foo_addToBar(%foo* @foo_instance, i16 3)
13861386
store i32 %call, i32* %x, align 4
13871387
ret void
13881388
}

src/codegen/tests/debug_tests.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ fn dbg_declare_has_valid_metadata_references_for_methods() {
364364
ret void, !dbg !13
365365
}
366366
367-
define void @fb.foo(%fb* %0) !dbg !14 {
367+
define void @fb_foo(%fb* %0) !dbg !14 {
368368
entry:
369369
call void @llvm.dbg.declare(metadata %fb* %0, metadata !15, metadata !DIExpression()), !dbg !16
370370
ret void, !dbg !16
@@ -457,7 +457,7 @@ fn action_with_var_temp() {
457457
call void @llvm.dbg.declare(metadata i32* %main, metadata !12, metadata !DIExpression()), !dbg !14
458458
store i32 0, i32* %main, align 4
459459
call void @PLC_PRG(%PLC_PRG* @PLC_PRG_instance), !dbg !15
460-
call void @PLC_PRG.act(%PLC_PRG* @PLC_PRG_instance), !dbg !16
460+
call void @PLC_PRG_act(%PLC_PRG* @PLC_PRG_instance), !dbg !16
461461
%main_ret = load i32, i32* %main, align 4, !dbg !17
462462
ret i32 %main_ret, !dbg !17
463463
}
@@ -472,7 +472,7 @@ fn action_with_var_temp() {
472472
ret void, !dbg !25
473473
}
474474
475-
define void @PLC_PRG.act(%PLC_PRG* %0) !dbg !26 {
475+
define void @PLC_PRG_act(%PLC_PRG* %0) !dbg !26 {
476476
entry:
477477
call void @llvm.dbg.declare(metadata %PLC_PRG* %0, metadata !27, metadata !DIExpression()), !dbg !28
478478
%x = alloca i32, align 4

src/codegen/tests/initialization_test/complex_initializers.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -388,15 +388,15 @@ fn nested_initializer_pous() {
388388
entry:
389389
%str_ref = getelementptr inbounds %foo, %foo* %0, i32 0, i32 0
390390
%b = getelementptr inbounds %foo, %foo* %0, i32 0, i32 1
391-
call void @bar.print(%bar* %b)
391+
call void @bar_print(%bar* %b)
392392
call void @bar(%bar* %b)
393393
ret void
394394
}
395395
396396
define void @bar(%bar* %0) {
397397
entry:
398398
%b = getelementptr inbounds %bar, %bar* %0, i32 0, i32 0
399-
call void @baz.print(%baz* %b)
399+
call void @baz_print(%baz* %b)
400400
ret void
401401
}
402402
@@ -418,24 +418,24 @@ fn nested_initializer_pous() {
418418
%other_ref_to_global = getelementptr inbounds %sideProg, %sideProg* %0, i32 0, i32 0
419419
%f = getelementptr inbounds %sideProg, %sideProg* %0, i32 0, i32 1
420420
call void @foo(%foo* %f)
421-
call void @foo.print(%foo* %f)
421+
call void @foo_print(%foo* %f)
422422
ret void
423423
}
424424
425-
define void @bar.print(%bar* %0) {
425+
define void @bar_print(%bar* %0) {
426426
entry:
427427
%b = getelementptr inbounds %bar, %bar* %0, i32 0, i32 0
428428
ret void
429429
}
430430
431-
define void @foo.print(%foo* %0) {
431+
define void @foo_print(%foo* %0) {
432432
entry:
433433
%str_ref = getelementptr inbounds %foo, %foo* %0, i32 0, i32 0
434434
%b = getelementptr inbounds %foo, %foo* %0, i32 0, i32 1
435435
ret void
436436
}
437437
438-
define void @baz.print(%baz* %0) {
438+
define void @baz_print(%baz* %0) {
439439
entry:
440440
%str_ref = getelementptr inbounds %baz, %baz* %0, i32 0, i32 0
441441
ret void
@@ -824,7 +824,7 @@ fn stateful_pous_methods_and_structs_get_init_functions() {
824824
ret void
825825
}
826826
827-
define void @foo.m(%foo* %0) {
827+
define void @foo_m(%foo* %0) {
828828
entry:
829829
ret void
830830
}
@@ -834,12 +834,12 @@ fn stateful_pous_methods_and_structs_get_init_functions() {
834834
ret void
835835
}
836836
837-
define void @cl.m(%cl* %0) {
837+
define void @cl_m(%cl* %0) {
838838
entry:
839839
ret void
840840
}
841841
842-
define void @foo.act(%foo* %0) {
842+
define void @foo_act(%foo* %0) {
843843
entry:
844844
ret void
845845
}
@@ -1640,7 +1640,7 @@ fn initializing_method_variables_with_refs() {
16401640
ret void
16411641
}
16421642
1643-
define void @foo.bar(%foo* %0) {
1643+
define void @foo_bar(%foo* %0) {
16441644
entry:
16451645
%x = alloca i32, align 4
16461646
%px = alloca i32*, align 8
@@ -1707,7 +1707,7 @@ fn initializing_method_variables_with_refs_referencing_parent_pou_variable() {
17071707
ret void
17081708
}
17091709
1710-
define void @foo.bar(%foo* %0) {
1710+
define void @foo_bar(%foo* %0) {
17111711
entry:
17121712
%x = getelementptr inbounds %foo, %foo* %0, i32 0, i32 0
17131713
%px = alloca i32*, align 8
@@ -1773,7 +1773,7 @@ fn initializing_method_variables_with_refs_referencing_global_variable() {
17731773
ret void
17741774
}
17751775
1776-
define void @foo.bar(%foo* %0) {
1776+
define void @foo_bar(%foo* %0) {
17771777
entry:
17781778
%px = alloca i32*, align 8
17791779
store i32* @x, i32** %px, align 8
@@ -1839,7 +1839,7 @@ fn initializing_method_variables_with_refs_shadowing() {
18391839
ret void
18401840
}
18411841
1842-
define void @foo.bar(%foo* %0) {
1842+
define void @foo_bar(%foo* %0) {
18431843
entry:
18441844
%x = alloca i32, align 4
18451845
%px = alloca i32*, align 8
@@ -1902,7 +1902,7 @@ fn initializing_method_variables_with_alias() {
19021902
ret void
19031903
}
19041904
1905-
define void @foo.bar(%foo* %0) {
1905+
define void @foo_bar(%foo* %0) {
19061906
entry:
19071907
%x = alloca i32, align 4
19081908
%px = alloca i32*, align 8
@@ -1965,7 +1965,7 @@ fn initializing_method_variables_with_reference_to() {
19651965
ret void
19661966
}
19671967
1968-
define void @foo.bar(%foo* %0) {
1968+
define void @foo_bar(%foo* %0) {
19691969
entry:
19701970
%x = alloca i32, align 4
19711971
%px = alloca i32*, align 8
@@ -2044,7 +2044,7 @@ fn methods_call_init_functions_for_their_members() {
20442044
ret void
20452045
}
20462046
2047-
define void @bar.baz(%bar* %0) {
2047+
define void @bar_baz(%bar* %0) {
20482048
entry:
20492049
%fb = alloca %foo, align 8
20502050
%1 = bitcast %foo* %fb to i8*

0 commit comments

Comments
 (0)