The structure is - OmpBeginDirective (aka OmpDirectiveSpecification) - Block - optional<OmpEndDirective> (aka optional<OmpDirectiveSpecification>) The OmpBeginDirective and OmpEndDirective are effectively different names for OmpDirectiveSpecification. They exist to allow the semantic analyses to distinguish between the beginning and the ending of a block construct without maintaining additional context. The actual changes are in the parser: parse-tree.h and openmp-parser.cpp in particular. The rest is simply changing the way the directive/clause information is accessed (typically for the simpler). All standalone and block constructs now use OmpDirectiveSpecification to store the directive/clause information.
182 lines
6.4 KiB
Fortran
182 lines
6.4 KiB
Fortran
! REQUIRES: openmp_runtime
|
|
|
|
! RUN: %flang_fc1 -fdebug-unparse-no-sema %openmp_flags %s | FileCheck --ignore-case %s
|
|
! RUN: %flang_fc1 -fdebug-dump-parse-tree %openmp_flags %s | FileCheck --check-prefix="PARSE-TREE" %s
|
|
! Checks the parsing of Openmp 5.0 Target Device constructs
|
|
!
|
|
PROGRAM main
|
|
USE OMP_LIB
|
|
IMPLICIT NONE
|
|
INTEGER :: X, Y
|
|
INTEGER :: M = 1
|
|
|
|
|
|
!------------------------------------------------------
|
|
! Check Device clause with a constant argument
|
|
!------------------------------------------------------
|
|
!CHECK: !$OMP TARGET DEVICE(1)
|
|
!$OMP TARGET DEVICE(1)
|
|
M = M + 1
|
|
!CHECK: !$OMP END TARGET
|
|
!$OMP END TARGET
|
|
|
|
!PARSE-TREE: OmpBeginDirective
|
|
!PARSE-TREE: OmpDirectiveName -> llvm::omp::Directive = target
|
|
!PARSE-TREE: OmpClauseList -> OmpClause -> Device -> OmpDeviceClause
|
|
!PARSE-TREE: Scalar -> Integer -> Expr = '1_4'
|
|
!PARSE-TREE: LiteralConstant -> IntLiteralConstant = '1'
|
|
!PARSE-TREE: OmpEndDirective
|
|
!PARSE-TREE: OmpDirectiveName -> llvm::omp::Directive = target
|
|
!PARSE-TREE: OmpClauseList ->
|
|
|
|
!------------------------------------------------------
|
|
! Check Device clause with a constant integer expression argument
|
|
!------------------------------------------------------
|
|
!CHECK: !$OMP TARGET DEVICE(2-1)
|
|
!$OMP TARGET DEVICE(2-1)
|
|
M = M + 1
|
|
!CHECK: !$OMP END TARGET
|
|
!$OMP END TARGET
|
|
|
|
!PARSE-TREE: OmpBeginDirective
|
|
!PARSE-TREE: OmpDirectiveName -> llvm::omp::Directive = target
|
|
!PARSE-TREE: OmpClauseList -> OmpClause -> Device -> OmpDeviceClause
|
|
!PARSE-TREE: Scalar -> Integer -> Expr = '1_4'
|
|
!PARSE-TREE: Subtract
|
|
!PARSE-TREE: Expr = '2_4'
|
|
!PARSE-TREE: LiteralConstant -> IntLiteralConstant = '2'
|
|
!PARSE-TREE: Expr = '1_4'
|
|
!PARSE-TREE: LiteralConstant -> IntLiteralConstant = '1'
|
|
!PARSE-TREE: OmpEndDirective
|
|
!PARSE-TREE: OmpDirectiveName -> llvm::omp::Directive = target
|
|
!PARSE-TREE: OmpClauseList ->
|
|
|
|
|
|
!------------------------------------------------------
|
|
! Check Device clause with a variable argument
|
|
!------------------------------------------------------
|
|
!CHECK: !$OMP TARGET DEVICE(X)
|
|
!$OMP TARGET DEVICE(X)
|
|
M = M + 1
|
|
!CHECK: !$OMP END TARGET
|
|
!$OMP END TARGET
|
|
|
|
!PARSE-TREE: OmpBeginDirective
|
|
!PARSE-TREE: OmpDirectiveName -> llvm::omp::Directive = target
|
|
!PARSE-TREE: OmpClauseList -> OmpClause -> Device -> OmpDeviceClause
|
|
!PARSE-TREE: Scalar -> Integer -> Expr = 'x'
|
|
!PARSE-TREE: Designator -> DataRef -> Name = 'x'
|
|
!PARSE-TREE: OmpEndDirective
|
|
!PARSE-TREE: OmpDirectiveName -> llvm::omp::Directive = target
|
|
!PARSE-TREE: OmpClauseList ->
|
|
|
|
|
|
!------------------------------------------------------
|
|
! Check Device clause with an variable integer expression
|
|
!------------------------------------------------------
|
|
!CHECK: !$OMP TARGET DEVICE(X+Y)
|
|
!$OMP TARGET DEVICE(X+Y)
|
|
M = M + 1
|
|
!CHECK: !$OMP END TARGET
|
|
!$OMP END TARGET
|
|
|
|
!PARSE-TREE: OmpBeginDirective
|
|
!PARSE-TREE: OmpDirectiveName -> llvm::omp::Directive = target
|
|
!PARSE-TREE: OmpClauseList -> OmpClause -> Device -> OmpDeviceClause
|
|
!PARSE-TREE: Scalar -> Integer -> Expr = 'x+y'
|
|
!PARSE-TREE: Add
|
|
!PARSE-TREE: Expr = 'x'
|
|
!PARSE-TREE: Designator -> DataRef -> Name = 'x'
|
|
!PARSE-TREE: Expr = 'y'
|
|
!PARSE-TREE: Designator -> DataRef -> Name = 'y'
|
|
!PARSE-TREE: OmpEndDirective
|
|
!PARSE-TREE: OmpDirectiveName -> llvm::omp::Directive = target
|
|
!PARSE-TREE: OmpClauseList ->
|
|
|
|
!------------------------------------------------------
|
|
! Check Device Ancestor clause with a constant argument
|
|
!------------------------------------------------------
|
|
!CHECK: !$OMP TARGET DEVICE(ANCESTOR: 1)
|
|
!$OMP TARGET DEVICE(ANCESTOR: 1)
|
|
M = M + 1
|
|
!CHECK: !$OMP END TARGET
|
|
!$OMP END TARGET
|
|
|
|
!PARSE-TREE: OmpBeginDirective
|
|
!PARSE-TREE: OmpDirectiveName -> llvm::omp::Directive = target
|
|
!PARSE-TREE: OmpClauseList -> OmpClause -> Device -> OmpDeviceClause
|
|
!PARSE-TREE: OmpDeviceModifier -> Value = Ancestor
|
|
!PARSE-TREE: Scalar -> Integer -> Expr = '1_4'
|
|
!PARSE-TREE: LiteralConstant -> IntLiteralConstant = '1'
|
|
!PARSE-TREE: OmpEndDirective
|
|
!PARSE-TREE: OmpDirectiveName -> llvm::omp::Directive = target
|
|
!PARSE-TREE: OmpClauseList ->
|
|
|
|
|
|
!--------------------------------------------------------
|
|
! Check Device Devive-Num clause with a constant argument
|
|
!--------------------------------------------------------
|
|
!CHECK: !$OMP TARGET DEVICE(DEVICE_NUM: 2)
|
|
!$OMP TARGET DEVICE(DEVICE_NUM: 2)
|
|
M = M + 1
|
|
!CHECK: !$OMP END TARGET
|
|
!$OMP END TARGET
|
|
|
|
!PARSE-TREE: OmpBeginDirective
|
|
!PARSE-TREE: OmpDirectiveName -> llvm::omp::Directive = target
|
|
!PARSE-TREE: OmpClauseList -> OmpClause -> Device -> OmpDeviceClause
|
|
!PARSE-TREE: OmpDeviceModifier -> Value = Device_Num
|
|
!PARSE-TREE: Scalar -> Integer -> Expr = '2_4'
|
|
!PARSE-TREE: LiteralConstant -> IntLiteralConstant = '2'
|
|
!PARSE-TREE: OmpEndDirective
|
|
!PARSE-TREE: OmpDirectiveName -> llvm::omp::Directive = target
|
|
!PARSE-TREE: OmpClauseList ->
|
|
|
|
|
|
!-------------------------------------------------------------------
|
|
! Check Device Ancestor clause with a variable expression argument
|
|
!-------------------------------------------------------------------
|
|
!CHECK: !$OMP TARGET DEVICE(ANCESTOR: X+Y)
|
|
!$OMP TARGET DEVICE(ANCESTOR: X + Y)
|
|
M = M + 1
|
|
!CHECK: !$OMP END TARGET
|
|
!$OMP END TARGET
|
|
|
|
!PARSE-TREE: OmpBeginDirective
|
|
!PARSE-TREE: OmpDirectiveName -> llvm::omp::Directive = target
|
|
!PARSE-TREE: OmpClauseList -> OmpClause -> Device -> OmpDeviceClause
|
|
!PARSE-TREE: OmpDeviceModifier -> Value = Ancestor
|
|
!PARSE-TREE: Scalar -> Integer -> Expr = 'x+y'
|
|
!PARSE-TREE: Add
|
|
!PARSE-TREE: Expr = 'x'
|
|
!PARSE-TREE: Designator -> DataRef -> Name = 'x'
|
|
!PARSE-TREE: Expr = 'y'
|
|
!PARSE-TREE: Designator -> DataRef -> Name = 'y'
|
|
!PARSE-TREE: OmpEndDirective
|
|
!PARSE-TREE: OmpDirectiveName -> llvm::omp::Directive = target
|
|
!PARSE-TREE: OmpClauseList ->
|
|
|
|
|
|
!-------------------------------------------------------------------
|
|
! Check Device Devive-Num clause with a variable expression argument
|
|
!-------------------------------------------------------------------
|
|
!CHECK: !$OMP TARGET DEVICE(DEVICE_NUM: X-Y)
|
|
!$OMP TARGET DEVICE(DEVICE_NUM: X - Y)
|
|
M = M + 1
|
|
!CHECK: !$OMP END TARGET
|
|
!$OMP END TARGET
|
|
|
|
!PARSE-TREE: OmpBeginDirective
|
|
!PARSE-TREE: OmpDirectiveName -> llvm::omp::Directive = target
|
|
!PARSE-TREE: OmpClauseList -> OmpClause -> Device -> OmpDeviceClause
|
|
!PARSE-TREE: OmpDeviceModifier -> Value = Device_Num
|
|
!PARSE-TREE: Scalar -> Integer -> Expr = 'x-y'
|
|
!PARSE-TREE: Subtract
|
|
!PARSE-TREE: Expr = 'x'
|
|
!PARSE-TREE: Designator -> DataRef -> Name = 'x'
|
|
!PARSE-TREE: Expr = 'y'
|
|
!PARSE-TREE: Designator -> DataRef -> Name = 'y'
|
|
!PARSE-TREE: OmpEndDirective
|
|
!PARSE-TREE: OmpDirectiveName -> llvm::omp::Directive = target
|
|
END PROGRAM
|