-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[flang] Add HOSTNM runtime and lowering intrinsics implementation #131910
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
25 commits
Select commit
Hold shift + click to select a range
9760096
Starting implementation of hostnm() non-standard intrinsic.
eugeneepshteyn 828cd76
In progress
eugeneepshteyn b0a8798
Continue Hostnm() implementation
eugeneepshteyn f670146
Merge branch 'llvm:main' into hostnm-intrinsic
eugeneepshteyn a0b6f85
Code complete. Functional unit tests.
eugeneepshteyn b190979
Test for semantic checks of hostnm()
eugeneepshteyn e9fa37e
Merge branch 'llvm:main' into hostnm-intrinsic
eugeneepshteyn 7cc9756
Documentation tweak
eugeneepshteyn 843db5c
Merge branch 'llvm:main' into hostnm-intrinsic
eugeneepshteyn d3384ec
Fixed incorrect handling of status code
eugeneepshteyn b9f2d8f
Merge branch 'llvm:main' into hostnm-intrinsic
eugeneepshteyn f316320
Merge branch 'llvm:main' into hostnm-intrinsic
eugeneepshteyn 4b61502
Merge branch 'llvm:main' into hostnm-intrinsic
eugeneepshteyn 378e57f
Merge branch 'llvm:main' into hostnm-intrinsic
eugeneepshteyn 42f7bc1
Merge branch 'llvm:main' into hostnm-intrinsic
eugeneepshteyn f9e8a39
Merge branch 'llvm:main' into hostnm-intrinsic
eugeneepshteyn 21c0723
Merge branch 'llvm:main' into hostnm-intrinsic
eugeneepshteyn d2068a8
Merge branch 'llvm:main' into hostnm-intrinsic
eugeneepshteyn e375cc9
Addressed functional code review comments
eugeneepshteyn 773055e
hostnm-sub.f90: hostnm() lowering test, subroutine form
eugeneepshteyn cb02a8e
Removed end-to-end tests
eugeneepshteyn d10fb71
Merge branch 'llvm:main' into hostnm-intrinsic
eugeneepshteyn 633d0ba
Merge branch 'llvm:main' into hostnm-intrinsic
eugeneepshteyn e81f7f7
Forced to use GetComputerNameExA(), ASCII version of GetComputerNameE…
eugeneepshteyn 719612a
Added hostnm-func.f90, a test for function form of hotnm()
eugeneepshteyn 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
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
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,23 @@ | ||
| !RUN: %flang_fc1 -emit-hlfir %s -o - | FileCheck %s | ||
|
|
||
| !CHECK-LABEL: func.func @_QPhostnm_test | ||
| !CHECK-SAME: %[[dummyHn:.*]]: !fir.boxchar<1> {fir.bindc_name = "hn"}) -> i32 { | ||
| integer function hostnm_test(hn) | ||
| CHARACTER(len=255) :: hn | ||
|
|
||
| ! Check that _FortranAHostnm is called with boxed char 255, some other char | ||
| ! string of variable length (source file path) and some integer (source line) | ||
| !CHECK-DAG: %[[func_result:.*]] = fir.alloca i32 {bindc_name = "hostnm_test", uniq_name = "_QFhostnm_testEhostnm_test"} | ||
| !CHECK-DAG: %[[func_result_decl:.*]]:{{.*}} = hlfir.declare %[[func_result]] {uniq_name = "_QFhostnm_testEhostnm_test"} : {{.*}}fir.ref<i32>{{.*}} | ||
| !CHECK-DAG: %[[line:.*]] = arith.constant {{.*}} : i32 | ||
| !CHECK-DAG: %[[hn:.*]] = fir.convert {{.*}} (!fir.box<!fir.char<1,255>>) -> !fir.box<none> | ||
| !CHECK-DAG: %[[src_path:.*]] = fir.convert {{.*}} (!fir.ref<!fir.char<1,{{.*}} -> !fir.ref<i8> | ||
| !CHECK: %[[hn_result:.*]] = fir.call @_FortranAHostnm(%[[hn]], %[[src_path]], %[[line]]) | ||
| !CHECK-SAME: -> i32 | ||
|
|
||
| ! Check _FortranAHostnm result code handling | ||
| !CHECK-DAG: hlfir.assign %[[hn_result]] to %[[func_result_decl]]{{.*}}i32{{.*}} | ||
| !CHECK-DAG: %[[load_result:.*]] = fir.load %[[func_result_decl]]{{.*}}i32{{.*}} | ||
| !CHECK: return %[[load_result]] : i32 | ||
| hostnm_test = hostnm(hn) | ||
| end function hostnm_test |
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,38 @@ | ||
| !RUN: %flang_fc1 -emit-hlfir %s -o - | FileCheck %s | ||
eugeneepshteyn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| !CHECK-LABEL: func.func @_QPhostnm_only | ||
| !CHECK-SAME: %[[dummyHn:.*]]: !fir.boxchar<1> {fir.bindc_name = "hn"}) { | ||
| subroutine hostnm_only(hn) | ||
| CHARACTER(len=255) :: hn | ||
|
|
||
| ! Check that _FortranAHostnm is called with boxed char 255, some other char | ||
| ! string of variable length (source file path) and some integer (source line) | ||
| !CHECK-DAG: %[[line:.*]] = arith.constant {{.*}} : i32 | ||
| !CHECK-DAG: %[[hn:.*]] = fir.convert {{.*}} (!fir.box<!fir.char<1,255>>) -> !fir.box<none> | ||
| !CHECK-DAG: %[[src_path:.*]] = fir.convert {{.*}} (!fir.ref<!fir.char<1,{{.*}} -> !fir.ref<i8> | ||
| !CHECK: fir.call @_FortranAHostnm(%[[hn]], %[[src_path]], %[[line]]) | ||
| !CHECK-SAME: -> i32 | ||
| call hostnm(hn) | ||
| end subroutine hostnm_only | ||
|
|
||
| !CHECK-LABEL: func.func @_QPall_arguments | ||
| !CHECK-SAME: %[[dummyHn:.*]]: !fir.boxchar<1> {fir.bindc_name = "hn"}, | ||
| !CHECK-SAME: %[[dummyStat:.*]]: !fir.ref<i32> {fir.bindc_name = "status"}) { | ||
| subroutine all_arguments(hn, status) | ||
| CHARACTER(len=255) :: hn | ||
| INTEGER :: status | ||
|
|
||
| ! Check that _FortranAHostnm is called with boxed char 255, some other char | ||
| ! string of variable length (source file path) and some integer (source line) | ||
| !CHECK-DAG: %[[line:.*]] = arith.constant {{.*}} : i32 | ||
| !CHECK-DAG: %[[hn:.*]] = fir.convert {{.*}} (!fir.box<!fir.char<1,255>>) -> !fir.box<none> | ||
| !CHECK-DAG: %[[src_path:.*]] = fir.convert {{.*}} (!fir.ref<!fir.char<1,{{.*}} -> !fir.ref<i8> | ||
| !CHECK: %[[hn_result:.*]] = fir.call @_FortranAHostnm(%[[hn]], %[[src_path]], %[[line]]) | ||
| !CHECK-SAME: -> i32 | ||
|
|
||
| ! Check _FortranAHostnm result code handling | ||
| !CHECK-DAG: %[[c0_i64:.*]] = arith.constant 0 : i64 | ||
| !CHECK-DAG: %[[cmp_result:.*]] = arith.cmpi ne, {{.*}}, %[[c0_i64]] : i64 | ||
| !CHECK: fir.store %[[hn_result]] {{.*}} !fir.ref<i32> | ||
| call hostnm(hn, status) | ||
| end subroutine all_arguments | ||
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,42 @@ | ||
| ! RUN: %python %S/test_errors.py %s %flang_fc1 -pedantic | ||
| ! Tests for the HOSTNM intrinsics. | ||
|
|
||
| subroutine bad_kind_error(cwd, status) | ||
| CHARACTER(len=255) :: cwd | ||
| INTEGER(2) :: status | ||
| !ERROR: Actual argument for 'status=' has bad type or kind 'INTEGER(2)' | ||
| call hostnm(cwd, status) | ||
| end subroutine bad_kind_error | ||
|
|
||
| subroutine bad_args_error() | ||
| !ERROR: missing mandatory 'c=' argument | ||
| call hostnm() | ||
| end subroutine bad_args_error | ||
|
|
||
| subroutine bad_function(cwd) | ||
| CHARACTER(len=255) :: cwd | ||
| INTEGER :: status | ||
| call hostnm(cwd, status) | ||
| !ERROR: Cannot call subroutine 'hostnm' like a function | ||
| status = hostnm(cwd) | ||
| end subroutine bad_function | ||
|
|
||
| subroutine bad_sub(cwd) | ||
| CHARACTER(len=255) :: cwd | ||
| INTEGER :: status | ||
| status = hostnm(cwd) | ||
| !ERROR: Cannot call function 'hostnm' like a subroutine | ||
| call hostnm(cwd, status) | ||
| end subroutine bad_sub | ||
|
|
||
| subroutine good_subroutine(cwd, status) | ||
| CHARACTER(len=255) :: cwd | ||
| INTEGER :: status | ||
| call hostnm(cwd, status) | ||
| end subroutine good_subroutine | ||
|
|
||
| subroutine good_function(cwd, status) | ||
| CHARACTER(len=255) :: cwd | ||
| INTEGER :: status | ||
| status = hostnm(cwd) | ||
| end subroutine good_function |
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.