OpenADFortTk (including Open64 and OpenAnalysis references)
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
main.cxx
Go to the documentation of this file.
1
// -*-Mode: C++;-*-
2
// $Header: /Volumes/cvsrep/developer/OpenADFortTk/src/sexp2whirl/main.cxx,v 1.4 2005/01/12 20:01:01 eraxxon Exp $
3
4
#include <fcntl.h>
// for use in ReadWhirlSexp()
5
#include <errno.h>
// for use in ReadWhirlSexp()
6
7
#include <sexp.h>
8
9
#include "
Open64IRInterface/Open64BasicTypes.h
"
10
#include "
cmplrs/rcodes.h
"
// return codes
11
#include "
tracing.h
"
// trace routines
12
#include "
ir_reader.h
"
// fdump_tree
13
#include "
Open64IRInterface/WhirlIO.h
"
14
#include "
Open64IRInterface/IFDiagnostics.h
"
15
16
#include "
Diagnostics.h
"
17
#include "
Exception.h
"
18
19
#include "
Args.h
"
20
#include "
sexp2whirl.h
"
21
22
static
int
real_main
(
int
argc,
char
**argv);
23
24
static
sexp_t*
ReadWhirlSexp
(
const
char
* filename);
25
26
27
int
28
main
(
int
argc,
char
**argv)
29
{
30
try
{
31
return
real_main
(argc, argv);
32
}
33
catch
(
CmdLineParser::Exception
& e) {
34
e.
Report
(cerr);
// fatal error
35
exit(1);
36
}
37
catch
(
fortTkSupport::BaseException
& e) {
38
e.
Report
(cerr);
39
exit(1);
40
}
41
catch
(...) {
42
cerr <<
"Unknown exception caught\n"
;
43
exit(1);
44
}
45
// FIXME: catch badalloc?
46
}
47
48
static
int
49
real_main
(
int
argc,
char
**argv)
50
{
51
// -------------------------------------------------------
52
// 1. Open64 Initialization
53
// -------------------------------------------------------
54
Handle_Signals
();
55
MEM_Initialize
();
56
Init_Error_Handler
( 100 );
57
Set_Error_Line
(
ERROR_LINE_UNKNOWN
);
58
Set_Error_File
(
NULL
);
59
Set_Error_Phase
(
"sexp2whirl"
);
60
IR_set_dump_order
(
TRUE
/*pre*/
);
// pre-order trees when debugging, please!
61
62
#ifdef Is_True_On
63
if
(
Get_Trace
(
TKIND_ALLOC
,
TP_MISC
)) {
64
MEM_Tracing_Enable
();
65
}
66
#endif
67
68
Preconfigure
();
// from config.cxx...
69
Configure
();
// needed for WN_lower!
70
Configure_Source
(
NULL
);
// Most config variables set here
71
72
Init_Operator_To_Opcode_Table
();
// FIXME
73
74
// -------------------------------------------------------
75
// 2. Local initialization (options, etc.)
76
// -------------------------------------------------------
77
Diag_Init
();
78
Diag_Set_Max_Diags
(100);
// Maximum 100 warnings by default
79
Diag_Set_Phase
(
"WHIRL to sexp: driver"
);
80
81
Args
args(argc, argv);
82
fortTkSupport::Diagnostics::setDiagnosticFilterLevel
(args.
debug
);
83
84
// -------------------------------------------------------
85
// 3. Read S-expressions and Translate into WHIRL
86
// -------------------------------------------------------
87
88
sexp_t* ir_sexp =
ReadWhirlSexp
(args.
sexpFileNm
.c_str());
89
90
PU_Info
* ir_whirl =
sexp2whirl::TranslateIR
(ir_sexp);
91
//sexp2whirl::DumpIR(ir_sexp, sexp2whirl::XlateFlags::NONE);
92
93
WriteIR
(args.
whirlFileNm
.c_str(), ir_whirl);
94
95
destroy_sexp(ir_sexp);
96
sexp_cleanup();
97
98
// -------------------------------------------------------
99
// 4. Finalization
100
// -------------------------------------------------------
101
102
// If we've seen errors, note them and terminate
103
INT
local_ecount, local_wcount;
104
if
(
Get_Error_Count
( &local_ecount, &local_wcount ) ) {
105
Terminate
(
Had_Internal_Error
() ?
RC_INTERNAL_ERROR
:
106
RC_NORECOVER_USER_ERROR
);
107
}
108
109
Diag_Exit
();
110
Cleanup_Files
(
TRUE
,
FALSE
);
// Open64
111
112
return
RC_OKAY
;
113
}
114
115
116
//***************************************************************************
117
//
118
//***************************************************************************
119
120
static
sexp_t*
121
ReadWhirlSexp
(
const
char
* filename)
122
{
123
// see readtests.c (FIXME)
124
int
fd = open(filename, O_RDONLY);
125
if
(fd < 0) {
126
FORTTK_DIE
(
"Error opening "
<< filename <<
": "
<< strerror(
errno
));
127
}
128
129
sexp_iowrap_t* iow = init_iowrap(fd);
130
sexp_t* sexp = read_one_sexp(iow);
131
return
sexp;
132
}
133
134
nfs
mercurial
ad
OpenADFortTk
src
sexp2whirl
main.cxx
Generated on Fri Mar 14 2014 04:22:51 for OpenADFortTk (including Open64 and OpenAnalysis references) by
1.8.4