1 /*
2  * Copyright (c) 2018, NVIDIA CORPORATION.  All rights reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 
18 #ifndef LL_FTN_H_
19 #define LL_FTN_H_
20 
21 #include "gbldefs.h"
22 #include "symtab.h"
23 #include "ll_structure.h"
24 
25 extern SPTR master_sptr;
26 
27 /**
28    \brief ...
29  */
30 ISZ_T get_socptr_offset(int sptr);
31 
32 /**
33    \brief ...
34  */
35 bool has_multiple_entries(int sptr);
36 
37 /**
38    \brief ...
39  */
40 bool is_fastcall(int ilix);
41 
42 /**
43    \brief ...
44  */
45 char *get_entret_arg_name(void);
46 
47 /**
48    \brief ...
49  */
50 char *get_llvm_ifacenm(SPTR sptr);
51 
52 /**
53    \brief ...
54  */
55 char *get_local_overlap_var(void);
56 
57 /// This function collect all arguments from all Entry include main routine,
58 /// removing the duplicates, put into new dpdsc
59 /// Returns the master_sptr value
60 int get_entries_argnum(void);
61 
62 /**
63    \brief ...
64  */
65 SPTR get_iface_sptr(SPTR sptr);
66 
67 /**
68    \brief ...
69  */
70 SPTR get_master_sptr(void);
71 
72 /**
73    \brief ...
74  */
75 DTYPE get_return_type(SPTR func_sptr);
76 
77 /**
78    \brief ...
79  */
80 int is_iso_cptr(DTYPE d_dtype);
81 
82 /**
83    \brief ...
84  */
85 int mk_charlen_address(int sptr);
86 
87 /**
88    \brief ...
89  */
90 LL_Type *get_ftn_lltype(SPTR sptr);
91 
92 /**
93    \brief ...
94  */
95 LL_Type *get_local_overlap_vartype(void);
96 
97 /**
98    \brief ...
99  */
100 void assign_array_lltype(DTYPE dtype, int size, int sptr);
101 
102 /**
103    \brief ...
104  */
105 void fix_llvm_fptriface(void);
106 
107 /**
108    \brief ...
109  */
110 void get_local_overlap_size(void);
111 
112 /**
113    \brief ...
114  */
115 void ll_process_routine_parameters(SPTR func_sptr);
116 
117 /**
118    \brief Write out all Entry's as a separate routine
119 
120    Each entry will call a master/common routine (MCR).  The first argument to
121    the MCR will determine which label(Entry) control will jump to upon entry
122    into the MCR.  If the MCR is a function, the next argument will be the
123    function's return value.  The next argument(s) will be all non-duplicate
124    aggregate arguments for all entries.  The MCR will always effectively be a
125    subroutine.
126  */
127 void print_entry_subroutine(LL_Module *module);
128 
129 /**
130    \brief ...
131  */
132 void reset_equiv_var(void);
133 
134 /**
135    \brief ...
136  */
137 void reset_master_sptr(void);
138 
139 /**
140    \brief ...
141  */
142 void stb_process_routine_parameters(void);
143 
144 /// Store interface function name in fptr_local table.  This table is done per
145 /// routine.  It stores the name that will be used to search for function
146 /// signature of what it points to.  The interface name is in the form of
147 /// <getname(gbl.currsub)>_$_<getname(iface)>, which is done in
148 /// get_llvm_ifacenm().
149 void store_llvm_localfptr(void);
150 
151 /**
152    \brief ...
153  */
154 void write_llvm_lltype(int sptr);
155 
156 /**
157    \brief ...
158  */
159 void write_local_overlap(void);
160 
161 /**
162    \brief ...
163  */
164 void write_master_entry_routine(void);
165 
166 /**
167    \brief ...
168  */
169 bool need_charlen(DTYPE);
170 
171 #endif // LL_FTN_H_
172