Skip to content
Permalink
Browse files

Convert flang2 to a C++ project

  • Loading branch information...
gklimowicz committed Sep 12, 2018
1 parent 804313c commit 23213ad759e2cb5f05798cb35d3e354564f9d649
Showing with 1,376 additions and 1,330 deletions.
  1. +12 −0 include/flang/Error/pgerror.h
  2. +3 −1 lib/CMakeLists.txt
  3. +12 −11 tools/flang1/flang1exe/symacc.c
  4. +6 −2 tools/flang1/flang1exe/symacc.h
  5. +74 −61 tools/flang2/flang2exe/CMakeLists.txt
  6. +3 −2 tools/flang2/flang2exe/aarch64-Linux/{ll_abi.c → ll_abi.cpp}
  7. 0 tools/flang2/flang2exe/{asm_anno.c → asm_anno.cpp}
  8. 0 tools/flang2/flang2exe/{bihutil.c → bihutil.cpp}
  9. +135 −114 tools/flang2/flang2exe/{cgmain.c → cgmain.cpp}
  10. 0 tools/flang2/flang2exe/{dinit.c → dinit.cpp}
  11. 0 tools/flang2/flang2exe/{dinitutl.c → dinitutl.cpp}
  12. 0 tools/flang2/flang2exe/{dtypeutl.c → dtypeutl.cpp}
  13. +1 −1 tools/flang2/flang2exe/{dwarf_names.c → dwarf_names.cpp}
  14. +15 −11 tools/flang2/flang2exe/{exp_ftn.c → exp_ftn.cpp}
  15. 0 tools/flang2/flang2exe/{exp_fvec.c → exp_fvec.cpp}
  16. +9 −9 tools/flang2/flang2exe/{exp_rte.c → exp_rte.cpp}
  17. +1 −1 tools/flang2/flang2exe/exp_rte.h
  18. +125 −131 tools/flang2/flang2exe/{expand.c → expand.cpp}
  19. 0 tools/flang2/flang2exe/{expatomics.c → expatomics.cpp}
  20. +1 −1 tools/flang2/flang2exe/{expdf.c → expdf.cpp}
  21. 0 tools/flang2/flang2exe/{expreg.c → expreg.cpp}
  22. +41 −41 tools/flang2/flang2exe/{expsmp.c → expsmp.cpp}
  23. 0 tools/flang2/flang2exe/{exputil.c → exputil.cpp}
  24. 0 tools/flang2/flang2exe/{fastset.c → fastset.cpp}
  25. +1 −1 tools/flang2/flang2exe/{fenddf.c → fenddf.cpp}
  26. 0 tools/flang2/flang2exe/{ili-rewrite.c → ili-rewrite.cpp}
  27. +8 −0 tools/flang2/flang2exe/ili.h
  28. +1 −1 tools/flang2/flang2exe/{ilidf.c → ilidf.cpp}
  29. +711 −747 tools/flang2/flang2exe/{iliutil.c → iliutil.cpp}
  30. 0 tools/flang2/flang2exe/{ilmutil.c → ilmutil.cpp}
  31. 0 tools/flang2/flang2exe/{iltutil.c → iltutil.cpp}
  32. 0 tools/flang2/flang2exe/{kmpcutil.c → kmpcutil.cpp}
  33. +21 −19 tools/flang2/flang2exe/kmpcutil.h
  34. 0 tools/flang2/flang2exe/{listing.c → listing.cpp}
  35. 0 tools/flang2/flang2exe/{ll_builder.c → ll_builder.cpp}
  36. 0 tools/flang2/flang2exe/{ll_dbgutl.c → ll_dbgutl.cpp}
  37. +3 −3 tools/flang2/flang2exe/{ll_ftn.c → ll_ftn.cpp}
  38. 0 tools/flang2/flang2exe/{ll_structure.c → ll_structure.cpp}
  39. 0 tools/flang2/flang2exe/{ll_write.c → ll_write.cpp}
  40. +16 −16 tools/flang2/flang2exe/{llassem.c → llassem.cpp}
  41. +11 −14 tools/flang2/flang2exe/llassem.h
  42. +10 −11 tools/flang2/flang2exe/{llassem_common.c → llassem_common.cpp}
  43. +1 −1 tools/flang2/flang2exe/llassem_common.h
  44. 0 tools/flang2/flang2exe/{lldebug.c → lldebug.cpp}
  45. +1 −1 tools/flang2/flang2exe/{llopt.c → llopt.cpp}
  46. 0 tools/flang2/flang2exe/{llsched.c → llsched.cpp}
  47. +3 −3 tools/flang2/flang2exe/{llutil.c → llutil.cpp}
  48. +0 −4 tools/flang2/flang2exe/llutil.h
  49. 0 tools/flang2/flang2exe/{machreg.c → machreg.cpp}
  50. 0 tools/flang2/flang2exe/{main.c → main.cpp}
  51. +1 −1 tools/flang2/flang2exe/{mwd.c → mwd.cpp}
  52. +5 −4 tools/flang2/flang2exe/{outliner.c → outliner.cpp}
  53. +1 −1 tools/flang2/flang2exe/outliner.h
  54. +4 −3 tools/flang2/flang2exe/ppc64le-Linux/{ll_abi.c → ll_abi.cpp}
  55. +1 −1 tools/flang2/flang2exe/{rbtree.c → rbtree.cpp}
  56. 0 tools/flang2/flang2exe/{regutil.c → regutil.cpp}
  57. 0 tools/flang2/flang2exe/{rmsmove.c → rmsmove.cpp}
  58. 0 tools/flang2/flang2exe/{scope.c → scope.cpp}
  59. +18 −12 tools/flang2/flang2exe/{semsym.c → semsym.cpp}
  60. 0 tools/flang2/flang2exe/{semutil0.c → semutil0.cpp}
  61. +12 −11 tools/flang2/flang2exe/{symacc.c → symacc.cpp}
  62. +6 −2 tools/flang2/flang2exe/symacc.h
  63. +57 −58 tools/flang2/flang2exe/{symtab.c → symtab.cpp}
  64. +1 −2 tools/flang2/flang2exe/{upper.c → upper.cpp}
  65. 0 tools/flang2/flang2exe/{verify.c → verify.cpp}
  66. 0 tools/flang2/flang2exe/{version.c → version.cpp}
  67. 0 tools/flang2/flang2exe/x86_64-Linux/{ll_abi.c → ll_abi.cpp}
  68. 0 tools/flang2/flang2exe/{xref.c → xref.cpp}
  69. +8 −6 tools/flang2/utils/symtab/symtab.in.h
  70. +5 −0 tools/shared/expand.h
  71. +2 −7 tools/shared/nmeutil.c
  72. +5 −2 tools/shared/nmeutil.h
  73. +7 −0 tools/shared/symfun.h
  74. +12 −11 tools/shared/utils/symacc.c
  75. +6 −2 tools/shared/utils/symacc.h
