Skip to content

Commit 23213ad

Browse files
committed
Convert flang2 to a C++ project
1 parent 804313c commit 23213ad

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+1376
-1330
lines changed

include/flang/Error/pgerror.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424

2525
#include "universal.h"
2626

27+
#ifndef IN_FLANG2
2728
BEGIN_DECL_WITH_C_LINKAGE
29+
#endif
2830

2931
/** \brief Severity of an error message.
3032
*/
@@ -37,10 +39,18 @@ typedef enum error_severity {
3739
ERR_SEVERITY_SIZE // must be last!
3840
} error_severity;
3941

42+
#ifdef IN_FLANG2
43+
#include "errmsgdf.h"
44+
#endif
45+
4046
/** \brief Error code type
4147
*/
4248
typedef enum error_code error_code_t;
4349

50+
#ifdef IN_FLANG2
51+
#include "error.h"
52+
#endif
53+
4454
#ifdef FE90
4555
void errWithSrc(error_code_t ecode, enum error_severity sev, int eline,
4656
const char *op1, const char *op2, int col, int deduceCol,
@@ -82,6 +92,8 @@ void dassert_err(const char *, int line, const char *exp, const char *txt);
8292
void asrt_failed(const char* file, int line);
8393
#endif
8494

95+
#ifndef IN_FLANG2
8596
END_DECL_WITH_C_LINKAGE
97+
#endif
8698

8799
#endif /* PGERROR_H_ */

lib/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
2+
# Copyright (c) 2015-2018, NVIDIA CORPORATION. All rights reserved.
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
@@ -14,6 +14,8 @@
1414
# limitations under the License.
1515
#
1616

17+
set(LIB_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} PARENT_SCOPE)
18+
1719
add_subdirectory(ADT)
1820
add_subdirectory(ArgParser)
1921
add_subdirectory(scutil)

tools/flang1/flang1exe/symacc.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,15 @@ sym_init_first(void)
5454

5555
if (stb.stg_base == NULL) {
5656
STG_ALLOC(stb, 1000);
57-
assert(stb.stg_base, "sym_init: no room for symtab", stb.stg_size, ERR_Fatal);
57+
assert(stb.stg_base, "sym_init: no room for symtab", stb.stg_size,
58+
ERR_Fatal);
5859
stb.n_size = 5024;
5960
NEW(stb.n_base, char, stb.n_size);
6061
assert(stb.n_base, "sym_init: no room for namtab", stb.n_size, ERR_Fatal);
6162
stb.n_base[0] = 0;
6263
STG_ALLOC(stb.dt, 400);
63-
assert(stb.dt.stg_base, "sym_init: no room for dtypes", stb.dt.stg_size, ERR_Fatal);
64+
assert(stb.dt.stg_base, "sym_init: no room for dtypes", stb.dt.stg_size,
65+
ERR_Fatal);
6466
/* basically, this is sidecar of dt_base */
6567

6668
stb.w_size = 32;
@@ -98,7 +100,8 @@ realloc_sym_storage()
98100
DEBUG_ASSERT(stb.stg_size > 0,
99101
"realloc_sym_storage: symbol storage not initialized?");
100102
STG_NEED(stb);
101-
DEBUG_ASSERT(stb.stg_avail <= stb.stg_size, "realloc_sym_storage: internal error");
103+
DEBUG_ASSERT(stb.stg_avail <= stb.stg_size,
104+
"realloc_sym_storage: internal error");
102105
}
103106

104107
/**
@@ -112,8 +115,8 @@ SPTR
112115
lookupsym(const char *name, int olength)
113116
{
114117
int length;
115-
SPTR sptr; /* pointer to symbol table entry */
116-
INT hashval; /* index into hashtb. */
118+
SPTR sptr; /* pointer to symbol table entry */
119+
INT hashval; /* index into hashtb. */
117120

