YAP 7.1.0
amijit.h
1/*
2 * amijit.h
3 *
4 * Created on: Jan 9, 2015
5 * Author: vsc
6 */
7
8#ifndef AMIJIT_H_
9#define AMIJIT_H_
10
11#if YAP_JIT
12/* Available LLVM (v. 3.1) Analysis Passes */
13typedef enum {
14 e_createAAEvalPass, //Exhaustive Alias Analysis Precision Evaluator
15 e_createAliasAnalysisCounterPass, //Count Alias Analysis Query Responses
16 e_createBasicAliasAnalysisPass, //Basic Alias Analysis (stateless AA impl)
17 e_createCFGOnlyPrinterPass, //Print CFG of function to 'dot' file (with no function bodies)
18 e_createCFGPrinterPass, //Print CFG of function to 'dot' file
19 e_createDbgInfoPrinterPass, //Print debug info in human readable form
20 e_createDomOnlyPrinterPass, //Print dominance tree of function to 'dot' file (with no function bodies)
21 e_createDomPrinterPass, //Print dominance tree of function to 'dot' file
22 e_createGlobalsModRefPass, //Simple mod/ref analysis for globals
23 e_createInstCountPass, //Counts the various types of Instructions
24 e_createIVUsersPass, //Induction Variable Users
25 e_createLazyValueInfoPass, //Lazy Value Information Analysis
26 e_createLibCallAliasAnalysisPass, //LibCall Alias Analysis
27 e_createLintPass, //Statically lint-checks LLVM IR
28 e_createLoopDependenceAnalysisPass, //Loop Dependence Analysis
29 e_createMemDepPrinter, //Memory Dependence Analysis
30 e_createModuleDebugInfoPrinterPass, //Decodes module-level debug info
31 e_createNoAAPass, //No Alias Analysis (always returns 'may' alias)
32 e_createNoPathProfileInfoPass, //No Path Profile Information
33 e_createNoProfileInfoPass, //No Profile Information
34 e_createObjCARCAliasAnalysisPass, //ObjC-ARC-Based Alias Analysis
35 e_createPathProfileLoaderPass, //Loads information from a path profile dump file
36 e_createPathProfileVerifierPass, //Verifies path profiling information
37 e_createPostDomOnlyPrinterPass, //Print postdominance tree of function to 'dot' file (with no function bodies)
38 e_createPostDomPrinterPass, //Print postdominance tree of function to 'dot' file
39 e_createProfileEstimatorPass, //Estimate profiling information
40 e_createProfileLoaderPass, //Load profile information from llvmprof.out
41 e_createProfileVerifierPass, //Verify profiling information
42 e_createRegionInfoPass, //Detect single entry single exit regions
43 e_createRegionOnlyPrinterPass, //Print regions of function to 'dot' file (with no function bodies)
44 e_createRegionPrinterPass, //Print regions of function to 'dot' file
45 e_createScalarEvolutionAliasAnalysisPass, //ScalarEvolution-based Alias Analysis
46 e_createTypeBasedAliasAnalysisPass //Type-Based Alias Analysis
47} enumAnalysisPasses;
48
49/* Available LLVM (v. 3.1) Transform Passes */
50typedef enum{
51 t_createAggressiveDCEPass, //This pass uses the SSA based Aggressive DCE algorithm
52 t_createArgumentPromotionPass, //Promotes "by reference" arguments to be passed by value if the number of elements passed is smaller or equal to maxElement
53 t_createBBVectorizePass, //A basic-block vectorization pass
54 t_createBlockExtractorPass, //Extracts all blocks (except those specified in the argument list) from the functions in the module
55 t_createBlockPlacementPass, //This pass reorders basic blocks in order to increase the number of fall-through conditional branches
56 t_createBreakCriticalEdgesPass, //Break all of the critical edges in the CFG by inserting a dummy basic block
57 t_createCFGSimplificationPass, //Merge basic blocks, eliminate unreachable blocks, simplify terminator instructions, etc...
58 t_createCodeGenPreparePass, //Prepares a function for instruction selection
59 t_createConstantMergePass, //Returns a new pass that merges duplicate global constants together into a single constant that is shared
60 t_createConstantPropagationPass, //A worklist driven constant propagation pass
61 t_createCorrelatedValuePropagationPass, //Propagate CFG-derived value information
62 t_createDeadArgEliminationPass, //This pass removes arguments from functions which are not used by the body of the function
63 t_createDeadArgHackingPass, //Same as DAE, but delete arguments of external functions as well
64 t_createDeadCodeEliminationPass, //This pass is more powerful than DeadInstElimination
65 t_createDeadInstEliminationPass, //Removes trivially dead instructions without modifying the CFG of the function
66 t_createDeadStoreEliminationPass, //Deletes stores that are post-dominated by must-aliased stores and are not loaded used between the stores
67 t_createDemoteRegisterToMemoryPass, //This pass is used to demote registers to memory references
68 t_createEarlyCSEPass, //This pass performs a simple and fast CSE pass over the dominator tree
69 t_createFunctionAttrsPass, //Discovers functions that do not access memory, or only read memory, and gives them the readnone/readonly attribute
70 t_createFunctionInliningPass,
71 t_createGlobalDCEPass, //This transform is designed to eliminate unreachable internal globals (functions or global variables)
72 t_createGlobalOptimizerPass, //Returns a new pass that optimizes non-address taken internal globals
73 t_createGVExtractionPass, //Deletes as much of the module as possible, except for the global values specified
74 t_createGVNPass, //Performs global value numbering and redundant load elimination cotemporaneously
75 t_createIndVarSimplifyPass, //Transform induction variables in a program to all use a single canonical induction variable per loop
76 t_createInstructionCombiningPass, //Combine instructions to form fewer, simple instructions
77 t_createInstructionNamerPass, //Give any unnamed non-void instructions "tmp" names
78 t_createInstructionSimplifierPass, //Remove redundant instructions
79 t_createInternalizePass, //Loops over all of the functions in the input module, internalizing all globals
80 t_createIPConstantPropagationPass, //Propagates constants from call sites into the bodies of functions
81 t_createIPSCCPPass, //Propagates constants from call sites into the bodies of functions, and keeps track of whether basic blocks are executable in the process
82 t_createJumpThreadingPass, //Thread control through mult-pred/multi-succ blocks where some preds always go to some succ
83 t_createLCSSAPass, //This pass inserts phi nodes at loop boundaries to simplify other loop optimizations
84 t_createLICMPass, //Loop invariant code motion and memory promotion pass
85 t_createLoopDeletionPass, //Performs DCE of non-infinite loops that it can prove are dead
86 t_createLoopExtractorPass, //Extracts all natural loops from the program into a function if it can
87 t_createLoopIdiomPass, //Recognizes and replaces idioms in loops
88 t_createLoopInstSimplifyPass, //Simplifies instructions in a loop's body
89 t_createLoopRotatePass, //Simple loop rotating pass
90 t_createLoopSimplifyPass, //Insert Pre-header blocks into the CFG for every function in the module
91 t_createLoopStrengthReducePass, //This pass is strength reduces GEP instructions that use a loop's canonical induction variable as one of their indices
92 t_createLoopUnrollPass, //Simple loop unrolling pass
93 t_createLoopUnswitchPass, //Simple loop unswitching pass
94 t_createLowerAtomicPass, //Lower atomic intrinsics to non-atomic form
95 t_createLowerExpectIntrinsicPass, //Removes llvm.expect intrinsics and creates "block_weights" metadata
96 t_createLowerInvokePass, //Converts invoke and unwind instructions to use sjlj exception handling mechanisms
97 t_createLowerSwitchPass, //Converts SwitchInst instructions into a sequence of chained binary branch instructions
98 t_createMemCpyOptPass, //Performs optimizations related to eliminating memcpy calls and/or combining multiple stores into memset's
99 t_createMergeFunctionsPass, //Discovers identical functions and collapses them
100 t_createObjCARCAPElimPass, //ObjC ARC autorelease pool elimination
101 t_createObjCARCContractPass, //Late ObjC ARC cleanups
102 t_createObjCARCExpandPass, //ObjC ARC preliminary simplifications
103 t_createObjCARCOptPass, //ObjC ARC optimization
104 t_createPartialInliningPass, //Inlines parts of functions
105 t_createPromoteMemoryToRegisterPass, //This pass is used to promote memory references to be register references
106 t_createPruneEHPass, //Return a new pass object which transforms invoke instructions into calls, if the callee can _no t_ unwind the stack
107 t_createReassociatePass, //This pass reassociates commutative expressions in an order that is designed to promote better constant propagation, GCSE, LICM, PRE...
108 t_createScalarReplAggregatesPass, //Break up alloca's of aggregates into multiple allocas if possible.
109 t_createSCCPPass, //Sparse conditional constant propagation
110 t_createSimplifyLibCallsPass, //Optimizes specific calls to specific well-known (library) functions
111 t_createSingleLoopExtractorPass, //Extracts one natural loop from the program into a function if it can
112 t_createSinkingPass, //Code Sinking
113 t_createStripDeadDebugInfoPass, //Removes unused symbols' debug info
114 t_createStripDeadPrototypesPass, //Removes any function declarations (prototypes) that are not used
115 t_createStripDebugDeclarePass, //Removes llvm.dbg.declare intrinsics
116 t_createStripNonDebugSymbolsPass, //Strips symbols from functions and modules
117 t_createStripSymbolsPass, //Removes symbols from functions and modules
118 t_createTailCallEliminationPass //Eliminates call instructions to the current function which occur immediately before return instructions
119} enumTransformPasses;
120
121/* Enumeration for points to verify module correctness */
122typedef enum {
123 NOPOINT, // no point -- module will not be verified
124 BEFORE, // before optimize -- module will be verified before transform passes
125 AFTER, // after optimize -- module will be verified after transform passes
126 BOTH // both -- module will be verified both before and after transform passes
127} enumPointToVerifiy;
128
129/* Enumeration for available execution modes */
130typedef enum {
131 JUST_INTERPRETED,
132 SMART_JIT,
133 CONTINUOUS_COMPILATION,
134 JUST_COMPILED
135} enumExecModes;
136
137/* Enumerations for available parameters for frequency measurement */
138typedef enum{
139 NO_FREQ, // without frequency (used on 'JUST_INTERPRETED' and 'JUST_COMPILED' modes)
140 COUNTER, // unity counters
141 TIME // unity execution times
142} enumFrequencyType;
143
144/* Enumerations for types of clauses that can be head on traces */
145typedef enum{
146 UNUSED, // not used
147 JUST_HOT, // enumFrequencyType associated to clause must reach threshold
148 HOT_AND_CALLEE, // JUST_HOT + clause must contain a callee opcode (fcall or call)
149 HOT_AND_GREATER, // JUST_HOT + clause size must be greater than others
150 HOT_AND_FEWER // JUST_HOT + clause's backtracks must be smaller than others
151} enumMainClauseType;
152
153/* Enumerations for available llvm registers allocators */
154typedef enum{
155 REG_ALLOC_BASIC, // Basic
156 REG_ALLOC_FAST, // Fast
157 REG_ALLOC_GREEDY, // Greedy
158 REG_ALLOC_PBQP // PBQP
159} enumRegAllocator;
160
161#include <pthread.h> // for 'CONTINUOUS_COMPILATION' mode
162
163/* Enumeration for points to apply debug predicates */
164typedef enum{
165 NO_PLACE = 0, // no place
166 ON_INTERPRETER = 1, // on interpreted opcodes
167 ON_PROFILED_INTERPRETER = 2, // on profiled opcodes
168 ON_NATIVE = 4 // on native code
169} enumPlace;
170
171/* This struct is used by debug predicates --
172 usually associated to yaam opcode, basic blocks or clauses */
173typedef struct printt_struc {
174 Int print; // Should I print?
175 CELL msg_before; // If I print, what message should come before?
176 CELL msg_after; // If I print, what message should come after?
177} PrinttStruc;
178
179
180/* This struct represents our experimental environment for YAP */
181typedef struct environment {
182 // struct for analysis predicates -- all fields are modified by analysis predicates (JIT_AnalysisPreds.c)
183 struct {
184 CELL outfile; // Where will analysis results be printed?
185 Int stats_enabled; // Should llvm stats be printed on 'shutdown_llvm()'?
186 Int time_pass_enabled; // Should llvm time passes be printed on 'shutdown_llvm()'?
187 enumPointToVerifiy pointtoverifymodule; // What point of code will llvm modules be verified?
188 COUNT n; // Number of elements on 'act_an'
189 enumAnalysisPasses *act_an; // List of analysis passes
190 } analysis_struc;
191
192 // struct for transform predicates -- all fields are modified by transform predicates (JIT_TransformPreds.c)
193 struct {
194 Int optlevel; // Optimization level -- 'act_tr' only will be used if 'optlevel' is '-1'
195 COUNT n; // Number of elements on 'act_tr'
196 enumTransformPasses *act_tr; // List of transform passes
197 struct {
198 CELL arg_promotion_max_elements; // Max elements on 'Argument Promotion Pass'
199 CELL strip_symbols_pass_type; // Argument for 'Strip Symbols Pass' -- if true, only debugging information is removed from the module
200 CELL scalar_replace_aggregates_threshold; // Threshold for 'Scalar Repl Aggregates Pass'
201 CELL loop_unswitch_optimize_for_size; // Argument for 'Loop Unswitch Pass' -- Should I optimize for size?
202 CELL loop_unroll_threshold; // Threshold for 'Loop Unroll Pass'
203 CELL inline_threshold; // Threshold for 'Function Inlining Pass'
204 } opt_args;
205 Int unit_at_time_enabled; // Should I enable IPO?
206 Int simplify_libcalls_enabled; // Should I simplify libcalls?
207 struct {
208 Int enabled; // Should I enable link-time optimizations?
209 CELL internalize; // Should I run 'Internalize Pass' on link-time optimization?
210 CELL runinliner; // Should I run 'Inline Pass' on link-time optimization?
211 } link_time_opt;
212 } transform_struc;
213
214 // struct for codegen predicates -- all fields are modified by codegen predicates (JIT_CodegenPreds.c)
215 struct {
216 struct {
217 Int noframepointerelim; // Should I use frame pointer elimination opt?
218 Int lessprecisefpmadoption; // Should I allow to generate multiply add if the result is "less precise"?
219 Int noexcessfpprecision; // Should I enable excess fp precision?
220 Int unsafefpmath; // Should I allow to produce results that are "less precise" than IEEE allows?
221 Int honorsigndependentroundingfpmathoption; // Which rounding mode should I use?
222 Int usesoftfloat; // Should I use libcalls or FP instructions to treat floating point libraries?
223 Int jitexceptionhandling; // Should JIT emit exception handling info?
224 Int jitemitdebuginfo; // Should JIT emit debug information?
225 Int jitemitdebuginfotodisk; // Should JIT write debug information to disk?
226 Int guaranteedtailcallopt; // Should I perform tail call optimization on calls which use fastcc calling convention?
227 Int disabletailcalls; // Should I use tail calls?
228 Int fastisel; // Should I use 'fast-path instruction selection' to reduce compilation time? If 'yes' native code won't have best quality
229 Int floatabitype; /* 0 = Default, 1 = Soft, 2 = Hard */
230 } struc_targetopt;
231 struct {
232 Int engineoptlevel; /* 0 = None, 1 = Less, 2 = Default, 3 = Agressive */
233 Int relocmodel; /* 0 = Default, 1 = Static, 2 = PIC, 3 = DynamicNoPIC */
234 Int codemodel; /* 0 = Default, 1 = JITDefault, 2 = Small, 3 = Kernel, 4 = Medium, 5 = Large */
235 Int usemcjit; // Should I use MC-JIT implementation (experimental)?
236 enumRegAllocator regallocator; // Active register allocator (predicate register_allocator/1)
237 } struc_enginebuilder;
238 } codegen_struc;
239
240 // struct for configuration predicates -- all fields are modified by configuration predicates (JIT_ConfigPreds.c)
241 struct {
242 enumExecModes execution_mode; // Active execution mode
243 enumFrequencyType frequency_type; // Active frequency type
244 Float frequency_bound; // Bound to become clauses as hot
245 Float profiling_startp; // Bound to init monitoring and trace building
246 enumMainClauseType mainclause_ty; // Types of clauses that can be head on traces
247 COUNT ncores; // Number of cores on processor -- used to determine default 'compilation_threads' (compilation_threads = ncores - 1)
248 COUNT compilation_threads; // Number of compilation threads (used only if 'execution_mode' is 'CONTINUOUS_COMPILATION')
249 pthread_t* threaded_compiler_threads; // List of threads (size = 'compilation_threads'). Used by function 'pthread_create'. Used on 'CONTINUOUS_COMPILATION' mode
250 CELL* posthreads; // Used to determine which threads are free/busy
251 Int torecompile; // Should I recompile traces?
252 Int current_displacement; // Jump displacement to run yaam opcodes on absmi. Zero is the default value and will make standard yaam opcodes are executed. 'TOTAL_OF_OPCODES' is the value after any clause become critical and will make 'traced_' yaam opcodes are executed.
253 COUNT TOTAL_OF_OPCODES; // Total of yaam opcodes. I must determine this dynamically due to several '#define' statements. Used to determine 'current_displacement' after any clause become critical.
254 Int useonlypi; // Execute only 'traced_' yaam opcodes. Don't compile. WARNING: if you enable this field (predicate only_profiled_interpreter/0), the system performance will decrease considerably. Use only to determine the actual cost of running such opcodes.
255 } config_struc;
256
257#if YAP_STAT_PREDS
258 // struct for statistic predicates -- all fields are modified by statistic predicates (JIT_StatisticPreds.c)
259 struct {
260 int papi_initialized; // Was PAPI initialized? Used on predicate 'statistics_jit/0' -- if 1, PAPI results will be emitted
261 int papi_eventset; // PAPI event set
262 long long *papi_values; // List of collected performance counter values
263 short *papi_valid_values; // List of performance counters that will be collected
264 int papi_event_type; // Type of event that will be collected -- 'papi_event_type' involves what performance counters will be within 'papi_valid_values'
265 } stats_struc;
266#endif
267
268#if YAP_DBG_PREDS
269 // struct for debug predicates -- all fields are modified by debug predicates (JIT_DebugPreds.c)
270 struct {
271 /* Here, one 'PrinttStruc' for each yaam opcode on 'YapAppliedOpcodes.h' */
272 #define OPCODE(OP,TYPE) \
273 PrinttStruc pyaam_##OP;
274 #include "YapAppliedOpcodes.h"
275 #undef OPCODE
276
277 /* Here, one 'PrinttStruc' for each basic block on 'AppliedBasicBlocks.h' */
278 #define BBLOCK(BB) \
279 PrinttStruc pbbs_##BB;
280 #include "Yap_AppliedBasicBlocks.h"
281 #undef BBLOCK
282
283 /* This 'PrinttStruc' inform system whether head-clauses on traces should be printed */
284 PrinttStruc pmainclause_on_head;
285
286 /* Fields to treat intermediate code */
287 struct{
288 Int print_to_std; // Should intermediate code be printed on std (stdout, stderr)? Default:: print_to_std = 0 (don't print to stdout nor stderr)
289 Int print_to_file; // Should intermediate code be printed on file? Default:: print_to_file = 0 (don't print to file)
290 CELL std_name; // if 'print_to_std' = 'yes', where should intermediate code be printed?
291 CELL file_name; // if 'print_to_file' = 'yes', what file should intermediate code be printed?
292 } pprint_intermediate;
293
294 /* Fields to treat llva code */
295 struct {
296 Int print_llva_before; // Should llva code be printed before optimizing module?
297 Int print_llva_after; // Shoud llva code be printed after optimizing module?
298 } pprint_llva;
299
300 /* Fields for predicate print_me/2 */
301 struct {
302 CELL interpreted_backtrack; // msg to print when backtrack on standard yaam opcodes occur
303 CELL profiled_interpreted_backtrack; // msg to print when backtrack on 'traced_' yaam opcodes occur
304 CELL native_backtrack; // msg to print when backtrack on native code occur
305 CELL interpreted_treat_heap; // msg to print when heap is treated on interpreter (standard and 'traced_' yaam opcodes)
306 CELL native_treat_heap; // msg to print when heap is treated on native code
307 CELL interpreted_treat_trail; // msg to print when trail is treated on interpreter (standard and 'traced_' yaam opcodes)
308 CELL native_treat_trail; // msg to print when trail is treated on native code
309 CELL criticals; // msg to print when any clause becomes critical
310 CELL at_compilation; // msg to print before compilation
311 CELL at_recompilation; // msg to print before recompilation
312 CELL nativerun_init; // msg to print when native code is about to be run
313 CELL nativerun_exit_by_success; // msg to print when native code exits by success, ie., basic block nonexistent in native code (allows rebuilding and recompilation of traces)
314 CELL nativerun_exit_by_fail; // msg to print when native code exits byfail, ie., exits to treat trail or heap (don't allow rebuilding and recompilation of traces)
315 } pprint_me;
316
317 /* Messages on all predicates */
318 struct {
319 Int info_msgs; // Should I allow info messages?
320 Int success_msgs; // Should I allow success messages?
321 Int warning_msgs; // Should I allow warning messages?
322 Int error_msgs; // Should I allow error messages?
323 } act_predicate_msgs;
324
325 /* Actions on all predicates */
326 struct {
327 Int exit_on_warning; // Should I exit when any warning occur?
328 Int disable_on_warning; // Shouldn't I adjust appropriate values when any warning occur (implies 'exit_on_warning' = 'false')
329 Int exit_on_error; // Should I exit when any error occur?
330 } act_predicate_actions;
331 } debug_struc;
332#endif
333
334} Environment;
335
336/* Enumeration for types of basic blocks -- used on trace construction */
337typedef enum block_try {
338 NONE, // untyped
339 SIMPLE_ENTRY, // first basic block of any yaam opcode
340 SIMPLE, // any other basic block of any yaam opcode
341 CONDITIONAL_HEADER, // basic block of any 'if' statement of any yaam opcode
342 MULTIPLE_DESTINY // basic block of many destinations (elementary block). Returns from native code to interpreter always will occur here
343} BlockTy;
344
345/* Struct to represent individual basic blocks within traces */
346typedef struct blocks_context {
347 union {
348 /* Fields for SIMPLE_ENTRY blocks */
349 struct {
350 UInt id; // block identifier (Yap_BasicBlocks.h)
351 char *label_entry; // entry label -- destinations of jumps from others 'SIMPLE_ENTRY' or 'SIMPLE' blocks
352 char *label_destiny; // destiny label -- where should I jump after I run?
353 } eb;
354
355 /* Fields for SIMPLE blocks */
356 struct {
357 UInt id; // block identifier (Yap_BasicBlocks.h)
358 char *label_destiny; // destiny label -- where should I jump after I run?
359 } sb;
360
361 /* Fields for CONDITIONAL_HEADER blocks */
362 struct {
363 char *exp; // expression of 'if' statement
364 struct blocks_context *_if; // destination if 'exp' is true
365 struct blocks_context *_else; // destination if 'exp' is false
366 } kb;
367
368 /* Fields for MULTIPLE_DESTINY blocks */
369 struct {
370 UInt id; // block identifier (Yap_BasicBlocks.h)
371 COUNT nfaillabels; // number of destinations caused by backtrack on native code
372 struct {
373 UInt *p;
374 char **labels;
375 } faildestiny; // destinations caused by backtrack on native code
376 COUNT ndest; // number of destinations that not be backtrack
377 struct {
378 UInt *p;
379 char **labels;
380 } destiny; // destinations that not be backtrack
381 } mdb;
382
383 /* Fields for untyped blocks */
384 struct {
385 CELL header; // just for aiding after treating 'CONDITIONAL_HEADER' blocks
386 } xb;
387 } u;
388 BlockTy blockty; // Basic block type
389 CELL thisp; // Value of PREG. Inside traces, basic blocks are only different from each other if 'id' and 'blockty' are different
390 CELL prev; // Previous basic block
391 CELL next; // Next basic block
392} BlocksContext;
393
394/* Struct to represent fully traces */
395typedef struct trace_context {
396 COUNT n; // number of basic blocks
397 CELL tracesize; // For statistics... list of size (bytes) of each trace
398 BlocksContext *bc; // basic blocks context
399} TraceContext;
400
401/* Struct to represent Intermediatecode Area */
402typedef struct intermediatecode_context {
403 COUNT n; // Total of traces stored
404 struct {
405 TraceContext** t; // List of pointers to traces -- total of 'n'
406 COUNT* ok; // List of traces ok (traces constructed and compiled at least once)
407 COUNT* isactive; // List of active traces (traces under construction). Initialized to zero
408 BlocksContext** lastblock; // List of last block added on each trace
409#if YAP_STAT_PREDS
410 double* profiling_time; // For statistics... list of profiling time of each trace
411#endif
412 } area;
413} IntermediatecodeContext;
414
415/* Struct to represent Nativecode Area */
416typedef struct native_context {
417 COUNT n; // Total of traces compiled (is not necessarily equal to 'IntermediatecodeContext.n')
418 struct {
419 void** p; // List of pointers to compiled codes -- total of 'n'
420 COUNT* ok; // List of compiled codes ok (traces constructed and compiled at least once)
421 CELL* pc; // List of first heads of each compiled code
422#if YAP_STAT_PREDS
423 COUNT *nrecomp; // For statistics... number of recompilations of each compiled code (max '1' if recompilation is disabled)
424 double **compilation_time; // For statistics... list of compilation time of each compiled code on each recompilation
425 CELL **native_size_bytes; // For statistics... list of native size (bytes) of each compiled code on each recompilation
426 CELL **trace_size_bytes; // For statistics... list of trace size (bytes) of each trace on each recompilation
427#endif
428 } area;
429#if YAP_STAT_PREDS
430 COUNT *runs; // List of calls of each compiled code
431 double *t_runs; // List of execution time of each compiled code
432 COUNT *success; // List of exit by success of each compiled code
433#endif
434} NativeContext;
435
436/*
437 * Control flags for managing intermediate code *
438 * from traces stored on Intermediatecode Area *
439 * Intermediatecode Area stores traces represented as *
440 * basic blocks sequence *
441*/
442typedef struct control_flags_context {
443 COUNT nemited;
444 char** emited_blocks;
445 short emit;
446 short leastonce;
447 char* clabel;
448 COUNT labelidx;
449 COUNT printlabel;
450 char** entries;
451 COUNT nentries;
452} ControlFlagsContext;
453
454
455/* Struct associated to 'jit_handler' opcode */
456typedef struct jit_handl_context {
457 /* Main yaam opcode features -- used by predicate 'main_clause_ty/1' */
458 struct {
459 CELL isground; // Does clause whose head is this 'jit_handler' have calls ('fcall' or 'call' opcode)? If 'yes', isground is '0'. Used when 'main_clause_ty(hot_and_callee)'
460 CELL clausesize; // Is clause whose head is this 'jit_handler' greater than other clauses? Used when ''main_clause_ty(hot_and_greater)'
461 CELL backtrack_counter; // Does clause whose head is this 'jit_handler' have fewer backtracks on history than other clauses? Used when ''main_clause_ty(hot_and_fewer)'
462 } mf;
463
464 /* Frequency Instrumenters -- only one is used */
465 struct {
466 union {
467 COUNT c; // counter
468 CELL t; // time
469 } bcst; // balance, counter, crossover, time
470 } fi;
471
472 /* Reverse pointers to code areas ('Intermediatecode Area' and 'Native Area') */
473 struct {
474 COUNT taddress; // intermediatecode area
475 COUNT naddress; // native area
476 } caa;
477
478 /* Fields for aiding trace construction and compilation */
479 struct {
480 char *cmd; // Argument to program 'echo' (called by fork on JIT_Compiler.cpp). Its value is C code that represent traces that will be compiled. Its value is freed after compilation.
481 ControlFlagsContext* cf; // Pointer to ControlFlagsContext. Just used here.
482 } tcc;
483
484 /* Fields for managing JIT -- recompilation and threads */
485 struct {
486 CELL used_thread;
487 CELL torecomp;
488 }jitman;
489} JitHandlContext;
490
491extern void **Yap_ABSMI_ControlLabels;
492
493extern Environment *Yap_ExpEnvP;
494
495#define ExpEnv (*Yap_ExpEnvP)
496
497#endif /* YAP_JIT */
498
499
500
501#endif /* _AMIJIT_H_ */