@@ -24,7 +24,9 @@

#include "universal.h"

#ifndef IN_FLANG2
BEGIN_DECL_WITH_C_LINKAGE
#endif

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

#ifdef IN_FLANG2
#include "errmsgdf.h"
#endif

/** \brief Error code type
*/
typedef enum error_code error_code_t;

#ifdef IN_FLANG2
#include "error.h"
#endif

#ifdef FE90
void errWithSrc(error_code_t ecode, enum error_severity sev, int eline,
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);
void asrt_failed(const char* file, int line);
#endif

#ifndef IN_FLANG2
END_DECL_WITH_C_LINKAGE
#endif

#endif /* PGERROR_H_ */
@@ -1,5 +1,5 @@
#
# Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
# Copyright (c) 2015-2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -14,6 +14,8 @@
# limitations under the License.
#

set(LIB_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} PARENT_SCOPE)

add_subdirectory(ADT)
add_subdirectory(ArgParser)
add_subdirectory(scutil)
@@ -54,13 +54,15 @@ sym_init_first(void)

if (stb.stg_base == NULL) {
STG_ALLOC(stb, 1000);
assert(stb.stg_base, "sym_init: no room for symtab", stb.stg_size, ERR_Fatal);
assert(stb.stg_base, "sym_init: no room for symtab", stb.stg_size,
ERR_Fatal);
stb.n_size = 5024;
NEW(stb.n_base, char, stb.n_size);
assert(stb.n_base, "sym_init: no room for namtab", stb.n_size, ERR_Fatal);
stb.n_base[0] = 0;
STG_ALLOC(stb.dt, 400);
assert(stb.dt.stg_base, "sym_init: no room for dtypes", stb.dt.stg_size, ERR_Fatal);
assert(stb.dt.stg_base, "sym_init: no room for dtypes", stb.dt.stg_size,
ERR_Fatal);
/* basically, this is sidecar of dt_base */

stb.w_size = 32;
@@ -98,7 +100,8 @@ realloc_sym_storage()
DEBUG_ASSERT(stb.stg_size > 0,
"realloc_sym_storage: symbol storage not initialized?");
STG_NEED(stb);
DEBUG_ASSERT(stb.stg_avail <= stb.stg_size, "realloc_sym_storage: internal error");
DEBUG_ASSERT(stb.stg_avail <= stb.stg_size,
"realloc_sym_storage: internal error");
}

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

