1 //===- llvm/unittest/IR/OpenMPIRParsingTest.cpp ---------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "llvm/Frontend/OpenMP/OMPConstants.h"
10 #include "gtest/gtest.h"
13 using namespace llvm::omp
;
17 TEST(OpenMPParsingTest
, OpenMPDirectiveKind
) {
18 EXPECT_EQ(getOpenMPDirectiveKind("foobar"), OMPD_unknown
);
20 EXPECT_EQ(getOpenMPDirectiveKind("for"), OMPD_for
);
21 EXPECT_EQ(getOpenMPDirectiveKind("simd"), OMPD_simd
);
22 EXPECT_EQ(getOpenMPDirectiveKind("for simd"), OMPD_for_simd
);
25 TEST(OpenMPParsingTest
, getOpenMPDirectiveName
) {
26 EXPECT_EQ(getOpenMPDirectiveName(OMPD_unknown
), "unknown");
28 EXPECT_EQ(getOpenMPDirectiveName(OMPD_for
), "for");
29 EXPECT_EQ(getOpenMPDirectiveName(OMPD_simd
), "simd");
30 EXPECT_EQ(getOpenMPDirectiveName(OMPD_for_simd
), "for simd");
33 TEST(OpenMPParsingTest
, getOpenMPClauseKind
) {
34 EXPECT_EQ(getOpenMPClauseKind("foobar"), OMPC_unknown
);
36 EXPECT_EQ(getOpenMPClauseKind("schedule"), OMPC_schedule
);
37 EXPECT_EQ(getOpenMPClauseKind("if"), OMPC_if
);
40 TEST(OpenMPParsingTest
, getOpenMPClauseName
) {
41 EXPECT_EQ(getOpenMPClauseName(OMPC_unknown
), "unknown");
43 EXPECT_EQ(getOpenMPClauseName(OMPC_schedule
), "schedule");
44 EXPECT_EQ(getOpenMPClauseName(OMPC_if
), "if");
47 TEST(OpenMPParsingTest
, isAllowedClauseForDirective
) {
48 EXPECT_TRUE(isAllowedClauseForDirective(OMPD_for
, OMPC_schedule
, 30));
49 EXPECT_FALSE(isAllowedClauseForDirective(OMPD_for
, OMPC_num_teams
, 30));
51 EXPECT_FALSE(isAllowedClauseForDirective(OMPD_for
, OMPC_order
, 30));
52 EXPECT_FALSE(isAllowedClauseForDirective(OMPD_for
, OMPC_order
, 45));
53 EXPECT_TRUE(isAllowedClauseForDirective(OMPD_for
, OMPC_order
, 50));
54 EXPECT_TRUE(isAllowedClauseForDirective(OMPD_for
, OMPC_order
, 51));
57 TEST(OpenMPParsingTest
, getOrderKind
) {
58 EXPECT_EQ(getOrderKind("foobar"), OMP_ORDER_unknown
);
59 EXPECT_EQ(getOrderKind("unknown"), OMP_ORDER_unknown
);
60 EXPECT_EQ(getOrderKind("concurrent"), OMP_ORDER_concurrent
);
63 TEST(OpenMPParsingTest
, getProcBindKind
) {
64 EXPECT_EQ(getProcBindKind("foobar"), OMP_PROC_BIND_unknown
);
66 EXPECT_EQ(getProcBindKind("master"), OMP_PROC_BIND_master
);
67 EXPECT_EQ(getProcBindKind("close"), OMP_PROC_BIND_close
);
68 EXPECT_EQ(getProcBindKind("spread"), OMP_PROC_BIND_spread
);
69 EXPECT_EQ(getProcBindKind("default"), OMP_PROC_BIND_default
);
70 EXPECT_EQ(getProcBindKind("unknown"), OMP_PROC_BIND_unknown
);
73 TEST(OpenMPParsingTest
, getScheduleKind
) {
74 EXPECT_EQ(getScheduleKind("foobar"), OMP_SCHEDULE_Default
);
76 EXPECT_EQ(getScheduleKind("static"), OMP_SCHEDULE_Static
);
77 EXPECT_EQ(getScheduleKind("dynamic"), OMP_SCHEDULE_Dynamic
);
78 EXPECT_EQ(getScheduleKind("guided"), OMP_SCHEDULE_Guided
);
79 EXPECT_EQ(getScheduleKind("auto"), OMP_SCHEDULE_Auto
);
80 EXPECT_EQ(getScheduleKind("runtime"), OMP_SCHEDULE_Runtime
);
81 EXPECT_EQ(getScheduleKind("default"), OMP_SCHEDULE_Default
);