118121
/*
119122
* Loop thru the appropriate hash link list to see if symbol is
@@ -208,8 +211,8 @@ SPTR
208211
installsym_ex(const char *name, int olength, IS_MODE mode)
209212
{
210213
int length;
211-
SPTR sptr; /* pointer to symbol table entry */
212-
INT hashval; /* index into hashtb. */
214+
SPTR sptr; /* pointer to symbol table entry */
215+
INT hashval; /* index into hashtb. */
213216
bool toolong;
214217
int nmptr;
215218
static int max_idlen = MAXIDLEN;
@@ -464,15 +467,13 @@ is_cimag_flt0(SPTR sptr)
464467
bool
465468
is_cmplx_dbl0(SPTR sptr)
466469
{
467-
return is_dbl0((SPTR)CONVAL1G(sptr)) && // ???
468-
is_dbl0((SPTR)CONVAL2G(sptr)); // ???
470+
return is_dbl0(SymConval1(sptr)) && is_dbl0(SymConval2(sptr));
469471
}
470472

471473
bool
472474
is_cmplx_quad0(SPTR sptr)
473475
{
474-
return is_quad0((SPTR)CONVAL1G(sptr)) && // ???
475-
is_quad0((SPTR)CONVAL2G(sptr)); // ???
476+
return is_quad0(SymConval1(sptr)) && is_quad0(SymConval2(sptr));
476477
}
477478

478479
void

