Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The trim intrinsic removes trailing blank spaces from a string. The intrinsic is lowered to a runtime call. This is part of the upstreaming effort from the fir-dev branch in [1]. [1] https://github.com/flang-compiler/f18-llvm-project Reviewed By: jeanPerier Differential Revision: https://reviews.llvm.org/D121901 Co-authored-by: Jean Perier <jperier@nvidia.com> Co-authored-by: Valentin Clement <clementval@gmail.com> Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
- Loading branch information
1 parent
5be0f0c
commit 2cdf5ef
Showing
2 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
! RUN: bbc -emit-fir %s -o - | FileCheck %s | ||
! RUN: %flang_fc1 -emit-fir %s -o - | FileCheck %s | ||
|
||
! CHECK-LABEL: func @_QPtrim_test( | ||
! CHECK-SAME: %[[arg0:.*]]: !fir.boxchar<1>{{.*}}) { | ||
subroutine trim_test(c) | ||
character(*) :: c | ||
! CHECK: %[[tmpBox:.*]] = fir.alloca !fir.box<!fir.heap<!fir.char<1,?>>> | ||
! CHECK-DAG: %[[c:.*]]:2 = fir.unboxchar %[[arg0]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index) | ||
! CHECK-DAG: %[[cBox:.*]] = fir.embox %[[c]]#0 typeparams %[[c]]#1 : (!fir.ref<!fir.char<1,?>>, index) -> !fir.box<!fir.char<1,?>> | ||
! CHECK-DAG: %[[cBoxNone:.*]] = fir.convert %[[cBox]] : (!fir.box<!fir.char<1,?>>) -> !fir.box<none> | ||
! CHECK-DAG: %[[resBox:.*]] = fir.convert %[[tmpBox]] : (!fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>) -> !fir.ref<!fir.box<none>> | ||
! CHECK: fir.call @{{.*}}Trim(%[[resBox]], %[[cBoxNone]], {{.*}}) : (!fir.ref<!fir.box<none>>, !fir.box<none>, !fir.ref<i8>, i32) -> none | ||
! CHECK-DAG: %[[tmpAddr:.*]] = fir.box_addr | ||
! CHECK-DAG: fir.box_elesize | ||
! CHECK: fir.call @{{.*}}bar_trim_test | ||
call bar_trim_test(trim(c)) | ||
! CHECK: fir.freemem %[[tmpAddr]] : <!fir.char<1,?>> | ||
return | ||
end subroutine | ||
|