Skip to content

Commit b55c51a

Browse files
Add support for passing integers by value
Signed-off-by: Dominik Adamski <[email protected]>
1 parent fd7e9ac commit b55c51a

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

tools/flang2/flang2exe/expand.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ expand(void)
237237
static std::map<int, int> process_expanded_map = std::map<int,int>();
238238
auto it = process_expanded_map.find(gbl.currsub);
239239
int process_expanded = 0;
240+
240241
// we reset flag because we do not know if we generate initialization
241242
// function for SPMD kernel (the function with kmpc_parallel_51 call)
242243
// or the proper kernel code (the function which is passed as an argument
@@ -507,6 +508,9 @@ static std::vector<int> get_allocated_symbols(OMPACCEL_TINFO *orig_symbols)
507508
int store_instr;
508509
int load_instr;
509510
for (unsigned i = 0; i < num_of_symbols; ++i) {
511+
if (PASSBYVALG(orig_symbols->symbols[i].device_sym) &&
512+
!PASSBYREFG(orig_symbols->symbols[i].device_sym))
513+
continue;
510514
if (!DT_ISSCALAR(DTYPEG(orig_symbols->symbols[i].device_sym))
511515
&& STYPEG(orig_symbols->symbols[i].host_sym) != ST_STRUCT) {
512516
continue;
@@ -531,7 +535,6 @@ static std::vector<int> get_allocated_symbols(OMPACCEL_TINFO *orig_symbols)
531535
chk_block(load_instr);
532536

533537
init_symbols.push_back(load_instr);
534-
535538
}
536539
return init_symbols;
537540

tools/flang2/flang2exe/kmpcutil.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1793,7 +1793,15 @@ ll_make_kmpc_parallel_51(int global_tid_sptr, std::vector<int> &symbols, SPTR he
17931793
for (int i = 0; i < n_symbols; ++i) {
17941794
if (check_if_skip_symbol(ompaccel_tinfo_get(gbl.currsub)->symbols[i].device_sym))
17951795
continue;
1796-
if (DT_ISSCALAR(DTYPEG(ompaccel_tinfo_get(gbl.currsub)->symbols[i].device_sym)) ||
1796+
else if (PASSBYVALG(ompaccel_tinfo_get(gbl.currsub)->symbols[i].device_sym) &&
1797+
!PASSBYREFG(ompaccel_tinfo_get(gbl.currsub)->symbols[i].device_sym)) {
1798+
ilix = mk_ompaccel_ldsptr(ompaccel_tinfo_get(gbl.currsub)->symbols[i].device_sym);
1799+
ilix = mk_ompaccel_store(ilix,
1800+
DT_INT8,
1801+
nme_args,
1802+
ad_acon(captured_vars, i * TARGET_PTRSIZE));
1803+
}
1804+
else if (DT_ISSCALAR(DTYPEG(ompaccel_tinfo_get(gbl.currsub)->symbols[i].device_sym)) ||
17971805
STYPEG(ompaccel_tinfo_get(gbl.currsub)->symbols[i].host_sym) == ST_STRUCT) {
17981806
ilix = mk_ompaccel_store(symbols[j++],
17991807
DT_INT8,

tools/flang2/flang2exe/outliner.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -514,12 +514,14 @@ ll_make_ftn_outlined_params(int func_sptr, int paramct, DTYPE *argtype, OMPACCEL
514514
NEED((current_tinfo->n_symbols + 1), current_tinfo->symbols, OMPACCEL_SYM,
515515
current_tinfo->sz_symbols, current_tinfo->sz_symbols * 2);
516516
if (cnt >= 2) {
517-
PASSBYVALP(sym, false);
518-
PASSBYREFP(sym, true);
517+
if (!(PASSBYVALG(sym) && !PASSBYREFG(sym) && DTYPEG(sym) == DT_INT8)) {
518+
PASSBYVALP(sym, false);
519+
PASSBYREFP(sym, true);
520+
}
519521
current_tinfo->symbols[current_tinfo->n_symbols].host_sym =
520522
ompaccel_tinfo_get(gbl.currsub)->symbols[cnt-2].device_sym;
521523
current_tinfo->symbols[current_tinfo->n_symbols].device_sym =
522-
ompaccel_tinfo_get(gbl.currsub)->symbols[cnt-2].device_sym;
524+
ompaccel_tinfo_get(gbl.currsub)->symbols[cnt-2].device_sym;
523525
}
524526
current_tinfo->symbols[current_tinfo->n_symbols].map_type = 0;
525527
current_tinfo->symbols[current_tinfo->n_symbols].in_map = 0;
@@ -2709,7 +2711,6 @@ ll_make_helper_function_for_kmpc_parallel_51(SPTR scope_sptr, OMPACCEL_TINFO *or
27092711
else {
27102712
func_args[k] = DTYPEG(symbols->device_sym);
27112713
}
2712-
PASSBYVALP(symbols->device_sym, false);
27132714
symbols++;
27142715
}
27152716

0 commit comments

Comments
 (0)