-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[flang] add SYSTEM runtime and lowering intrinsics support #74309
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
14f8c3e
Add SYSTEM runtime and lowering intrinsic support
yiwu0b11 be27d36
test fixes
d821529
remove unnecessary clang-format change
yiwu0b11 9a73cb8
required parameter use reference not pointer, ensure command is null-…
yiwu0b11 da3f993
remove redundant clang-format and minor fixes
yiwu0b11 2dbeb81
tests fixes: avoid hard-coded SSA
yiwu0b11 27aa276
move EnsureNullTerminated to tools.h, capitalized and free memory aft…
yiwu0b11 cb88f6e
declare in tools.g, define in tools.cpp
yiwu0b11 fb15f83
free memoryin the end
yiwu0b11 d147dbb
memory deallocation fixes, and use std::size_t
yiwu0b11 a273460
Merge remote-tracking branch 'yi/main' into yi_dev_system
yiwu0b11 4336e53
Merge remote-tracking branch 'yi/main' into yi_dev_system
yiwu0b11 cce1664
refactor: move SYSTEM from command.cpp to execute.cpp
yiwu0b11 31c3a42
clang format and change exitstat type from AnyInt to DefaultInt to ma…
yiwu0b11 25c26f9
Windows fixes
yiwu0b11 836cd28
reuse ExecuteCommandLine runtime library and lowering
yiwu0b11 1b908ad
add tests
yiwu0b11 da6089d
remove debug leftover and test fixes based on #78302
yiwu0b11 ceac5e9
more code clean up
yiwu0b11 a157933
test fixes
yiwu0b11 762982b
Merge remote-tracking branch 'yi/main' into yi_dev_system
yiwu0b11 97c7bbf
Merge remote-tracking branch 'yi/main' into yi_dev_system
yiwu0b11 e18ac12
change inout to out and use getI16Type
yiwu0b11 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,34 @@ | ||
! RUN: bbc -emit-hlfir %s -o - | FileCheck %s | ||
|
||
! CHECK-LABEL: func.func @_QPall_args( | ||
! CHECK-SAME: %[[commandArg:.*]]: !fir.boxchar<1> {fir.bindc_name = "command", fir.optional}, | ||
! CHECK-SAME: %[[exitstatArg:.*]]: !fir.ref<i32> {fir.bindc_name = "exitstat", fir.optional}) { | ||
subroutine all_args(command, exitstat) | ||
CHARACTER(*), OPTIONAL :: command | ||
INTEGER, OPTIONAL :: exitstat | ||
call system(command, exitstat) | ||
|
||
! CHECK-NEXT: %[[cmdstatVal:.*]] = fir.alloca i16 | ||
! CHECK-NEXT: %[[commandUnbox:.*]]:2 = fir.unboxchar %[[commandArg]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index) | ||
! CHECK-NEXT: %[[commandDeclare:.*]]:2 = hlfir.declare %[[commandUnbox]]#0 typeparams %[[commandUnbox]]#1 {fortran_attrs = #fir.var_attrs<optional>, uniq_name = "_QFall_argsEcommand"} : (!fir.ref<!fir.char<1,?>>, index) -> (!fir.boxchar<1>, !fir.ref<!fir.char<1,?>>) | ||
! CHECK-NEXT: %[[exitstatDeclare:.*]]:2 = hlfir.declare %[[exitstatArg]] {fortran_attrs = #fir.var_attrs<optional>, uniq_name = "_QFall_argsEexitstat"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>) | ||
! CHECK-NEXT: %[[exitstatIsPresent:.*]] = fir.is_present %[[exitstatDeclare]]#0 : (!fir.ref<i32>) -> i1 | ||
! CHECK-NEXT: %[[commandBox:.*]] = fir.embox %[[commandDeclare]]#1 typeparams %[[commandUnbox]]#1 : (!fir.ref<!fir.char<1,?>>, index) -> !fir.box<!fir.char<1,?>> | ||
! CHECK-NEXT: %[[exitstatBox:.*]] = fir.embox %[[exitstatDeclare]]#1 : (!fir.ref<i32>) -> !fir.box<i32> | ||
! CHECK-NEXT: %[[absentIntBox:.*]] = fir.absent !fir.box<i32> | ||
! CHECK-NEXT: %[[exitstatRealBox:.*]] = arith.select %[[exitstatIsPresent]], %[[exitstatBox]], %[[absentIntBox]] : !fir.box<i32> | ||
! CHECK-NEXT: %[[true:.*]] = arith.constant true | ||
! CHECK-NEXT: %[[c0_i2:.*]] = arith.constant 0 : i2 | ||
! CHECK-NEXT: %[[c0_i16:.*]] = fir.convert %[[c0_i2]] : (i2) -> i16 | ||
! CHECK-NEXT: fir.store %[[c0_i16]] to %[[cmdstatVal]] : !fir.ref<i16> | ||
! CHECK-NEXT: %[[cmdstatBox:.*]] = fir.embox %[[cmdstatVal]] : (!fir.ref<i16>) -> !fir.box<i16> | ||
! CHECK-NEXT: %[[absentBox:.*]] = fir.absent !fir.box<none> | ||
! CHECK: %[[c9_i32:.*]] = arith.constant 9 : i32 | ||
! CHECK-NEXT: %[[command:.*]] = fir.convert %[[commandBox]] : (!fir.box<!fir.char<1,?>>) -> !fir.box<none> | ||
! CHECK-NEXT: %[[exitstat:.*]] = fir.convert %[[exitstatRealBox]] : (!fir.box<i32>) -> !fir.box<none> | ||
! CHECK-NEXT: %[[cmdstat:.*]] = fir.convert %[[cmdstatBox]] : (!fir.box<i16>) -> !fir.box<none> | ||
! CHECK: %[[VAL_16:.*]] = fir.call @_FortranAExecuteCommandLine(%[[command]], %[[true]], %[[exitstat]], %[[cmdstat]], %[[absentBox]], %[[VAL_15:.*]], %[[c9_i32]]) fastmath<contract> : (!fir.box<none>, i1, !fir.box<none>, !fir.box<none>, !fir.box<none>, !fir.ref<i8>, i32) -> none | ||
! CHECK-NEXT: return | ||
! CHECK-NEXT: } | ||
|
||
end subroutine all_args |
This file contains hidden or 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,53 @@ | ||
! RUN: bbc -emit-hlfir %s -o - | FileCheck %s | ||
|
||
! CHECK-LABEL: func.func @_QPall_args( | ||
! CHECK-SAME: %[[commandArg:.*]]: !fir.boxchar<1> {fir.bindc_name = "command"}, | ||
! CHECK-SAME: %[[exitstatArg:.*]]: !fir.ref<i32> {fir.bindc_name = "exitstat"}) { | ||
subroutine all_args(command, exitstat) | ||
CHARACTER(*) :: command | ||
INTEGER :: exitstat | ||
call system(command, exitstat) | ||
! CHECK-NEXT: %[[cmdstatVal:.*]] = fir.alloca i16 | ||
! CHECK-NEXT: %[[commandUnbox:.*]]:2 = fir.unboxchar %[[commandArg]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index) | ||
! CHECK-NEXT: %[[commandDeclare:.*]]:2 = hlfir.declare %[[commandUnbox]]#0 typeparams %[[commandUnbox]]#1 {uniq_name = "_QFall_argsEcommand"} : (!fir.ref<!fir.char<1,?>>, index) -> (!fir.boxchar<1>, !fir.ref<!fir.char<1,?>>) | ||
! CHECK-NEXT: %[[exitstatDeclare:.*]]:2 = hlfir.declare %[[exitstatArg]] {uniq_name = "_QFall_argsEexitstat"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>) | ||
! CHECK-NEXT: %[[commandBox:.*]] = fir.embox %[[commandDeclare]]#1 typeparams %[[commandUnbox]]#1 : (!fir.ref<!fir.char<1,?>>, index) -> !fir.box<!fir.char<1,?>> | ||
! CHECK-NEXT: %[[exitstatBox:.*]] = fir.embox %[[exitstatDeclare]]#1 : (!fir.ref<i32>) -> !fir.box<i32> | ||
! CHECK-NEXT: %[[true:.*]] = arith.constant true | ||
! CHECK-NEXT: %[[c0_i2:.*]] = arith.constant 0 : i2 | ||
! CHECK-NEXT: %[[c0_i16:.*]] = fir.convert %[[c0_i2]] : (i2) -> i16 | ||
! CHECK-NEXT: fir.store %[[c0_i16]] to %[[cmdstatVal]] : !fir.ref<i16> | ||
! CHECK-NEXT: %[[cmdstatBox:.*]] = fir.embox %[[cmdstatVal]] : (!fir.ref<i16>) -> !fir.box<i16> | ||
! CHECK-NEXT: %[[absentBox:.*]] = fir.absent !fir.box<none> | ||
! CHECK: %[[c9_i32:.*]] = arith.constant 9 : i32 | ||
! CHECK-NEXT: %[[command:.*]] = fir.convert %[[commandBox]] : (!fir.box<!fir.char<1,?>>) -> !fir.box<none> | ||
! CHECK-NEXT: %[[exitstat:.*]] = fir.convert %[[exitstatBox]] : (!fir.box<i32>) -> !fir.box<none> | ||
! CHECK-NEXT: %[[cmdstat:.*]] = fir.convert %[[cmdstatBox]] : (!fir.box<i16>) -> !fir.box<none> | ||
! CHECK: %[[VAL_13:.*]] = fir.call @_FortranAExecuteCommandLine(%[[command]], %[[true]], %[[exitstat]], %[[cmdstat]], %[[absentBox]], %[[VAL_12:.*]], %[[c9_i32]]) fastmath<contract> : (!fir.box<none>, i1, !fir.box<none>, !fir.box<none>, !fir.box<none>, !fir.ref<i8>, i32) -> none | ||
! CHECK-NEXT: return | ||
! CHECK-NEXT: } | ||
end subroutine all_args | ||
|
||
! CHECK-LABEL: func.func @_QPonly_command( | ||
! CHECK-SAME: %[[commandArg:.*]]: !fir.boxchar<1> {fir.bindc_name = "command"}) { | ||
subroutine only_command(command) | ||
CHARACTER(*) :: command | ||
call system(command) | ||
! CHECK-NEXT: %[[cmdstatVal:.*]] = fir.alloca i16 | ||
! CHECK-NEXT: %[[commandUnbox:.*]]:2 = fir.unboxchar %arg0 : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index) | ||
! CHECK-NEXT: %[[commandDeclare:.*]]:2 = hlfir.declare %[[commandUnbox]]#0 typeparams %[[commandUnbox]]#1 {uniq_name = "_QFonly_commandEcommand"} : (!fir.ref<!fir.char<1,?>>, index) -> (!fir.boxchar<1>, !fir.ref<!fir.char<1,?>>) | ||
! CHECK-NEXT: %[[commandBox:.*]] = fir.embox %[[commandDeclare]]#1 typeparams %[[commandUnbox]]#1 : (!fir.ref<!fir.char<1,?>>, index) -> !fir.box<!fir.char<1,?>> | ||
! CHECK-NEXT: %[[true:.*]] = arith.constant true | ||
! CHECK-NEXT: %[[absentBox:.*]] = fir.absent !fir.box<none> | ||
! CHECK-NEXT: %[[c0_i2:.*]] = arith.constant 0 : i2 | ||
! CHECK-NEXT: %[[c0_i16:.*]] = fir.convert %[[c0_i2]] : (i2) -> i16 | ||
! CHECK-NEXT: fir.store %[[c0_i16]] to %[[cmdstatVal]] : !fir.ref<i16> | ||
! CHECK-NEXT: %[[cmdstatBox:.*]] = fir.embox %[[cmdstatVal]] : (!fir.ref<i16>) -> !fir.box<i16> | ||
! CHECK-NEXT: %[[absentBox2:.*]] = fir.absent !fir.box<none> | ||
! CHECK: %[[c35_i32:.*]] = arith.constant 35 : i32 | ||
! CHECK-NEXT: %[[command:.*]] = fir.convert %[[commandBox]] : (!fir.box<!fir.char<1,?>>) -> !fir.box<none> | ||
! CHECK-NEXT: %[[cmdstat:.*]] = fir.convert %[[cmdstatBox]] : (!fir.box<i16>) -> !fir.box<none> | ||
! CHECK: %[[VAL_12:.*]] = fir.call @_FortranAExecuteCommandLine(%[[command]], %[[true]], %[[absentBox]], %[[cmdstat]], %[[absentBox2]], %[[VAL_11:.*]], %[[c35_i32]]) fastmath<contract> : (!fir.box<none>, i1, !fir.box<none>, !fir.box<none>, !fir.box<none>, !fir.ref<i8>, i32) -> none | ||
! CHECK-NEXT: return | ||
! CHECK-NEXT: } | ||
end subroutine only_command |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.