tools/flang1/flang1exe/symacc.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,11 +240,15 @@ typedef struct {
240240
extern STB stb;
241241

242242
#ifdef __cplusplus
243-
inline SPTR SymConv1(SPTR sptr) {
243+
inline SPTR SymConval1(SPTR sptr) {
244244
return static_cast<SPTR>(CONVAL1G(sptr));
245245
}
246+
inline SPTR SymConval2(SPTR sptr) {
247+
return static_cast<SPTR>(CONVAL2G(sptr));
248+
}
246249
#else
247-
#define SymConv1 CONVAL1G
250+
#define SymConval1 CONVAL1G
251+
#define SymConval2 CONVAL2G
248252
#endif
249253

250254
/** mode parameter for installsym_ex. */

tools/flang2/flang2exe/CMakeLists.txt

Lines changed: 74 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -16,83 +16,79 @@
1616

1717
if( ${TARGET_ARCHITECTURE} STREQUAL "x86_64" )
1818
set(ARCH_DEP_FILES
19-
x86_64-Linux/ll_abi.c
19+
x86_64-Linux/ll_abi.cpp
2020
)
2121
elseif( ${TARGET_ARCHITECTURE} STREQUAL "aarch64" )
2222
set(ARCH_DEP_FILES
23-
aarch64-Linux/ll_abi.c
23+
aarch64-Linux/ll_abi.cpp
2424
)
2525
elseif( ${TARGET_ARCHITECTURE} STREQUAL "ppc64le" )
2626
set(ARCH_DEP_FILES
27-
ppc64le-Linux/ll_abi.c
27+
ppc64le-Linux/ll_abi.cpp
2828
)
2929
endif()
3030

31-
3231
set(SOURCES
3332
${ARCH_DEP_FILES}
34-
bihutil.c
35-
dinitutl.c
36-
dinit.c
37-
dtypeutl.c
38-
fenddf.c
39-
ilmutil.c
40-
listing.c
41-
mwd.c
42-
semsym.c
43-
semutil0.c
44-
symtab.c
45-
symacc.c
46-
upper.c
47-
xref.c
48-
expreg.c
49-
exputil.c
50-
regutil.c
51-
expdf.c
52-
ili-rewrite.c
53-
ilidf.c
54-
iliutil.c
55-
iltutil.c
56-
expand.c
57-
expatomics.c
58-
expsmp.c
59-
exp_ftn.c
60-
exp_fvec.c
61-
exp_rte.c
62-
outliner.c
63-
rmsmove.c
64-
scope.c
65-
rbtree.c
66-
ll_dbgutl.c
67-
dwarf_names.c
68-
llassem.c
69-
llassem_common.c
70-
asm_anno.c
71-
main.c
72-
version.c
73-
cgmain.c
74-
fastset.c
75-
lldebug.c
76-
llutil.c
77-
ll_ftn.c
78-
ll_structure.c
79-
ll_write.c
80-
ll_builder.c
81-
llopt.c
82-
llsched.c
83-
machreg.c
84-
kmpcutil.c
85-
verify.c
33+
bihutil.cpp
34+
dinitutl.cpp
35+
dinit.cpp
36+
dtypeutl.cpp
37+
fenddf.cpp
38+
ilmutil.cpp
39+
listing.cpp
40+
mwd.cpp
41+
semsym.cpp
42+
semutil0.cpp
43+
symtab.cpp
44+
symacc.cpp
45+
upper.cpp
46+
xref.cpp
47+
expreg.cpp
48+
exputil.cpp
49+
regutil.cpp
50+
expdf.cpp
51+
ili-rewrite.cpp
52+
ilidf.cpp
53+
iliutil.cpp
54+
iltutil.cpp
55+
expand.cpp
56+
expatomics.cpp
57+
expsmp.cpp
58+
exp_ftn.cpp
59+
exp_fvec.cpp
60+
exp_rte.cpp
61+
outliner.cpp
62+
rmsmove.cpp
63+
scope.cpp
64+
rbtree.cpp
65+
ll_dbgutl.cpp
66+
dwarf_names.cpp
67+
llassem.cpp
68+
llassem_common.cpp
69+
asm_anno.cpp
70+
main.cpp
71+
version.cpp
72+
cgmain.cpp
73+
fastset.cpp
74+
lldebug.cpp
75+
llutil.cpp
76+
ll_ftn.cpp
77+
ll_structure.cpp
78+
ll_write.cpp
79+
ll_builder.cpp
80+
llopt.cpp
81+
llsched.cpp
82+
machreg.cpp
83+
kmpcutil.cpp
84+
verify.cpp
8685
kmpcutil.h
8786
)
8887

8988
set(COMMON_DEFS
9089
MMD
9190
NOVECTORIZE
92-
)
93-
94-
set(COMPILE_OPTS
95-
-std=c11
91+
IN_FLANG2
9692
)
9793

9894
set(INCLUDE_DIRS
@@ -110,8 +106,25 @@ set(INCLUDE_DIRS
110106
${UTILS_SHARED_DIR}
111107
)
112108

109+
set(SHARED_SOURCES
110+
${SHARED_SOURCES}
111+
${LIB_SOURCE_DIR}/ADT/hash.c
112+
${LIB_SOURCE_DIR}/ArgParser/arg_parser.c
113+
${LIB_SOURCE_DIR}/ArgParser/debug_action.c
114+
${LIB_SOURCE_DIR}/ArgParser/xflag.c
115+
)
116+
117+
118+
foreach(FILE ${SHARED_SOURCES})
119+
get_filename_component(TOFILE ${FILE} NAME)
120+
add_custom_command(OUTPUT ${TOFILE}pp
121+
COMMAND ${CMAKE_COMMAND} -E create_symlink ${FILE} ${TOFILE}pp
122+
MAIN_DEPENDENCY ${FILE})
123+
set(SHARED_CPP_SOURCES ${SHARED_CPP_SOURCES} ${TOFILE}pp)
124+
endforeach()
125+
113126
add_flang_executable(flang2
114-
${SOURCES} ${SHARED_SOURCES}
127+
${SOURCES} ${SHARED_CPP_SOURCES}
115128
)
116129

117130
target_compile_definitions(flang2

tools/flang2/flang2exe/aarch64-Linux/ll_abi.c renamed to tools/flang2/flang2exe/aarch64-Linux/ll_abi.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
2+
* Copyright (c) 2014-2018, NVIDIA CORPORATION. All rights reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -26,6 +26,7 @@
2626
#include "symtab.h"
2727
#include "llutil.h"
2828
#include "ll_structure.h"
29+
#include "dtypeutl.h"
2930

3031
#define DT_VOIDNONE DT_NONE
3132

@@ -59,7 +60,7 @@ update_homogeneous(void *context, DTYPE dtype, unsigned address,
5960
dtype = DT_BASETYPE(dtype);
6061

6162
if (DTY(dtype) == TY_ARRAY)
62-
dtype = DTY(dtype + 1);
63+
dtype = (DTYPE)DTY(dtype + 1); // ???
6364

6465
switch (dtype) {
6566
case DT_CMPLX:

0 commit comments

Comments
 (0)