/*
* Loop thru the appropriate hash link list to see if symbol is
@@ -208,8 +211,8 @@ SPTR
installsym_ex(const char *name, int olength, IS_MODE mode)
{
int length;
SPTR sptr; /* pointer to symbol table entry */
INT hashval; /* index into hashtb. */
SPTR sptr; /* pointer to symbol table entry */
INT hashval; /* index into hashtb. */
bool toolong;
int nmptr;
static int max_idlen = MAXIDLEN;
@@ -464,15 +467,13 @@ is_cimag_flt0(SPTR sptr)
bool
is_cmplx_dbl0(SPTR sptr)
{
return is_dbl0((SPTR)CONVAL1G(sptr)) && // ???
is_dbl0((SPTR)CONVAL2G(sptr)); // ???
return is_dbl0(SymConval1(sptr)) && is_dbl0(SymConval2(sptr));
}

bool
is_cmplx_quad0(SPTR sptr)
{
return is_quad0((SPTR)CONVAL1G(sptr)) && // ???
is_quad0((SPTR)CONVAL2G(sptr)); // ???
return is_quad0(SymConval1(sptr)) && is_quad0(SymConval2(sptr));
}

void
@@ -240,11 +240,15 @@ typedef struct {
extern STB stb;

#ifdef __cplusplus
inline SPTR SymConv1(SPTR sptr) {
inline SPTR SymConval1(SPTR sptr) {
return static_cast<SPTR>(CONVAL1G(sptr));
}
inline SPTR SymConval2(SPTR sptr) {
return static_cast<SPTR>(CONVAL2G(sptr));
}
#else
#define SymConv1 CONVAL1G
#define SymConval1 CONVAL1G
#define SymConval2 CONVAL2G
#endif

/** mode parameter for installsym_ex. */
@@ -16,83 +16,79 @@

if( ${TARGET_ARCHITECTURE} STREQUAL "x86_64" )
set(ARCH_DEP_FILES
x86_64-Linux/ll_abi.c
x86_64-Linux/ll_abi.cpp
)
elseif( ${TARGET_ARCHITECTURE} STREQUAL "aarch64" )
set(ARCH_DEP_FILES
aarch64-Linux/ll_abi.c
aarch64-Linux/ll_abi.cpp
)
elseif( ${TARGET_ARCHITECTURE} STREQUAL "ppc64le" )
set(ARCH_DEP_FILES
ppc64le-Linux/ll_abi.c
ppc64le-Linux/ll_abi.cpp
)
endif()


set(SOURCES
${ARCH_DEP_FILES}
bihutil.c
dinitutl.c
dinit.c
dtypeutl.c
fenddf.c
ilmutil.c
listing.c
mwd.c
semsym.c
semutil0.c
symtab.c
symacc.c
upper.c
xref.c
expreg.c
exputil.c
regutil.c
expdf.c
ili-rewrite.c
ilidf.c
iliutil.c
iltutil.c
expand.c
expatomics.c
expsmp.c
exp_ftn.c
exp_fvec.c
exp_rte.c
outliner.c
rmsmove.c
scope.c
rbtree.c
ll_dbgutl.c
dwarf_names.c
llassem.c
llassem_common.c
asm_anno.c
main.c
version.c
cgmain.c
fastset.c
lldebug.c
llutil.c
ll_ftn.c
ll_structure.c
ll_write.c
ll_builder.c
llopt.c
llsched.c
machreg.c
kmpcutil.c
verify.c
bihutil.cpp
dinitutl.cpp
dinit.cpp
dtypeutl.cpp
fenddf.cpp
ilmutil.cpp
listing.cpp
mwd.cpp
semsym.cpp
semutil0.cpp
symtab.cpp
symacc.cpp
upper.cpp
xref.cpp
expreg.cpp
exputil.cpp
regutil.cpp
expdf.cpp
ili-rewrite.cpp
ilidf.cpp
iliutil.cpp
iltutil.cpp
expand.cpp
expatomics.cpp
expsmp.cpp
exp_ftn.cpp
exp_fvec.cpp
exp_rte.cpp
outliner.cpp
rmsmove.cpp
scope.cpp
rbtree.cpp
ll_dbgutl.cpp
dwarf_names.cpp
llassem.cpp
llassem_common.cpp
asm_anno.cpp
main.cpp
version.cpp
cgmain.cpp
fastset.cpp
lldebug.cpp
llutil.cpp
ll_ftn.cpp
ll_structure.cpp
ll_write.cpp
ll_builder.cpp
llopt.cpp
llsched.cpp
machreg.cpp
kmpcutil.cpp
verify.cpp
kmpcutil.h
)

set(COMMON_DEFS
MMD
NOVECTORIZE
)

set(COMPILE_OPTS
-std=c11
IN_FLANG2
)

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

set(SHARED_SOURCES
${SHARED_SOURCES}
${LIB_SOURCE_DIR}/ADT/hash.c
${LIB_SOURCE_DIR}/ArgParser/arg_parser.c
${LIB_SOURCE_DIR}/ArgParser/debug_action.c
${LIB_SOURCE_DIR}/ArgParser/xflag.c
)


foreach(FILE ${SHARED_SOURCES})
get_filename_component(TOFILE ${FILE} NAME)
add_custom_command(OUTPUT ${TOFILE}pp
COMMAND ${CMAKE_COMMAND} -E create_symlink ${FILE} ${TOFILE}pp
MAIN_DEPENDENCY ${FILE})
set(SHARED_CPP_SOURCES ${SHARED_CPP_SOURCES} ${TOFILE}pp)
endforeach()

add_flang_executable(flang2
${SOURCES} ${SHARED_SOURCES}
${SOURCES} ${SHARED_CPP_SOURCES}
)

target_compile_definitions(flang2
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
* Copyright (c) 2014-2018, NVIDIA CORPORATION. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,6 +26,7 @@
#include "symtab.h"
#include "llutil.h"
#include "ll_structure.h"
#include "dtypeutl.h"

#define DT_VOIDNONE DT_NONE

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

if (DTY(dtype) == TY_ARRAY)
dtype = DTY(dtype + 1);
dtype = (DTYPE)DTY(dtype + 1); // ???

switch (dtype) {
case DT_CMPLX:
Oops, something went wrong.

0 comments on commit 23213ad

Please sign in to comment.
You can’t perform that action at this time.