New JIt system, developed by George Oliveira and Anderson Faustino.

This commit is contained in:
Vítor Santos Costa 2014-07-12 23:30:14 -05:00
parent 95bbdc8a17
commit 0738fe0bd2
94 changed files with 110573 additions and 11 deletions

223
JIT/HPP/EnvironmentInit.h Normal file
View File

@ -0,0 +1,223 @@
#if YAP_STAT_PREDS
#include <papi.h>
#endif
extern Environment ExpEnv;
#if YAP_JIT
Int STD_PROTO(Get_N_Cores,(void));
X_API Int STD_PROTO(Init_Analysis_Struc,(void));
X_API Int STD_PROTO(Init_Transform_Struc,(void));
X_API Int STD_PROTO(Init_Codegen_Struc,(void));
X_API Int STD_PROTO(Init_Config_Struc,(void));
#if YAP_STAT_PREDS
X_API Int STD_PROTO(Init_Stats_Struc, (void));
#endif
#endif /* YAP_JIT */
#if YAP_DBG_PREDS
X_API Int STD_PROTO(Init_Debug_Struc,(void));
#endif
X_API Int STD_PROTO(YAP_Init_ExpEnv,(void));
#if YAP_JIT
Int
Get_N_Cores() {
#ifdef WIN32
SYSTEM_INFO sysinfo;
GetSystemInfo(&sysinfo);
return sysinfo.dwNumberOfProcessors;
#elif MACOS
int nm[2];
size_t len = 4;
uint32_t count;
nm[0] = CTL_HW; nm[1] = HRW_AVAILCPU;
sysctl(nm, 2, &count, &len, NULL, 0);
if(count < 1) {
nm[1] = HRW_NCPU;
sysctl(nm, 2, &count, &len, NULL, 0);
if(count < 1) { count = 1; }
}
return count;
#else
return sysconf(_SC_NPROCESSORS_ONLN);
#endif
}
X_API Int
Init_Analysis_Struc()
{
ExpEnv.analysis_struc.stats_enabled = 0;
ExpEnv.analysis_struc.time_pass_enabled = 0;
ExpEnv.analysis_struc.pointtoverifymodule = NOPOINT;
ExpEnv.analysis_struc.n = 0;
ExpEnv.analysis_struc.act_an = NULL;
ExpEnv.analysis_struc.outfile = (CELL)malloc(7*sizeof(char));
strcpy(((char*)ExpEnv.analysis_struc.outfile), "STDERR");
return TRUE;
}
X_API Int
Init_Transform_Struc()
{
ExpEnv.transform_struc.optlevel = 3;
ExpEnv.transform_struc.n = 0;
ExpEnv.transform_struc.act_tr = NULL;
ExpEnv.transform_struc.opt_args.arg_promotion_max_elements = 3;
ExpEnv.transform_struc.opt_args.strip_symbols_pass_type = 0;
ExpEnv.transform_struc.opt_args.scalar_replace_aggregates_threshold = -1;
ExpEnv.transform_struc.opt_args.loop_unswitch_optimize_for_size = 0;
ExpEnv.transform_struc.opt_args.loop_unroll_threshold = -1;
ExpEnv.transform_struc.opt_args.inline_threshold = 225;
ExpEnv.transform_struc.unit_at_time_enabled = 1;
ExpEnv.transform_struc.simplify_libcalls_enabled = 1;
ExpEnv.transform_struc.link_time_opt.enabled = 0;
ExpEnv.transform_struc.link_time_opt.internalize = 0;
ExpEnv.transform_struc.link_time_opt.runinliner = 0;
return TRUE;
}
X_API Int
Init_Codegen_Struc()
{
ExpEnv.codegen_struc.struc_targetopt.noframepointerelim = 0;
ExpEnv.codegen_struc.struc_targetopt.lessprecisefpmadoption = 0;
ExpEnv.codegen_struc.struc_targetopt.noexcessfpprecision = 0;
ExpEnv.codegen_struc.struc_targetopt.unsafefpmath = 0;
ExpEnv.codegen_struc.struc_targetopt.honorsigndependentroundingfpmathoption = 0;
ExpEnv.codegen_struc.struc_targetopt.usesoftfloat = 0;
ExpEnv.codegen_struc.struc_targetopt.jitexceptionhandling = 0;
ExpEnv.codegen_struc.struc_targetopt.jitemitdebuginfo = 0;
ExpEnv.codegen_struc.struc_targetopt.jitemitdebuginfotodisk = 0;
ExpEnv.codegen_struc.struc_targetopt.guaranteedtailcallopt = 0;
ExpEnv.codegen_struc.struc_targetopt.disabletailcalls = 0;
ExpEnv.codegen_struc.struc_targetopt.fastisel = 0;
ExpEnv.codegen_struc.struc_targetopt.floatabitype = 0;
ExpEnv.codegen_struc.struc_enginebuilder.engineoptlevel = 3;
ExpEnv.codegen_struc.struc_enginebuilder.relocmodel = 0;
ExpEnv.codegen_struc.struc_enginebuilder.codemodel = 1;
ExpEnv.codegen_struc.struc_enginebuilder.usemcjit = 0;
ExpEnv.codegen_struc.struc_enginebuilder.regallocator = REG_ALLOC_GREEDY;
return TRUE;
}
X_API Int
Init_Config_Struc()
{
if (Yap_ExecutionMode == MIXED_MODE) {
ExpEnv.config_struc.execution_mode = SMART_JIT;
ExpEnv.config_struc.frequency_type = COUNTER;
ExpEnv.config_struc.frequency_bound = 1024.0;
ExpEnv.config_struc.profiling_startp = 0.72;
ExpEnv.config_struc.mainclause_ty = HROT_AND_CALLEE;
ExpEnv.config_struc.torecompile = 1;
}
else {
if (Yap_ExecutionMode == COMPILED)
ExpEnv.config_struc.execution_mode = JUST_COMPILED;
else
ExpEnv.config_struc.execution_mode = JUST_INTERPRETED;
ExpEnv.config_struc.frequency_type = NO_FREQ;
ExpEnv.config_struc.frequency_bound = 0.0;
ExpEnv.config_struc.profiling_startp = 0.0;
ExpEnv.config_struc.mainclause_ty = UNUSED;
ExpEnv.config_struc.torecompile = 0;
}
ExpEnv.config_struc.ncores = Get_N_Cores();
ExpEnv.config_struc.useonlypi = 0;
ExpEnv.config_struc.compilation_threads = 0;
ExpEnv.config_struc.threaded_compiler_threads = NULL;
ExpEnv.config_struc.posthreads = NULL;
return TRUE;
}
#if YAP_STAT_PREDS
X_API Int
Init_Stats_Struc()
{
ExpEnv.stats_struc.papi_initialized = 0;
ExpEnv.stats_struc.papi_eventset = PAPI_NULL;
return TRUE;
}
#endif
#endif /* YAP_JIT */
#if YAP_DBG_PREDS
X_API Int
Init_Debug_Struc()
{
#define OPCODE(OP,TYPE) \
ExpEnv.debug_struc.pyaam_##OP.print = (Int)NO_PLACE; \
ExpEnv.debug_struc.pyaam_##OP.msg_before = 0; \
ExpEnv.debug_struc.pyaam_##OP.msg_after = 0;
#include "YapAppliedOpcodes.h"
#undef OPCODE
#define BBLOCK(BB) \
ExpEnv.debug_struc.pbbs_##BB.print = (Int)NO_PLACE; \
ExpEnv.debug_struc.pbbs_##BB.msg_before = 0; \
ExpEnv.debug_struc.pbbs_##BB.msg_after = 0;
#include "Yap_AppliedBasicBlocks.h"
#undef BBLOCK
ExpEnv.debug_struc.pmainclause_on_head.print = (Int)NO_PLACE;
ExpEnv.debug_struc.pmainclause_on_head.msg_before = 0;
ExpEnv.debug_struc.pmainclause_on_head.msg_after = 0;
ExpEnv.debug_struc.pprint_intermediate.print_to_std = 0;
ExpEnv.debug_struc.pprint_intermediate.print_to_file = 0;
ExpEnv.debug_struc.pprint_intermediate.std_name = 0;
ExpEnv.debug_struc.pprint_intermediate.file_name = 0;
ExpEnv.debug_struc.pprint_llva.print_llva_before = 0;
ExpEnv.debug_struc.pprint_llva.print_llva_after = 0;
ExpEnv.debug_struc.pprint_me.interpreted_backtrack = 0;
ExpEnv.debug_struc.pprint_me.profiled_interpreted_backtrack = 0;
ExpEnv.debug_struc.pprint_me.native_backtrack = 0;
ExpEnv.debug_struc.pprint_me.interpreted_treat_heap = 0;
ExpEnv.debug_struc.pprint_me.native_treat_heap = 0;
ExpEnv.debug_struc.pprint_me.interpreted_treat_trail = 0;
ExpEnv.debug_struc.pprint_me.native_treat_trail = 0;
ExpEnv.debug_struc.pprint_me.criticals = 0;
ExpEnv.debug_struc.pprint_me.at_compilation = 0;
ExpEnv.debug_struc.pprint_me.at_recompilation = 0;
ExpEnv.debug_struc.pprint_me.nativerun_init = 0;
ExpEnv.debug_struc.pprint_me.nativerun_exit_by_success = 0;
ExpEnv.debug_struc.pprint_me.nativerun_exit_by_fail = 0;
ExpEnv.debug_struc.act_predicate_msgs.info_msgs = 0;
ExpEnv.debug_struc.act_predicate_msgs.success_msgs = 0;
ExpEnv.debug_struc.act_predicate_msgs.warning_msgs = 1;
ExpEnv.debug_struc.act_predicate_msgs.error_msgs = 1;
ExpEnv.debug_struc.act_predicate_actions.exit_on_warning = 0;
ExpEnv.debug_struc.act_predicate_actions.disable_on_warning = 1;
ExpEnv.debug_struc.act_predicate_actions.exit_on_error = 1;
return TRUE;
}
#endif
X_API Int
YAP_Init_ExpEnv()
{
//ExpEnv.in = (char*)malloc(1024*sizeof(char));
//strcpy(ExpEnv.in, fin);
#if YAP_JIT
Init_Analysis_Struc();
Init_Transform_Struc();
Init_Codegen_Struc();
Init_Config_Struc();
#if YAP_STAT_PREDS
Init_Stats_Struc();
#endif
#endif /* YAP_JIT */
#if YAP_DBG_PREDS
Init_Debug_Struc();
#endif
return TRUE;
}

2421
JIT/HPP/IsGround.h Normal file

File diff suppressed because it is too large Load Diff

24
JIT/HPP/JIT.hh Normal file
View File

@ -0,0 +1,24 @@
#ifndef JIT_HPP
#define JIT_HPP
#ifdef __cplusplus
#include <vector>
#include <string>
#include <cstdio>
#include <iostream>
#include <fstream>
#include <time.h>
#include <dlfcn.h>
#include "config.h"
#include "absmi.h"
using namespace std;
#else
#define LIMIT_COUNT 4096
#endif
#endif

104
JIT/HPP/JIT_Compiler.hh Normal file
View File

@ -0,0 +1,104 @@
#ifndef JIT_COMPILER_HPP
#define JIT_COMPILER_HPP
#ifdef __cplusplus
#include "llvm/LLVMContext.h"
#include "llvm/Module.h"
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Instructions.h"
#include "llvm/Linker.h"
#include "llvm/PassManager.h"
#include "llvm/CallGraphSCCPass.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/ADT/Triple.h"
#include "llvm/Assembly/PrintModulePass.h"
#include "llvm/CodeGen/Passes.h"
#include "llvm/CodeGen/MachineCodeInfo.h"
#include "llvm/ExecutionEngine/JIT.h"
#include "llvm/ExecutionEngine/Interpreter.h"
#include "llvm/ExecutionEngine/GenericValue.h"
#include "llvm/ExecutionEngine/JITMemoryManager.h"
#include "llvm/ExecutionEngine/JITEventListener.h"
#include "llvm/Support/DataStream.h"
#include "llvm/Support/IRReader.h"
#include "llvm/Support/Host.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/TargetSelect.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/raw_os_ostream.h"
#include "llvm/Support/IRBuilder.h"
#include "llvm/Support/PathV1.h"
#include "llvm/Support/TypeBuilder.h"
#include "llvm/Support/ToolOutputFile.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetOptions.h"
#include "llvm/Target/TargetLibraryInfo.h"
#include "llvm/Analysis/Passes.h"
#include "llvm/Analysis/IVUsers.h"
#include "llvm/Analysis/Lint.h"
#include "llvm/Analysis/DebugInfo.h"
#include "llvm/Analysis/Verifier.h"
#include "llvm/Analysis/LoopPass.h"
#include "llvm/Analysis/RegionPass.h"
#include "llvm/Analysis/CFGPrinter.h"
#include "llvm/Analysis/DomPrinter.h"
#include "llvm/Analysis/BranchProbabilityInfo.h"
#include "llvm/Analysis/RegionPrinter.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/system_error.h"
#include "llvm/Support/Process.h"
#include "llvm/Bitcode/ReaderWriter.h"
#include "llvm/Transforms/IPO.h"
#include "llvm/Transforms/Scalar.h"
#include "llvm/Transforms/Vectorize.h"
#include "llvm/Transforms/IPO/PassManagerBuilder.h"
#include "llvm/Transforms/Utils/Cloning.h"
using namespace llvm;
#include <fcntl.h>
#include <errno.h>
#include "JIT.hpp"
using namespace std;
extern short global;
extern Environment ExpEnv;
extern NativeContext *NativeArea;
class JIT_Compiler {
private:
/* main method of JIT Compiler: compiles by clang, analyzes, optimizs and generates code accordingly the user choices */
void* compile_all(LLVMContext* &Context, yamop* p);
/* aid method to 'compile_all': adds register allocator pass to be used.
WARNING: don't use! For some reasons llvm crashes when I use it */
void set_regalloc_pass(PassManager &PM);
/* aid method to 'compile_all': optimizes module by individual transform passes or transform level */
void optimize_module(llvm::Module* &M);
/* aid method to 'compile_all': analyzes module by individual analysis passes */
void analyze_module(llvm::Module* &M);
public:
/* method invoked by wrapper 'call_JIT_Compiler' */
void* compile(yamop*);
};
#else
struct JIT_Compiler{}; // Doing this, I can call class 'JIT_Compiler' from C code
#endif
#ifdef __cplusplus
extern "C" void* call_JIT_Compiler(JIT_Compiler* jc, yamop* p) { return jc->compile(p); }
extern "C" void shutdown_llvm() { llvm_shutdown(); }
#endif //#ifdef __cplusplus
#endif

183
JIT/HPP/PassPrinters.hh Normal file
View File

@ -0,0 +1,183 @@
/**
* The code below is adapted from opt tool according to clearance and conditions established in NCSA license as follows:
* Copyright (c) 2003 University of Illinois. All rights reserved.
* Developed by: LLVM Developer Group
* University of Illinois
* http://llvm.org/
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
* files (the "Software"), to deal with the Software without restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
* is furnished to do so, subject to the following conditions:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimers.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimers
* in the documentation and/or other materials provided with the distribution.
* Neither the names of LLVM Developer Group, University of Illinois, nor the names of its contributors may be used to endorse or
* promote products derived from this Software without specific prior written permission.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HROLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE.
**/
struct CallGraphSCCPassPrinter : public CallGraphSCCPass {
static char ID;
const PassInfo *PassToPrint;
std::string PassName;
CallGraphSCCPassPrinter(const PassInfo *PI) :
CallGraphSCCPass(ID), PassToPrint(PI) {
std::string PassToPrintName = PassToPrint->getPassName();
PassName = "CallGraphSCCPass Printer: " + PassToPrintName;
}
virtual bool runOnSCC(CallGraphSCC &SCC) {
errs() << "Printing analysis '" << PassToPrint->getPassName() << "':\n";
// Get and print pass...
for (CallGraphSCC::iterator I = SCC.begin(), E = SCC.end(); I != E; ++I) {
Function *F = (*I)->getFunction();
if (F)
getAnalysisID<Pass>(PassToPrint->getTypeInfo()).print(errs(),
F->getParent());
}
return false;
}
virtual const char *getPassName() const { return PassName.c_str(); }
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.addRequiredID(PassToPrint->getTypeInfo());
AU.setPreservesAll();
}
};
char CallGraphSCCPassPrinter::ID = 0;
struct ModulePassPrinter : public ModulePass {
static char ID;
const PassInfo *PassToPrint;
std::string PassName;
ModulePassPrinter(const PassInfo *PI)
: ModulePass(ID), PassToPrint(PI) {
std::string PassToPrintName = PassToPrint->getPassName();
PassName = "ModulePass Printer: " + PassToPrintName;
}
virtual bool runOnModule(Module &M) {
errs() << "Printing analysis '" << PassToPrint->getPassName() << "':\n";
// Get and print pass...
getAnalysisID<Pass>(PassToPrint->getTypeInfo()).print(errs(), &M);
return false;
}
virtual const char *getPassName() const { return PassName.c_str(); }
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.addRequiredID(PassToPrint->getTypeInfo());
AU.setPreservesAll();
}
};
char ModulePassPrinter::ID = 0;
struct FunctionPassPrinter : public FunctionPass {
const PassInfo *PassToPrint;
static char ID;
std::string PassName;
FunctionPassPrinter(const PassInfo *PI)
: FunctionPass(ID), PassToPrint(PI) {
std::string PassToPrintName = PassToPrint->getPassName();
PassName = "FunctionPass Printer: " + PassToPrintName;
}
virtual bool runOnFunction(Function &F) {
errs() << "Printing analysis '" << PassToPrint->getPassName()
<< "' for function '" << F.getName() << "':\n";
// Get and print pass...
getAnalysisID<Pass>(PassToPrint->getTypeInfo()).print(errs(),
F.getParent());
return false;
}
virtual const char *getPassName() const { return PassName.c_str(); }
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.addRequiredID(PassToPrint->getTypeInfo());
AU.setPreservesAll();
}
};
char FunctionPassPrinter::ID = 0;
struct LoopPassPrinter : public LoopPass {
static char ID;
const PassInfo *PassToPrint;
std::string PassName;
LoopPassPrinter(const PassInfo *PI) :
LoopPass(ID), PassToPrint(PI) {
std::string PassToPrintName = PassToPrint->getPassName();
PassName = "LoopPass Printer: " + PassToPrintName;
}
virtual bool runOnLoop(Loop *L, LPPassManager &LPM) {
errs() << "Printing analysis '" << PassToPrint->getPassName() << "':\n";
// Get and print pass...
getAnalysisID<Pass>(PassToPrint->getTypeInfo()).print(errs(),
L->getHeader()->getParent()->getParent());
return false;
}
virtual const char *getPassName() const { return PassName.c_str(); }
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.addRequiredID(PassToPrint->getTypeInfo());
AU.setPreservesAll();
}
};
char LoopPassPrinter::ID = 0;
struct RegionPassPrinter : public RegionPass {
static char ID;
const PassInfo *PassToPrint;
std::string PassName;
RegionPassPrinter(const PassInfo *PI) : RegionPass(ID),
PassToPrint(PI) {
std::string PassToPrintName = PassToPrint->getPassName();
PassName = "RegionPass Printer: " + PassToPrintName;
}
virtual bool runOnRegion(Region *R, RGPassManager &RGM) {
errs() << "Printing analysis '" << PassToPrint->getPassName() << "' for "
<< "region: '" << R->getNameStr() << "' in function '"
<< R->getEntry()->getParent()->getName() << "':\n";
// Get and print pass...
getAnalysisID<Pass>(PassToPrint->getTypeInfo()).print(errs(),
R->getEntry()->getParent()->getParent());
return false;
}
virtual const char *getPassName() const { return PassName.c_str(); }
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.addRequiredID(PassToPrint->getTypeInfo());
AU.setPreservesAll();
}
};
char RegionPassPrinter::ID = 0;

File diff suppressed because it is too large Load Diff

1503
JIT/HPP/Yap_BasicBlocks.h Normal file

File diff suppressed because it is too large Load Diff

73
JIT/HPP/debug_printers.h Normal file
View File

@ -0,0 +1,73 @@
void print_main_when_head(yamop*, enumPlace);
inline void
print_main_when_head(yamop* p, enumPlace place)
{
if((ExpEnv.debug_struc.pmainclause_on_head.print & place) == place) {
fprintf(stderr, "%s:%d\n", __FILE__, __LINE__);
fprintf(stderr, "%s", (char*)ExpEnv.debug_struc.pmainclause_on_head.msg_before);
print_preg(p);
fprintf(stderr, "%s", (char*)ExpEnv.debug_struc.pmainclause_on_head.msg_after);
}
}
void print_instruction(yamop*, enumPlace);
inline void
print_instruction(yamop* p, enumPlace place)
{
op_numbers op = Yap_op_from_opcode(p->opc);
switch(op) {
#define OPCODE(OP,TYPE) \
case _##OP: \
if((ExpEnv.debug_struc.pyaam_##OP.print & place) == place) { \
char *tmp = (char*)malloc((16+strlen((char*)ExpEnv.debug_struc.pyaam_##OP.msg_after))*sizeof(char)); \
switch(place) { \
case ON_INTERPRETER: \
strcpy(tmp, " (as standard)"); \
break; \
case ON_PROFILED_INTERPRETER: \
strcpy(tmp, " (as profiled)"); \
break; \
case ON_NATIVE: \
strcpy(tmp, " (as native)"); \
break; \
default:; \
} \
strcat(tmp, (char*)ExpEnv.debug_struc.pyaam_##OP.msg_after); \
fprintf(stderr, "%s:%d\n", __FILE__, __LINE__); \
print_op((char*)ExpEnv.debug_struc.pyaam_##OP.msg_before, op, tmp); \
} \
break;
#include "YapAppliedOpcodes.h"
#undef OPCODE
default:;
}
}
#if YAP_JIT
void print_block(YAP_BBs, enumPlace);
inline void
print_block(YAP_BBs block, enumPlace place)
{
switch(block) {
#define BBLOCK(BB) \
case BB: \
if((ExpEnv.debug_struc.pbbs_##BB.print & place) == place) { \
fprintf(stderr, "%s:%d\n", __FILE__, __LINE__); \
fprintf(stderr, "%s", (char*)ExpEnv.debug_struc.pbbs_##BB.msg_before); \
fprint_block(block); \
{ \
if (place == ON_NATIVE) fprintf(stderr, " (on native)"); \
else fprintf(stderr, " (on interpreter)"); \
} \
fprintf(stderr, "%s", (char*)ExpEnv.debug_struc.pbbs_##BB.msg_after); \
} \
break;
#include "Yap_AppliedBasicBlocks.h"
#undef BBLOCK
default:;
}
}
#endif

4016
JIT/HPP/fprintblock.h Normal file

File diff suppressed because it is too large Load Diff

545
JIT/HPP/indexing_ext.h Normal file
View File

@ -0,0 +1,545 @@
#define USER_SWITCH_INSTINIT \
BLOCKADDRESS = (CELL)(*_PREG); \
{ \
yamop *new = Yap_udi_search((*_PREG)->u.lp.p); \
if (!new) { \
(*_PREG) = (*_PREG)->u.lp.l; \
JMPNext(); \
} \
else { \
(*_PREG) = new; \
JMPNext(); \
} \
}
#define USER_SWITCH_END \
BLOCK = (CELL)USER_SWITCH_END;
#define SWITCH_ON_TYPE_INSTINIT \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0; \
register CELL *pt0; \
d0 = CACHED_A1(); \
Int nonvar = 1; \
if (IsVarTerm(d0)) { \
nonvar = 0; \
(pt0) = (CELL *)(d0); \
(d0) = *(CELL *)(d0); \
while (Unsigned(pt0) != (d0)) { \
if(!IsVarTerm(d0)) { \
nonvar = 1; \
break; \
} \
(pt0) = (CELL *)(d0); \
(d0) = *(CELL *)(d0); \
} \
if (!nonvar) { \
copy_jmp_address((*_PREG)->u.llll.l4); \
(*_PREG) = (*_PREG)->u.llll.l4; \
JMPNext(); \
} \
} \
if (nonvar) { \
if (IsPairTerm(d0)) { \
(*_SREG) = RepPair(d0); \
copy_jmp_address((*_PREG)->u.llll.l1); \
(*_PREG) = (*_PREG)->u.llll.l1; \
JMPNext(); \
} \
else if (!IsApplTerm(d0)) { \
copy_jmp_address((*_PREG)->u.llll.l2); \
(*_PREG) = (*_PREG)->u.llll.l2; \
I_R = d0; \
JMPNext(); \
} \
else { \
copy_jmp_address((*_PREG)->u.llll.l3); \
(*_PREG) = (*_PREG)->u.llll.l3; \
(*_SREG) = RepAppl(d0); \
JMPNext(); \
} \
}
#define SWITCH_ON_TYPE_END \
BLOCK = (CELL)SWITCH_ON_TYPE_END;
#if UNIQUE_TAG_FOR_PAIRS
#define SWITCH_LIST_NL_INSTINIT \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0; \
register CELL *pt0; \
ALWAYS_LOOKAHEAD((*_PREG)->u.ollll.pop); \
d0 = CACHED_A1(); \
Int nonvar = 0; \
Int pair = 1; \
if (!IsPairTerm(d0)) { \
pair = 0; \
do { \
if (!IsVarTerm(d0)) { \
if (d0 == TermNil) { \
(*_PREG) = (*_PREG)->u.ollll.l2; \
JMPNext(); \
} \
else { \
if (IsApplTerm(d0)) { \
copy_jmp_address((*_PREG)->u.ollll.l3); \
(*_PREG) = (*_PREG)->u.ollll.l3; \
(*_SREG) = RepAppl(d0); \
JMPNext(); \
} else { \
copy_jmp_address((*_PREG)->u.ollll.l3); \
(*_PREG) = (*_PREG)->u.ollll.l3; \
I_R = d0; \
JMPNext(); \
} \
} \
nonvar = 1; \
break; \
} \
(pt0) = (CELL *)(d0); \
(d0) = *(pt0); \
if (Unsigned(pt0) == (d0)) break; \
if (IsPairTerm(d0)) { \
pair = 1; \
break; \
} \
} while (TRUE); \
if (!nonvar && !pair) { \
copy_jmp_address((*_PREG)->u.ollll.l4); \
(*_PREG) = (*_PREG)->u.ollll.l4; \
JMPNext(); \
} \
} \
if (!nonvar && pair) { \
copy_jmp_address((*_PREG)->u.ollll.l1); \
(*_PREG) = (*_PREG)->u.ollll.l1; \
(*_SREG) = RepPair(d0); \
ALWAYS_GONext(); \
}
#else
#define SWITCH_LIST_NL_INSTINIT \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0; \
register CELL *pt0; \
ALWAYS_LOOKAHEAD((*_PREG)->u.ollll.pop); \
d0 = CACHED_A1(); \
Int nonvar = 0; \
if (IsVarTerm(d0)) { \
(pt0) = (CELL *)(d0); \
(d0) = *(CELL *)(d0); \
while (Unsigned(pt0) != (d0)) { \
if(!IsVarTerm(d0)) { \
nonvar = 1; \
break; \
} \
(pt0) = (CELL *)(d0); \
(d0) = *(CELL *)(d0); \
} \
if (!nonvar) { \
copy_jmp_address((*_PREG)->u.ollll.l4); \
(*_PREG) = (*_PREG)->u.ollll.l4; \
JMPNext(); \
} \
} \
if (nonvar) { \
if (__builtin_expect(IsPairTerm(d0),1)) { \
copy_jmp_address((*_PREG)->u.ollll.l1); \
(*_PREG) = (*_PREG)->u.ollll.l1; \
(*_SREG) = RepPair(d0); \
ALWAYS_GONext(); \
} \
if (d0 == TermNil) { \
(*_PREG) = (*_PREG)->u.ollll.l2; \
JMPNext(); \
} \
else { \
if (IsApplTerm(d0)) { \
copy_jmp_address((*_PREG)->u.ollll.l3); \
(*_PREG) = (*_PREG)->u.ollll.l3; \
(*_SREG) = RepAppl(d0); \
JMPNext(); \
} else { \
copy_jmp_address((*_PREG)->u.ollll.l3); \
(*_PREG) = (*_PREG)->u.ollll.l3; \
I_R = d0; \
JMPNext(); \
} \
} \
}
#endif
#define SWITCH_LIST_NL_END \
BLOCK = (CELL)SWITCH_LIST_NL_END;
#define SWITCH_ON_ARG_TYPE_INSTINIT \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0; \
register CELL *pt0; \
d0 = XREG((*_PREG)->u.xllll.x); \
Int nonvar = 1; \
if (IsVarTerm(d0)) { \
nonvar = 0; \
(pt0) = (CELL *)(d0); \
(d0) = *(CELL *)(d0); \
while (Unsigned(pt0) != (d0)) { \
if(!IsVarTerm(d0)) { \
nonvar = 1; \
break; \
} \
(pt0) = (CELL *)(d0); \
(d0) = *(CELL *)(d0); \
} \
if (!nonvar) { \
copy_jmp_address((*_PREG)->u.xllll.l4); \
(*_PREG) = (*_PREG)->u.xllll.l4; \
JMPNext(); \
} \
} \
if (nonvar) { \
if (IsPairTerm(d0)) { \
copy_jmp_address((*_PREG)->u.xllll.l1); \
(*_PREG) = (*_PREG)->u.xllll.l1; \
(*_SREG) = RepPair(d0); \
JMPNext(); \
} \
else if (!IsApplTerm(d0)) { \
copy_jmp_address((*_PREG)->u.xllll.l2); \
(*_PREG) = (*_PREG)->u.xllll.l2; \
I_R = d0; \
JMPNext(); \
} \
else { \
copy_jmp_address((*_PREG)->u.xllll.l3); \
(*_PREG) = (*_PREG)->u.xllll.l3; \
(*_SREG) = RepAppl(d0); \
JMPNext(); \
} \
}
#define SWITCH_ON_ARG_TYPE_END \
BLOCK = (CELL)SWITCH_ON_ARG_TYPE_END;
#define SWITCH_ON_SUB_ARG_TYPE_INSTINIT \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0; \
register CELL *pt0; \
d0 = (*_SREG)[(*_PREG)->u.sllll.s]; \
Int nonvar = 1; \
if (IsVarTerm(d0)) { \
nonvar = 0; \
(pt0) = (CELL *)(d0); \
(d0) = *(CELL *)(d0); \
while (Unsigned(pt0) != (d0)) { \
if(!IsVarTerm(d0)) { \
nonvar = 1; \
break; \
} \
(pt0) = (CELL *)(d0); \
(d0) = *(CELL *)(d0); \
} \
if (!nonvar) { \
copy_jmp_address((*_PREG)->u.sllll.l4); \
(*_PREG) = (*_PREG)->u.sllll.l4; \
JMPNext(); \
} \
} \
if (nonvar) { \
if (IsPairTerm(d0)) { \
copy_jmp_address((*_PREG)->u.sllll.l1); \
(*_PREG) = (*_PREG)->u.sllll.l1; \
(*_SREG) = RepPair(d0); \
JMPNext(); \
} \
else if (!IsApplTerm(d0)) { \
copy_jmp_address((*_PREG)->u.sllll.l2); \
(*_PREG) = (*_PREG)->u.sllll.l2; \
I_R = d0; \
JMPNext(); \
} \
else { \
copy_jmp_address((*_PREG)->u.sllll.l3); \
(*_PREG) = (*_PREG)->u.sllll.l3; \
(*_SREG) = RepAppl(d0); \
JMPNext(); \
} \
}
#define SWITCH_ON_SUB_ARG_TYPE_END \
BLOCK = (CELL)SWITCH_ON_SUB_ARG_TYPE_END;
#define JUMP_IF_VAR_INSTINIT \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0; \
register CELL *pt0; \
d0 = CACHED_A1(); \
Int nonvar = 1; \
if (IsVarTerm(d0)) { \
nonvar = 0; \
(pt0) = (CELL *)(d0); \
(d0) = *(CELL *)(d0); \
while (Unsigned(pt0) != (d0)) { \
if(!IsVarTerm(d0)) { \
nonvar = 1; \
break; \
} \
(pt0) = (CELL *)(d0); \
(d0) = *(CELL *)(d0); \
} \
if (!nonvar) { \
copy_jmp_address((*_PREG)->u.l.l); \
(*_PREG) = (*_PREG)->u.l.l; \
JMPNext(); \
} \
} \
if (nonvar) { \
(*_PREG) = NEXTOP((*_PREG), l); \
JMPNext(); \
}
#define JUMP_IF_VAR_END \
BLOCK = (CELL)JUMP_IF_VAR_END;
#define JUMP_IF_NONVAR_INSTINIT \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0; \
register CELL *pt0; \
d0 = XREG((*_PREG)->u.xll.x); \
Int nonvar = 0; \
if (IsVarTerm(d0)) { \
(pt0) = (CELL *)(d0); \
(d0) = *(CELL *)(d0); \
while (Unsigned(pt0) != (d0)) { \
if(!IsVarTerm(d0)) { \
nonvar = 1; \
break; \
} \
(pt0) = (CELL *)(d0); \
(d0) = *(CELL *)(d0); \
} \
if (!nonvar) { \
(*_PREG) = NEXTOP((*_PREG), xll); \
JMPNext(); \
} \
} \
if (nonvar) { \
copy_jmp_address((*_PREG)->u.xll.l1); \
(*_PREG) = (*_PREG)->u.xll.l1; \
JMPNext(); \
}
#define JUMP_IF_NONVAR_END \
BLOCK = (CELL)JUMP_IF_NONVAR_END;
#define IF_NOT_THEN_INSTINIT \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0; \
register CELL *pt0; \
d0 = CACHED_A1(); \
Int nonvar = 1; \
if (IsVarTerm(d0)) { \
nonvar = 0; \
(pt0) = (CELL *)(d0); \
(d0) = *(CELL *)(d0); \
while (Unsigned(pt0) != (d0)) { \
if(!IsVarTerm(d0)) { \
nonvar = 1; \
break; \
} \
(pt0) = (CELL *)(d0); \
(d0) = *(CELL *)(d0); \
} \
if (!nonvar) { \
copy_jmp_address((*_PREG)->u.clll.l3); \
(*_PREG) = (*_PREG)->u.clll.l3; \
JMPNext(); \
} \
} \
if (nonvar) { \
if (d0 == (*_PREG)->u.clll.c) { \
copy_jmp_address((*_PREG)->u.clll.l2); \
(*_PREG) = (*_PREG)->u.clll.l2; \
JMPNext(); \
} \
else { \
copy_jmp_address((*_PREG)->u.clll.l1); \
(*_PREG) = (*_PREG)->u.clll.l1; \
JMPNext(); \
} \
}
#define IF_NOT_THEN_END \
BLOCK = (CELL)IF_NOT_THEN_END;
#define HRASH_SHIFT 6
#define SWITCH_ON_FUNC_INSTINIT \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0, d1; \
register CELL *pt0; \
d1 = *(*_SREG)++; \
{ \
CELL \
Mask = ((*_PREG)->u.sssl.s - 1) << 1, \
hash = d1 >> (HRASH_SHIFT - 1) & Mask; \
CELL *base; \
base = (CELL *)(*_PREG)->u.sssl.l; \
pt0 = base + hash; \
d0 = pt0[0]; \
if (d0 == d1 || d0 == 0) { \
copy_jmp_addressa(pt0+1); \
(*_PREG) = (yamop *) (pt0[1]); \
JMPNext(); \
} \
else { \
register CELL d = ((d1 | 1) << 1) & Mask; \
while (1) { \
hash = (hash + d) & Mask; \
pt0 = base + hash; \
d0 = pt0[0]; \
if (d0 == d1 || d0 == 0) { \
copy_jmp_addressa(pt0+1); \
(*_PREG) = (yamop *) pt0[1]; \
break; \
} \
} \
} \
}
#define SWITCH_ON_FUNC_END \
BLOCK = (CELL)SWITCH_ON_FUNC_END;
#define SWITCH_ON_CONS_INSTINIT \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0, d1; \
register CELL *pt0; \
d1 = I_R; \
{ \
CELL \
Mask = ((*_PREG)->u.sssl.s - 1) << 1, \
hash = d1 >> (HRASH_SHIFT - 1) & Mask; \
CELL *base; \
base = (CELL *)(*_PREG)->u.sssl.l; \
pt0 = base + hash; \
d0 = pt0[0]; \
if (d0 == d1 || d0 == 0) { \
copy_jmp_addressa(pt0+1); \
(*_PREG) = (yamop *) (pt0[1]); \
JMPNext(); \
} \
else { \
register CELL d = ((d1 | 1) << 1) & Mask; \
while (1) { \
hash = (hash + d) & Mask; \
pt0 = base + hash; \
d0 = pt0[0]; \
if (d0 == d1 || d0 == 0) { \
copy_jmp_addressa(pt0+1); \
(*_PREG) = (yamop *) pt0[1]; \
break; \
} \
} \
} \
}
#define SWITCH_ON_CONS_END \
BLOCK = (CELL)SWITCH_ON_CONS_END;
#define GO_ON_FUNC_INSTINIT \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0; \
{ \
CELL *pt = (CELL *)((*_PREG)->u.sssl.l); \
d0 = *(*_SREG)++; \
if (d0 == pt[0]) { \
copy_jmp_addressa(pt+1); \
(*_PREG) = (yamop *) pt[1]; \
JMPNext(); \
} else { \
copy_jmp_addressa(pt+3); \
(*_PREG) = (yamop *) pt[3]; \
JMPNext(); \
} \
}
#define GO_ON_FUNC_END \
BLOCK = (CELL)GO_ON_FUNC_END;
#define GO_ON_CONS_INSTINIT \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0; \
{ \
CELL *pt = (CELL *)((*_PREG)->u.sssl.l); \
d0 = I_R; \
if (d0 == pt[0]) { \
copy_jmp_addressa(pt+1); \
(*_PREG) = (yamop *) pt[1]; \
JMPNext(); \
} else { \
copy_jmp_addressa(pt+3); \
(*_PREG) = (yamop *) pt[3]; \
JMPNext(); \
} \
}
#define GO_ON_CONS_END \
BLOCK = (CELL)GO_ON_CONS_END;
#define IF_FUNC_INSTINIT \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d1; \
register CELL *pt0; \
pt0 = (CELL *) (*_PREG)->u.sssl.l; \
d1 = *(*_SREG)++; \
while (pt0[0] != d1 && pt0[0] != (CELL)NULL ) { \
pt0 += 2; \
} \
copy_jmp_addressa(pt0+1); \
(*_PREG) = (yamop *) (pt0[1]); \
JMPNext();
#define IF_FUNC_END \
BLOCK = (CELL)IF_FUNC_END;
#define IF_CONS_INSTINIT \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d1; \
register CELL *pt0; \
pt0 = (CELL *) (*_PREG)->u.sssl.l; \
d1 = I_R; \
while (pt0[0] != d1 && pt0[0] != 0L ) { \
pt0 += 2; \
} \
copy_jmp_addressa(pt0+1); \
(*_PREG) = (yamop *) (pt0[1]); \
JMPNext();
#define IF_CONS_END \
BLOCK = (CELL)IF_CONS_END;
#define INDEX_DBREF_INSTINIT \
BLOCKADDRESS = (CELL)(*_PREG); \
(*_PREG) = NEXTOP((*_PREG), e); \
I_R = AbsAppl((*_SREG)-1); \
GONext();
#define INDEX_DBREF_END \
BLOCK = (CELL)INDEX_DBREF_END;
#define INDEX_BLOB_INSTINIT \
BLOCKADDRESS = (CELL)(*_PREG); \
(*_PREG) = NEXTOP((*_PREG), e); \
I_R = Yap_DoubleP_key((*_SREG)); \
GONext();
#define INDEX_BLOB_END \
BLOCK = (CELL)INDEX_BLOB_END;
#define INDEX_LONG_INSTINIT \
BLOCKADDRESS = (CELL)(*_PREG); \
(*_PREG) = NEXTOP((*_PREG), e); \
I_R = Yap_IntP_key((*_SREG)); \
GONext();
#define INDEX_LONG_END \
BLOCK = (CELL)INDEX_LONG_INSTINIT;

563
JIT/HPP/indexing_ext_d.h Normal file
View File

@ -0,0 +1,563 @@
#define USER_SWITCH_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
BLOCKADDRESS = (CELL)(*_PREG); \
{ \
yamop *new = Yap_udi_search((*_PREG)->u.lp.p); \
if (!new) { \
(*_PREG) = (*_PREG)->u.lp.l; \
JMPNext(); \
} \
else { \
(*_PREG) = new; \
JMPNext(); \
} \
}
#define USER_SWITCH_END \
BLOCK = (CELL)USER_SWITCH_END;
#define SWITCH_ON_TYPE_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0; \
register CELL *pt0; \
d0 = CACHED_A1(); \
Int nonvar = 1; \
if (IsVarTerm(d0)) { \
nonvar = 0; \
(pt0) = (CELL *)(d0); \
(d0) = *(CELL *)(d0); \
while (Unsigned(pt0) != (d0)) { \
if(!IsVarTerm(d0)) { \
nonvar = 1; \
break; \
} \
(pt0) = (CELL *)(d0); \
(d0) = *(CELL *)(d0); \
} \
if (!nonvar) { \
copy_jmp_address((*_PREG)->u.llll.l4); \
(*_PREG) = (*_PREG)->u.llll.l4; \
JMPNext(); \
} \
} \
if (nonvar) { \
if (IsPairTerm(d0)) { \
(*_SREG) = RepPair(d0); \
copy_jmp_address((*_PREG)->u.llll.l1); \
(*_PREG) = (*_PREG)->u.llll.l1; \
JMPNext(); \
} \
else if (!IsApplTerm(d0)) { \
copy_jmp_address((*_PREG)->u.llll.l2); \
(*_PREG) = (*_PREG)->u.llll.l2; \
I_R = d0; \
JMPNext(); \
} \
else { \
copy_jmp_address((*_PREG)->u.llll.l3); \
(*_PREG) = (*_PREG)->u.llll.l3; \
(*_SREG) = RepAppl(d0); \
JMPNext(); \
} \
}
#define SWITCH_ON_TYPE_END \
BLOCK = (CELL)SWITCH_ON_TYPE_END;
#if UNIQUE_TAG_FOR_PAIRS
#define SWITCH_LIST_NL_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0; \
register CELL *pt0; \
ALWAYS_LOOKAHEAD((*_PREG)->u.ollll.pop); \
d0 = CACHED_A1(); \
Int nonvar = 0; \
Int pair = 1; \
if (!IsPairTerm(d0)) { \
pair = 0; \
do { \
if (!IsVarTerm(d0)) { \
if (d0 == TermNil) { \
(*_PREG) = (*_PREG)->u.ollll.l2; \
JMPNext(); \
} \
else { \
if (IsApplTerm(d0)) { \
copy_jmp_address((*_PREG)->u.ollll.l3); \
(*_PREG) = (*_PREG)->u.ollll.l3; \
(*_SREG) = RepAppl(d0); \
JMPNext(); \
} else { \
copy_jmp_address((*_PREG)->u.ollll.l3); \
(*_PREG) = (*_PREG)->u.ollll.l3; \
I_R = d0; \
JMPNext(); \
} \
} \
nonvar = 1; \
break; \
} \
(pt0) = (CELL *)(d0); \
(d0) = *(pt0); \
if (Unsigned(pt0) == (d0)) break; \
if (IsPairTerm(d0)) { \
pair = 1; \
break; \
} \
} while (TRUE); \
if (!nonvar && !pair) { \
copy_jmp_address((*_PREG)->u.ollll.l4); \
(*_PREG) = (*_PREG)->u.ollll.l4; \
JMPNext(); \
} \
} \
if (!nonvar && pair) { \
copy_jmp_address((*_PREG)->u.ollll.l1); \
(*_PREG) = (*_PREG)->u.ollll.l1; \
(*_SREG) = RepPair(d0); \
ALWAYS_GONext(); \
}
#else
#define SWITCH_LIST_NL_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0; \
register CELL *pt0; \
ALWAYS_LOOKAHEAD((*_PREG)->u.ollll.pop); \
d0 = CACHED_A1(); \
Int nonvar = 0; \
if (IsVarTerm(d0)) { \
(pt0) = (CELL *)(d0); \
(d0) = *(CELL *)(d0); \
while (Unsigned(pt0) != (d0)) { \
if(!IsVarTerm(d0)) { \
nonvar = 1; \
break; \
} \
(pt0) = (CELL *)(d0); \
(d0) = *(CELL *)(d0); \
} \
if (!nonvar) { \
copy_jmp_address((*_PREG)->u.ollll.l4); \
(*_PREG) = (*_PREG)->u.ollll.l4; \
JMPNext(); \
} \
} \
if (nonvar) { \
if (__builtin_expect(IsPairTerm(d0),1)) { \
copy_jmp_address((*_PREG)->u.ollll.l1); \
(*_PREG) = (*_PREG)->u.ollll.l1; \
(*_SREG) = RepPair(d0); \
ALWAYS_GONext(); \
} \
if (d0 == TermNil) { \
(*_PREG) = (*_PREG)->u.ollll.l2; \
JMPNext(); \
} \
else { \
if (IsApplTerm(d0)) { \
copy_jmp_address((*_PREG)->u.ollll.l3); \
(*_PREG) = (*_PREG)->u.ollll.l3; \
(*_SREG) = RepAppl(d0); \
JMPNext(); \
} else { \
copy_jmp_address((*_PREG)->u.ollll.l3); \
(*_PREG) = (*_PREG)->u.ollll.l3; \
I_R = d0; \
JMPNext(); \
} \
} \
}
#endif
#define SWITCH_LIST_NL_END \
BLOCK = (CELL)SWITCH_LIST_NL_END;
#define SWITCH_ON_ARG_TYPE_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0; \
register CELL *pt0; \
d0 = XREG((*_PREG)->u.xllll.x); \
Int nonvar = 1; \
if (IsVarTerm(d0)) { \
nonvar = 0; \
(pt0) = (CELL *)(d0); \
(d0) = *(CELL *)(d0); \
while (Unsigned(pt0) != (d0)) { \
if(!IsVarTerm(d0)) { \
nonvar = 1; \
break; \
} \
(pt0) = (CELL *)(d0); \
(d0) = *(CELL *)(d0); \
} \
if (!nonvar) { \
copy_jmp_address((*_PREG)->u.xllll.l4); \
(*_PREG) = (*_PREG)->u.xllll.l4; \
JMPNext(); \
} \
} \
if (nonvar) { \
if (IsPairTerm(d0)) { \
copy_jmp_address((*_PREG)->u.xllll.l1); \
(*_PREG) = (*_PREG)->u.xllll.l1; \
(*_SREG) = RepPair(d0); \
JMPNext(); \
} \
else if (!IsApplTerm(d0)) { \
copy_jmp_address((*_PREG)->u.xllll.l2); \
(*_PREG) = (*_PREG)->u.xllll.l2; \
I_R = d0; \
JMPNext(); \
} \
else { \
copy_jmp_address((*_PREG)->u.xllll.l3); \
(*_PREG) = (*_PREG)->u.xllll.l3; \
(*_SREG) = RepAppl(d0); \
JMPNext(); \
} \
}
#define SWITCH_ON_ARG_TYPE_END \
BLOCK = (CELL)SWITCH_ON_ARG_TYPE_END;
#define SWITCH_ON_SUB_ARG_TYPE_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0; \
register CELL *pt0; \
d0 = (*_SREG)[(*_PREG)->u.sllll.s]; \
Int nonvar = 1; \
if (IsVarTerm(d0)) { \
nonvar = 0; \
(pt0) = (CELL *)(d0); \
(d0) = *(CELL *)(d0); \
while (Unsigned(pt0) != (d0)) { \
if(!IsVarTerm(d0)) { \
nonvar = 1; \
break; \
} \
(pt0) = (CELL *)(d0); \
(d0) = *(CELL *)(d0); \
} \
if (!nonvar) { \
copy_jmp_address((*_PREG)->u.sllll.l4); \
(*_PREG) = (*_PREG)->u.sllll.l4; \
JMPNext(); \
} \
} \
if (nonvar) { \
if (IsPairTerm(d0)) { \
copy_jmp_address((*_PREG)->u.sllll.l1); \
(*_PREG) = (*_PREG)->u.sllll.l1; \
(*_SREG) = RepPair(d0); \
JMPNext(); \
} \
else if (!IsApplTerm(d0)) { \
copy_jmp_address((*_PREG)->u.sllll.l2); \
(*_PREG) = (*_PREG)->u.sllll.l2; \
I_R = d0; \
JMPNext(); \
} \
else { \
copy_jmp_address((*_PREG)->u.sllll.l3); \
(*_PREG) = (*_PREG)->u.sllll.l3; \
(*_SREG) = RepAppl(d0); \
JMPNext(); \
} \
}
#define SWITCH_ON_SUB_ARG_TYPE_END \
BLOCK = (CELL)SWITCH_ON_SUB_ARG_TYPE_END;
#define JUMP_IF_VAR_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0; \
register CELL *pt0; \
d0 = CACHED_A1(); \
Int nonvar = 1; \
if (IsVarTerm(d0)) { \
nonvar = 0; \
(pt0) = (CELL *)(d0); \
(d0) = *(CELL *)(d0); \
while (Unsigned(pt0) != (d0)) { \
if(!IsVarTerm(d0)) { \
nonvar = 1; \
break; \
} \
(pt0) = (CELL *)(d0); \
(d0) = *(CELL *)(d0); \
} \
if (!nonvar) { \
copy_jmp_address((*_PREG)->u.l.l); \
(*_PREG) = (*_PREG)->u.l.l; \
JMPNext(); \
} \
} \
if (nonvar) { \
(*_PREG) = NEXTOP((*_PREG), l); \
JMPNext(); \
}
#define JUMP_IF_VAR_END \
BLOCK = (CELL)JUMP_IF_VAR_END;
#define JUMP_IF_NONVAR_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0; \
register CELL *pt0; \
d0 = XREG((*_PREG)->u.xll.x); \
Int nonvar = 0; \
if (IsVarTerm(d0)) { \
(pt0) = (CELL *)(d0); \
(d0) = *(CELL *)(d0); \
while (Unsigned(pt0) != (d0)) { \
if(!IsVarTerm(d0)) { \
nonvar = 1; \
break; \
} \
(pt0) = (CELL *)(d0); \
(d0) = *(CELL *)(d0); \
} \
if (!nonvar) { \
(*_PREG) = NEXTOP((*_PREG), xll); \
JMPNext(); \
} \
} \
if (nonvar) { \
copy_jmp_address((*_PREG)->u.xll.l1); \
(*_PREG) = (*_PREG)->u.xll.l1; \
JMPNext(); \
}
#define JUMP_IF_NONVAR_END \
BLOCK = (CELL)JUMP_IF_NONVAR_END;
#define IF_NOT_THEN_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0; \
register CELL *pt0; \
d0 = CACHED_A1(); \
Int nonvar = 1; \
if (IsVarTerm(d0)) { \
nonvar = 0; \
(pt0) = (CELL *)(d0); \
(d0) = *(CELL *)(d0); \
while (Unsigned(pt0) != (d0)) { \
if(!IsVarTerm(d0)) { \
nonvar = 1; \
break; \
} \
(pt0) = (CELL *)(d0); \
(d0) = *(CELL *)(d0); \
} \
if (!nonvar) { \
copy_jmp_address((*_PREG)->u.clll.l3); \
(*_PREG) = (*_PREG)->u.clll.l3; \
JMPNext(); \
} \
} \
if (nonvar) { \
if (d0 == (*_PREG)->u.clll.c) { \
copy_jmp_address((*_PREG)->u.clll.l2); \
(*_PREG) = (*_PREG)->u.clll.l2; \
JMPNext(); \
} \
else { \
copy_jmp_address((*_PREG)->u.clll.l1); \
(*_PREG) = (*_PREG)->u.clll.l1; \
JMPNext(); \
} \
}
#define IF_NOT_THEN_END \
BLOCK = (CELL)IF_NOT_THEN_END;
#define HRASH_SHIFT 6
#define SWITCH_ON_FUNC_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0, d1; \
register CELL *pt0; \
d1 = *(*_SREG)++; \
{ \
CELL \
Mask = ((*_PREG)->u.sssl.s - 1) << 1, \
hash = d1 >> (HRASH_SHIFT - 1) & Mask; \
CELL *base; \
base = (CELL *)(*_PREG)->u.sssl.l; \
pt0 = base + hash; \
d0 = pt0[0]; \
if (d0 == d1 || d0 == 0) { \
copy_jmp_addressa(pt0+1); \
(*_PREG) = (yamop *) (pt0[1]); \
JMPNext(); \
} \
else { \
register CELL d = ((d1 | 1) << 1) & Mask; \
while (1) { \
hash = (hash + d) & Mask; \
pt0 = base + hash; \
d0 = pt0[0]; \
if (d0 == d1 || d0 == 0) { \
copy_jmp_addressa(pt0+1); \
(*_PREG) = (yamop *) pt0[1]; \
break; \
} \
} \
} \
}
#define SWITCH_ON_FUNC_END \
BLOCK = (CELL)SWITCH_ON_FUNC_END;
#define SWITCH_ON_CONS_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0, d1; \
register CELL *pt0; \
d1 = I_R; \
{ \
CELL \
Mask = ((*_PREG)->u.sssl.s - 1) << 1, \
hash = d1 >> (HRASH_SHIFT - 1) & Mask; \
CELL *base; \
base = (CELL *)(*_PREG)->u.sssl.l; \
pt0 = base + hash; \
d0 = pt0[0]; \
if (d0 == d1 || d0 == 0) { \
copy_jmp_addressa(pt0+1); \
(*_PREG) = (yamop *) (pt0[1]); \
JMPNext(); \
} \
else { \
register CELL d = ((d1 | 1) << 1) & Mask; \
while (1) { \
hash = (hash + d) & Mask; \
pt0 = base + hash; \
d0 = pt0[0]; \
if (d0 == d1 || d0 == 0) { \
copy_jmp_addressa(pt0+1); \
(*_PREG) = (yamop *) pt0[1]; \
break; \
} \
} \
} \
}
#define SWITCH_ON_CONS_END \
BLOCK = (CELL)SWITCH_ON_CONS_END;
#define GO_ON_FUNC_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0; \
{ \
CELL *pt = (CELL *)((*_PREG)->u.sssl.l); \
d0 = *(*_SREG)++; \
if (d0 == pt[0]) { \
copy_jmp_addressa(pt+1); \
(*_PREG) = (yamop *) pt[1]; \
JMPNext(); \
} else { \
copy_jmp_addressa(pt+3); \
(*_PREG) = (yamop *) pt[3]; \
JMPNext(); \
} \
}
#define GO_ON_FUNC_END \
BLOCK = (CELL)GO_ON_FUNC_END;
#define GO_ON_CONS_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0; \
{ \
CELL *pt = (CELL *)((*_PREG)->u.sssl.l); \
d0 = I_R; \
if (d0 == pt[0]) { \
copy_jmp_addressa(pt+1); \
(*_PREG) = (yamop *) pt[1]; \
JMPNext(); \
} else { \
copy_jmp_addressa(pt+3); \
(*_PREG) = (yamop *) pt[3]; \
JMPNext(); \
} \
}
#define GO_ON_CONS_END \
BLOCK = (CELL)GO_ON_CONS_END;
#define IF_FUNC_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d1; \
register CELL *pt0; \
pt0 = (CELL *) (*_PREG)->u.sssl.l; \
d1 = *(*_SREG)++; \
while (pt0[0] != d1 && pt0[0] != (CELL)NULL ) { \
pt0 += 2; \
} \
copy_jmp_addressa(pt0+1); \
(*_PREG) = (yamop *) (pt0[1]); \
JMPNext();
#define IF_FUNC_END \
BLOCK = (CELL)IF_FUNC_END;
#define IF_CONS_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d1; \
register CELL *pt0; \
pt0 = (CELL *) (*_PREG)->u.sssl.l; \
d1 = I_R; \
while (pt0[0] != d1 && pt0[0] != 0L ) { \
pt0 += 2; \
} \
copy_jmp_addressa(pt0+1); \
(*_PREG) = (yamop *) (pt0[1]); \
JMPNext();
#define IF_CONS_END \
BLOCK = (CELL)IF_CONS_END;
#define INDEX_DBREF_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
BLOCKADDRESS = (CELL)(*_PREG); \
(*_PREG) = NEXTOP((*_PREG), e); \
I_R = AbsAppl((*_SREG)-1); \
GONext();
#define INDEX_DBREF_END \
BLOCK = (CELL)INDEX_DBREF_END;
#define INDEX_BLOB_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
BLOCKADDRESS = (CELL)(*_PREG); \
(*_PREG) = NEXTOP((*_PREG), e); \
I_R = Yap_DoubleP_key((*_SREG)); \
GONext();
#define INDEX_BLOB_END \
BLOCK = (CELL)INDEX_BLOB_END;
#define INDEX_LONG_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
BLOCKADDRESS = (CELL)(*_PREG); \
(*_PREG) = NEXTOP((*_PREG), e); \
I_R = Yap_IntP_key((*_SREG)); \
GONext();
#define INDEX_LONG_END \
BLOCK = (CELL)INDEX_LONG_INSTINIT;

1316
JIT/HPP/indexing_std.h Normal file

File diff suppressed because it is too large Load Diff

1350
JIT/HPP/indexing_std_d.h Normal file

File diff suppressed because it is too large Load Diff

45
JIT/HPP/jit_predicates.hh Normal file
View File

@ -0,0 +1,45 @@
#include "Yap.h"
#include "clause.h"
#include "eval.h"
#if HRAVE_ERRNO_H
#include <errno.h>
#else
extern int errno;
#endif
#include <string.h>
#include <ctype.h>
#define UPPER_ENTRY(S) \
tmp = (char*)malloc((strlen(S)+1)*sizeof(char)); \
while (S[i]) { \
if (S[i] != '-' && S[i] != '_' && S[i] != ' ') { \
if ((S[i] >= '0' && S[i] <= '9') || (S[i] == '.')) \
tmp[j] = S[i]; \
else \
tmp[j] = toupper(S[i]); \
j++; \
} \
i++; \
} \
tmp[j] = 0; \
strcpy(S, tmp); \
free(tmp);
#if YAP_JIT
void Yap_InitJitAnalysisPreds( void );
void Yap_InitJitCodegenPreds( void );
void Yap_InitJitConfigPreds( void );
void Yap_InitJitTransformPreds( void );
#if YAP_STAT_PREDS
void Yap_InitJitStatisticPreds( void );
#endif
#endif /* YAP_JIT */
#if YAP_DBG_PREDS
void Yap_InitJitDebugPreds( void );
#endif
Environment ExpEnv;
#if YAP_JIT
extern NativeContext *NativeArea;
extern IntermediatecodeContext *IntermediatecodeArea;
#endif

2398
JIT/HPP/lastop.h Normal file

File diff suppressed because it is too large Load Diff

17
JIT/HPP/native_header.h Normal file
View File

@ -0,0 +1,17 @@
#include <yaam_basics.h>
#include <yaam_primitive_predicates.h>
#include <yaam_call.h>
#include <yaam_call_count.h>
#include <yaam_cpred.h>
#include <yaam_cut.h>
#include <yaam_failure.h>
#include <yaam_get.h>
#include <indexing_ext.h>
#include <indexing_std.h>
#include <yaam_misc.h>
#include <yaam_pop.h>
#include <yaam_put.h>
#include <yaam_unify.h>
#include <yaam_write.h>
extern void print_block(YAP_BBs block, enumPlace place);

19
JIT/HPP/native_header_d.h Normal file
View File

@ -0,0 +1,19 @@
#include <yaam_basics_d.h>
#include <yaam_primitive_predicates_d.h>
#include <yaam_call_d.h>
#include <yaam_call_count_d.h>
#include <yaam_cpred_d.h>
#include <yaam_cut_d.h>
#include <yaam_failure_d.h>
#include <yaam_get_d.h>
#include <indexing_ext_d.h>
#include <indexing_std_d.h>
#include <yaam_misc_d.h>
#include <yaam_pop_d.h>
#include <yaam_put_d.h>
#include <yaam_unify_d.h>
#include <yaam_write_d.h>
extern void print_instruction(yamop*, enumPlace);
extern void print_block(YAP_BBs, enumPlace);
extern void print_main_when_head(yamop*, enumPlace);

2390
JIT/HPP/nextof.hh Normal file

File diff suppressed because it is too large Load Diff

661
JIT/HPP/p_dif.i Normal file
View File

@ -0,0 +1,661 @@
#define P_DIF_INSTINIT \
BLOCKADDRESS = (CELL)(*_PREG); \
#ifdef LOW_LEVEL_TRACER
#define P_DIF_LOW_LEVEL_TRACER \
low_level_trace(enter_pred,RepPredProp(Yap_GetPredPropByFunc(FunctorDiff,0)),XREGS+1);
#endif
#define P_DIF_POST_LOW_LEVEL_TRACER \
register CELL d0, d1; \
register CELL *pt0; \
d0 = ARG1;
#define P_DIF_DIF_NVAR1 \
d1 = ARG2;
#ifdef COROUTINING
#if defined(YAPOR_SBA) && defined(YAPOR)
#ifdef MULTI_ASSIGNMENT_VARIABLES
#ifdef FROZEN_STACKS
#define P_DIF_DIF_NVAR1_NVAR2 \
BLOCK = (CELL)P_DIF_DIF_NVAR1_NVAR2; \
if (d0 == d1) { \
(*_PREG) = (*_PREG)->u.l.l; \
GONext(); \
} \
else { \
if (IsAtomOrIntTerm(d0) || IsAtomOrIntTerm(d1)) { \
(*_PREG) = NEXTOP((*_PREG), l); \
GONext(); \
} \
else { \
Int opresult; \
CELL OldWokenGoals = Yap_ReadTimedVar(LOCAL_WokenGoals); \
register tr_fr_ptr pt0; \
pt0 = TR; \
BEGCHO(pt1); \
pt1 = B; \
HRBREG = HR; \
B = (choiceptr) HR; \
B->cp_h = HR; \
SET_BB(B); \
save_hb(); \
opresult = Yap_IUnify(d0, d1); \
Yap_UpdateTimedVar(LOCAL_WokenGoals, OldWokenGoals); \
if (OldWokenGoals == TermNil) { \
Yap_undo_signal(YAP_WAKEUP_SIGNAL); \
}\
B = pt1; \
SET_BB(PROTECT_FROZEN_B(pt1)); \
HR = HRBREG; \
HRBREG = B->cp_h; \
while (TR != pt0) { \
d1 = TrailTerm(--TR); \
if (IsVarTerm(d1)) { \
if (Unsigned((Int)(d1)-(Int)(H_FZ)) > \
Unsigned((Int)(B_FZ)-(Int)(H_FZ))) { \
RESET_VARIABLE(STACK_TO_SBA(d1)); \
} else \
RESET_VARIABLE(d1); \
} else { \
CELL *pt = RepAppl(d1); \
pt[0] = TrailVal(--TR); \
} \
} \
if (opresult) { \
(*_PREG) = (*_PREG)->u.l.l; \
GONext(); \
} \
else { \
(*_PREG) = NEXTOP((*_PREG), l); \
GONext(); \
} \
ENDCHO(pt1); \
} \
}
#else /* FROZEN_STACKS */
#define P_DIF_DIF_NVAR1_NVAR2 \
BLOCK = (CELL)P_DIF_DIF_NVAR1_NVAR2; \
if (d0 == d1) { \
(*_PREG) = (*_PREG)->u.l.l; \
GONext(); \
} \
else { \
if (IsAtomOrIntTerm(d0) || IsAtomOrIntTerm(d1)) { \
(*_PREG) = NEXTOP((*_PREG), l); \
GONext(); \
} \
else { \
Int opresult; \
CELL OldWokenGoals = Yap_ReadTimedVar(LOCAL_WokenGoals); \
register tr_fr_ptr pt0; \
pt0 = TR; \
BEGCHO(pt1); \
pt1 = B; \
HRBREG = HR; \
B = (choiceptr) HR; \
B->cp_h = HR; \
SET_BB(B); \
save_hb(); \
opresult = Yap_IUnify(d0, d1); \
Yap_UpdateTimedVar(LOCAL_WokenGoals, OldWokenGoals); \
if (OldWokenGoals == TermNil) { \
Yap_undo_signal(YAP_WAKEUP_SIGNAL); \
}\
B = pt1; \
SET_BB(PROTECT_FROZEN_B(pt1)); \
HR = HRBREG; \
HRBREG = B->cp_h; \
while (TR != pt0) { \
d1 = TrailTerm(--TR); \
if (IsVarTerm(d1)) { \
if (Unsigned((Int)(d1)-(Int)(H_FZ)) > \
Unsigned((Int)(B_FZ)-(Int)(H_FZ))) { \
RESET_VARIABLE(STACK_TO_SBA(d1)); \
} else \
RESET_VARIABLE(d1); \
} else { \
CELL *pt = RepAppl(d1); \
pt[0] = TrailTerm(--TR); \
TR--; \
} \
} \
if (opresult) { \
(*_PREG) = (*_PREG)->u.l.l; \
GONext(); \
} \
else { \
(*_PREG) = NEXTOP((*_PREG), l); \
GONext(); \
} \
ENDCHO(pt1); \
} \
}
#endif /* FROZEN_STACKS */
#else /*MULTI_ASSIGNMENT_VARIABLES */
#define P_DIF_DIF_NVAR1_NVAR2 \
BLOCK = (CELL)P_DIF_DIF_NVAR1_NVAR2; \
if (d0 == d1) { \
(*_PREG) = (*_PREG)->u.l.l; \
GONext(); \
} \
else { \
if (IsAtomOrIntTerm(d0) || IsAtomOrIntTerm(d1)) { \
(*_PREG) = NEXTOP((*_PREG), l); \
GONext(); \
} \
else { \
Int opresult; \
CELL OldWokenGoals = Yap_ReadTimedVar(LOCAL_WokenGoals); \
register tr_fr_ptr pt0; \
pt0 = TR; \
BEGCHO(pt1); \
pt1 = B; \
HRBREG = HR; \
B = (choiceptr) HR; \
B->cp_h = HR; \
SET_BB(B); \
save_hb(); \
opresult = Yap_IUnify(d0, d1); \
Yap_UpdateTimedVar(LOCAL_WokenGoals, OldWokenGoals); \
if (OldWokenGoals == TermNil) { \
Yap_undo_signal(YAP_WAKEUP_SIGNAL); \
}\
B = pt1; \
SET_BB(PROTECT_FROZEN_B(pt1)); \
HR = HRBREG; \
HRBREG = B->cp_h; \
while (TR != pt0) { \
d1 = TrailTerm(--TR); \
if (IsVarTerm(d1)) { \
if (Unsigned((Int)(d1)-(Int)(H_FZ)) > \
Unsigned((Int)(B_FZ)-(Int)(H_FZ))) { \
RESET_VARIABLE(STACK_TO_SBA(d1)); \
} else \
RESET_VARIABLE(d1); \
} \
} \
if (opresult) { \
(*_PREG) = (*_PREG)->u.l.l; \
GONext(); \
} \
else { \
(*_PREG) = NEXTOP((*_PREG), l); \
GONext(); \
} \
ENDCHO(pt1); \
} \
}
#endif /*MULTI_ASSIGNMENT_VARIABLES */
#else /* defined(YAPOR_SBA) && defined(YAPOR) */
#ifdef MULTI_ASSIGNMENT_VARIABLES
#ifdef FROZEN_STACKS
#define P_DIF_DIF_NVAR1_NVAR2 \
BLOCK = (CELL)P_DIF_DIF_NVAR1_NVAR2; \
if (d0 == d1) { \
(*_PREG) = (*_PREG)->u.l.l; \
GONext(); \
} \
else { \
if (IsAtomOrIntTerm(d0) || IsAtomOrIntTerm(d1)) { \
(*_PREG) = NEXTOP((*_PREG), l); \
GONext(); \
} \
else { \
Int opresult; \
CELL OldWokenGoals = Yap_ReadTimedVar(LOCAL_WokenGoals); \
register tr_fr_ptr pt0; \
pt0 = TR; \
BEGCHO(pt1); \
pt1 = B; \
HRBREG = HR; \
B = (choiceptr) HR; \
B->cp_h = HR; \
SET_BB(B); \
save_hb(); \
opresult = Yap_IUnify(d0, d1); \
Yap_UpdateTimedVar(LOCAL_WokenGoals, OldWokenGoals); \
if (OldWokenGoals == TermNil) { \
Yap_undo_signal(YAP_WAKEUP_SIGNAL); \
} \
B = pt1; \
SET_BB(PROTECT_FROZEN_B(pt1)); \
HR = HRBREG; \
HRBREG = B->cp_h; \
while (TR != pt0) { \
d1 = TrailTerm(--TR); \
if (IsVarTerm(d1)) { \
RESET_VARIABLE(d1); \
} else { \
CELL *pt = RepAppl(d1); \
pt[0] = TrailVal(--TR); \
} \
} \
if (opresult) { \
(*_PREG) = (*_PREG)->u.l.l; \
GONext(); \
} \
else { \
(*_PREG) = NEXTOP((*_PREG), l); \
GONext(); \
} \
ENDCHO(pt1); \
} \
}
#else /* FROZEN_STACKS */
#define P_DIF_DIF_NVAR1_NVAR2 \
BLOCK = (CELL)P_DIF_DIF_NVAR1_NVAR2; \
if (d0 == d1) { \
(*_PREG) = (*_PREG)->u.l.l; \
GONext(); \
} \
else { \
if (IsAtomOrIntTerm(d0) || IsAtomOrIntTerm(d1)) { \
(*_PREG) = NEXTOP((*_PREG), l); \
GONext(); \
} \
else { \
Int opresult; \
CELL OldWokenGoals = Yap_ReadTimedVar(LOCAL_WokenGoals); \
register tr_fr_ptr pt0; \
pt0 = TR; \
BEGCHO(pt1); \
pt1 = B; \
HRBREG = HR; \
B = (choiceptr) HR; \
B->cp_h = HR; \
SET_BB(B); \
save_hb(); \
opresult = Yap_IUnify(d0, d1); \
Yap_UpdateTimedVar(LOCAL_WokenGoals, OldWokenGoals); \
if (OldWokenGoals == TermNil) { \
Yap_undo_signal(YAP_WAKEUP_SIGNAL); \
}\
B = pt1; \
SET_BB(PROTECT_FROZEN_B(pt1)); \
HR = HRBREG; \
HRBREG = B->cp_h; \
while (TR != pt0) { \
d1 = TrailTerm(--TR); \
if (IsVarTerm(d1)) { \
RESET_VARIABLE(d1); \
} else { \
CELL *pt = RepAppl(d1); \
pt[0] = TrailTerm(--TR); \
TR--; \
} \
} \
if (opresult) { \
(*_PREG) = (*_PREG)->u.l.l; \
GONext(); \
} \
else { \
(*_PREG) = NEXTOP((*_PREG), l); \
GONext(); \
} \
ENDCHO(pt1); \
} \
}
#endif /* FROZEN_STACKS */
#else /*MULTI_ASSIGNMENT_VARIABLES */
#define P_DIF_DIF_NVAR1_NVAR2 \
BLOCK = (CELL)P_DIF_DIF_NVAR1_NVAR2; \
if (d0 == d1) { \
(*_PREG) = (*_PREG)->u.l.l; \
GONext(); \
} \
else { \
if (IsAtomOrIntTerm(d0) || IsAtomOrIntTerm(d1)) { \
(*_PREG) = NEXTOP((*_PREG), l); \
GONext(); \
} \
else { \
Int opresult; \
CELL OldWokenGoals = Yap_ReadTimedVar(LOCAL_WokenGoals); \
register tr_fr_ptr pt0; \
pt0 = TR; \
BEGCHO(pt1); \
pt1 = B; \
HRBREG = HR; \
B = (choiceptr) HR; \
B->cp_h = HR; \
SET_BB(B); \
save_hb(); \
opresult = Yap_IUnify(d0, d1); \
Yap_UpdateTimedVar(LOCAL_WokenGoals, OldWokenGoals); \
if (OldWokenGoals == TermNil) { \
Yap_undo_signal(YAP_WAKEUP_SIGNAL); \
}\
B = pt1; \
SET_BB(PROTECT_FROZEN_B(pt1)); \
HR = HRBREG; \
HRBREG = B->cp_h; \
while (TR != pt0) { \
d1 = TrailTerm(--TR); \
if (IsVarTerm(d1)) { \
RESET_VARIABLE(d1); \
} \
} \
if (opresult) { \
(*_PREG) = (*_PREG)->u.l.l; \
GONext(); \
} \
else { \
(*_PREG) = NEXTOP((*_PREG), l); \
GONext(); \
} \
ENDCHO(pt1); \
} \
}
#endif /*MULTI_ASSIGNMENT_VARIABLES */
#endif /* defined(YAPOR_SBA) && defined(YAPOR) */
#else /* COROUTINING */
#if defined(YAPOR_SBA) && defined(YAPOR)
#ifdef MULTI_ASSIGNMENT_VARIABLES
#ifdef FROZEN_STACKS
#define P_DIF_DIF_NVAR1_NVAR2 \
BLOCK = (CELL)P_DIF_DIF_NVAR1_NVAR2; \
if (d0 == d1) { \
(*_PREG) = (*_PREG)->u.l.l; \
GONext(); \
} \
else { \
if (IsAtomOrIntTerm(d0) || IsAtomOrIntTerm(d1)) { \
(*_PREG) = NEXTOP((*_PREG), l); \
GONext(); \
} \
else { \
Int opresult; \
register tr_fr_ptr pt0; \
pt0 = TR; \
BEGCHO(pt1); \
pt1 = B; \
HRBREG = HR; \
B = (choiceptr) HR; \
B->cp_h = HR; \
SET_BB(B); \
save_hb(); \
opresult = Yap_IUnify(d0, d1); \
B = pt1; \
SET_BB(PROTECT_FROZEN_B(pt1)); \
HRBREG = B->cp_h; \
while (TR != pt0) { \
d1 = TrailTerm(--TR); \
if (IsVarTerm(d1)) { \
if (Unsigned((Int)(d1)-(Int)(H_FZ)) > \
Unsigned((Int)(B_FZ)-(Int)(H_FZ))) { \
RESET_VARIABLE(STACK_TO_SBA(d1)); \
} else \
RESET_VARIABLE(d1); \
} else { \
CELL *pt = RepAppl(d1); \
pt[0] = TrailVal(--TR); \
} \
} \
if (opresult) { \
(*_PREG) = (*_PREG)->u.l.l; \
GONext(); \
} \
else { \
(*_PREG) = NEXTOP((*_PREG), l); \
GONext(); \
} \
ENDCHO(pt1); \
} \
}
#else /* FROZEN_STACKS */
#define P_DIF_DIF_NVAR1_NVAR2 \
BLOCK = (CELL)P_DIF_DIF_NVAR1_NVAR2; \
if (d0 == d1) { \
(*_PREG) = (*_PREG)->u.l.l; \
GONext(); \
} \
else { \
if (IsAtomOrIntTerm(d0) || IsAtomOrIntTerm(d1)) { \
(*_PREG) = NEXTOP((*_PREG), l); \
GONext(); \
} \
else { \
Int opresult; \
register tr_fr_ptr pt0; \
pt0 = TR; \
BEGCHO(pt1); \
pt1 = B; \
HRBREG = HR; \
B = (choiceptr) HR; \
B->cp_h = HR; \
SET_BB(B); \
save_hb(); \
opresult = Yap_IUnify(d0, d1); \
B = pt1; \
SET_BB(PROTECT_FROZEN_B(pt1)); \
HRBREG = B->cp_h; \
while (TR != pt0) { \
d1 = TrailTerm(--TR); \
if (IsVarTerm(d1)) { \
if (Unsigned((Int)(d1)-(Int)(H_FZ)) > \
Unsigned((Int)(B_FZ)-(Int)(H_FZ))) { \
RESET_VARIABLE(STACK_TO_SBA(d1)); \
} else \
RESET_VARIABLE(d1); \
} else { \
CELL *pt = RepAppl(d1); \
pt[0] = TrailTerm(--TR); \
TR--; \
} \
} \
if (opresult) { \
(*_PREG) = (*_PREG)->u.l.l; \
GONext(); \
} \
else { \
(*_PREG) = NEXTOP((*_PREG), l); \
GONext(); \
} \
ENDCHO(pt1); \
} \
}
#endif /* FROZEN_STACKS */
#else /*MULTI_ASSIGNMENT_VARIABLES */
#define P_DIF_DIF_NVAR1_NVAR2 \
BLOCK = (CELL)P_DIF_DIF_NVAR1_NVAR2; \
if (d0 == d1) { \
(*_PREG) = (*_PREG)->u.l.l; \
GONext(); \
} \
else { \
if (IsAtomOrIntTerm(d0) || IsAtomOrIntTerm(d1)) { \
(*_PREG) = NEXTOP((*_PREG), l); \
GONext(); \
} \
else { \
Int opresult; \
register tr_fr_ptr pt0; \
pt0 = TR; \
BEGCHO(pt1); \
pt1 = B; \
HRBREG = HR; \
B = (choiceptr) HR; \
B->cp_h = HR; \
SET_BB(B); \
save_hb(); \
opresult = Yap_IUnify(d0, d1); \
B = pt1; \
SET_BB(PROTECT_FROZEN_B(pt1)); \
HRBREG = B->cp_h; \
while (TR != pt0) { \
d1 = TrailTerm(--TR); \
if (IsVarTerm(d1)) { \
if (Unsigned((Int)(d1)-(Int)(H_FZ)) > \
Unsigned((Int)(B_FZ)-(Int)(H_FZ))) { \
RESET_VARIABLE(STACK_TO_SBA(d1)); \
} else \
RESET_VARIABLE(d1); \
} \
} \
if (opresult) { \
(*_PREG) = (*_PREG)->u.l.l; \
GONext(); \
} \
else { \
(*_PREG) = NEXTOP((*_PREG), l); \
GONext(); \
} \
ENDCHO(pt1); \
} \
}
#endif /*MULTI_ASSIGNMENT_VARIABLES */
#else /* defined(YAPOR_SBA) && defined(YAPOR) */
#ifdef MULTI_ASSIGNMENT_VARIABLES
#ifdef FROZEN_STACKS
#define P_DIF_DIF_NVAR1_NVAR2 \
BLOCK = (CELL)P_DIF_DIF_NVAR1_NVAR2; \
if (d0 == d1) { \
(*_PREG) = (*_PREG)->u.l.l; \
GONext(); \
} \
else { \
if (IsAtomOrIntTerm(d0) || IsAtomOrIntTerm(d1)) { \
(*_PREG) = NEXTOP((*_PREG), l); \
GONext(); \
} \
else { \
Int opresult; \
register tr_fr_ptr pt0; \
pt0 = TR; \
BEGCHO(pt1); \
pt1 = B; \
HRBREG = HR; \
B = (choiceptr) HR; \
B->cp_h = HR; \
SET_BB(B); \
save_hb(); \
opresult = Yap_IUnify(d0, d1); \
B = pt1; \
SET_BB(PROTECT_FROZEN_B(pt1)); \
HRBREG = B->cp_h; \
while (TR != pt0) { \
d1 = TrailTerm(--TR); \
if (IsVarTerm(d1)) { \
RESET_VARIABLE(d1); \
} else { \
CELL *pt = RepAppl(d1); \
pt[0] = TrailVal(--TR); \
} \
} \
if (opresult) { \
(*_PREG) = (*_PREG)->u.l.l; \
GONext(); \
} \
else { \
(*_PREG) = NEXTOP((*_PREG), l); \
GONext(); \
} \
ENDCHO(pt1); \
} \
}
#else /* FROZEN_STACKS */
#define P_DIF_DIF_NVAR1_NVAR2 \
BLOCK = (CELL)P_DIF_DIF_NVAR1_NVAR2; \
if (d0 == d1) { \
(*_PREG) = (*_PREG)->u.l.l; \
GONext(); \
} \
else { \
if (IsAtomOrIntTerm(d0) || IsAtomOrIntTerm(d1)) { \
(*_PREG) = NEXTOP((*_PREG), l); \
GONext(); \
} \
else { \
Int opresult; \
register tr_fr_ptr pt0; \
pt0 = TR; \
BEGCHO(pt1); \
pt1 = B; \
HRBREG = HR; \
B = (choiceptr) HR; \
B->cp_h = HR; \
SET_BB(B); \
save_hb(); \
opresult = Yap_IUnify(d0, d1); \
B = pt1; \
SET_BB(PROTECT_FROZEN_B(pt1)); \
HRBREG = B->cp_h; \
while (TR != pt0) { \
d1 = TrailTerm(--TR); \
if (IsVarTerm(d1)) { \
RESET_VARIABLE(d1); \
} else { \
CELL *pt = RepAppl(d1); \
pt[0] = TrailTerm(--TR); \
TR--; \
} \
} \
if (opresult) { \
(*_PREG) = (*_PREG)->u.l.l; \
GONext(); \
} \
else { \
(*_PREG) = NEXTOP((*_PREG), l); \
GONext(); \
} \
ENDCHO(pt1); \
} \
}
#endif /* FROZEN_STACKS */
#else /*MULTI_ASSIGNMENT_VARIABLES */
#define P_DIF_DIF_NVAR1_NVAR2 \
BLOCK = (CELL)P_DIF_DIF_NVAR1_NVAR2; \
if (d0 == d1) { \
(*_PREG) = (*_PREG)->u.l.l; \
GONext(); \
} \
else { \
if (IsAtomOrIntTerm(d0) || IsAtomOrIntTerm(d1)) { \
(*_PREG) = NEXTOP((*_PREG), l); \
GONext(); \
} \
else { \
Int opresult; \
register tr_fr_ptr pt0; \
pt0 = TR; \
BEGCHO(pt1); \
pt1 = B; \
HRBREG = HR; \
B = (choiceptr) HR; \
B->cp_h = HR; \
SET_BB(B); \
save_hb(); \
opresult = Yap_IUnify(d0, d1); \
B = pt1; \
SET_BB(PROTECT_FROZEN_B(pt1)); \
HRBREG = B->cp_h; \
while (TR != pt0) { \
d1 = TrailTerm(--TR); \
if (IsVarTerm(d1)) { \
RESET_VARIABLE(d1); \
} \
} \
if (opresult) { \
(*_PREG) = (*_PREG)->u.l.l; \
GONext(); \
} \
else { \
(*_PREG) = NEXTOP((*_PREG), l); \
GONext(); \
} \
ENDCHO(pt1); \
} \
}
#endif /*MULTI_ASSIGNMENT_VARIABLES */
#endif /* defined(YAPOR_SBA) && defined(YAPOR) */
#endif /* COROUTINING */
#define P_DIF_DIF_UNK1 \
(*_PREG) = (*_PREG)->u.l.l; \
GONext();
#define P_DIF_DIF_NVAR1_UNK2 \
(*_PREG) = (*_PREG)->u.l.l; \
GONext();

261
JIT/HPP/p_eq.i Normal file
View File

@ -0,0 +1,261 @@
#define P_EQ_INSTINIT \
BLOCKADDRESS = (CELL)(*_PREG); \
#ifdef LOW_LEVEL_TRACER
#define P_EQ_LOW_LEVEL_TRACER \
low_level_trace(enter_pred,RepPredProp(Yap_GetPredPropByFunc(FunctorSame,0)),XREGS+1);
#endif
#define P_EQ_POST_LOW_LEVEL_TRACER \
register CELL d0, d1, d2; \
register CELL *pt0, *pt1; \
d0 = ARG1;
#define P_EQ_P_EQ_NVAR1 \
d1 = ARG2;
#ifdef USE_GMP
#define P_EQ_P_EQ_NVAR1_NVAR2 \
BLOCK = (CELL)P_EQ_P_EQ_NVAR1_NVAR2; \
FAILED = 0; \
if (d0 == d1) { \
(*_PREG) = NEXTOP((*_PREG), l); \
GONext(); \
} \
else { \
if (IsPairTerm(d0)) { \
if (!IsPairTerm(d1)) { \
(*_PREG) = (*_PREG)->u.l.l; \
GONext(); \
} \
else { \
always_save_pc(); \
d2 = iequ_complex(RepPair(d0)-1, RepPair(d0)+1,RepPair(d1)-1); \
if (d2 == FALSE) { \
(*_PREG) = (*_PREG)->u.l.l; \
GONext(); \
} \
else { \
always_set_pc(); \
(*_PREG) = NEXTOP((*_PREG), l); \
GONext(); \
} \
} \
} \
else if (IsApplTerm(d0)) { \
Functor f0 = FunctorOfTerm(d0); \
Functor f1; \
if (!IsApplTerm(d1)) { \
(*_PREG) = (*_PREG)->u.l.l; \
GONext(); \
} \
else { \
f1 = FunctorOfTerm(d1); \
if (IsExtensionFunctor(f0)) { \
switch ((CELL)f0) { \
case (CELL)FunctorDBRef: \
if (d0 == d1) { \
(*_PREG) = NEXTOP((*_PREG), l); \
GONext(); \
} \
else { \
(*_PREG) = (*_PREG)->u.l.l; \
GONext(); \
} \
break; \
case (CELL)FunctorLongInt: \
if (f1 != FunctorLongInt) { \
(*_PREG) = (*_PREG)->u.l.l; \
GONext(); \
} \
else if (LongIntOfTerm(d0) == LongIntOfTerm(d1)) { \
(*_PREG) = NEXTOP((*_PREG), l); \
GONext(); \
} \
else { \
(*_PREG) = (*_PREG)->u.l.l; \
GONext(); \
} \
break; \
case (CELL)FunctorBigInt: \
if (f1 != FunctorBigInt) { \
(*_PREG) = (*_PREG)->u.l.l; \
GONext(); \
} \
else if (Yap_gmp_tcmp_big_big(d0,d1) == 0) { \
(*_PREG) = NEXTOP((*_PREG), l); \
GONext(); \
} \
else { \
(*_PREG) = (*_PREG)->u.l.l; \
GONext(); \
} \
break; \
case (CELL)FunctorDouble: \
if (f1 != FunctorDouble) { \
(*_PREG) = (*_PREG)->u.l.l; \
GONext(); \
} \
else if (FloatOfTerm(d0) == FloatOfTerm(d1)) { \
(*_PREG) = NEXTOP((*_PREG), l); \
GONext(); \
} \
break; \
default: \
(*_PREG) = (*_PREG)->u.l.l; \
GONext(); \
} \
} \
else { \
if (f0 != f1) { \
(*_PREG) = (*_PREG)->u.l.l; \
GONext(); \
} \
else { \
always_save_pc(); \
d2 = iequ_complex(RepAppl(d0), RepAppl(d0)+ArityOfFunctor(f0), RepAppl(d1)); \
if (d2 == FALSE) { \
(*_PREG) = (*_PREG)->u.l.l; \
GONext(); \
} \
else { \
always_set_pc(); \
(*_PREG) = NEXTOP((*_PREG), l); \
GONext(); \
} \
} \
} \
} \
} \
else { \
(*_PREG) = (*_PREG)->u.l.l; \
GONext(); \
} \
}
#else /* USE_GMP */
#define P_EQ_P_EQ_NVAR1_NVAR2 \
BLOCK = (CELL)P_EQ_P_EQ_NVAR1_NVAR2; \
FAILED = 0; \
if (d0 == d1) { \
(*_PREG) = NEXTOP((*_PREG), l); \
GONext(); \
} \
else { \
if (IsPairTerm(d0)) { \
if (!IsPairTerm(d1)) { \
(*_PREG) = (*_PREG)->u.l.l; \
GONext(); \
} \
else { \
always_save_pc(); \
d2 = iequ_complex(RepPair(d0)-1, RepPair(d0)+1,RepPair(d1)-1); \
if (d2 == FALSE) { \
(*_PREG) = (*_PREG)->u.l.l; \
GONext(); \
} \
else { \
always_set_pc(); \
(*_PREG) = NEXTOP((*_PREG), l); \
GONext(); \
} \
} \
} \
else if (IsApplTerm(d0)) { \
Functor f0 = FunctorOfTerm(d0); \
Functor f1; \
if (!IsApplTerm(d1)) { \
(*_PREG) = (*_PREG)->u.l.l; \
GONext(); \
} \
else { \
f1 = FunctorOfTerm(d1); \
if (IsExtensionFunctor(f0)) { \
switch ((CELL)f0) { \
case (CELL)FunctorDBRef: \
if (d0 == d1) { \
(*_PREG) = NEXTOP((*_PREG), l); \
GONext(); \
} \
else { \
(*_PREG) = (*_PREG)->u.l.l; \
GONext(); \
} \
break; \
case (CELL)FunctorLongInt: \
if (f1 != FunctorLongInt) { \
(*_PREG) = (*_PREG)->u.l.l; \
GONext(); \
} \
else if (LongIntOfTerm(d0) == LongIntOfTerm(d1)) { \
(*_PREG) = NEXTOP((*_PREG), l); \
GONext(); \
} \
else { \
(*_PREG) = (*_PREG)->u.l.l; \
GONext(); \
} \
break; \
case (CELL)FunctorDouble: \
if (f1 != FunctorDouble) { \
(*_PREG) = (*_PREG)->u.l.l; \
GONext(); \
} \
else if (FloatOfTerm(d0) == FloatOfTerm(d1)) { \
(*_PREG) = NEXTOP((*_PREG), l); \
GONext(); \
} \
break; \
default: \
(*_PREG) = (*_PREG)->u.l.l; \
GONext(); \
} \
} \
else { \
if (f0 != f1) { \
(*_PREG) = (*_PREG)->u.l.l; \
GONext(); \
} \
else { \
always_save_pc(); \
d2 = iequ_complex(RepAppl(d0), RepAppl(d0)+ArityOfFunctor(f0), RepAppl(d1)); \
if (d2 == FALSE) { \
(*_PREG) = (*_PREG)->u.l.l; \
GONext(); \
} \
else { \
always_set_pc(); \
(*_PREG) = NEXTOP((*_PREG), l); \
GONext(); \
} \
} \
} \
} \
} \
else { \
(*_PREG) = (*_PREG)->u.l.l; \
GONext(); \
} \
}
#endif /* USE_GMP */
#define P_EQ_P_EQ_NVAR1_UNK2 \
(*_PREG) = (*_PREG)->u.l.l; \
GONext();
#define P_EQ_P_EQ_UNK1 \
d1 = ARG2;
#define P_EQ_P_EQ_VAR1_NVAR2 \
(*_PREG) = (*_PREG)->u.l.l; \
GONext();
#define P_EQ_P_EQ_VAR1_UNK2_END \
BLOCK = (CELL)P_EQ_P_EQ_VAR1_UNK2_END; \
if (pt1 != pt0) { \
(*_PREG) = (*_PREG)->u.l.l; \
GONext(); \
} \
else { \
(*_PREG) = NEXTOP((*_PREG), l); \
GONext(); \
}

1134
JIT/HPP/p_functor.i Normal file

File diff suppressed because it is too large Load Diff

3181
JIT/HPP/print_op.hh Normal file

File diff suppressed because it is too large Load Diff

3959
JIT/HPP/print_preg.h Normal file

File diff suppressed because it is too large Load Diff

5426
JIT/HPP/printblock.h Normal file

File diff suppressed because it is too large Load Diff

97
JIT/HPP/processa.cpp Normal file
View File

@ -0,0 +1,97 @@
#include <iostream>
#include <fstream>
#include <string>
#include <string.h>
#include <cstdlib>
using namespace std;
#define NFILES 13
string files[NFILES] = {"yaam_primitive_predicates",
"yaam_call",
"yaam_call_count",
"yaam_cut",
"yaam_failure",
"yaam_get",
"yaam_indexing_ext",
"yaam_indexing_std",
"yaam_misc",
"yaam_pop",
"yaam_put",
"yaam_unify",
"yaam_write"};
int main(int argc, char **argv)
{
std::string fileinname, fileoutname, linein, lineout;
char lineout_char[256];
ifstream filein;
ofstream fileout;
int k;
for (int i = 0; i < NFILES; i++)
{
linein = "";
lineout = "";
fileinname = files[i] + ".h";
fileoutname = files[i] + "_mod.h";
filein.open(fileinname.c_str());
if (!filein.is_open()) {
cout << "Erro ao abrir arquivo " << fileinname << " para leitura! Saindo..." << endl;
exit(1);
}
fileout.open(fileoutname.c_str());
if (!fileout.is_open()) {
cout << "Erro ao abrir arquivo " << fileoutname << " para escrita! Saindo..." << endl;
exit(1);
}
cout << "Processando arquivo " << fileinname << "!\n";
getline(filein, linein);
while (!filein.eof())
{
lineout = "";
strcpy(lineout_char, "");
//cout << "linein = " << linein << endl; /* */
if (linein.size() > 6)
{
if (linein.substr(0, 7) == "#define")
{
lineout = "#define";
k = 0;
for (int j = 7; j < linein.size(); j++)
{
if (linein[j] >= 'a' && linein[j] <= 'z')
{
//cout << "linein[j] = " << linein[j] << endl;
lineout_char[k++] = linein[j] - 32;
}
else
{
lineout_char[k++] = linein[j];
}
}
lineout_char[k] = '\0';
lineout += lineout_char;
//cout << "lineout 1 = " << lineout << endl;
}
else
{
lineout = linein;
//cout << "lineout 2 = " << lineout << endl;
}
}
else
{
lineout = linein;
//cout << "lineout 3 = " << lineout << endl;
}
fileout << lineout << endl;
getline(filein, linein);
}
lineout = linein;
fileout << lineout << endl;
filein.close();
fileout.close();
}
return 0;
}

View File

@ -0,0 +1,76 @@
#if (defined(YAPOR_SBA) && defined(YAPOR)) || defined(TABLING)
#define check_stack_on_fail \
if (__builtin_expect( ((Int)(Unsigned(YOUNGEST_CP((choiceptr)ENV_YREG,B_FZ)) - Unsigned(YOUNGEST_H(H_FZ,H))) < CreepFlag), 0) ) return external_labels[10];
#else
#define check_stack_on_fail \
if (__builtin_expect(((Int)(Unsigned(ENV_YREG) - Unsigned(HR)) < CreepFlag ), 0) ) return external_labels[10];
#endif /* YAPOR_SBA && YAPOR */
#define GONEXT() \
if (idx != -1) goto *NOp_Address_R[idx]; \
else BACK();
#define GONEXTW() \
if (idx != -1) goto *NOp_Address_W[idx]; \
else BACK();
#define YAAM_UnifyBound_TEST_ATTACHED(f,d0,pt0,d1) \
if (IsExtensionFunctor(f)) { \
if (unify_extension(f, d0, RepAppl(d0), d1)) \
{ GONEXT(); } \
else \
{ FAIL(); } \
}
#define YAAM_UnifyBound(d0,d1) \
if (d0 == d1) { GONEXT(); } \
if (IsPairTerm(d0)) { \
register CELL *ipt0, *ipt1; \
if (!IsPairTerm(d1)) { FAIL(); } \
ipt0 = RepPair(d0); \
ipt1 = RepPair(d1); \
save_hb(); \
always_save_pc(); \
if (IUnify_complex(ipt0-1,ipt0+1,ipt1-1)) {always_set_pc(); GONEXT();}\
else { FAIL(); } \
} else if (IsApplTerm(d0)) { \
register CELL *ipt0, *ipt1; \
register Functor f; \
if (!IsApplTerm(d1)) { FAIL(); } \
ipt0 = RepAppl(d0); \
ipt1 = RepAppl(d1); \
f = (Functor)*ipt0; \
if (f != (Functor)*ipt1) { FAIL(); } \
YAAM_UnifyBound_TEST_ATTACHED(f,d0,ipt0,d1); \
d0 = ArityOfFunctor(f); \
always_save_pc(); \
save_hb(); \
if (IUnify_complex(ipt0, ipt0+d0, ipt1)) {always_set_pc(); GONEXT();} \
else { FAIL(); } \
} \
else { FAIL(); }
#define _native_me_instinit \
(*_PREG) = NEXTOP((*_PREG), aFlp); \
GONEXT();
#ifdef COROUTINING
#define _op_fail_instinit \
if (PP) { \
UNLOCK(PP->PELock); \
PP = NULL; \
} \
CACHE_Y_AS_ENV(YREG); \
check_stack_on_fail; \
ENDCACHE_Y_AS_ENV(); \
FAIL();
#else /* COROUTINING */
#define _op_fail_instinit \
if (PP) { \
UNLOCK(PP->PELock); \
PP = NULL; \
} \
FAIL();
#endif /* COROUTINING */
#define I_R (XREGS[0])

2874
JIT/HPP/singlecode_call.h Normal file

File diff suppressed because it is too large Load Diff

3116
JIT/HPP/singlecode_cpred.h Normal file

File diff suppressed because it is too large Load Diff

247
JIT/HPP/singlecode_cut.h Normal file
View File

@ -0,0 +1,247 @@
#if (defined(YAPOR_SBA) && defined(YAPOR)) || defined(TABLING)
#define check_stack_on_cut \
if (__builtin_expect( ((Int)(Unsigned(YOUNGEST_CP((choiceptr)ENV_YREG,B_FZ)) - Unsigned(YOUNGEST_H(H_FZ,H))) < CreepFlag), 0) ) return external_labels[1];
#else
#define check_stack_on_cut \
if (__builtin_expect(((Int)(Unsigned(ENV_YREG) - Unsigned(HR)) < CreepFlag ), 0) ) return external_labels[1];
#endif /* YAPOR_SBA && YAPOR */
#if (defined(YAPOR_SBA) && defined(YAPOR)) || defined(TABLING)
#define check_stack_on_cutt \
if (__builtin_expect( ((Int)(Unsigned(YOUNGEST_CP((choiceptr)ENV_YREG,B_FZ)) - Unsigned(YOUNGEST_H(H_FZ,H))) < CreepFlag), 0) ) return external_labels[3];
#else
#define check_stack_on_cutt \
if (__builtin_expect(((Int)(Unsigned(ENV_YREG) - Unsigned(HR)) < CreepFlag ), 0) ) return external_labels[3];
#endif /* YAPOR_SBA && YAPOR */
#if (defined(YAPOR_SBA) && defined(YAPOR)) || defined(TABLING)
#define check_stack_on_commitx \
if (__builtin_expect( ((Int)(Unsigned(YOUNGEST_CP((choiceptr)ENV_YREG,B_FZ)) - Unsigned(YOUNGEST_H(H_FZ,H))) < CreepFlag), 0) ) return external_labels[11];
#else
#define check_stack_on_commitx \
if (__builtin_expect(((Int)(Unsigned(ENV_YREG) - Unsigned(HR)) < CreepFlag ), 0) ) return external_labels[11];
#endif /* YAPOR_SBA && YAPOR */
#ifdef COROUTINING
#define _cut_instinit \
if (FALSE) { \
CACHE_Y_AS_ENV(YREG); \
check_stack_on_cut; \
ENDCACHE_Y_AS_ENV(); \
} \
do_cut: \
SET_ASP(YREG, (*_PREG)->u.s.s); \
(*_PREG) = NEXTOP(NEXTOP(NEXTOP((*_PREG), s),Osbpp),l); \
saveregs(); \
prune((choiceptr)YREG[E_CB]); \
setregs(); \
GONEXT();
#else /* COROUTINING */
#define _cut_instinit \
SET_ASP(YREG, (*_PREG)->u.s.s); \
(*_PREG) = NEXTOP(NEXTOP(NEXTOP((*_PREG), s),Osbpp),l); \
saveregs(); \
prune((choiceptr)YREG[E_CB]); \
setregs(); \
GONEXT();
#endif /* COROUTINING */
#ifdef COROUTINING
#define _cut_t_instinit \
if (FALSE) { \
CACHE_Y_AS_ENV(YREG); \
check_stack_on_cutt; \
ENDCACHE_Y_AS_ENV(); \
} \
do_cut_t: \
SET_ASP(YREG, (*_PREG)->u.s.s); \
saveregs(); \
prune((choiceptr)YREG[E_CB]); \
setregs(); \
(*_PREG) = NEXTOP(NEXTOP(NEXTOP((*_PREG), s),Osbpp),l); \
GONEXT();
#else /* COROUTINING */
#define _cut_t_instinit \
SET_ASP(YREG, (*_PREG)->u.s.s); \
saveregs(); \
prune((choiceptr)YREG[E_CB]); \
setregs(); \
(*_PREG) = NEXTOP(NEXTOP(NEXTOP((*_PREG), s),Osbpp),l); \
GONEXT();
#endif /* COROUTINING */
#define CUT_E_INSTINIT
#ifdef COROUTINING
#define CUT_E_COROUTINING \
CACHE_Y_AS_ENV(YREG); \
check_stack(NoStackCutE, HR); \
ENDCACHE_Y_AS_ENV();
#endif
#define CUT_E_NOCOROUTINING \
SET_ASP(YREG, (*_PREG)->u.s.s); \
(*_PREG) = NEXTOP(NEXTOP(NEXTOP((*_PREG), s),Osbpp),l); \
saveregs(); \
prune((choiceptr)(*_SREG)[E_CB]); \
setregs(); \
GONext();
#if defined(YAPOR_SBA) && defined(FROZEN_STACKS)
#define _save_b_x_instinit \
BEGD(d0); \
d0 = (*_PREG)->u.x.x; \
XREG(d0) = MkIntegerTerm((Int)B); \
(*_PREG) = NEXTOP((*_PREG), x); \
ENDD(d0); \
GONEXT();
#else /* defined(YAPOR_SBA) && defined(FROZEN_STACKS) */
#define _save_b_x_instinit \
BEGD(d0); \
d0 = (*_PREG)->u.x.x; \
XREG(d0) = MkIntegerTerm(LCL0-(CELL *) (B)); \
(*_PREG) = NEXTOP((*_PREG), x); \
ENDD(d0); \
GONEXT();
#endif /* defined(YAPOR_SBA) && defined(FROZEN_STACKS) */
#if defined(YAPOR_SBA)
#define _save_b_y_instinit \
INITIALIZE_PERMVAR(YREG+(*_PREG)->u.y.y,MkIntegerTerm((Int)B)); \
(*_PREG) = NEXTOP((*_PREG), y); \
GONEXT();
#else /* defined(YAPOR_SBA) */
#define _save_b_y_instinit \
INITIALIZE_PERMVAR(YREG+(*_PREG)->u.y.y,MkIntegerTerm(LCL0-(CELL *)(B))); \
(*_PREG) = NEXTOP((*_PREG), y); \
GONEXT();
#endif /* defined(YAPOR_SBA) */
#ifdef COROUTINING
#if defined(YAPOR_SBA) && defined(FROZEN_STACKS)
#define _commit_b_x_instinit \
CACHE_Y_AS_ENV(YREG); \
check_stack_on_commitx; \
ENDCACHE_Y_AS_ENV(); \
do_commit_b_x: \
BEGD(d0); \
d0 = XREG((*_PREG)->u.xps.x); \
deref_head(d0, commit_b_x_unk); \
commit_b_x_nvar: \
SET_ASP(YREG, (*_PREG)->u.xps.s); \
(*_PREG) = NEXTOP(NEXTOP(NEXTOP((*_PREG), xps),Osbpp),l); \
{ \
choiceptr pt0; \
pt0 = (choiceptr)IntegerOfTerm(d0); \
saveregs(); \
prune(pt0); \
setregs(); \
} \
GONEXT(); \
\
BEGP(pt1); \
deref_body(d0, pt1, commit_b_x_unk, commit_b_x_nvar); \
ENDP(pt1); \
FAIL(); \
ENDD(d0);
#else /* defined(YAPOR_SBA) && defined(FROZEN_STACKS) */
#define _commit_b_x_instinit \
CACHE_Y_AS_ENV(YREG); \
check_stack_on_commitx; \
ENDCACHE_Y_AS_ENV(); \
do_commit_b_x: \
BEGD(d0); \
d0 = XREG((*_PREG)->u.xps.x); \
deref_head(d0, commit_b_x_unk); \
commit_b_x_nvar: \
SET_ASP(YREG, (*_PREG)->u.xps.s); \
(*_PREG) = NEXTOP(NEXTOP(NEXTOP((*_PREG), xps),Osbpp),l); \
{ \
choiceptr pt0; \
pt0 = (choiceptr)(LCL0-IntegerOfTerm(d0)); \
saveregs(); \
prune(pt0); \
setregs(); \
} \
GONEXT(); \
\
BEGP(pt1); \
deref_body(d0, pt1, commit_b_x_unk, commit_b_x_nvar); \
ENDP(pt1); \
FAIL(); \
ENDD(d0);
#endif /* defined(YAPOR_SBA) && defined(FROZEN_STACKS) */
#else /* COROUTINING */
#if defined(YAPOR_SBA) && defined(FROZEN_STACKS)
#define _commit_b_x_instinit \
BEGD(d0); \
d0 = XREG((*_PREG)->u.xps.x); \
deref_head(d0, commit_b_x_unk); \
commit_b_x_nvar: \
SET_ASP(YREG, (*_PREG)->u.xps.s); \
(*_PREG) = NEXTOP(NEXTOP(NEXTOP((*_PREG), xps),Osbpp),l); \
{ \
choiceptr pt0; \
pt0 = (choiceptr)IntegerOfTerm(d0); \
saveregs(); \
prune(pt0); \
setregs(); \
} \
GONEXT(); \
\
BEGP(pt1); \
deref_body(d0, pt1, commit_b_x_unk, commit_b_x_nvar); \
ENDP(pt1); \
FAIL(); \
ENDD(d0);
#else /* defined(YAPOR_SBA) && defined(FROZEN_STACKS) */
#define _commit_b_x_instinit \
BEGD(d0); \
d0 = XREG((*_PREG)->u.xps.x); \
deref_head(d0, commit_b_x_unk); \
commit_b_x_nvar: \
SET_ASP(YREG, (*_PREG)->u.xps.s); \
(*_PREG) = NEXTOP(NEXTOP(NEXTOP((*_PREG), xps),Osbpp),l); \
{ \
choiceptr pt0; \
pt0 = (choiceptr)(LCL0-IntegerOfTerm(d0)); \
saveregs(); \
prune(pt0); \
setregs(); \
} \
GONEXT(); \
\
BEGP(pt1); \
deref_body(d0, pt1, commit_b_x_unk, commit_b_x_nvar); \
ENDP(pt1); \
FAIL(); \
ENDD(d0);
#endif /* defined(YAPOR_SBA) && defined(FROZEN_STACKS) */
#endif /* COROUTINING */
#define COMMIT_B_Y_INSTINIT \
register CELL d0; \
register CELL *pt1;
#define COMMIT_B_Y_DO_COMMIT_B_Y \
d0 = YREG[(*_PREG)->u.yps.y];
#define COMMIT_B_Y_COMMIT_B_Y_NVAR \
SET_ASP(YREG, (*_PREG)->u.yps.s); \
(*_PREG) = NEXTOP(NEXTOP(NEXTOP((*_PREG), yps),Osbpp),l); \
choiceptr pt0;
#if defined(YAPOR_SBA) && defined(FROZEN_STACKS)
#define COMMIT_B_Y_YSBA_FROZEN \
pt0 = (choiceptr)IntegerOfTerm(d0);
#else
#define COMMIT_B_Y_NOYSBA_NOFROZEN \
pt0 = (choiceptr)(LCL0-IntegerOfTerm(d0));
#endif
#define COMMIT_B_Y_POST_YSBA_FROZEN \
saveregs(); \
prune(pt0); \
setregs(); \
GONext();

864
JIT/HPP/singlecode_get.h Normal file
View File

@ -0,0 +1,864 @@
#define _get_x_var_instinit \
register CELL d0; \
d0 = XREG((*_PREG)->u.xx.xr); \
XREG((*_PREG)->u.xx.xl) = d0; \
(*_PREG) = NEXTOP((*_PREG), xx); \
GONEXT();
#define _get_y_var_instinit \
register CELL d0; \
register CELL *pt0; \
pt0 = YREG + (*_PREG)->u.yx.y; \
d0 = XREG((*_PREG)->u.yx.x); \
(*_PREG) = NEXTOP((*_PREG), yx); \
INITIALIZE_PERMVAR(pt0,d0); \
GONEXT();
#define _get_yy_var_instinit \
register CELL d0, d1; \
register CELL *pt0, *pt1; \
CACHE_Y(YREG); \
pt0 = S_YREG + (*_PREG)->u.yyxx.y1; \
d0 = XREG((*_PREG)->u.yyxx.x1); \
pt1 = S_YREG + (*_PREG)->u.yyx.y2; \
d1 = XREG((*_PREG)->u.yyxx.x2); \
(*_PREG) = NEXTOP((*_PREG), yyxx); \
INITIALIZE_PERMVAR(pt0,d0); \
INITIALIZE_PERMVAR(pt1,d1); \
ENDCACHE_Y(); \
GONEXT();
#define _get_x_val_instinit \
BEGD(d0); \
d0 = XREG((*_PREG)->u.xx.xl); \
deref_head(d0, gvalx_unk); \
\
gvalx_nonvar: \
BEGD(d1); \
d1 = XREG((*_PREG)->u.xx.xr); \
deref_head(d1, gvalx_nonvar_unk); \
\
gvalx_nonvar_nonvar: \
(*_PREG) = NEXTOP((*_PREG), xx); \
YAAM_UnifyBound(d0, d1); \
\
BEGP(pt0); \
deref_body(d1, pt0, gvalx_nonvar_unk, gvalx_nonvar_nonvar); \
(*_PREG) = NEXTOP((*_PREG), xx); \
Bind(pt0, d0); \
GONEXT(); \
ENDP(pt0); \
ENDD(d1); \
\
BEGP(pt0); \
deref_body(d0, pt0, gvalx_unk, gvalx_nonvar); \
BEGD(d1); \
d1 = XREG((*_PREG)->u.xx.xr); \
deref_head(d1, gvalx_var_unk); \
\
gvalx_var_nonvar: \
(*_PREG) = NEXTOP((*_PREG), xx); \
Bind(pt0, d1); \
GONEXT(); \
\
BEGP(pt1); \
deref_body(d1, pt1, gvalx_var_unk, gvalx_var_nonvar); \
(*_PREG) = NEXTOP((*_PREG), xx); \
UnifyCells(pt0, pt1); \
GONEXT(); \
ENDP(pt1); \
ENDD(d1); \
ENDP(pt0); \
ENDD(d0);
#define _get_y_val_instinit \
BEGD(d0); \
BEGD(d1); \
BEGP(pt0); \
pt0 = YREG + (*_PREG)->u.yx.y; \
d0 = *pt0; \
\
deref_head(d0, gvaly_unk); \
gvaly_nonvar: \
d1 = XREG((*_PREG)->u.yx.x); \
deref_head(d1, gvaly_nonvar_unk); \
\
gvaly_nonvar_nonvar: \
(*_PREG) = NEXTOP((*_PREG), yx); \
YAAM_UnifyBound(d0, d1); \
\
BEGP(pt1); \
deref_body(d1, pt1, gvaly_nonvar_unk, gvaly_nonvar_nonvar); \
(*_PREG) = NEXTOP((*_PREG), yx); \
Bind(pt1, d0); \
GONEXT(); \
ENDP(pt1); \
\
derefa_body(d0, pt0, gvaly_unk, gvaly_nonvar); \
d1 = XREG((*_PREG)->u.yx.x); \
deref_head(d1, gvaly_var_unk); \
gvaly_var_nonvar: \
(*_PREG) = NEXTOP((*_PREG), yx); \
Bind(pt0, d1); \
GONEXT(); \
\
BEGP(pt1); \
deref_body(d1, pt1, gvaly_var_unk, gvaly_var_nonvar); \
(*_PREG) = NEXTOP((*_PREG), yx); \
UnifyCells(pt0, pt1); \
GONEXT(); \
ENDP(pt1); \
ENDP(pt0); \
ENDD(d1); \
ENDD(d0);
#define _get_atom_instinit \
BEGD(d0); \
BEGD(d1); \
d0 = XREG((*_PREG)->u.xc.x); \
d1 = (*_PREG)->u.xc.c; \
\
BEGP(pt0); \
deref_head(d0, gatom_unk); \
gatom_nonvar: \
if (d0 == d1) { \
(*_PREG) = NEXTOP((*_PREG), xc); \
GONEXT(); \
} \
else { \
FAIL(); \
} \
\
deref_body(d0, pt0, gatom_unk, gatom_nonvar); \
(*_PREG) = NEXTOP((*_PREG), xc); \
Bind(pt0, d1); \
GONEXT(); \
ENDP(pt0); \
ENDD(d1); \
ENDD(d0);
#define _get_2atoms_instinit \
BEGD(d0); \
BEGD(d1); \
d0 = ARG1; \
\
BEGP(pt0); \
deref_head(d0, gatom_2unk); \
gatom_2nonvar: \
if (d0 == (*_PREG)->u.cc.c1) { \
goto gatom_2b; \
} \
else { \
FAIL(); \
} \
\
deref_body(d0, pt0, gatom_2unk, gatom_2nonvar); \
Bind(pt0, (*_PREG)->u.cc.c1); \
ENDP(pt0); \
gatom_2b: \
d0 = ARG2; \
d1 = (*_PREG)->u.cc.c2; \
\
BEGP(pt0); \
deref_head(d0, gatom_2bunk); \
gatom_2bnonvar: \
if (d0 == d1) { \
(*_PREG) = NEXTOP((*_PREG), cc); \
GONEXT(); \
} \
else { \
FAIL(); \
} \
\
deref_body(d0, pt0, gatom_2bunk, gatom_2bnonvar); \
(*_PREG) = NEXTOP((*_PREG), cc); \
Bind(pt0, d1); \
GONEXT(); \
ENDP(pt0); \
ENDD(d1); \
ENDD(d0);
#define _get_3atoms_instinit \
BEGD(d0); \
BEGD(d1); \
d0 = ARG1; \
\
BEGP(pt0); \
deref_head(d0, gatom_3unk); \
gatom_3nonvar: \
if (d0 == (*_PREG)->u.ccc.c1) { \
goto gatom_3b; \
} \
else { \
FAIL(); \
} \
\
deref_body(d0, pt0, gatom_3unk, gatom_3nonvar); \
Bind(pt0, (*_PREG)->u.ccc.c1); \
ENDP(pt0); \
gatom_3b: \
d0 = ARG2; \
\
BEGP(pt0); \
deref_head(d0, gatom_3bunk); \
gatom_3bnonvar: \
if (d0 == (*_PREG)->u.ccc.c2) { \
goto gatom_3c; \
} \
else { \
FAIL(); \
} \
\
deref_body(d0, pt0, gatom_3bunk, gatom_3bnonvar); \
Bind(pt0, (*_PREG)->u.ccc.c2); \
ENDP(pt0); \
gatom_3c: \
d0 = ARG3; \
d1 = (*_PREG)->u.ccc.c3; \
\
BEGP(pt0); \
deref_head(d0, gatom_3cunk); \
gatom_3cnonvar: \
if (d0 == d1) { \
(*_PREG) = NEXTOP((*_PREG), ccc); \
GONEXT(); \
} \
else { \
FAIL(); \
} \
\
deref_body(d0, pt0, gatom_3cunk, gatom_3cnonvar); \
(*_PREG) = NEXTOP((*_PREG), ccc); \
Bind(pt0, d1); \
GONEXT(); \
ENDP(pt0); \
ENDD(d1); \
ENDD(d0);
#define GET_4ATOMS_INSTINIT \
register CELL d0, d1; \
register CELL *pt0; \
d0 = ARG1;
#define GET_4ATOMS_GATOM_4UNK \
Bind(pt0, (*_PREG)->u.cccc.c1);
#define GET_4ATOMS_GATOM_4B \
d0 = ARG2;
#define GET_4ATOMS_GATOM_4BUNK \
Bind(pt0, (*_PREG)->u.cccc.c2);
#define GET_4ATOMS_GATOM_4C \
d0 = ARG3;
#define GET_4ATOMS_GATOM_4CUNK \
Bind(pt0, (*_PREG)->u.cccc.c3);
#define GET_4ATOMS_GATOM_4D \
d0 = ARG4; \
d1 = (*_PREG)->u.cccc.c4;
#define GET_4ATOMS_EQUALS \
(*_PREG) = NEXTOP((*_PREG), cccc); \
GONext();
#define GET_4ATOMS_GATOM_4DUNK \
(*_PREG) = NEXTOP((*_PREG), cccc); \
Bind(pt0, d1); \
GONext();
#define GET_5ATOMS_INSTINIT \
register CELL d0, d1; \
register CELL *pt0; \
d0 = ARG1;
#define GET_5ATOMS_GATOM_5UNK \
Bind(pt0, (*_PREG)->u.ccccc.c1);
#define GET_5ATOMS_GATOM_5B \
d0 = ARG2;
#define GET_5ATOMS_GATOM_5BUNK \
Bind(pt0, (*_PREG)->u.ccccc.c2);
#define GET_5ATOMS_GATOM_5C \
d0 = ARG3;
#define GET_5ATOMS_GATOM_5CUNK \
Bind(pt0, (*_PREG)->u.ccccc.c3);
#define GET_5ATOMS_GATOM_5D \
d0 = ARG4;
#define GET_5ATOMS_GATOM_5DUNK \
Bind(pt0, (*_PREG)->u.ccccc.c4);
#define GET_5ATOMS_GATOM_5E \
d0 = ARG5; \
d1 = (*_PREG)->u.ccccc.c5;
#define GET_5ATOMS_EQUALS \
(*_PREG) = NEXTOP((*_PREG), ccccc); \
GONext();
#define GET_5ATOMS_GATOM_5EUNK \
(*_PREG) = NEXTOP((*_PREG), ccccc); \
Bind(pt0, d1); \
GONext();
#define GET_6ATOMS_INSTINIT \
register CELL d0, d1; \
register CELL *pt0; \
d0 = ARG1;
#define GET_6ATOMS_GATOM_6UNK \
Bind(pt0, (*_PREG)->u.cccccc.c1);
#define GET_6ATOMS_GATOM_6B \
d0 = ARG2;
#define GET_6ATOMS_GATOM_6BUNK \
Bind(pt0, (*_PREG)->u.cccccc.c2);
#define GET_6ATOMS_GATOM_6C \
d0 = ARG3;
#define GET_6ATOMS_GATOM_6CUNK \
Bind(pt0, (*_PREG)->u.cccccc.c3);
#define GET_6ATOMS_GATOM_6D \
d0 = ARG4;
#define GET_6ATOMS_GATOM_6DUNK \
Bind(pt0, (*_PREG)->u.cccccc.c4);
#define GET_6ATOMS_GATOM_6E \
d0 = ARG5;
#define GET_6ATOMS_GATOM_6EUNK \
Bind(pt0, (*_PREG)->u.cccccc.c5);
#define GET_6ATOMS_GATOM_6F \
d0 = ARG6; \
d1 = (*_PREG)->u.cccccc.c6;
#define GET_6ATOMS_EQUALS \
(*_PREG) = NEXTOP((*_PREG), cccccc); \
GONext();
#define GET_6ATOMS_GATOM_6FUNK \
(*_PREG) = NEXTOP((*_PREG), cccccc); \
Bind(pt0, d1); \
GONext();
#define _get_list_instinit \
BEGD(d0); \
d0 = XREG((*_PREG)->u.x.x); \
deref_head(d0, glist_unk); \
\
glist_nonvar: \
if (!IsPairTerm(d0)) { \
FAIL(); \
} \
(*_PREG) = NEXTOP((*_PREG), x); \
(*_SREG) = RepPair(d0); \
GONEXT(); \
\
BEGP(pt0); \
deref_body(d0, pt0, glist_unk, glist_nonvar); \
CACHE_S(); \
S_SREG = HR; \
(*_PREG) = NEXTOP((*_PREG), x); \
BEGD(d0); \
d0 = AbsPair(S_SREG); \
Bind(pt0, d0); \
S_SREG = HR; \
HR = S_SREG + 2; \
ENDD(d0); \
WRITEBACK_S(S_SREG); \
GONEXTW(); \
ENDCACHE_S(); \
ENDP(pt0); \
ENDD(d0);
#define _get_struct_instinit \
BEGD(d0); \
d0 = XREG((*_PREG)->u.xfa.x); \
deref_head(d0, gstruct_unk); \
\
gstruct_nonvar: \
if (!IsApplTerm(d0)) { \
FAIL(); \
} \
CACHE_S(); \
S_SREG = RepAppl(d0); \
d0 = (CELL) ((*_PREG)->u.xfa.f); \
if (*S_SREG != d0) { \
FAIL(); \
} \
WRITEBACK_S(S_SREG+1); \
ENDCACHE_S(); \
(*_PREG) = NEXTOP((*_PREG), xfa); \
GONEXT(); \
\
BEGP(pt0); \
deref_body(d0, pt0, gstruct_unk, gstruct_nonvar); \
BEGD(d1); \
d1 = AbsAppl(HR); \
Bind(pt0, d1); \
pt0 = HR; \
ENDD(d1); \
d0 = (CELL) ((*_PREG)->u.xfa.f); \
*pt0++ = d0; \
HR = pt0 + (*_PREG)->u.xfa.a; \
(*_PREG) = NEXTOP((*_PREG), xfa); \
(*_SREG) = pt0; \
GONEXTW(); \
ENDP(pt0); \
ENDD(d0);
#if SIZEOF_DOUBLE == 2*SIZEOF_INT_P
#define _get_float_instinit \
BEGD(d0); \
d0 = XREG((*_PREG)->u.xd.x); \
deref_head(d0, gfloat_unk); \
\
gfloat_nonvar: \
if (!IsApplTerm(d0)) { \
FAIL(); \
} \
BEGP(pt0); \
pt0 = RepAppl(d0); \
if (*pt0 != (CELL)FunctorDouble) { \
FAIL(); \
} \
BEGP(pt1); \
pt1 = (*_PREG)->u.xd.d; \
(*_PREG) = NEXTOP((*_PREG), xd); \
if ( \
pt1[1] != pt0[1] \
|| pt1[2] != pt0[2] \
) { \
FAIL(); \
} \
ENDP(pt1); \
ENDP(pt0); \
GONEXT(); \
\
BEGP(pt0); \
deref_body(d0, pt0, gfloat_unk, gfloat_nonvar); \
BEGD(d1); \
d1 = AbsAppl((*_PREG)->u.xd.d); \
(*_PREG) = NEXTOP((*_PREG), xd); \
Bind(pt0, d1); \
GONEXT(); \
ENDD(d1); \
ENDP(pt0); \
ENDD(d0);
#else /* SIZEOF_DOUBLE == 2*SIZEOF_INT_P */
#define _get_float_instinit \
BEGD(d0); \
d0 = XREG((*_PREG)->u.xd.x); \
deref_head(d0, gfloat_unk); \
\
gfloat_nonvar: \
if (!IsApplTerm(d0)) { \
FAIL(); \
} \
BEGP(pt0); \
pt0 = RepAppl(d0); \
if (*pt0 != (CELL)FunctorDouble) { \
FAIL(); \
} \
BEGP(pt1); \
pt1 = (*_PREG)->u.xd.d; \
(*_PREG) = NEXTOP((*_PREG), xd); \
if ( \
pt1[1] != pt0[1] \
) { \
FAIL(); \
} \
ENDP(pt1); \
ENDP(pt0); \
GONEXT(); \
\
BEGP(pt0); \
deref_body(d0, pt0, gfloat_unk, gfloat_nonvar); \
BEGD(d1); \
d1 = AbsAppl((*_PREG)->u.xd.d); \
(*_PREG) = NEXTOP((*_PREG), xd); \
Bind(pt0, d1); \
GONEXT(); \
ENDD(d1); \
ENDP(pt0); \
ENDD(d0);
#endif /* SIZEOF_DOUBLE == 2*SIZEOF_INT_P */
#define GET_LONGINT_INSTINIT \
register CELL d0, d1; \
register CELL *pt0; \
d0 = XREG((*_PREG)->u.xi.x);
#define GET_LONGINT_GLONGINT_NONVAR_INIT \
START_PREFETCH(xi); \
pt0 = RepAppl(d0);
#define GET_LONGINT_GLONGINT_NONVAR_END \
(*_PREG) = NEXTOP((*_PREG), xi); \
GONext(); \
END_PREFETCH();
#define GET_LONGINT_GLONGINT_UNK \
START_PREFETCH(xi); \
d1 = AbsAppl((*_PREG)->u.xi.i); \
(*_PREG) = NEXTOP((*_PREG), xi); \
Bind(pt0, d1); \
GONext(); \
END_PREFETCH();
#ifdef USE_GMP
#define GET_BIGINT_INSTINIT \
register CELL d0, d1; \
register CELL *pt0; \
d0 = XREG((*_PREG)->u.xN.x);
#define GET_BIGINT_GBIGINT_NONVAR_INIT \
START_PREFETCH(xN); \
pt0 = RepAppl(d0);
#define GET_BIGINT_GBIGINT_NONVAR_END \
(*_PREG) = NEXTOP((*_PREG), xN); \
GONext(); \
END_PREFETCH();
#define GET_BIGINT_GBIGINT_UNK \
START_PREFETCH(xN); \
d1 = (*_PREG)->u.xN.b; \
(*_PREG) = NEXTOP((*_PREG), xN); \
Bind(pt0, d1); \
GONext(); \
END_PREFETCH();
#endif
#define GET_DBTERM_INSTINIT \
register CELL d0, d1; \
register CELL *pt0; \
d0 = XREG((*_PREG)->u.xD.x);
#define GET_DBTERM_GDBTERM_NONVAR \
BLOCK = (CELL)GET_DBTERM_GDBTERM_NONVAR; \
d1 = (*_PREG)->u.xD.D; \
(*_PREG) = NEXTOP((*_PREG), xD); \
YAAM_UNIFYBOUND;
#define GET_DBTERM_GDBTERM_UNK \
START_PREFETCH(xD); \
d1 = (*_PREG)->u.xD.D; \
(*_PREG) = NEXTOP((*_PREG), xD); \
Bind(pt0, d1); \
GONext(); \
END_PREFETCH();
#define _glist_valx_instinit \
BEGD(d0); \
d0 = XREG((*_PREG)->u.xx.xl); \
deref_head(d0, glist_valx_write); \
glist_valx_read: \
BEGP(pt0); \
if (!IsPairTerm(d0)) { \
FAIL(); \
} \
pt0 = RepPair(d0); \
(*_SREG) = pt0 + 1; \
d0 = *pt0; \
deref_head(d0, glist_valx_unk); \
\
glist_valx_nonvar: \
BEGD(d1); \
d1 = XREG((*_PREG)->u.xx.xr); \
deref_head(d1, glist_valx_nonvar_unk); \
\
glist_valx_nonvar_nonvar: \
(*_PREG) = NEXTOP((*_PREG), xx); \
YAAM_UnifyBound(d0, d1); \
\
BEGP(pt1); \
deref_body(d1, pt1, glist_valx_nonvar_unk, glist_valx_nonvar_nonvar); \
(*_PREG) = NEXTOP((*_PREG), xx); \
Bind(pt1, d0); \
GONEXT(); \
ENDP(pt1); \
ENDD(d1); \
\
derefa_body(d0, pt0, glist_valx_unk, glist_valx_nonvar); \
d0 = XREG((*_PREG)->u.xx.xr); \
deref_head(d0, glist_valx_var_unk); \
\
glist_valx_var_nonvar: \
(*_PREG) = NEXTOP((*_PREG), xx); \
Bind_Global(pt0, d0); \
GONEXT(); \
\
BEGP(pt1); \
deref_body(d0, pt1, glist_valx_var_unk, glist_valx_var_nonvar); \
(*_PREG) = NEXTOP((*_PREG), xx); \
UnifyGlobalCellToCell(pt0, pt1); \
GONEXT(); \
ENDP(pt1); \
ENDP(pt0); \
\
BEGP(pt0); \
deref_body(d0, pt0, glist_valx_write, glist_valx_read); \
CACHE_S(); \
S_SREG = HR; \
BEGD(d1); \
d1 = XREG((*_PREG)->u.xx.xr); \
d0 = AbsPair(S_SREG); \
S_SREG[0] = d1; \
ENDD(d1); \
(*_PREG) = NEXTOP((*_PREG), xx); \
HR = S_SREG + 2; \
WRITEBACK_S(S_SREG+1); \
Bind(pt0, d0); \
GONEXTW(); \
ENDCACHE_S(); \
ENDP(pt0); \
ENDD(d0);
#define GLIST_VALY_INSTINIT \
register CELL d0, d1; \
register CELL *pt0, *pt1; \
d0 = XREG((*_PREG)->u.yx.x);
#define GLIST_VALY_GLIST_VALY_READ \
if (!IsPairTerm(d0)) { \
YAAM_FAIL; \
} \
START_PREFETCH(yx); \
pt0 = RepPair(d0); \
(*_SREG) = pt0 + 1; \
d0 = *pt0;
#define GLIST_VALY_GLIST_VALY_NONVAR \
pt1 = YREG + (*_PREG)->u.yx.y; \
d1 = *pt1; \
(*_PREG) = NEXTOP((*_PREG), yx);
#define GLIST_VALY_GLIST_VALY_NONVAR_NONVAR \
BLOCK = (CELL)GLIST_VALY_GLIST_VALY_NONVAR_NONVAR; \
(*_SREG) = pt0 + 1; \
YAAM_UNIFYBOUND;
#define GLIST_VALY_GLIST_VALY_NONVAR_UNK \
Bind(pt1, d0); \
GONext();
#define GLIST_VALY_GLIST_VALY_UNK \
pt1 = YREG+(*_PREG)->u.yx.y; \
d1 = *pt1;
#define GLIST_VALY_GLIST_VALY_VAR_NONVAR \
(*_PREG) = NEXTOP((*_PREG), yx); \
Bind_Global(pt0, d1); \
GONext();
#define GLIST_VALY_GLIST_VALY_VAR_UNK \
(*_PREG) = NEXTOP((*_PREG), yx); \
UnifyGlobalCellToCell(pt0, pt1); \
GONext(); \
END_PREFETCH();
#define GLIST_VALY_GLIST_VALY_WRITE \
START_PREFETCH_W(yx); \
pt1 = HR; \
d0 = AbsPair(pt1); \
Bind(pt0, d0); \
d0 = YREG[(*_PREG)->u.yx.y]; \
pt1[0] = d0; \
HR = pt1 + 2; \
(*_SREG) = pt1 + 1; \
(*_PREG) = NEXTOP((*_PREG), yx); \
GONextW(); \
END_PREFETCH_W();
#define _gl_void_varx_instinit \
BEGD(d0); \
d0 = XREG((*_PREG)->u.xx.xl); \
deref_head(d0, glist_void_varx_write); \
glist_void_varx_read: \
if (!IsPairTerm(d0)) { \
FAIL(); \
} \
BEGP(pt0); \
pt0 = RepPair(d0); \
d0 = pt0[1]; \
XREG((*_PREG)->u.xx.xr) = d0; \
(*_PREG) = NEXTOP((*_PREG), xx); \
GONEXT(); \
ENDP(pt0); \
\
BEGP(pt0); \
deref_body(d0, pt0, glist_void_varx_write, glist_void_varx_read); \
BEGP(pt1); \
pt1 = HR; \
XREG((*_PREG)->u.xx.xr) = \
Unsigned(pt1 + 1); \
RESET_VARIABLE(pt1); \
RESET_VARIABLE(pt1+1); \
HR = pt1 + 2; \
BEGD(d0); \
d0 = AbsPair(pt1); \
Bind(pt0, d0); \
(*_PREG) = NEXTOP((*_PREG), xx); \
ENDD(d0); \
ENDP(pt1); \
GONEXT(); \
ENDP(pt0); \
ENDD(d0);
#define GL_VOID_VARY_INSTINIT \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0; \
register CELL *pt0, *pt1; \
d0 = XREG((*_PREG)->u.yx.x);
#define GL_VOID_VARY_GLIST_VOID_VARY_READ \
BLOCK = (CELL)GL_VOID_VARY_GLIST_VOID_VARY_READ; \
FAILED = 0; \
if (!IsPairTerm(d0)) { \
YAAM_FAIL; \
} \
else { \
pt0 = RepPair(d0); \
d0 = pt0[1]; \
INITIALIZE_PERMVAR(YREG+(*_PREG)->u.yx.y,d0); \
(*_PREG) = NEXTOP((*_PREG), yx); \
GONext(); \
}
#define GL_VOID_VARY_GLIST_VOID_VARY_WRITE \
pt1 = HR; \
INITIALIZE_PERMVAR(YREG+(*_PREG)->u.yx.y,Unsigned(pt1 + 1)); \
(*_PREG) = NEXTOP((*_PREG), yx); \
RESET_VARIABLE(pt1); \
RESET_VARIABLE(pt1+1); \
d0 = AbsPair(pt1); \
HR = pt1 + 2; \
Bind(pt0, d0); \
GONext();
#define GL_VOID_VALX_INSTINIT \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0, d1; \
register CELL *pt0, *pt1; \
d0 = XREG((*_PREG)->u.xx.xl);
#define GL_VOID_VALX_GLIST_VOID_VALX_READ \
BLOCK = (CELL)GL_VOID_VALX_GLIST_VOID_VALX_READ; \
FAILED = 0; \
if (!IsPairTerm(d0)) { \
YAAM_FAIL; \
} \
else { \
pt0 = RepPair(d0)+1; \
d0 = *pt0; \
}
#define GL_VOID_VALX_GLIST_VOID_VALX_NONVAR \
d1 = XREG((*_PREG)->u.xx.xr);
#define GL_VOID_VALX_GLIST_VOID_VALX_NONVAR_NONVAR \
BLOCK = (CELL)GL_VOID_VALX_GLIST_VOID_VALX_NONVAR_NONVAR; \
(*_PREG) = NEXTOP((*_PREG), xx); \
YAAM_UNIFYBOUND;
#define GL_VOID_VALX_GLIST_VOID_VALX_NONVAR_UNK \
(*_PREG) = NEXTOP((*_PREG), xx); \
Bind(pt1, d0); \
GONext();
#define GL_VOID_VALX_GLIST_VOID_VALX_UNK \
d1 = XREG((*_PREG)->u.xx.xr);
#define GL_VOID_VALX_GLIST_VOID_VALX_VAR_NONVAR \
(*_PREG) = NEXTOP((*_PREG), xx); \
Bind_Global(pt0, d1); \
GONext();
#define GL_VOID_VALX_GLIST_VOID_VALX_VAR_UNK \
(*_PREG) = NEXTOP((*_PREG), xx); \
UnifyGlobalCellToCell(pt0, pt1); \
GONext();
#define GL_VOID_VALX_GLIST_VOID_VALX_WRITE \
pt1 = HR; \
d0 = AbsPair(pt1); \
Bind(pt0, d0); \
pt1 = HR; \
d0 = XREG((*_PREG)->u.xx.xr); \
RESET_VARIABLE(pt1); \
pt1[1] = d0; \
HR = pt1 + 2; \
(*_PREG) = NEXTOP((*_PREG), xx); \
GONext();
#define GL_VOID_VALY_INSTINIT \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0, d1; \
register CELL *pt0, *pt1; \
d0 = XREG((*_PREG)->u.yx.x);
#define GL_VOID_VALY_GLIST_VOID_VALY_READ \
BLOCK = (CELL)GL_VOID_VALY_GLIST_VOID_VALY_READ; \
FAILED = 0; \
if (!IsPairTerm(d0)) { \
YAAM_FAIL; \
} \
else { \
pt0 = RepPair(d0)+1; \
d0 = *pt0; \
}
#define GL_VOID_VALY_GLIST_VOID_VALY_NONVAR \
pt1 = YREG+(*_PREG)->u.yx.y; \
d1 = *pt1;
#define GL_VOID_VALY_GLIST_VOID_VALY_NONVAR_NONVAR \
BLOCK = (CELL)GL_VOID_VALY_GLIST_VOID_VALY_NONVAR_NONVAR; \
(*_PREG) = NEXTOP((*_PREG), yx); \
YAAM_UNIFYBOUND;
#define GL_VOID_VALY_GLIST_VOID_VALY_NONVAR_UNK \
(*_PREG) = NEXTOP((*_PREG), yx); \
Bind(pt1, d0); \
GONext();
#define GL_VOID_VALY_GLIST_VOID_VALY_UNK \
pt1 = YREG+(*_PREG)->u.yx.y; \
d1 = *pt1;
#define GL_VOID_VALY_GLIST_VOID_VALY_VAR_NONVAR \
(*_PREG) = NEXTOP((*_PREG), yx); \
Bind_Global(pt0, d1); \
GONext();
#define GL_VOID_VALY_GLIST_VOID_VALY_VAR_UNK \
(*_PREG) = NEXTOP((*_PREG), yx); \
UnifyGlobalCellToCell(pt0, pt1); \
GONext();
#define GL_VOID_VALY_GLIST_VOID_VALY_WRITE \
CACHE_S(); \
S_SREG = HR; \
d0 = AbsPair(S_SREG); \
Bind(pt0, d0); \
S_SREG = HR; \
d1 = YREG[(*_PREG)->u.yx.y]; \
RESET_VARIABLE(S_SREG); \
S_SREG[1] = d1; \
(*_PREG) = NEXTOP((*_PREG), yx); \
HR = S_SREG + 2; \
ENDCACHE_S(); \
GONext();

1753
JIT/HPP/singlecode_misc.h Normal file

File diff suppressed because it is too large Load Diff

36
JIT/HPP/singlecode_pop.h Normal file
View File

@ -0,0 +1,36 @@
#define POP_N_INIT \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0; \
d0 = (*_PREG)->u.os.s; \
SP = (CELL *) (((char *) SP) + d0); \
d0 = SP[0]; \
if (d0) { \
(*_SREG) = (CELL *) (SP[1]); \
SP += 2; \
(*_PREG) = NEXTOP((*_PREG), s); \
GONext(); \
} \
else { \
(*_SREG) = (CELL *) (SP[1]); \
SP += 2; \
(*_PREG) = NEXTOP((*_PREG), s); \
GONextW(); \
}
#define POP_N_END \
BLOCK = (CELL)POP_N_END;
#define _pop_instinit \
BEGD(d0); \
d0 = SP[0]; \
(*_SREG) = (CELL *) (SP[1]); \
SP += 2; \
if (d0) { \
(*_PREG) = NEXTOP((*_PREG), e); \
GONEXT(); \
} \
else { \
(*_PREG) = NEXTOP((*_PREG), e); \
GONEXTW(); \
} \
ENDD(d0);

File diff suppressed because it is too large Load Diff

180
JIT/HPP/singlecode_put.h Normal file
View File

@ -0,0 +1,180 @@
#define _put_x_var_instinit \
register CELL *pt0; \
pt0 = HR; \
XREG((*_PREG)->u.xx.xl) = Unsigned(pt0); \
HR = pt0 + 1; \
XREG((*_PREG)->u.xx.xr) = Unsigned(pt0); \
(*_PREG) = NEXTOP((*_PREG), xx); \
RESET_VARIABLE(pt0); \
GONEXT();
#if defined(YAPOR_SBA) && defined(FROZEN_STACKS)
#define _put_y_var_instinit \
register CELL *pt0; \
pt0 = YREG + (*_PREG)->u.yx.y; \
XREG((*_PREG)->u.yx.x) = (CELL) pt0; \
(*_PREG) = NEXTOP((*_PREG), yx); \
if (Unsigned((Int)(pt0)-(Int)(H_FZ)) > \
Unsigned((Int)(B_FZ)-(Int)(H_FZ))) { \
*pt0 = (CELL)STACK_TO_SBA(pt0); \
} else \
INITIALIZE_PERMVAR(pt0, (CELL)pt0); \
GONEXT();
#else /* defined(YAPOR_SBA) && defined(FROZEN_STACKS) */
#define _put_y_var_instinit \
register CELL *pt0; \
pt0 = YREG + (*_PREG)->u.yx.y; \
XREG((*_PREG)->u.yx.x) = (CELL) pt0; \
(*_PREG) = NEXTOP((*_PREG), yx); \
INITIALIZE_PERMVAR(pt0, (CELL)pt0); \
GONEXT();
#endif /* defined(YAPOR_SBA) && defined(FROZEN_STACKS) */
#define _put_x_val_instinit \
register CELL d0; \
d0 = XREG((*_PREG)->u.xx.xl); \
XREG((*_PREG)->u.xx.xr) = d0; \
(*_PREG) = NEXTOP((*_PREG), xx); \
GONEXT();
#define _put_xx_val_instinit \
register CELL d0, d1; \
d0 = XREG((*_PREG)->u.xxxx.xl1); \
d1 = XREG((*_PREG)->u.xxxx.xl2); \
XREG((*_PREG)->u.xxxx.xr1) = d0; \
XREG((*_PREG)->u.xxxx.xr2) = d1; \
(*_PREG) = NEXTOP((*_PREG), xxxx); \
GONEXT();
#ifdef YAPOR_SBA
#define _put_y_val_instinit \
register CELL d0; \
d0 = YREG[(*_PREG)->u.yx.y]; \
if (d0 == 0) { \
XREG((*_PREG)->u.yx.x) = (CELL)(YREG+(*_PREG)->u.yx.y); \
} else \
XREG((*_PREG)->u.yx.x) = d0; \
(*_PREG) = NEXTOP((*_PREG), yx); \
GONEXT();
#else /* YAPOR_SBA */
#define _put_y_val_instinit \
register CELL d0; \
d0 = YREG[(*_PREG)->u.yx.y]; \
XREG((*_PREG)->u.yx.x) = d0; \
(*_PREG) = NEXTOP((*_PREG), yx); \
GONEXT();
#endif /* YAPOR_SBA */
#ifdef YAPOR_SBA
#define _put_y_vals_instinit \
register CELL d0, d1; \
d0 = YREG[(*_PREG)->u.yyxx.y1]; \
if (d0 == 0) \
XREG((*_PREG)->u.yyxx.x1) = (CELL)(YREG+(*_PREG)->u.yyxx.y1); \
else \
XREG((*_PREG)->u.yyxx.x1) = d0; \
(*_PREG) = NEXTOP((*_PREG), yyxx); \
d1 = YREG[PREVOP((*_PREG),yyxx)->u.yyxx.y2]; \
if (d1 == 0) \
XREG(PREVOP((*_PREG)->u.yyxx,yyxx).x2) = (CELL)(YREG+(*_PREG)->u.yyxx.y2); \
else \
XREG(PREVOP((*_PREG),yyxx)->u.yyxx.x2) = d1; \
GONEXT();
#else /* YAPOR_SBA */
#define _put_y_vals_instinit \
register CELL d0, d1; \
d0 = YREG[(*_PREG)->u.yyxx.y1]; \
XREG((*_PREG)->u.yyxx.x1) = d0; \
(*_PREG) = NEXTOP((*_PREG), yyxx); \
d1 = YREG[PREVOP((*_PREG),yyxx)->u.yyxx.y2]; \
XREG(PREVOP((*_PREG),yyxx)->u.yyxx.x2) = d1; \
GONEXT();
#endif /* YAPOR_SBA */
#define _put_unsafe_instinit \
BEGD(d0); \
BEGP(pt0); \
pt0 = YREG+(*_PREG)->u.yx.y; \
d0 = *pt0; \
deref_head(d0, punsafe_unk); \
punsafe_nonvar: \
XREG((*_PREG)->u.yx.x) = d0; \
(*_PREG) = NEXTOP((*_PREG), yx); \
GONEXT(); \
\
derefa_body(d0, pt0, punsafe_unk, punsafe_nonvar); \
if (pt0 <= HR || pt0 >= YREG) { \
XREG((*_PREG)->u.yx.x) = Unsigned(pt0); \
(*_PREG) = NEXTOP((*_PREG), yx); \
GONEXT(); \
} \
else { \
Bind_Local(pt0, Unsigned(HR)); \
XREG((*_PREG)->u.yx.x) = (CELL) HR; \
RESET_VARIABLE(HR); \
H++; \
(*_PREG) = NEXTOP((*_PREG), yx); \
GONEXT(); \
} \
ENDP(pt0); \
ENDD(d0);
#define _put_atom_instinit \
register CELL d0; \
d0 = (*_PREG)->u.xc.c; \
XREG((*_PREG)->u.xc.x) = d0; \
(*_PREG) = NEXTOP((*_PREG), xc); \
GONEXT();
#define PUT_DBTERM_INSTINIT \
register CELL d0; \
d0 = (*_PREG)->u.xD.D; \
XREG((*_PREG)->u.xD.x) = d0; \
(*_PREG) = NEXTOP((*_PREG), xD); \
GONext();
#define PUT_BIGINT_INSTINIT \
register CELL d0; \
d0 = (*_PREG)->u.xN.b; \
XREG((*_PREG)->u.xN.x) = d0; \
(*_PREG) = NEXTOP((*_PREG), xN); \
GONext();
#define _put_float_instinit \
register CELL d0; \
d0 = AbsAppl((*_PREG)->u.xd.d); \
XREG((*_PREG)->u.xd.x) = d0; \
(*_PREG) = NEXTOP((*_PREG), xd); \
GONEXT();
#define PUT_LONGINT_INSTINIT \
register CELL d0; \
d0 = AbsAppl((*_PREG)->u.xi.i); \
XREG((*_PREG)->u.xi.x) = d0; \
(*_PREG) = NEXTOP((*_PREG), xi); \
GONext();
#define _put_list_instinit \
register CELL d0; \
CACHE_S(); \
READ_IN_S(); \
S_SREG = HR; \
HR += 2; \
d0 = AbsPair(S_SREG); \
XREG((*_PREG)->u.x.x) = d0; \
(*_PREG) = NEXTOP((*_PREG), x); \
WRITEBACK_S(S_SREG); \
ENDCACHE_S(); \
GONEXT();
#define _put_struct_instinit \
register CELL d0; \
d0 = AbsAppl(HR); \
XREG((*_PREG)->u.xfa.x) = d0; \
d0 = (CELL) ((*_PREG)->u.xfa.f); \
*H++ = d0; \
(*_SREG) = HR; \
HR += (*_PREG)->u.xfa.a; \
(*_PREG) = NEXTOP((*_PREG), xfa); \
GONEXT();

1373
JIT/HPP/singlecode_unify.h Normal file

File diff suppressed because it is too large Load Diff

374
JIT/HPP/singlecode_write.h Normal file
View File

@ -0,0 +1,374 @@
#define WRITE_X_VAR_INSTINIT \
XREG((*_PREG)->u.x.x) = Unsigned((*_SREG)); \
(*_PREG) = NEXTOP((*_PREG), x); \
RESET_VARIABLE((*_SREG)); \
(*_SREG)++; \
GONext();
#define WRITE_VOID_INSTINIT \
(*_PREG) = NEXTOP((*_PREG), e); \
RESET_VARIABLE((*_SREG)); \
(*_SREG)++; \
GONext();
#define WRITE_N_VOIDS_INSTINIT \
register CELL d0; \
d0 = (*_PREG)->u.s.s; \
(*_PREG) = NEXTOP((*_PREG), s); \
for (; d0 > 0; d0--) { \
RESET_VARIABLE((*_SREG)); \
(*_SREG)++; \
} \
GONext();
#define _write_y_var_instinit \
INITIALIZE_PERMVAR(YREG+(*_PREG)->u.y.y,Unsigned((*_SREG))); \
(*_PREG) = NEXTOP((*_PREG), y); \
RESET_VARIABLE((*_SREG)); \
(*_SREG)++; \
GONEXT();
#define _write_x_val_instinit \
register CELL d0; \
d0 = XREG((*_PREG)->u.x.x); \
*(*_SREG)++ = d0; \
(*_PREG) = NEXTOP((*_PREG), x); \
GONEXT();
#if defined(YAPOR_SBA) && defined(FROZEN_STACKS)
#ifdef FROZEN_STACKS
#define _write_x_loc_instinit \
BEGD(d0); \
d0 = XREG((*_PREG)->u.x.x); \
(*_PREG) = NEXTOP((*_PREG), x); \
deref_head(d0, w_x_unk); \
w_x_bound: \
*(*_SREG)++ = d0; \
GONEXT(); \
\
BEGP(pt0); \
deref_body(d0, pt0, w_x_unk, w_x_bound); \
if (pt0 > HR && pt0<(CELL *)B_FZ) { \
Bind_Local(pt0, Unsigned((*_SREG))); \
RESET_VARIABLE((*_SREG)); \
(*_SREG)++; \
GONEXT(); \
} \
else { \
*(*_SREG)++ = Unsigned(pt0); \
GONEXT(); \
} \
ENDP(pt0); \
ENDD(d0);
#else /* FROZEN_STACKS */
#define _write_x_loc_instinit \
BEGD(d0); \
d0 = XREG((*_PREG)->u.x.x); \
(*_PREG) = NEXTOP((*_PREG), x); \
deref_head(d0, w_x_unk); \
w_x_bound: \
*(*_SREG)++ = d0; \
GONEXT(); \
\
BEGP(pt0); \
deref_body(d0, pt0, w_x_unk, w_x_bound); \
if (pt0 > HR && pt0<(CELL *)B_FZ) { \
TRAIL_LOCAL(pt0, Unsigned((*_SREG))); \
*pt0 = Unsigned((*_SREG)); \
RESET_VARIABLE((*_SREG)); \
(*_SREG)++; \
GONEXT(); \
} \
else { \
*(*_SREG)++ = Unsigned(pt0); \
GONEXT(); \
} \
ENDP(pt0); \
ENDD(d0);
#endif /* FROZEN_STACKS */
#else /* defined(YAPOR_SBA) && defined(FROZEN_STACKS) */
#ifdef FROZEN_STACKS
#define _write_x_loc_instinit \
BEGD(d0); \
d0 = XREG((*_PREG)->u.x.x); \
(*_PREG) = NEXTOP((*_PREG), x); \
deref_head(d0, w_x_unk); \
w_x_bound: \
*(*_SREG)++ = d0; \
GONEXT(); \
\
BEGP(pt0); \
deref_body(d0, pt0, w_x_unk, w_x_bound); \
if (pt0 > HR) { \
Bind_Local(pt0, Unsigned((*_SREG))); \
RESET_VARIABLE((*_SREG)); \
(*_SREG)++; \
GONEXT(); \
} \
else { \
*(*_SREG)++ = Unsigned(pt0); \
GONEXT(); \
} \
ENDP(pt0); \
ENDD(d0);
#else /* FROZEN_STACKS */
#define _write_x_loc_instinit \
BEGD(d0); \
d0 = XREG((*_PREG)->u.x.x); \
(*_PREG) = NEXTOP((*_PREG), x); \
deref_head(d0, w_x_unk); \
w_x_bound: \
*(*_SREG)++ = d0; \
GONEXT(); \
\
BEGP(pt0); \
deref_body(d0, pt0, w_x_unk, w_x_bound); \
if (pt0 > HR) { \
TRAIL_LOCAL(pt0, Unsigned((*_SREG))); \
*pt0 = Unsigned((*_SREG)); \
RESET_VARIABLE((*_SREG)); \
(*_SREG)++; \
GONEXT(); \
} \
else { \
*(*_SREG)++ = Unsigned(pt0); \
GONEXT(); \
} \
ENDP(pt0); \
ENDD(d0);
#endif /* FROZEN_STACKS */
#endif /* defined(YAPOR_SBA) && defined(FROZEN_STACKS) */
#ifdef YAPOR_SBA
#define _write_y_val_instinit \
register CELL d0; \
d0 = YREG[(*_PREG)->u.y.y]; \
if (d0 == 0) \
*(*_SREG)++ = (CELL)(YREG+(*_PREG)->u.y.y); \
else \
*(*_SREG)++ = d0; \
(*_PREG) = NEXTOP((*_PREG), y); \
GONEXT();
#else /* YAPOR_SBA */
#define _write_y_val_instinit \
register CELL d0; \
d0 = YREG[(*_PREG)->u.y.y]; \
*(*_SREG)++ = d0; \
(*_PREG) = NEXTOP((*_PREG), y); \
GONEXT();
#endif /* YAPOR_SBA */
#if defined(YAPOR_SBA) && defined(FROZEN_STACKS)
#ifdef FROZEN_STACKS
#define _write_y_loc_instinit \
BEGD(d0); \
BEGP(pt0); \
pt0 = YREG+(*_PREG)->u.y.y; \
d0 = *pt0; \
deref_head(d0, w_y_unk); \
w_y_bound: \
(*_PREG) = NEXTOP((*_PREG), y); \
*(*_SREG)++ = d0; \
GONEXT(); \
\
derefa_body(d0, pt0, w_y_unk, w_y_bound); \
if (pt0 > HR \
&& pt0<(CELL *)B_FZ \
) { \
(*_PREG) = NEXTOP((*_PREG), y); \
Bind_Local(pt0, Unsigned((*_SREG))); \
RESET_VARIABLE((*_SREG)); \
(*_SREG)++; \
GONEXT(); \
} else { \
(*_PREG) = NEXTOP((*_PREG), y); \
*(*_SREG)++ = Unsigned(pt0); \
GONEXT(); \
} \
ENDP(pt0); \
ENDD(d0);
#else /* FROZEN_STACKS */
#define _write_y_loc_instinit \
BEGD(d0); \
BEGP(pt0); \
pt0 = YREG+(*_PREG)->u.y.y; \
d0 = *pt0; \
deref_head(d0, w_y_unk); \
w_y_bound: \
(*_PREG) = NEXTOP((*_PREG), y); \
*(*_SREG)++ = d0; \
GONEXT(); \
\
derefa_body(d0, pt0, w_y_unk, w_y_bound); \
if (pt0 > HR \
&& pt0<(CELL *)B_FZ \
) { \
(*_PREG) = NEXTOP((*_PREG), y); \
*pt0 = Unsigned((*_SREG)); \
TRAIL_LOCAL(pt0, Unsigned((*_SREG))); \
RESET_VARIABLE((*_SREG)); \
(*_SREG)++; \
GONEXT(); \
} else { \
(*_PREG) = NEXTOP((*_PREG), y); \
*(*_SREG)++ = Unsigned(pt0); \
GONEXT(); \
} \
ENDP(pt0); \
ENDD(d0);
#endif /* FROZEN_STACKS */
#else /* defined(YAPOR_SBA) && defined(FROZEN_STACKS) */
#ifdef FROZEN_STACKS
#define _write_y_loc_instinit \
BEGD(d0); \
BEGP(pt0); \
pt0 = YREG+(*_PREG)->u.y.y; \
d0 = *pt0; \
deref_head(d0, w_y_unk); \
w_y_bound: \
(*_PREG) = NEXTOP((*_PREG), y); \
*(*_SREG)++ = d0; \
GONEXT(); \
\
derefa_body(d0, pt0, w_y_unk, w_y_bound); \
if (pt0 > HR \
) { \
(*_PREG) = NEXTOP((*_PREG), y); \
Bind_Local(pt0, Unsigned((*_SREG))); \
RESET_VARIABLE((*_SREG)); \
(*_SREG)++; \
GONEXT(); \
} else { \
(*_PREG) = NEXTOP((*_PREG), y); \
*(*_SREG)++ = Unsigned(pt0); \
GONEXT(); \
} \
ENDP(pt0); \
ENDD(d0);
#else /* FROZEN_STACKS */
#define _write_y_loc_instinit \
BEGD(d0); \
BEGP(pt0); \
pt0 = YREG+(*_PREG)->u.y.y; \
d0 = *pt0; \
deref_head(d0, w_y_unk); \
w_y_bound: \
(*_PREG) = NEXTOP((*_PREG), y); \
*(*_SREG)++ = d0; \
GONEXT(); \
\
derefa_body(d0, pt0, w_y_unk, w_y_bound); \
if (pt0 > HR \
) { \
(*_PREG) = NEXTOP((*_PREG), y); \
*pt0 = Unsigned((*_SREG)); \
TRAIL_LOCAL(pt0, Unsigned((*_SREG))); \
RESET_VARIABLE((*_SREG)); \
(*_SREG)++; \
GONEXT(); \
} else { \
(*_PREG) = NEXTOP((*_PREG), y); \
*(*_SREG)++ = Unsigned(pt0); \
GONEXT(); \
} \
ENDP(pt0); \
ENDD(d0);
#endif /* FROZEN_STACKS */
#endif /* defined(YAPOR_SBA) && defined(FROZEN_STACKS) */
#define _write_atom_instinit \
register CELL d0; \
d0 = (*_PREG)->u.c.c; \
*(*_SREG)++ = d0; \
(*_PREG) = NEXTOP((*_PREG), c); \
GONEXT();
#define WRITE_BIGINT_INSTINIT \
register CELL d0; \
d0 = (*_PREG)->u.N.b; \
*(*_SREG)++ = d0; \
(*_PREG) = NEXTOP((*_PREG), N); \
GONext();
#define _write_dbterm_instinit \
register CELL d0; \
d0 = (*_PREG)->u.D.D; \
*(*_SREG)++ = d0; \
(*_PREG) = NEXTOP((*_PREG), D); \
GONEXT();
#define _write_float_instinit \
register CELL d0; \
d0 = AbsAppl((*_PREG)->u.d.d); \
*(*_SREG)++ = d0; \
(*_PREG) = NEXTOP((*_PREG), d); \
GONEXT();
#define WRITE_LONGIT_INSTINIT \
register CELL d0; \
d0 = AbsAppl((*_PREG)->u.i.i); \
*(*_SREG)++ = d0; \
(*_PREG) = NEXTOP((*_PREG), i); \
GONext();
#define WRITE_N_ATOMS_INSTINIT \
register CELL d0, d1; \
d0 = (*_PREG)->u.sc.s; \
d1 = (*_PREG)->u.sc.c; \
for (; d0 > 0; d0--) { \
*(*_SREG)++ = d1; \
} \
(*_PREG) = NEXTOP((*_PREG), sc); \
GONext();
#define WRITE_LIST_INSTINIT \
register CELL d0; \
d0 = AbsPair(HR); \
*(*_SREG)++ = d0; \
SP[-1] = Unsigned((*_SREG)); \
SP[-2] = 1; \
SP -= 2; \
(*_SREG) = HR; \
HR += 2; \
(*_PREG) = NEXTOP((*_PREG), e); \
GONext();
#define _write_l_list_instinit \
register CELL d0; \
(*_PREG) = NEXTOP((*_PREG), e); \
CACHE_S(); \
READ_IN_S(); \
d0 = AbsPair(HR); \
*S_SREG = d0; \
WRITEBACK_S(HR); \
HR += 2; \
ENDCACHE_S(); \
GONEXT(); \
#define _write_struct_instinit \
register CELL d0; \
d0 = AbsAppl(HR); \
*(*_SREG)++ = d0; \
SP[-1] = Unsigned((*_SREG)); \
SP[-2] = 1; \
SP -= 2; \
d0 = (CELL) ((*_PREG)->u.fa.f); \
*H++ = d0; \
d0 = (*_PREG)->u.fa.a; \
(*_PREG) = NEXTOP((*_PREG), fa); \
(*_SREG) = HR; \
HR += d0; \
GONEXT();
#define _write_l_struc_instinit \
register CELL d0; \
d0 = AbsAppl(HR); \
*(*_SREG) = d0; \
d0 = (CELL) ((*_PREG)->u.fa.f); \
*H++ = d0; \
(*_SREG) = HR; \
d0 = (*_PREG)->u.fa.a; \
(*_PREG) = NEXTOP((*_PREG), fa); \
HR += d0; \
GONEXT();

3182
JIT/HPP/sprint_op.hh Normal file

File diff suppressed because it is too large Load Diff

8033
JIT/HPP/sprintblock.h Normal file

File diff suppressed because it is too large Load Diff

14985
JIT/HPP/traced_absmi_insts.i Normal file

File diff suppressed because it is too large Load Diff

198
JIT/HPP/yaam_basics.h Normal file
View File

@ -0,0 +1,198 @@
#define JIT_HANDLER_INSTINIT \
(*_PREG) = NEXTOP((*_PREG), jhc);
#define I_R (XREGS[0])
#define YAAM_CHECK_TRAIL_TR { check_trail(TR); }
#define YAAM_DEREF_BODY_D0PT0 \
if (!IsVarTerm(d0)) { BACK(); } \
pt0 = (CELL *)d0; \
d0 = *(CELL *)d0;
#define YAAM_DEREF_BODY_D0PT1 \
if (!IsVarTerm(d0)) { BACK(); } \
pt1 = (CELL *)d0; \
d0 = *(CELL *)d0;
#define YAAM_DEREF_BODY_D1PT0 \
if (!IsVarTerm(d1)) { BACK(); } \
pt0 = (CELL *)d1; \
d1 = *(CELL *)d1;
#define YAAM_DEREF_BODY_D1PT1 \
if (!IsVarTerm(d1)) { BACK(); } \
pt1 = (CELL *)d1; \
d1 = *(CELL *)d1;
#define YAAM_UNIFYBOUND \
if (d0 == d1) { \
GONext(); \
} \
else if (IsPairTerm(d0)) { \
if (!IsPairTerm(d1)) { \
YAAM_FAIL; \
} \
else { \
register CELL *ipt0, *ipt1; \
ipt0 = RepPair(d0); \
ipt1 = RepPair(d1); \
save_hb(); \
always_save_pc(); \
if (IUnify_complex(ipt0-1,ipt0+1,ipt1-1)) { \
always_set_pc(); \
GONext(); \
} \
else { \
YAAM_FAIL; \
} \
} \
} \
else if (IsApplTerm(d0)) { \
if (!IsApplTerm(d1)) { \
YAAM_FAIL; \
} \
else { \
register CELL *ipt0, *ipt1; \
register Functor f; \
ipt0 = RepAppl(d0); \
ipt1 = RepAppl(d1); \
f = (Functor)*ipt0; \
if (f != (Functor)*ipt1) { \
YAAM_FAIL; \
} \
else if (IsExtensionFunctor(f)) { \
if (unify_extension(f, d0, RepAppl(d0), d1)) { \
GONext(); \
} \
else { \
YAAM_FAIL; \
} \
} \
else { \
d0 = ArityOfFunctor(f); \
always_save_pc(); \
save_hb(); \
if (IUnify_complex(ipt0, ipt0+d0, ipt1)) { \
always_set_pc(); \
GONext(); \
} \
else { \
YAAM_FAIL; \
} \
} \
} \
} \
else { \
YAAM_FAIL; \
}
#if (defined(YAPOR_SBA) && defined(YAPOR)) || defined(TABLING)
#define NoStackDeallocate_Exception \
if (__builtin_expect( ((Int)(Unsigned(YOUNGEST_CP((choiceptr)ENV_YREG,B_FZ)) - Unsigned(YOUNGEST_H(H_FZ,H))) < CreepFlag), 0) ) { \
return external_labels[8]; \
}
#define NoStackCall_Exception \
CACHE_Y_AS_ENV(YREG); \
if (__builtin_expect( ((Int)(Unsigned(YOUNGEST_CP((choiceptr)ENV_YREG,B_FZ)) - Unsigned(YOUNGEST_H(H_FZ,H))) < CreepFlag), 0) ) { \
return external_labels[6]; \
} \
ENDCACHE_Y_AS_ENV();
#define NoStackDExecute_Exception \
if (__builtin_expect( ((Int)(Unsigned(YOUNGEST_CP((choiceptr)ENV_YREG,B_FZ)) - Unsigned(YOUNGEST_H(H_FZ,H))) < CreepFlag), 0) ) { \
return external_labels[7]; \
}
#define NoStackExecute_Exception \
CACHE_Y_AS_ENV(YREG); \
if (__builtin_expect( ((Int)(Unsigned(YOUNGEST_CP((choiceptr)ENV_YREG,B_FZ)) - Unsigned(YOUNGEST_H(H_FZ,H))) < CreepFlag), 0) ) { \
return external_labels[5]; \
} \
ENDCACHE_Y_AS_ENV();
#define NoStackFail_Exception \
CACHE_Y_AS_ENV(YREG); \
if (__builtin_expect( ((Int)(Unsigned(YOUNGEST_CP((choiceptr)ENV_YREG,B_FZ)) - Unsigned(YOUNGEST_H(H_FZ,H))) < CreepFlag), 0) ) { \
return external_labels[10]; \
} \
ENDCACHE_Y_AS_ENV();
#define NoStackEither_Exception \
CACHE_Y_AS_ENV(YREG); \
if (__builtin_expect( ((Int)(Unsigned(YOUNGEST_CP((choiceptr)ENV_YREG,B_FZ)) - Unsigned(YOUNGEST_H(H_FZ,H))) < CreepFlag), 0) ) { \
return external_labels[4]; \
} \
ENDCACHE_Y_AS_ENV();
#define NoStackCommitY_Exception \
CACHE_Y_AS_ENV(YREG); \
if (__builtin_expect( ((Int)(Unsigned(YOUNGEST_CP((choiceptr)ENV_YREG,B_FZ)) - Unsigned(YOUNGEST_H(H_FZ,H))) < CreepFlag), 0) ) { \
return external_labels[2]; \
} \
ENDCACHE_Y_AS_ENV();
#define NoStackCommitX_Exception \
CACHE_Y_AS_ENV(YREG); \
if (__builtin_expect( ((Int)(Unsigned(YOUNGEST_CP((choiceptr)ENV_YREG,B_FZ)) - Unsigned(YOUNGEST_H(H_FZ,H))) < CreepFlag), 0) ) { \
return external_labels[11]; \
} \
ENDCACHE_Y_AS_ENV();
#else
#define NoStackDeallocate_Exception \
if (__builtin_expect(((Int)(Unsigned(ENV_YREG) - Unsigned(HR)) < CreepFlag ), 0) ) { \
return external_labels[8]; \
}
#define NoStackCall_Exception \
CACHE_Y_AS_ENV(YREG); \
if (__builtin_expect(((Int)(Unsigned(ENV_YREG) - Unsigned(HR)) < CreepFlag ), 0) ) { \
return external_labels[6]; \
} \
ENDCACHE_Y_AS_ENV();
#define NoStackDExecute_Exception \
if (__builtin_expect(((Int)(Unsigned(ENV_YREG) - Unsigned(HR)) < CreepFlag ), 0) ) { \
return external_labels[7]; \
}
#define NoStackExecute_Exception \
CACHE_Y_AS_ENV(YREG); \
if (__builtin_expect(((Int)(Unsigned(ENV_YREG) - Unsigned(HR)) < CreepFlag ), 0) ) { \
return external_labels[5]; \
} \
ENDCACHE_Y_AS_ENV();
#define NoStackFail_Exception \
CACHE_Y_AS_ENV(YREG); \
if (__builtin_expect(((Int)(Unsigned(ENV_YREG) - Unsigned(HR)) < CreepFlag ), 0) ) { \
return external_labels[10]; \
} \
ENDCACHE_Y_AS_ENV();
#define NoStackEither_Exception \
CACHE_Y_AS_ENV(YREG); \
if (__builtin_expect(((Int)(Unsigned(ENV_YREG) - Unsigned(HR)) < CreepFlag ), 0) ) { \
return external_labels[4]; \
} \
ENDCACHE_Y_AS_ENV();
#define NoStackCommitY_Exception \
CACHE_Y_AS_ENV(YREG); \
if (__builtin_expect(((Int)(Unsigned(ENV_YREG) - Unsigned(HR)) < CreepFlag ), 0) ) { \
return external_labels[2]; \
} \
ENDCACHE_Y_AS_ENV();
#define NoStackCommitX_Exception \
CACHE_Y_AS_ENV(YREG); \
if (__builtin_expect(((Int)(Unsigned(ENV_YREG) - Unsigned(HR)) < CreepFlag ), 0) ) { \
return external_labels[11]; \
} \
ENDCACHE_Y_AS_ENV();
#endif /* YAPOR_SBA && YAPOR */
#define YAAM_FAIL \
FAILED = 1;

264
JIT/HPP/yaam_basics_d.h Normal file
View File

@ -0,0 +1,264 @@
#define JIT_HANDLER_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
print_main_when_head((*_PREG), ON_NATIVE); \
(*_PREG) = NEXTOP((*_PREG), jhc);
#define I_R (XREGS[0])
#define YAAM_CHECK_TRAIL_TR { check_trail(TR); }
#define YAAM_DEREF_BODY_D0PT0 \
if (!IsVarTerm(d0)) { BACK(); } \
pt0 = (CELL *)d0; \
d0 = *(CELL *)d0;
#define YAAM_DEREF_BODY_D0PT1 \
if (!IsVarTerm(d0)) { BACK(); } \
pt1 = (CELL *)d0; \
d0 = *(CELL *)d0;
#define YAAM_DEREF_BODY_D1PT0 \
if (!IsVarTerm(d1)) { BACK(); } \
pt0 = (CELL *)d1; \
d1 = *(CELL *)d1;
#define YAAM_DEREF_BODY_D1PT1 \
if (!IsVarTerm(d1)) { BACK(); } \
pt1 = (CELL *)d1; \
d1 = *(CELL *)d1;
#define YAAM_UNIFYBOUND \
if (d0 == d1) { \
GONext(); \
} \
else if (IsPairTerm(d0)) { \
if (!IsPairTerm(d1)) { \
YAAM_FAIL; \
} \
else { \
register CELL *ipt0, *ipt1; \
ipt0 = RepPair(d0); \
ipt1 = RepPair(d1); \
save_hb(); \
always_save_pc(); \
if (IUnify_complex(ipt0-1,ipt0+1,ipt1-1)) { \
always_set_pc(); \
GONext(); \
} \
else { \
YAAM_FAIL; \
} \
} \
} \
else if (IsApplTerm(d0)) { \
if (!IsApplTerm(d1)) { \
YAAM_FAIL; \
} \
else { \
register CELL *ipt0, *ipt1; \
register Functor f; \
ipt0 = RepAppl(d0); \
ipt1 = RepAppl(d1); \
f = (Functor)*ipt0; \
if (f != (Functor)*ipt1) { \
YAAM_FAIL; \
} \
else if (IsExtensionFunctor(f)) { \
if (unify_extension(f, d0, RepAppl(d0), d1)) { \
GONext(); \
} \
else { \
YAAM_FAIL; \
} \
} \
else { \
d0 = ArityOfFunctor(f); \
always_save_pc(); \
save_hb(); \
if (IUnify_complex(ipt0, ipt0+d0, ipt1)) { \
always_set_pc(); \
GONext(); \
} \
else { \
YAAM_FAIL; \
} \
} \
} \
} \
else { \
YAAM_FAIL; \
}
#if (defined(YAPOR_SBA) && defined(YAPOR)) || defined(TABLING)
#define NoStackDeallocate_Exception \
if (__builtin_expect( ((Int)(Unsigned(YOUNGEST_CP((choiceptr)ENV_YREG,B_FZ)) - Unsigned(YOUNGEST_H(H_FZ,H))) < CreepFlag), 0) ) { \
if ((char*)ExpEnv.debug_struc.pprint_me.native_treat_heap != 0 && (char*)ExpEnv.debug_struc.pprint_me.native_treat_heap != (char*)0x1) { \
fprintf(stderr, "%s:%d\n", __FILE__, __LINE__); \
fprintf(stderr, "%s", (char*)ExpEnv.debug_struc.pprint_me.native_treat_heap); \
} \
return external_labels[8]; \
}
#define NoStackCall_Exception \
CACHE_Y_AS_ENV(YREG); \
if (__builtin_expect( ((Int)(Unsigned(YOUNGEST_CP((choiceptr)ENV_YREG,B_FZ)) - Unsigned(YOUNGEST_H(H_FZ,H))) < CreepFlag), 0) ) { \
if ((char*)ExpEnv.debug_struc.pprint_me.native_treat_heap != 0 && (char*)ExpEnv.debug_struc.pprint_me.native_treat_heap != (char*)0x1) { \
fprintf(stderr, "%s:%d\n", __FILE__, __LINE__); \
fprintf(stderr, "%s", (char*)ExpEnv.debug_struc.pprint_me.native_treat_heap); \
} \
return external_labels[6]; \
} \
ENDCACHE_Y_AS_ENV();
#define NoStackDExecute_Exception \
if (__builtin_expect( ((Int)(Unsigned(YOUNGEST_CP((choiceptr)ENV_YREG,B_FZ)) - Unsigned(YOUNGEST_H(H_FZ,H))) < CreepFlag), 0) ) { \
if ((char*)ExpEnv.debug_struc.pprint_me.native_treat_heap != 0 && (char*)ExpEnv.debug_struc.pprint_me.native_treat_heap != (char*)0x1) { \
fprintf(stderr, "%s:%d\n", __FILE__, __LINE__); \
fprintf(stderr, "%s", (char*)ExpEnv.debug_struc.pprint_me.native_treat_heap); \
} \
return external_labels[7]; \
}
#define NoStackExecute_Exception \
CACHE_Y_AS_ENV(YREG); \
if (__builtin_expect( ((Int)(Unsigned(YOUNGEST_CP((choiceptr)ENV_YREG,B_FZ)) - Unsigned(YOUNGEST_H(H_FZ,H))) < CreepFlag), 0) ) { \
if ((char*)ExpEnv.debug_struc.pprint_me.native_treat_heap != 0 && (char*)ExpEnv.debug_struc.pprint_me.native_treat_heap != (char*)0x1) { \
fprintf(stderr, "%s:%d\n", __FILE__, __LINE__); \
fprintf(stderr, "%s", (char*)ExpEnv.debug_struc.pprint_me.native_treat_heap); \
} \
return external_labels[5]; \
} \
ENDCACHE_Y_AS_ENV();
#define NoStackFail_Exception \
CACHE_Y_AS_ENV(YREG); \
if (__builtin_expect( ((Int)(Unsigned(YOUNGEST_CP((choiceptr)ENV_YREG,B_FZ)) - Unsigned(YOUNGEST_H(H_FZ,H))) < CreepFlag), 0) ) { \
if ((char*)ExpEnv.debug_struc.pprint_me.native_treat_heap != 0 && (char*)ExpEnv.debug_struc.pprint_me.native_treat_heap != (char*)0x1) { \
fprintf(stderr, "%s:%d\n", __FILE__, __LINE__); \
fprintf(stderr, "%s", (char*)ExpEnv.debug_struc.pprint_me.native_treat_heap); \
} \
return external_labels[10]; \
} \
ENDCACHE_Y_AS_ENV();
#define NoStackEither_Exception \
CACHE_Y_AS_ENV(YREG); \
if (__builtin_expect( ((Int)(Unsigned(YOUNGEST_CP((choiceptr)ENV_YREG,B_FZ)) - Unsigned(YOUNGEST_H(H_FZ,H))) < CreepFlag), 0) ) { \
if ((char*)ExpEnv.debug_struc.pprint_me.native_treat_heap != 0 && (char*)ExpEnv.debug_struc.pprint_me.native_treat_heap != (char*)0x1) { \
fprintf(stderr, "%s:%d\n", __FILE__, __LINE__); \
fprintf(stderr, "%s", (char*)ExpEnv.debug_struc.pprint_me.native_treat_heap); \
} \
return external_labels[4]; \
} \
ENDCACHE_Y_AS_ENV();
#define NoStackCommitY_Exception \
CACHE_Y_AS_ENV(YREG); \
if (__builtin_expect( ((Int)(Unsigned(YOUNGEST_CP((choiceptr)ENV_YREG,B_FZ)) - Unsigned(YOUNGEST_H(H_FZ,H))) < CreepFlag), 0) ) { \
if ((char*)ExpEnv.debug_struc.pprint_me.native_treat_heap != 0 && (char*)ExpEnv.debug_struc.pprint_me.native_treat_heap != (char*)0x1) { \
fprintf(stderr, "%s:%d\n", __FILE__, __LINE__); \
fprintf(stderr, "%s", (char*)ExpEnv.debug_struc.pprint_me.native_treat_heap); \
} \
return external_labels[2]; \
} \
ENDCACHE_Y_AS_ENV();
#define NoStackCommitX_Exception \
CACHE_Y_AS_ENV(YREG); \
if (__builtin_expect( ((Int)(Unsigned(YOUNGEST_CP((choiceptr)ENV_YREG,B_FZ)) - Unsigned(YOUNGEST_H(H_FZ,H))) < CreepFlag), 0) ) { \
if ((char*)ExpEnv.debug_struc.pprint_me.native_treat_heap != 0 && (char*)ExpEnv.debug_struc.pprint_me.native_treat_heap != (char*)0x1) { \
fprintf(stderr, "%s:%d\n", __FILE__, __LINE__); \
fprintf(stderr, "%s", (char*)ExpEnv.debug_struc.pprint_me.native_treat_heap); \
} \
return external_labels[11]; \
} \
ENDCACHE_Y_AS_ENV();
#else
#define NoStackDeallocate_Exception \
if (__builtin_expect(((Int)(Unsigned(ENV_YREG) - Unsigned(HR)) < CreepFlag ), 0) ) { \
if ((char*)ExpEnv.debug_struc.pprint_me.native_treat_heap != 0 && (char*)ExpEnv.debug_struc.pprint_me.native_treat_heap != (char*)0x1) { \
fprintf(stderr, "%s:%d\n", __FILE__, __LINE__); \
fprintf(stderr, "%s", (char*)ExpEnv.debug_struc.pprint_me.native_treat_heap); \
} \
return external_labels[8]; \
}
#define NoStackCall_Exception \
CACHE_Y_AS_ENV(YREG); \
if (__builtin_expect(((Int)(Unsigned(ENV_YREG) - Unsigned(HR)) < CreepFlag ), 0) ) { \
if ((char*)ExpEnv.debug_struc.pprint_me.native_treat_heap != 0 && (char*)ExpEnv.debug_struc.pprint_me.native_treat_heap != (char*)0x1) { \
fprintf(stderr, "%s:%d\n", __FILE__, __LINE__); \
fprintf(stderr, "%s", (char*)ExpEnv.debug_struc.pprint_me.native_treat_heap); \
} \
return external_labels[6]; \
} \
ENDCACHE_Y_AS_ENV();
#define NoStackDExecute_Exception \
if (__builtin_expect(((Int)(Unsigned(ENV_YREG) - Unsigned(HR)) < CreepFlag ), 0) ) { \
if ((char*)ExpEnv.debug_struc.pprint_me.native_treat_heap != 0 && (char*)ExpEnv.debug_struc.pprint_me.native_treat_heap != (char*)0x1) { \
fprintf(stderr, "%s:%d\n", __FILE__, __LINE__); \
fprintf(stderr, "%s", (char*)ExpEnv.debug_struc.pprint_me.native_treat_heap); \
} \
return external_labels[7]; \
}
#define NoStackExecute_Exception \
CACHE_Y_AS_ENV(YREG); \
if (__builtin_expect(((Int)(Unsigned(ENV_YREG) - Unsigned(HR)) < CreepFlag ), 0) ) { \
if ((char*)ExpEnv.debug_struc.pprint_me.native_treat_heap != 0 && (char*)ExpEnv.debug_struc.pprint_me.native_treat_heap != (char*)0x1) { \
fprintf(stderr, "%s:%d\n", __FILE__, __LINE__); \
fprintf(stderr, "%s", (char*)ExpEnv.debug_struc.pprint_me.native_treat_heap); \
} \
return external_labels[5]; \
} \
ENDCACHE_Y_AS_ENV();
#define NoStackFail_Exception \
CACHE_Y_AS_ENV(YREG); \
if (__builtin_expect(((Int)(Unsigned(ENV_YREG) - Unsigned(HR)) < CreepFlag ), 0) ) { \
if ((char*)ExpEnv.debug_struc.pprint_me.native_treat_heap != 0 && (char*)ExpEnv.debug_struc.pprint_me.native_treat_heap != (char*)0x1) { \
fprintf(stderr, "%s:%d\n", __FILE__, __LINE__); \
fprintf(stderr, "%s", (char*)ExpEnv.debug_struc.pprint_me.native_treat_heap); \
} \
return external_labels[10]; \
} \
ENDCACHE_Y_AS_ENV();
#define NoStackEither_Exception \
CACHE_Y_AS_ENV(YREG); \
if (__builtin_expect(((Int)(Unsigned(ENV_YREG) - Unsigned(HR)) < CreepFlag ), 0) ) { \
if ((char*)ExpEnv.debug_struc.pprint_me.native_treat_heap != 0 && (char*)ExpEnv.debug_struc.pprint_me.native_treat_heap != (char*)0x1) { \
fprintf(stderr, "%s:%d\n", __FILE__, __LINE__); \
fprintf(stderr, "%s", (char*)ExpEnv.debug_struc.pprint_me.native_treat_heap); \
} \
return external_labels[4]; \
} \
ENDCACHE_Y_AS_ENV();
#define NoStackCommitY_Exception \
CACHE_Y_AS_ENV(YREG); \
if (__builtin_expect(((Int)(Unsigned(ENV_YREG) - Unsigned(HR)) < CreepFlag ), 0) ) { \
if ((char*)ExpEnv.debug_struc.pprint_me.native_treat_heap != 0 && (char*)ExpEnv.debug_struc.pprint_me.native_treat_heap != (char*)0x1) { \
fprintf(stderr, "%s:%d\n", __FILE__, __LINE__); \
fprintf(stderr, "%s", (char*)ExpEnv.debug_struc.pprint_me.native_treat_heap); \
} \
return external_labels[2]; \
} \
ENDCACHE_Y_AS_ENV();
#define NoStackCommitX_Exception \
CACHE_Y_AS_ENV(YREG); \
if (__builtin_expect(((Int)(Unsigned(ENV_YREG) - Unsigned(HR)) < CreepFlag ), 0) ) { \
if ((char*)ExpEnv.debug_struc.pprint_me.native_treat_heap != 0 && (char*)ExpEnv.debug_struc.pprint_me.native_treat_heap != (char*)0x1) { \
fprintf(stderr, "%s:%d\n", __FILE__, __LINE__); \
fprintf(stderr, "%s", (char*)ExpEnv.debug_struc.pprint_me.native_treat_heap); \
} \
return external_labels[11]; \
} \
ENDCACHE_Y_AS_ENV();
#endif /* YAPOR_SBA && YAPOR */
#define YAAM_FAIL \
FAILED = 1;

373
JIT/HPP/yaam_call.h Normal file
View File

@ -0,0 +1,373 @@
#define EXECUTE_INSTINIT \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0; \
PredEntry *pt0; \
register CELL *ENV_YREG = (YREG); \
pt0 = (*_PREG)->u.pp.p;
#ifdef LOW_LEVEL_TRACER
#define EXECUTE_LOW_LEVEL_TRACER \
low_level_trace(enter_pred,pt0,XREGS+1);
#endif
#define EXECUTE_POST_LOW_LEVEL_TRACER \
CACHE_A1(); \
ALWAYS_LOOKAHEAD(pt0->OpcodeOfPred); \
d0 = (CELL)B;
#define EXECUTE_POST_NOCHECKING \
(*_PREG) = pt0->CodeOfPred; \
save_pc(); \
ENV_YREG[E_CB] = d0;
#ifdef DEPTH_LIMIT
#define EXECUTE_DEPTH_MINOR \
FAILED = 0; \
if (pt0->ModuleOfPred) { \
if (DEPTH == MkIntTerm(0)) { \
YAAM_FAIL; \
} \
else { \
DEPTH = RESET_DEPTH(); \
} \
}
#define EXECUTE_DEPTH_MOFPRED \
FAILED = 0; \
DEPTH -= MkIntConstant(2);
#define EXECUTE_DEPTH_END \
FAILED = 0;
#endif
#define EXECUTE_END_END \
BLOCK = (CELL)EXECUTE_END_END; \
if (!FAILED) { \
ALWAYS_GONext(); \
} \
#define DEXECUTE_INSTINIT \
BLOCKADDRESS = (CELL)(*_PREG); \
#ifdef LOW_LEVEL_TRACER
#define DEXECUTE_LOW_LEVEL_TRACER \
low_level_trace(enter_pred,(*_PREG)->u.pp.p,XREGS+1);
#endif
#define DEXECUTE_POST_LOW_LEVEL_TRACER \
CACHE_Y_AS_ENV(YREG); \
PredEntry *pt0; \
CACHE_A1(); \
pt0 = (*_PREG)->u.pp.p;
#ifdef DEPTH_LIMIT
#define DEXECUTE_DEPTH_MINOR \
FAILED = 0; \
if (pt0->ModuleOfPred) { \
if (DEPTH == MkIntTerm(0)) { \
YAAM_FAIL; \
} \
else { \
DEPTH = RESET_DEPTH(); \
} \
}
#define DEXECUTE_DEPTH_MOFPRED \
FAILED = 0; \
DEPTH -= MkIntConstant(2);
#define DEXECUTE_DEPTH_END \
FAILED = 0;
#endif
#ifdef FROZEN_STACKS
#ifdef YAPOR_SBA
#define DEXECUTE_END_END \
BLOCK = (CELL)DEXECUTE_END_END; \
if (!FAILED) { \
(*_PREG) = pt0->CodeOfPred; \
save_pc(); \
(*_CPREG) = (yamop *) ENV_YREG[E_CP]; \
ENV_YREG = ENV = (CELL *) ENV_YREG[E_E]; \
choiceptr top_b = PROTECT_FROZEN_B(B); \
if (ENV_YREG > (CELL *) top_b || ENV_YREG < HR) { \
ENV_YREG = (CELL *) top_b; \
} \
else { \
ENV_YREG = (CELL *)((CELL)ENV_YREG + ENV_Size((*_CPREG))); \
} \
WRITEBACK_Y_AS_ENV(); \
ENV_YREG[E_CB] = (CELL) B; \
ALWAYS_GONext(); \
} \
ENDCACHE_Y_AS_ENV();
#else /* YAPOR_SBA */
#define DEXECUTE_END_END \
BLOCK = (CELL)DEXECUTE_END_END; \
if (!FAILED) { \
(*_PREG) = pt0->CodeOfPred; \
save_pc(); \
(*_CPREG) = (yamop *) ENV_YREG[E_CP]; \
ENV_YREG = ENV = (CELL *) ENV_YREG[E_E]; \
choiceptr top_b = PROTECT_FROZEN_B(B); \
if (ENV_YREG > (CELL *) top_b) { \
ENV_YREG = (CELL *) top_b; \
} \
else { \
ENV_YREG = (CELL *)((CELL)ENV_YREG + ENV_Size((*_CPREG))); \
} \
WRITEBACK_Y_AS_ENV(); \
ENV_YREG[E_CB] = (CELL) B; \
ALWAYS_GONext(); \
} \
ENDCACHE_Y_AS_ENV();
#endif /* YAPOR_SBA */
#else /* FROZEN_STACKS */
#define DEXECUTE_END_END \
BLOCK = (CELL)DEXECUTE_END_END; \
if (!FAILED) { \
(*_PREG) = pt0->CodeOfPred; \
save_pc(); \
(*_CPREG) = (yamop *) ENV_YREG[E_CP]; \
ENV_YREG = ENV = (CELL *) ENV_YREG[E_E]; \
if (ENV_YREG > (CELL *)B) { \
ENV_YREG = (CELL *)B; \
} \
else { \
ENV_YREG = (CELL *) ((CELL) ENV_YREG + ENV_Size((*_CPREG))); \
} \
WRITEBACK_Y_AS_ENV(); \
ENV_YREG[E_CB] = (CELL) B; \
ALWAYS_GONext(); \
} \
ENDCACHE_Y_AS_ENV();
#endif /* FROZEN_STACKS */
#ifdef DEPTH_LIMIT
#define FCALL_INST \
CACHE_Y_AS_ENV(YREG); \
ENV_YREG[E_CP] = (CELL) (*_CPREG); \
ENV_YREG[E_E] = (CELL) ENV; \
ENV_YREG[E_DEPTH] = DEPTH; \
ENDCACHE_Y_AS_ENV();
#else /* DEPTH_LIMIT */
#define FCALL_INST \
CACHE_Y_AS_ENV(YREG); \
ENV_YREG[E_CP] = (CELL) (*_CPREG); \
ENV_YREG[E_E] = (CELL) ENV; \
ENDCACHE_Y_AS_ENV();
#endif /* DEPTH_LIMIT */
#define CALL_INSTINIT \
BLOCKADDRESS = (CELL)(*_PREG); \
if (Yap_op_from_opcode((*_PREG)->opc) == _fcall) { \
FCALL_INST; \
}
#ifdef LOW_LEVEL_TRACER
#define CALL_LOW_LEVEL_TRACER \
low_level_trace(enter_pred,(*_PREG)->u.Osbpp.p,XREGS+1);
#endif
#define CALL_POST_LOW_LEVEL_TRACER \
register CELL *ENV_YREG = (YREG); \
PredEntry *pt; \
pt = (*_PREG)->u.Osbpp.p; \
CACHE_A1();
#define CALL_POST_NO_CHECKING \
ENV = ENV_YREG; \
ENV_YREG = (CELL *) (((char *) ENV_YREG) + (*_PREG)->u.Osbpp.s); \
(*_CPREG) = NEXTOP((*_PREG), Osbpp); \
(*_PREG) = pt->CodeOfPred; \
save_pc(); \
#ifdef DEPTH_LIMIT
#define CALL_DEPTH_MINOR \
FAILED = 0; \
if (pt->ModuleOfPred) { \
if (DEPTH == MkIntTerm(0)){ \
YAAM_FAIL; \
} else { \
DEPTH = RESET_DEPTH(); \
} \
}
#define CALL_DEPTH_MOFPRED \
FAILED = 0; \
DEPTH -= MkIntConstant(2);
#define CALL_DEPTH_END \
FAILED = 0;
#endif
#ifdef YAPOR
#ifdef FROZEN_STACKS
#ifdef YAPOR_SBA
#define CALL_END_END \
BLOCK = (CELL)CALL_END_END; \
if (!FAILED) { \
{ \
choiceptr top_b = PROTECT_FROZEN_B(B); \
if (ENV_YREG > (CELL *) top_b || ENV_YREG < HR) { \
ENV_YREG = (CELL *) top_b; \
} \
} \
WRITEBACK_Y_AS_ENV(); \
ENV_YREG[E_CB] = (CELL) B; \
SCH_check_requests(); \
ALWAYS_GONext(); \
}
#else /* YAPOR_SBA */
#define CALL_END_END \
BLOCK = (CELL)CALL_END_END; \
if (!FAILED) { \
{ \
choiceptr top_b = PROTECT_FROZEN_B(B); \
if (ENV_YREG > (CELL *) top_b) { \
ENV_YREG = (CELL *) top_b; \
} \
} \
WRITEBACK_Y_AS_ENV(); \
ENV_YREG[E_CB] = (CELL) B; \
SCH_check_requests(); \
ALWAYS_GONext(); \
}
#endif /* YAPOR_SBA */
#else /* FROZEN_STACKS */
#define CALL_END_END \
BLOCK = (CELL)CALL_END_END; \
if (!FAILED) { \
if (ENV_YREG > (CELL *) B) { \
ENV_YREG = (CELL *) B; \
} \
WRITEBACK_Y_AS_ENV(); \
ENV_YREG[E_CB] = (CELL) B; \
SCH_check_requests(); \
ALWAYS_GONext(); \
}
#endif /* FROZEN_STACKS */
#else /* YAPOR */
#ifdef FROZEN_STACKS
#ifdef YAPOR_SBA
#define CALL_END_END \
BLOCK = (CELL)CALL_END_END; \
if (!FAILED) { \
{ \
choiceptr top_b = PROTECT_FROZEN_B(B); \
if (ENV_YREG > (CELL *) top_b || ENV_YREG < HR) { \
ENV_YREG = (CELL *) top_b; \
} \
} \
WRITEBACK_Y_AS_ENV(); \
ENV_YREG[E_CB] = (CELL) B; \
ALWAYS_GONext(); \
}
#else /* YAPOR_SBA */
#define CALL_END_END \
BLOCK = (CELL)CALL_END_END; \
if (!FAILED) { \
{ \
choiceptr top_b = PROTECT_FROZEN_B(B); \
if (ENV_YREG > (CELL *) top_b) { \
ENV_YREG = (CELL *) top_b; \
} \
} \
WRITEBACK_Y_AS_ENV(); \
ENV_YREG[E_CB] = (CELL) B; \
ALWAYS_GONext(); \
}
#endif /* YAPOR_SBA */
#else /* FROZEN_STACKS */
#define CALL_END_END \
BLOCK = (CELL)CALL_END_END; \
if (!FAILED) { \
if (ENV_YREG > (CELL *) B) { \
ENV_YREG = (CELL *) B; \
} \
WRITEBACK_Y_AS_ENV(); \
ENV_YREG[E_CB] = (CELL) B; \
ALWAYS_GONext(); \
}
#endif /* FROZEN_STACKS */
#endif /* YAPOR */
#define PROCCEED_INSTINIT \
BLOCKADDRESS = (CELL)(*_PREG); \
CACHE_Y_AS_ENV(YREG); \
(*_PREG) = (*_CPREG); \
save_pc(); \
ENV_YREG = ENV;
#ifdef DEPTH_LIMIT
#define PROCCEED_DEPTH \
DEPTH = ENV_YREG[E_DEPTH];
#endif
#define PROCCEED_END \
BLOCK = (CELL)PROCCEED_END; \
WRITEBACK_Y_AS_ENV(); \
ENDCACHE_Y_AS_ENV(); \
ALWAYS_GONext();
#define ALLOCATE_INSTINIT \
CACHE_Y_AS_ENV(YREG); \
(*_PREG) = NEXTOP((*_PREG), e); \
ENV_YREG[E_CP] = (CELL) (*_CPREG); \
ENV_YREG[E_E] = (CELL) ENV;
#ifdef DEPTH_LIMIT
#define ALLOCATE_DEPTH \
ENV_YREG[E_DEPTH] = DEPTH;
#endif
#define ALLOCATE_END \
ENV = ENV_YREG; \
ENDCACHE_Y_AS_ENV(); \
GONext();
#define DEALLOCATE_INSTINIT
#define DEALLOCATE_POST_CHECK \
CACHE_Y_AS_ENV(YREG); \
(*_PREG) = NEXTOP((*_PREG), p); \
(*_SREG) = YREG; \
(*_CPREG) = (yamop *) ENV_YREG[E_CP]; \
ENV = ENV_YREG = (CELL *) ENV_YREG[E_E];
#ifdef DEPTH_LIMIT
#define DEALLOCATE_DEPTH \
DEPTH = ENV_YREG[E_DEPTH];
#endif
#ifdef FROZEN_STACKS
#ifdef YAPOR_SBA
#define DEALLOCATE_FROZEN \
choiceptr top_b = PROTECT_FROZEN_B(B); \
if (ENV_YREG > (CELL *) top_b || ENV_YREG < HR) \
ENV_YREG = (CELL *) top_b; \
else \
ENV_YREG = (CELL *)((CELL) ENV_YREG + ENV_Size(CPREG));
#else /* YAPOR_SBA */
#define DEALLOCATE_FROZEN \
choiceptr top_b = PROTECT_FROZEN_B(B); \
if (ENV_YREG > (CELL *) top_b) \
ENV_YREG = (CELL *) top_b; \
else \
ENV_YREG = (CELL *)((CELL) ENV_YREG + ENV_Size(CPREG));
#endif /* YAPOR_SBA */
#else /* FROZEN_STACKS */
#define DEALLOCATE_FROZEN \
if (ENV_YREG > (CELL *) B) \
ENV_YREG = (CELL *) B; \
else \
ENV_YREG = (CELL *) ((CELL) ENV_YREG + ENV_Size(CPREG));
#endif /* FROZEN_STACKS */
#define DEALLOCATE_POST_FROZEN \
WRITEBACK_Y_AS_ENV();
#define DEALLOCATE_END \
ENDCACHE_Y_AS_ENV(); \
GONext();

1251
JIT/HPP/yaam_call_count.h Normal file

File diff suppressed because it is too large Load Diff

1271
JIT/HPP/yaam_call_count_d.h Normal file

File diff suppressed because it is too large Load Diff

379
JIT/HPP/yaam_call_d.h Normal file
View File

@ -0,0 +1,379 @@
#define EXECUTE_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0; \
PredEntry *pt0; \
register CELL *ENV_YREG = (YREG); \
pt0 = (*_PREG)->u.pp.p;
#ifdef LOW_LEVEL_TRACER
#define EXECUTE_LOW_LEVEL_TRACER \
low_level_trace(enter_pred,pt0,XREGS+1);
#endif
#define EXECUTE_POST_LOW_LEVEL_TRACER \
CACHE_A1(); \
ALWAYS_LOOKAHEAD(pt0->OpcodeOfPred); \
d0 = (CELL)B;
#define EXECUTE_POST_NOCHECKING \
(*_PREG) = pt0->CodeOfPred; \
save_pc(); \
ENV_YREG[E_CB] = d0;
#ifdef DEPTH_LIMIT
#define EXECUTE_DEPTH_MINOR \
FAILED = 0; \
if (pt0->ModuleOfPred) { \
if (DEPTH == MkIntTerm(0)) { \
YAAM_FAIL; \
} \
else { \
DEPTH = RESET_DEPTH(); \
} \
}
#define EXECUTE_DEPTH_MOFPRED \
FAILED = 0; \
DEPTH -= MkIntConstant(2);
#define EXECUTE_DEPTH_END \
FAILED = 0;
#endif
#define EXECUTE_END_END \
BLOCK = (CELL)EXECUTE_END_END; \
if (!FAILED) { \
ALWAYS_GONext(); \
} \
#define DEXECUTE_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
BLOCKADDRESS = (CELL)(*_PREG); \
#ifdef LOW_LEVEL_TRACER
#define DEXECUTE_LOW_LEVEL_TRACER \
low_level_trace(enter_pred,(*_PREG)->u.pp.p,XREGS+1);
#endif
#define DEXECUTE_POST_LOW_LEVEL_TRACER \
CACHE_Y_AS_ENV(YREG); \
PredEntry *pt0; \
CACHE_A1(); \
pt0 = (*_PREG)->u.pp.p;
#ifdef DEPTH_LIMIT
#define DEXECUTE_DEPTH_MINOR \
FAILED = 0; \
if (pt0->ModuleOfPred) { \
if (DEPTH == MkIntTerm(0)) { \
YAAM_FAIL; \
} \
else { \
DEPTH = RESET_DEPTH(); \
} \
}
#define DEXECUTE_DEPTH_MOFPRED \
FAILED = 0; \
DEPTH -= MkIntConstant(2);
#define DEXECUTE_DEPTH_END \
FAILED = 0;
#endif
#ifdef FROZEN_STACKS
#ifdef YAPOR_SBA
#define DEXECUTE_END_END \
BLOCK = (CELL)DEXECUTE_END_END; \
if (!FAILED) { \
(*_PREG) = pt0->CodeOfPred; \
save_pc(); \
(*_CPREG) = (yamop *) ENV_YREG[E_CP]; \
ENV_YREG = ENV = (CELL *) ENV_YREG[E_E]; \
choiceptr top_b = PROTECT_FROZEN_B(B); \
if (ENV_YREG > (CELL *) top_b || ENV_YREG < HR) { \
ENV_YREG = (CELL *) top_b; \
} \
else { \
ENV_YREG = (CELL *)((CELL)ENV_YREG + ENV_Size((*_CPREG))); \
} \
WRITEBACK_Y_AS_ENV(); \
ENV_YREG[E_CB] = (CELL) B; \
ALWAYS_GONext(); \
} \
ENDCACHE_Y_AS_ENV();
#else /* YAPOR_SBA */
#define DEXECUTE_END_END \
BLOCK = (CELL)DEXECUTE_END_END; \
if (!FAILED) { \
(*_PREG) = pt0->CodeOfPred; \
save_pc(); \
(*_CPREG) = (yamop *) ENV_YREG[E_CP]; \
ENV_YREG = ENV = (CELL *) ENV_YREG[E_E]; \
choiceptr top_b = PROTECT_FROZEN_B(B); \
if (ENV_YREG > (CELL *) top_b) { \
ENV_YREG = (CELL *) top_b; \
} \
else { \
ENV_YREG = (CELL *)((CELL)ENV_YREG + ENV_Size((*_CPREG))); \
} \
WRITEBACK_Y_AS_ENV(); \
ENV_YREG[E_CB] = (CELL) B; \
ALWAYS_GONext(); \
} \
ENDCACHE_Y_AS_ENV();
#endif /* YAPOR_SBA */
#else /* FROZEN_STACKS */
#define DEXECUTE_END_END \
BLOCK = (CELL)DEXECUTE_END_END; \
if (!FAILED) { \
(*_PREG) = pt0->CodeOfPred; \
save_pc(); \
(*_CPREG) = (yamop *) ENV_YREG[E_CP]; \
ENV_YREG = ENV = (CELL *) ENV_YREG[E_E]; \
if (ENV_YREG > (CELL *)B) { \
ENV_YREG = (CELL *)B; \
} \
else { \
ENV_YREG = (CELL *) ((CELL) ENV_YREG + ENV_Size((*_CPREG))); \
} \
WRITEBACK_Y_AS_ENV(); \
ENV_YREG[E_CB] = (CELL) B; \
ALWAYS_GONext(); \
} \
ENDCACHE_Y_AS_ENV();
#endif /* FROZEN_STACKS */
#ifdef DEPTH_LIMIT
#define FCALL_INST \
CACHE_Y_AS_ENV(YREG); \
ENV_YREG[E_CP] = (CELL) (*_CPREG); \
ENV_YREG[E_E] = (CELL) ENV; \
ENV_YREG[E_DEPTH] = DEPTH; \
ENDCACHE_Y_AS_ENV();
#else /* DEPTH_LIMIT */
#define FCALL_INST \
CACHE_Y_AS_ENV(YREG); \
ENV_YREG[E_CP] = (CELL) (*_CPREG); \
ENV_YREG[E_E] = (CELL) ENV; \
ENDCACHE_Y_AS_ENV();
#endif /* DEPTH_LIMIT */
#define CALL_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
BLOCKADDRESS = (CELL)(*_PREG); \
if (Yap_op_from_opcode((*_PREG)->opc) == _fcall) { \
FCALL_INST; \
}
#ifdef LOW_LEVEL_TRACER
#define CALL_LOW_LEVEL_TRACER \
low_level_trace(enter_pred,(*_PREG)->u.Osbpp.p,XREGS+1);
#endif
#define CALL_POST_LOW_LEVEL_TRACER \
register CELL *ENV_YREG = (YREG); \
PredEntry *pt; \
pt = (*_PREG)->u.Osbpp.p; \
CACHE_A1();
#define CALL_POST_NO_CHECKING \
ENV = ENV_YREG; \
ENV_YREG = (CELL *) (((char *) ENV_YREG) + (*_PREG)->u.Osbpp.s); \
(*_CPREG) = NEXTOP((*_PREG), Osbpp); \
(*_PREG) = pt->CodeOfPred; \
save_pc(); \
#ifdef DEPTH_LIMIT
#define CALL_DEPTH_MINOR \
FAILED = 0; \
if (pt->ModuleOfPred) { \
if (DEPTH == MkIntTerm(0)){ \
YAAM_FAIL; \
} else { \
DEPTH = RESET_DEPTH(); \
} \
}
#define CALL_DEPTH_MOFPRED \
FAILED = 0; \
DEPTH -= MkIntConstant(2);
#define CALL_DEPTH_END \
FAILED = 0;
#endif
#ifdef YAPOR
#ifdef FROZEN_STACKS
#ifdef YAPOR_SBA
#define CALL_END_END \
BLOCK = (CELL)CALL_END_END; \
if (!FAILED) { \
{ \
choiceptr top_b = PROTECT_FROZEN_B(B); \
if (ENV_YREG > (CELL *) top_b || ENV_YREG < HR) { \
ENV_YREG = (CELL *) top_b; \
} \
} \
WRITEBACK_Y_AS_ENV(); \
ENV_YREG[E_CB] = (CELL) B; \
SCH_check_requests(); \
ALWAYS_GONext(); \
}
#else /* YAPOR_SBA */
#define CALL_END_END \
BLOCK = (CELL)CALL_END_END; \
if (!FAILED) { \
{ \
choiceptr top_b = PROTECT_FROZEN_B(B); \
if (ENV_YREG > (CELL *) top_b) { \
ENV_YREG = (CELL *) top_b; \
} \
} \
WRITEBACK_Y_AS_ENV(); \
ENV_YREG[E_CB] = (CELL) B; \
SCH_check_requests(); \
ALWAYS_GONext(); \
}
#endif /* YAPOR_SBA */
#else /* FROZEN_STACKS */
#define CALL_END_END \
BLOCK = (CELL)CALL_END_END; \
if (!FAILED) { \
if (ENV_YREG > (CELL *) B) { \
ENV_YREG = (CELL *) B; \
} \
WRITEBACK_Y_AS_ENV(); \
ENV_YREG[E_CB] = (CELL) B; \
SCH_check_requests(); \
ALWAYS_GONext(); \
}
#endif /* FROZEN_STACKS */
#else /* YAPOR */
#ifdef FROZEN_STACKS
#ifdef YAPOR_SBA
#define CALL_END_END \
BLOCK = (CELL)CALL_END_END; \
if (!FAILED) { \
{ \
choiceptr top_b = PROTECT_FROZEN_B(B); \
if (ENV_YREG > (CELL *) top_b || ENV_YREG < HR) { \
ENV_YREG = (CELL *) top_b; \
} \
} \
WRITEBACK_Y_AS_ENV(); \
ENV_YREG[E_CB] = (CELL) B; \
ALWAYS_GONext(); \
}
#else /* YAPOR_SBA */
#define CALL_END_END \
BLOCK = (CELL)CALL_END_END; \
if (!FAILED) { \
{ \
choiceptr top_b = PROTECT_FROZEN_B(B); \
if (ENV_YREG > (CELL *) top_b) { \
ENV_YREG = (CELL *) top_b; \
} \
} \
WRITEBACK_Y_AS_ENV(); \
ENV_YREG[E_CB] = (CELL) B; \
ALWAYS_GONext(); \
}
#endif /* YAPOR_SBA */
#else /* FROZEN_STACKS */
#define CALL_END_END \
BLOCK = (CELL)CALL_END_END; \
if (!FAILED) { \
if (ENV_YREG > (CELL *) B) { \
ENV_YREG = (CELL *) B; \
} \
WRITEBACK_Y_AS_ENV(); \
ENV_YREG[E_CB] = (CELL) B; \
ALWAYS_GONext(); \
}
#endif /* FROZEN_STACKS */
#endif /* YAPOR */
#define PROCCEED_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
BLOCKADDRESS = (CELL)(*_PREG); \
CACHE_Y_AS_ENV(YREG); \
(*_PREG) = (*_CPREG); \
save_pc(); \
ENV_YREG = ENV;
#ifdef DEPTH_LIMIT
#define PROCCEED_DEPTH \
DEPTH = ENV_YREG[E_DEPTH];
#endif
#define PROCCEED_END \
BLOCK = (CELL)PROCCEED_END; \
WRITEBACK_Y_AS_ENV(); \
ENDCACHE_Y_AS_ENV(); \
ALWAYS_GONext();
#define ALLOCATE_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
CACHE_Y_AS_ENV(YREG); \
(*_PREG) = NEXTOP((*_PREG), e); \
ENV_YREG[E_CP] = (CELL) (*_CPREG); \
ENV_YREG[E_E] = (CELL) ENV;
#ifdef DEPTH_LIMIT
#define ALLOCATE_DEPTH \
ENV_YREG[E_DEPTH] = DEPTH;
#endif
#define ALLOCATE_END \
ENV = ENV_YREG; \
ENDCACHE_Y_AS_ENV(); \
GONext();
#define DEALLOCATE_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
#define DEALLOCATE_POST_CHECK \
CACHE_Y_AS_ENV(YREG); \
(*_PREG) = NEXTOP((*_PREG), p); \
(*_SREG) = YREG; \
(*_CPREG) = (yamop *) ENV_YREG[E_CP]; \
ENV = ENV_YREG = (CELL *) ENV_YREG[E_E];
#ifdef DEPTH_LIMIT
#define DEALLOCATE_DEPTH \
DEPTH = ENV_YREG[E_DEPTH];
#endif
#ifdef FROZEN_STACKS
#ifdef YAPOR_SBA
#define DEALLOCATE_FROZEN \
choiceptr top_b = PROTECT_FROZEN_B(B); \
if (ENV_YREG > (CELL *) top_b || ENV_YREG < HR) \
ENV_YREG = (CELL *) top_b; \
else \
ENV_YREG = (CELL *)((CELL) ENV_YREG + ENV_Size(CPREG));
#else /* YAPOR_SBA */
#define DEALLOCATE_FROZEN \
choiceptr top_b = PROTECT_FROZEN_B(B); \
if (ENV_YREG > (CELL *) top_b) \
ENV_YREG = (CELL *) top_b; \
else \
ENV_YREG = (CELL *)((CELL) ENV_YREG + ENV_Size(CPREG));
#endif /* YAPOR_SBA */
#else /* FROZEN_STACKS */
#define DEALLOCATE_FROZEN \
if (ENV_YREG > (CELL *) B) \
ENV_YREG = (CELL *) B; \
else \
ENV_YREG = (CELL *) ((CELL) ENV_YREG + ENV_Size(CPREG));
#endif /* FROZEN_STACKS */
#define DEALLOCATE_POST_FROZEN \
WRITEBACK_Y_AS_ENV();
#define DEALLOCATE_END \
ENDCACHE_Y_AS_ENV(); \
GONext();

323
JIT/HPP/yaam_cpred.h Normal file
View File

@ -0,0 +1,323 @@
#define CALL_CPRED_INSTINIT \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0;
#if (defined(YAPOR_SBA) && defined(YAPOR)) || defined(TABLING)
#define CALL_CPRED_TEST_STACK \
if (!((*_PREG)->u.Osbpp.p->PredFlags & (SafePredFlag|HiddenPredFlag))) { \
CACHE_Y_AS_ENV(YREG); \
if (__builtin_expect( ((Int)(Unsigned(YOUNGEST_CP((choiceptr)ENV_YREG,B_FZ)) - Unsigned(YOUNGEST_H(H_FZ,H))) < CreepFlag), 0) ) { return external_labels[6]; } \
ENDCACHE_Y_AS_ENV(); \
}
#else
#define CALL_CPRED_TEST_STACK \
if (!((*_PREG)->u.Osbpp.p->PredFlags & (SafePredFlag|HiddenPredFlag))) { \
CACHE_Y_AS_ENV(YREG); \
if (__builtin_expect(((Int)(Unsigned(ENV_YREG) - Unsigned(HR)) < CreepFlag ), 0) ) { return external_labels[6]; } \
ENDCACHE_Y_AS_ENV(); \
}
#endif
#ifdef FROZEN_STACKS
#define CALL_CPRED_FROZEN_INIT \
choiceptr top_b = PROTECT_FROZEN_B(B);
#ifdef YAPOR_SBA
#define CALL_CPRED_TOPB \
if (YREG > (CELL *) top_b || YREG < HR) \
ASP = (CELL *)top_b; \
else \
ASP = (CELL *)(((char *)YREG) + (*_PREG)->u.Osbpp.s);
#else /* YAPOR_SBA */
#define CALL_CPRED_TOPB \
if (YREG > (CELL *) top_b) \
ASP = (CELL *)top_b; \
else \
ASP = (CELL *)(((char *)YREG) + (*_PREG)->u.Osbpp.s);
#endif /* YAPOR_SBA */
#else
#define CALL_CPRED_NOFROZEN \
SET_ASP(YREG, (*_PREG)->u.Osbpp.s);
#endif
#ifdef LOW_LEVEL_TRACER
#define CALL_CPRED_LOW_LEVEL_TRACER \
low_level_trace(enter_pred,(*_PREG)->u.Osbpp.p,XREGS+1);
#endif
#define CALL_CPRED_POST_LOW_LEVEL_TRACER \
CPredicate f = (*_PREG)->u.Osbpp.p->cs.f_code; \
(*_PREG) = NEXTOP((*_PREG), Osbpp); \
saveregs(); \
d0 = (f)(PASS_REGS1); \
setregs();
#ifdef SHADOW_S
#define CALL_CPRED_SETSREG \
(*_SREG) = Yap_REGS.S_;
#endif
#define CALL_CPRED_END \
BLOCK = (CELL)CALL_CPRED_END; \
FAILED = 0; \
if (!d0) { \
YAAM_FAIL; \
} \
else { \
CACHE_A1(); \
JMPNext(); \
}
#define EXECUTE_CPRED_INSTINIT \
BLOCKADDRESS = (CELL)(*_PREG); \
#define EXECUTE_CPRED_POST_CHECK_TRAIL \
PredEntry *pt0; \
CELL d0; \
CACHE_Y_AS_ENV(YREG);
#ifdef FROZEN_STACKS
#define EXECUTE_CPRED_FROZEN \
choiceptr top_b = PROTECT_FROZEN_B(B);
#ifdef YAPOR_SBA
#define EXECUTE_CPRED_TOPB \
if (YREG > (CELL *) top_b || YREG < HR) { \
ASP = (CELL *)top_b; \
} \
else { \
ASP = YREG+E_CB; \
}
#else
#define EXECUTE_CPRED_TOPB \
if (YREG > (CELL *) top_b) { \
ASP = (CELL *)top_b; \
} \
else { \
ASP = YREG+E_CB; \
}
#endif
#else
#define EXECUTE_CPRED_NOFROZEN \
SET_ASP(YREG, E_CB*sizeof(CELL));
#endif
#define EXECUTE_CPRED_POST_FROZEN \
pt0 = (*_PREG)->u.pp.p;
#ifdef LOW_LEVEL_TRACER
#define EXECUTE_CPRED_LOW_LEVEL_TRACER \
low_level_trace(enter_pred,pt0,XREGS+1);
#endif
#define EXECUTE_CPRED_POST_LOW_LEVEL_TRACER \
CACHE_A1(); \
register CELL d0; \
d0 = (CELL)B;
#define EXECUTE_CPRED_SAVE_PC \
save_pc(); \
ENV_YREG[E_CB] = d0;
#ifdef DEPTH_LIMIT
#define EXECUTE_CPRED_DEPTH_MINOR \
FAILED = 0; \
if (pt0->ModuleOfPred) { \
if (DEPTH == MkIntTerm(0)) { \
YAAM_FAIL; \
} \
else { \
DEPTH = RESET_DEPTH(); \
} \
}
#define EXECUTE_CPRED_DEPTH_MOFPRED \
FAILED = 0; \
DEPTH -= MkIntConstant(2);
#define EXECUTE_CPRED_DEPTH_END \
FAILED = 0;
#endif
#ifdef SHADOW_S
#ifdef DEPTH_LIMIT
#define EXECUTE_CPRED_END \
BLOCK = (CELL)EXECUTE_CPRED_END; \
if (!FAILED) { \
CPredicate f = (*_PREG)->u.pp.p->cs.f_code; \
yamop *oldPREG = (*_PREG); \
saveregs(); \
d0 = (f)(PASS_REGS1); \
setregs(); \
(*_SREG) = Yap_REGS.S_; \
if (!d0) { \
YAAM_FAIL; \
} \
else { \
if (oldPREG == (*_PREG)) { \
(*_PREG) = (*_CPREG); \
ENV_YREG = ENV; \
DEPTH = ENV_YREG[E_DEPTH]; \
WRITEBACK_Y_AS_ENV(); \
} else { \
CACHE_A1(); \
} \
JMPNext(); \
} \
} \
ENDCACHE_Y_AS_ENV();
#else /* DEPTH_LIMIT */
#define EXECUTE_CPRED_END \
BLOCK = (CELL)EXECUTE_CPRED_END; \
if (!FAILED) { \
CPredicate f = (*_PREG)->u.pp.p->cs.f_code; \
yamop *oldPREG = (*_PREG); \
saveregs(); \
d0 = (f)(PASS_REGS1); \
setregs(); \
(*_SREG) = Yap_REGS.S_; \
if (!d0) { \
YAAM_FAIL; \
} \
else { \
if (oldPREG == (*_PREG)) { \
(*_PREG) = (*_CPREG); \
ENV_YREG = ENV; \
WRITEBACK_Y_AS_ENV(); \
} else { \
CACHE_A1(); \
} \
JMPNext(); \
} \
} \
ENDCACHE_Y_AS_ENV();
#endif /* DEPTH_LIMIT */
#else /* SHADOW_S */
#ifdef DEPTH_LIMIT
#define EXECUTE_CPRED_END \
BLOCK = (CELL)EXECUTE_CPRED_END; \
if (!FAILED) { \
CPredicate f = (*_PREG)->u.pp.p->cs.f_code; \
yamop *oldPREG = (*_PREG); \
saveregs(); \
d0 = (f)(PASS_REGS1); \
setregs(); \
if (!d0) { \
YAAM_FAIL; \
} \
else { \
if (oldPREG == (*_PREG)) { \
(*_PREG) = (*_CPREG); \
ENV_YREG = ENV; \
DEPTH = ENV_YREG[E_DEPTH]; \
WRITEBACK_Y_AS_ENV(); \
} else { \
CACHE_A1(); \
} \
JMPNext(); \
} \
} \
ENDCACHE_Y_AS_ENV();
#else /* DEPTH_LIMIT */
#define EXECUTE_CPRED_END \
BLOCK = (CELL)EXECUTE_CPRED_END; \
if (!FAILED) { \
CPredicate f = (*_PREG)->u.pp.p->cs.f_code; \
yamop *oldPREG = (*_PREG); \
saveregs(); \
d0 = (f)(PASS_REGS1); \
setregs(); \
if (!d0) { \
YAAM_FAIL; \
} \
else { \
if (oldPREG == (*_PREG)) { \
(*_PREG) = (*_CPREG); \
ENV_YREG = ENV; \
WRITEBACK_Y_AS_ENV(); \
} else { \
CACHE_A1(); \
} \
JMPNext(); \
} \
} \
ENDCACHE_Y_AS_ENV();
#endif /* DEPTH_LIMIT */
#endif /* SHADOW_S */
#if (defined(YAPOR_SBA) && defined(YAPOR)) || defined(TABLING)
#define CALL_USERCPRED_INSTINIT \
BLOCKADDRESS = (CELL)(*_PREG); \
CACHE_Y_AS_ENV(YREG); \
if (__builtin_expect( ((Int)(Unsigned(YOUNGEST_CP((choiceptr)ENV_YREG,B_FZ)) - Unsigned(YOUNGEST_H(H_FZ,H))) < CreepFlag), 0) ) { return external_labels[6]; } \
ENDCACHE_Y_AS_ENV();
#else
#define CALL_USERCPRED_INSTINIT \
BLOCKADDRESS = (CELL)(*_PREG); \
CACHE_Y_AS_ENV(YREG); \
if (__builtin_expect(((Int)(Unsigned(ENV_YREG) - Unsigned(HR)) < CreepFlag ), 0) ) { return external_labels[6]; } \
ENDCACHE_Y_AS_ENV();
#endif
#ifdef LOW_LEVEL_TRACER
#define CALL_USERCPRED_LOW_LEVEL_TRACER \
low_level_trace(enter_pred,(*_PREG)->u.Osbpp.p,XREGS+1);
#endif
#ifdef FROZEN_STACKS
#ifdef YAPOR_SBA
#define CALL_USERCPRED_FROZEN \
choiceptr top_b = PROTECT_FROZEN_B(B); \
if (YREG > (CELL *) top_b || YREG < HR) \
ASP = (CELL *) top_b; \
else \
ASP = (CELL *)(((char *)YREG) + (*_PREG)->u.Osbpp.s);
#else /* YAPOR_SBA */
#define CALL_USERCPRED_FROZEN \
choiceptr top_b = PROTECT_FROZEN_B(B); \
if (YREG > (CELL *) top_b) \
ASP = (CELL *) top_b; \
else \
ASP = (CELL *)(((char *)YREG) + (*_PREG)->u.Osbpp.s);
#endif /* YAPOR_SBA */
#else /* FROZEN_STACKS */
#define CALL_USERCPRED_FROZEN \
SET_ASP(YREG, (*_PREG)->u.Osbpp.s);
#endif /* FROZEN_STACKS */
#define CALL_USERCPRED_POST_FROZEN \
yamop *savedP; \
Yap_StartSlots( PASS_REGS1 ); \
LOCAL_PrologMode = UserCCallMode; \
{ \
PredEntry *p = (*_PREG)->u.Osbpp.p; \
(*_PREG) = NEXTOP((*_PREG), Osbpp); \
savedP = (*_PREG); \
saveregs(); \
save_machine_regs(); \
(*_SREG) = (CELL *) YAP_Execute(p, p->cs.f_code); \
} \
Yap_CloseSlots( PASS_REGS1 ); \
setregs(); \
LOCAL_PrologMode = UserMode; \
restore_machine_regs(); \
(*_PREG) = savedP;
#define CALL_USERCPRED_END \
BLOCK = (CELL)CALL_USERCPRED_END; \
FAILED = 0; \
if (EX) { \
struct DB_TERM *exp = EX; \
EX = NULL; \
Yap_JumpToEnv(Yap_PopTermFromDB(exp)); \
} \
if (!(*_SREG)) { \
YAAM_FAIL; \
} \
else { \
YENV = ENV; \
YREG = ENV; \
JMPNext(); \
}

327
JIT/HPP/yaam_cpred_d.h Normal file
View File

@ -0,0 +1,327 @@
#define CALL_CPRED_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0;
#if (defined(YAPOR_SBA) && defined(YAPOR)) || defined(TABLING)
#define CALL_CPRED_TEST_STACK \
if (!((*_PREG)->u.Osbpp.p->PredFlags & (SafePredFlag|HiddenPredFlag))) { \
CACHE_Y_AS_ENV(YREG); \
if (__builtin_expect( ((Int)(Unsigned(YOUNGEST_CP((choiceptr)ENV_YREG,B_FZ)) - Unsigned(YOUNGEST_H(H_FZ,H))) < CreepFlag), 0) ) { return external_labels[6]; } \
ENDCACHE_Y_AS_ENV(); \
}
#else
#define CALL_CPRED_TEST_STACK \
if (!((*_PREG)->u.Osbpp.p->PredFlags & (SafePredFlag|HiddenPredFlag))) { \
CACHE_Y_AS_ENV(YREG); \
if (__builtin_expect(((Int)(Unsigned(ENV_YREG) - Unsigned(HR)) < CreepFlag ), 0) ) { return external_labels[6]; } \
ENDCACHE_Y_AS_ENV(); \
}
#endif
#ifdef FROZEN_STACKS
#define CALL_CPRED_FROZEN_INIT \
choiceptr top_b = PROTECT_FROZEN_B(B);
#ifdef YAPOR_SBA
#define CALL_CPRED_TOPB \
if (YREG > (CELL *) top_b || YREG < HR) \
ASP = (CELL *)top_b; \
else \
ASP = (CELL *)(((char *)YREG) + (*_PREG)->u.Osbpp.s);
#else /* YAPOR_SBA */
#define CALL_CPRED_TOPB \
if (YREG > (CELL *) top_b) \
ASP = (CELL *)top_b; \
else \
ASP = (CELL *)(((char *)YREG) + (*_PREG)->u.Osbpp.s);
#endif /* YAPOR_SBA */
#else
#define CALL_CPRED_NOFROZEN \
SET_ASP(YREG, (*_PREG)->u.Osbpp.s);
#endif
#ifdef LOW_LEVEL_TRACER
#define CALL_CPRED_LOW_LEVEL_TRACER \
low_level_trace(enter_pred,(*_PREG)->u.Osbpp.p,XREGS+1);
#endif
#define CALL_CPRED_POST_LOW_LEVEL_TRACER \
CPredicate f = (*_PREG)->u.Osbpp.p->cs.f_code; \
(*_PREG) = NEXTOP((*_PREG), Osbpp); \
saveregs(); \
d0 = (f)(PASS_REGS1); \
setregs();
#ifdef SHADOW_S
#define CALL_CPRED_SETSREG \
(*_SREG) = Yap_REGS.S_;
#endif
#define CALL_CPRED_END \
BLOCK = (CELL)CALL_CPRED_END; \
FAILED = 0; \
if (!d0) { \
YAAM_FAIL; \
} \
else { \
CACHE_A1(); \
JMPNext(); \
}
#define EXECUTE_CPRED_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
BLOCKADDRESS = (CELL)(*_PREG); \
#define EXECUTE_CPRED_POST_CHECK_TRAIL \
PredEntry *pt0; \
CELL d0; \
CACHE_Y_AS_ENV(YREG);
#ifdef FROZEN_STACKS
#define EXECUTE_CPRED_FROZEN \
choiceptr top_b = PROTECT_FROZEN_B(B);
#ifdef YAPOR_SBA
#define EXECUTE_CPRED_TOPB \
if (YREG > (CELL *) top_b || YREG < HR) { \
ASP = (CELL *)top_b; \
} \
else { \
ASP = YREG+E_CB; \
}
#else
#define EXECUTE_CPRED_TOPB \
if (YREG > (CELL *) top_b) { \
ASP = (CELL *)top_b; \
} \
else { \
ASP = YREG+E_CB; \
}
#endif
#else
#define EXECUTE_CPRED_NOFROZEN \
SET_ASP(YREG, E_CB*sizeof(CELL));
#endif
#define EXECUTE_CPRED_POST_FROZEN \
pt0 = (*_PREG)->u.pp.p;
#ifdef LOW_LEVEL_TRACER
#define EXECUTE_CPRED_LOW_LEVEL_TRACER \
low_level_trace(enter_pred,pt0,XREGS+1);
#endif
#define EXECUTE_CPRED_POST_LOW_LEVEL_TRACER \
CACHE_A1(); \
register CELL d0; \
d0 = (CELL)B;
#define EXECUTE_CPRED_SAVE_PC \
save_pc(); \
ENV_YREG[E_CB] = d0;
#ifdef DEPTH_LIMIT
#define EXECUTE_CPRED_DEPTH_MINOR \
FAILED = 0; \
if (pt0->ModuleOfPred) { \
if (DEPTH == MkIntTerm(0)) { \
YAAM_FAIL; \
} \
else { \
DEPTH = RESET_DEPTH(); \
} \
}
#define EXECUTE_CPRED_DEPTH_MOFPRED \
FAILED = 0; \
DEPTH -= MkIntConstant(2);
#define EXECUTE_CPRED_DEPTH_END \
FAILED = 0;
#endif
#ifdef SHADOW_S
#ifdef DEPTH_LIMIT
#define EXECUTE_CPRED_END \
BLOCK = (CELL)EXECUTE_CPRED_END; \
if (!FAILED) { \
CPredicate f = (*_PREG)->u.pp.p->cs.f_code; \
yamop *oldPREG = (*_PREG); \
saveregs(); \
d0 = (f)(PASS_REGS1); \
setregs(); \
(*_SREG) = Yap_REGS.S_; \
if (!d0) { \
YAAM_FAIL; \
} \
else { \
if (oldPREG == (*_PREG)) { \
(*_PREG) = (*_CPREG); \
ENV_YREG = ENV; \
DEPTH = ENV_YREG[E_DEPTH]; \
WRITEBACK_Y_AS_ENV(); \
} else { \
CACHE_A1(); \
} \
JMPNext(); \
} \
} \
ENDCACHE_Y_AS_ENV();
#else /* DEPTH_LIMIT */
#define EXECUTE_CPRED_END \
BLOCK = (CELL)EXECUTE_CPRED_END; \
if (!FAILED) { \
CPredicate f = (*_PREG)->u.pp.p->cs.f_code; \
yamop *oldPREG = (*_PREG); \
saveregs(); \
d0 = (f)(PASS_REGS1); \
setregs(); \
(*_SREG) = Yap_REGS.S_; \
if (!d0) { \
YAAM_FAIL; \
} \
else { \
if (oldPREG == (*_PREG)) { \
(*_PREG) = (*_CPREG); \
ENV_YREG = ENV; \
WRITEBACK_Y_AS_ENV(); \
} else { \
CACHE_A1(); \
} \
JMPNext(); \
} \
} \
ENDCACHE_Y_AS_ENV();
#endif /* DEPTH_LIMIT */
#else /* SHADOW_S */
#ifdef DEPTH_LIMIT
#define EXECUTE_CPRED_END \
BLOCK = (CELL)EXECUTE_CPRED_END; \
if (!FAILED) { \
CPredicate f = (*_PREG)->u.pp.p->cs.f_code; \
yamop *oldPREG = (*_PREG); \
saveregs(); \
d0 = (f)(PASS_REGS1); \
setregs(); \
if (!d0) { \
YAAM_FAIL; \
} \
else { \
if (oldPREG == (*_PREG)) { \
(*_PREG) = (*_CPREG); \
ENV_YREG = ENV; \
DEPTH = ENV_YREG[E_DEPTH]; \
WRITEBACK_Y_AS_ENV(); \
} else { \
CACHE_A1(); \
} \
JMPNext(); \
} \
} \
ENDCACHE_Y_AS_ENV();
#else /* DEPTH_LIMIT */
#define EXECUTE_CPRED_END \
BLOCK = (CELL)EXECUTE_CPRED_END; \
if (!FAILED) { \
CPredicate f = (*_PREG)->u.pp.p->cs.f_code; \
yamop *oldPREG = (*_PREG); \
saveregs(); \
d0 = (f)(PASS_REGS1); \
setregs(); \
if (!d0) { \
YAAM_FAIL; \
} \
else { \
if (oldPREG == (*_PREG)) { \
(*_PREG) = (*_CPREG); \
ENV_YREG = ENV; \
WRITEBACK_Y_AS_ENV(); \
} else { \
CACHE_A1(); \
} \
JMPNext(); \
} \
} \
ENDCACHE_Y_AS_ENV();
#endif /* DEPTH_LIMIT */
#endif /* SHADOW_S */
#if (defined(YAPOR_SBA) && defined(YAPOR)) || defined(TABLING)
#define CALL_USERCPRED_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
BLOCKADDRESS = (CELL)(*_PREG); \
CACHE_Y_AS_ENV(YREG); \
if (__builtin_expect( ((Int)(Unsigned(YOUNGEST_CP((choiceptr)ENV_YREG,B_FZ)) - Unsigned(YOUNGEST_H(H_FZ,H))) < CreepFlag), 0) ) { return external_labels[6]; } \
ENDCACHE_Y_AS_ENV();
#else
#define CALL_USERCPRED_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
BLOCKADDRESS = (CELL)(*_PREG); \
CACHE_Y_AS_ENV(YREG); \
if (__builtin_expect(((Int)(Unsigned(ENV_YREG) - Unsigned(HR)) < CreepFlag ), 0) ) { return external_labels[6]; } \
ENDCACHE_Y_AS_ENV();
#endif
#ifdef LOW_LEVEL_TRACER
#define CALL_USERCPRED_LOW_LEVEL_TRACER \
low_level_trace(enter_pred,(*_PREG)->u.Osbpp.p,XREGS+1);
#endif
#ifdef FROZEN_STACKS
#ifdef YAPOR_SBA
#define CALL_USERCPRED_FROZEN \
choiceptr top_b = PROTECT_FROZEN_B(B); \
if (YREG > (CELL *) top_b || YREG < HR) \
ASP = (CELL *) top_b; \
else \
ASP = (CELL *)(((char *)YREG) + (*_PREG)->u.Osbpp.s);
#else /* YAPOR_SBA */
#define CALL_USERCPRED_FROZEN \
choiceptr top_b = PROTECT_FROZEN_B(B); \
if (YREG > (CELL *) top_b) \
ASP = (CELL *) top_b; \
else \
ASP = (CELL *)(((char *)YREG) + (*_PREG)->u.Osbpp.s);
#endif /* YAPOR_SBA */
#else /* FROZEN_STACKS */
#define CALL_USERCPRED_FROZEN \
SET_ASP(YREG, (*_PREG)->u.Osbpp.s);
#endif /* FROZEN_STACKS */
#define CALL_USERCPRED_POST_FROZEN \
yamop *savedP; \
Yap_StartSlots( PASS_REGS1 ); \
LOCAL_PrologMode = UserCCallMode; \
{ \
PredEntry *p = (*_PREG)->u.Osbpp.p; \
(*_PREG) = NEXTOP((*_PREG), Osbpp); \
savedP = (*_PREG); \
saveregs(); \
save_machine_regs(); \
(*_SREG) = (CELL *) YAP_Execute(p, p->cs.f_code); \
} \
Yap_CloseSlots( PASS_REGS1 ); \
setregs(); \
LOCAL_PrologMode = UserMode; \
restore_machine_regs(); \
(*_PREG) = savedP;
#define CALL_USERCPRED_END \
BLOCK = (CELL)CALL_USERCPRED_END; \
FAILED = 0; \
if (EX) { \
struct DB_TERM *exp = EX; \
EX = NULL; \
Yap_JumpToEnv(Yap_PopTermFromDB(exp)); \
} \
if (!(*_SREG)) { \
YAAM_FAIL; \
} \
else { \
YENV = ENV; \
YREG = ENV; \
JMPNext(); \
}

135
JIT/HPP/yaam_cut.h Normal file
View File

@ -0,0 +1,135 @@
#define CUT_INSTINIT
#ifdef COROUTINING
#define CUT_COROUTINING \
if (FALSE) { \
NoStackCut_Exception; \
}
#endif
#define CUT_NOCOROUTINING \
SET_ASP(YREG, (*_PREG)->u.s.s); \
(*_PREG) = NEXTOP(NEXTOP(NEXTOP((*_PREG), s),Osbpp),l); \
saveregs(); \
prune((choiceptr)YREG[E_CB]); \
setregs(); \
GONext();
#define CUT_T_INSTINIT
#ifdef COROUTINING
#define CUT_T_COROUTINING \
if (FALSE) { \
NoStackCutT_Exception; \
}
#endif
#define CUT_T_NOCOROUTINING \
SET_ASP(YREG, (*_PREG)->u.s.s); \
saveregs(); \
prune((choiceptr)YREG[E_CB]); \
setregs(); \
(*_PREG) = NEXTOP(NEXTOP(NEXTOP((*_PREG), s),Osbpp),l); \
GONext();
#define CUT_E_INSTINIT
#ifdef COROUTINING
#define CUT_E_COROUTINING \
if (FALSE) { \
NoStackCutE_Exception; \
}
#endif
#define CUT_E_NOCOROUTINING \
SET_ASP(YREG, (*_PREG)->u.s.s); \
(*_PREG) = NEXTOP(NEXTOP(NEXTOP((*_PREG), s),Osbpp),l); \
saveregs(); \
prune((choiceptr)(*_SREG)[E_CB]); \
setregs(); \
GONext();
#define SAVE_B_X_INSTINIT \
register CELL d0; \
d0 = (*_PREG)->u.x.x;
#if defined(YAPOR_SBA) && defined(FROZEN_STACKS)
#define SAVE_B_X_YSBA_FROZEN \
XREG(d0) = MkIntegerTerm((Int)B);
#else
#define SAVE_B_X_NOYSBA_NOFROZEN \
XREG(d0) = MkIntegerTerm(LCL0-(CELL *) (B));
#endif
#define SAVE_B_X_END \
(*_PREG) = NEXTOP((*_PREG), x); \
GONext();
#define SAVE_B_Y_INSTINIT
#if defined(YAPOR_SBA)
#define SAVE_B_Y_YSBA \
INITIALIZE_PERMVAR(YREG+(*_PREG)->u.y.y,MkIntegerTerm((Int)B));
#else
#define SAVE_B_Y_NOYSBA \
INITIALIZE_PERMVAR(YREG+(*_PREG)->u.y.y,MkIntegerTerm(LCL0-(CELL *)(B)));
#endif
#define SAVE_B_Y_END \
(*_PREG) = NEXTOP((*_PREG), y); \
GONext();
#define COMMIT_B_X_INSTINIT \
register CELL d0; \
register CELL *pt1;
#define COMMIT_B_X_DO_COMMIT_B_X \
d0 = XREG((*_PREG)->u.xps.x);
#define COMMIT_B_X_COMMIT_B_X_NVAR \
SET_ASP(YREG, (*_PREG)->u.xps.s); \
(*_PREG) = NEXTOP(NEXTOP(NEXTOP((*_PREG), xps),Osbpp),l); \
choiceptr pt0;
#if defined(YAPOR_SBA) && defined(FROZEN_STACKS)
#define COMMIT_B_X_YSBA_FROZEN \
pt0 = (choiceptr)IntegerOfTerm(d0);
#else
#define COMMIT_B_X_NOYSBA_NOFROZEN \
pt0 = (choiceptr)(LCL0-IntegerOfTerm(d0));
#endif
#define COMMIT_B_X_POST_YSBA_FROZEN \
saveregs(); \
prune(pt0); \
setregs(); \
GONext();
#define COMMIT_B_X_END
#define COMMIT_B_Y_INSTINIT \
register CELL d0; \
register CELL *pt1;
#define COMMIT_B_Y_DO_COMMIT_B_Y \
d0 = YREG[(*_PREG)->u.yps.y];
#define COMMIT_B_Y_COMMIT_B_Y_NVAR \
SET_ASP(YREG, (*_PREG)->u.yps.s); \
(*_PREG) = NEXTOP(NEXTOP(NEXTOP((*_PREG), yps),Osbpp),l); \
choiceptr pt0;
#if defined(YAPOR_SBA) && defined(FROZEN_STACKS)
#define COMMIT_B_Y_YSBA_FROZEN \
pt0 = (choiceptr)IntegerOfTerm(d0);
#else
#define COMMIT_B_Y_NOYSBA_NOFROZEN \
pt0 = (choiceptr)(LCL0-IntegerOfTerm(d0));
#endif
#define COMMIT_B_Y_POST_YSBA_FROZEN \
saveregs(); \
prune(pt0); \
setregs(); \
GONext();

141
JIT/HPP/yaam_cut_d.h Normal file
View File

@ -0,0 +1,141 @@
#define CUT_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
#ifdef COROUTINING
#define CUT_COROUTINING \
if (FALSE) { \
NoStackCut_Exception; \
}
#endif
#define CUT_NOCOROUTINING \
SET_ASP(YREG, (*_PREG)->u.s.s); \
(*_PREG) = NEXTOP(NEXTOP(NEXTOP((*_PREG), s),Osbpp),l); \
saveregs(); \
prune((choiceptr)YREG[E_CB]); \
setregs(); \
GONext();
#define CUT_T_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
#ifdef COROUTINING
#define CUT_T_COROUTINING \
if (FALSE) { \
NoStackCutT_Exception; \
}
#endif
#define CUT_T_NOCOROUTINING \
SET_ASP(YREG, (*_PREG)->u.s.s); \
saveregs(); \
prune((choiceptr)YREG[E_CB]); \
setregs(); \
(*_PREG) = NEXTOP(NEXTOP(NEXTOP((*_PREG), s),Osbpp),l); \
GONext();
#define CUT_E_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
#ifdef COROUTINING
#define CUT_E_COROUTINING \
if (FALSE) { \
NoStackCutE_Exception; \
}
#endif
#define CUT_E_NOCOROUTINING \
SET_ASP(YREG, (*_PREG)->u.s.s); \
(*_PREG) = NEXTOP(NEXTOP(NEXTOP((*_PREG), s),Osbpp),l); \
saveregs(); \
prune((choiceptr)(*_SREG)[E_CB]); \
setregs(); \
GONext();
#define SAVE_B_X_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
register CELL d0; \
d0 = (*_PREG)->u.x.x;
#if defined(YAPOR_SBA) && defined(FROZEN_STACKS)
#define SAVE_B_X_YSBA_FROZEN \
XREG(d0) = MkIntegerTerm((Int)B);
#else
#define SAVE_B_X_NOYSBA_NOFROZEN \
XREG(d0) = MkIntegerTerm(LCL0-(CELL *) (B));
#endif
#define SAVE_B_X_END \
(*_PREG) = NEXTOP((*_PREG), x); \
GONext();
#define SAVE_B_Y_INSTINIT
#if defined(YAPOR_SBA)
#define SAVE_B_Y_YSBA \
INITIALIZE_PERMVAR(YREG+(*_PREG)->u.y.y,MkIntegerTerm((Int)B));
#else
#define SAVE_B_Y_NOYSBA \
INITIALIZE_PERMVAR(YREG+(*_PREG)->u.y.y,MkIntegerTerm(LCL0-(CELL *)(B)));
#endif
#define SAVE_B_Y_END \
(*_PREG) = NEXTOP((*_PREG), y); \
GONext();
#define COMMIT_B_X_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
register CELL d0; \
register CELL *pt1;
#define COMMIT_B_X_DO_COMMIT_B_X \
d0 = XREG((*_PREG)->u.xps.x);
#define COMMIT_B_X_COMMIT_B_X_NVAR \
SET_ASP(YREG, (*_PREG)->u.xps.s); \
(*_PREG) = NEXTOP(NEXTOP(NEXTOP((*_PREG), xps),Osbpp),l); \
choiceptr pt0;
#if defined(YAPOR_SBA) && defined(FROZEN_STACKS)
#define COMMIT_B_X_YSBA_FROZEN \
pt0 = (choiceptr)IntegerOfTerm(d0);
#else
#define COMMIT_B_X_NOYSBA_NOFROZEN \
pt0 = (choiceptr)(LCL0-IntegerOfTerm(d0));
#endif
#define COMMIT_B_X_POST_YSBA_FROZEN \
saveregs(); \
prune(pt0); \
setregs(); \
GONext();
#define COMMIT_B_X_END
#define COMMIT_B_Y_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
register CELL d0; \
register CELL *pt1;
#define COMMIT_B_Y_DO_COMMIT_B_Y \
d0 = YREG[(*_PREG)->u.yps.y];
#define COMMIT_B_Y_COMMIT_B_Y_NVAR \
SET_ASP(YREG, (*_PREG)->u.yps.s); \
(*_PREG) = NEXTOP(NEXTOP(NEXTOP((*_PREG), yps),Osbpp),l); \
choiceptr pt0;
#if defined(YAPOR_SBA) && defined(FROZEN_STACKS)
#define COMMIT_B_Y_YSBA_FROZEN \
pt0 = (choiceptr)IntegerOfTerm(d0);
#else
#define COMMIT_B_Y_NOYSBA_NOFROZEN \
pt0 = (choiceptr)(LCL0-IntegerOfTerm(d0));
#endif
#define COMMIT_B_Y_POST_YSBA_FROZEN \
saveregs(); \
prune(pt0); \
setregs(); \
GONext();

1379
JIT/HPP/yaam_failure.h Normal file

File diff suppressed because it is too large Load Diff

1400
JIT/HPP/yaam_failure_d.h Normal file

File diff suppressed because it is too large Load Diff

838
JIT/HPP/yaam_get.h Normal file
View File

@ -0,0 +1,838 @@
#define GET_X_VAR_INSTINIT \
register CELL d0; \
d0 = XREG((*_PREG)->u.xx.xr); \
XREG((*_PREG)->u.xx.xl) = d0; \
(*_PREG) = NEXTOP((*_PREG), xx); \
GONext();
#define GET_Y_VAR_INSTINIT \
register CELL d0; \
register CELL *pt0; \
pt0 = YREG + (*_PREG)->u.yx.y; \
d0 = XREG((*_PREG)->u.yx.x); \
(*_PREG) = NEXTOP((*_PREG), yx); \
INITIALIZE_PERMVAR(pt0,d0); \
GONext();
#define GET_YY_VAR_INSTINIT \
register CELL d0, d1; \
register CELL *pt0, *pt1; \
CACHE_Y(YREG); \
pt0 = S_YREG + (*_PREG)->u.yyxx.y1; \
d0 = XREG((*_PREG)->u.yyxx.x1); \
pt1 = S_YREG + (*_PREG)->u.yyx.y2; \
d1 = XREG((*_PREG)->u.yyxx.x2); \
(*_PREG) = NEXTOP((*_PREG), yyxx); \
INITIALIZE_PERMVAR(pt0,d0); \
INITIALIZE_PERMVAR(pt1,d1); \
ENDCACHE_Y(); \
GONext();
#define GET_X_VAL_INSTINIT \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0, d1; \
register CELL *pt0, *pt1; \
d0 = XREG((*_PREG)->u.xx.xl);
#define GET_X_VAL_GVALX_NONVAR \
d1 = XREG((*_PREG)->u.xx.xr);
#define GET_X_VAL_GVALX_NONVAR_NONVAR \
BLOCK = (CELL)GET_X_VAL_GVALX_NONVAR_NONVAR; \
(*_PREG) = NEXTOP((*_PREG), xx); \
YAAM_UNIFYBOUND;
#define GET_X_VAL_GVALX_NONVAR_UNK \
(*_PREG) = NEXTOP((*_PREG), xx); \
Bind(pt0, d0); \
GONext();
#define GET_X_VAL_GVALX_UNK \
d1 = XREG((*_PREG)->u.xx.xr);
#define GET_X_VAL_GVALX_VAR_NONVAR \
(*_PREG) = NEXTOP((*_PREG), xx); \
Bind(pt0, d1); \
GONext();
#define GET_X_VAL_GVALX_VAR_UNK \
(*_PREG) = NEXTOP((*_PREG), xx); \
UnifyCells(pt0, pt1); \
GONext();
#define GET_Y_VAL_INSTINIT \
register CELL d0, d1; \
register CELL *pt0, *pt1; \
pt0 = YREG + (*_PREG)->u.yx.y; \
d0 = *pt0;
#define GET_Y_VAL_GVALY_NONVAR \
d1 = XREG((*_PREG)->u.yx.x);
#define GET_Y_VAL_GVALY_NONVAR_NONVAR \
BLOCK = (CELL)GET_Y_VAL_GVALY_NONVAR_NONVAR; \
(*_PREG) = NEXTOP((*_PREG), yx); \
YAAM_UNIFYBOUND;
#define GET_Y_VAL_GVALY_NONVAR_UNK \
(*_PREG) = NEXTOP((*_PREG), yx); \
Bind(pt1, d0); \
GONext();
#define GET_Y_VAL_GVALY_UNK \
d1 = XREG((*_PREG)->u.yx.x);
#define GET_Y_VAL_GVALY_VAR_NONVAR \
(*_PREG) = NEXTOP((*_PREG), yx); \
Bind(pt0, d1); \
GONext();
#define GET_Y_VAL_GVALY_VAR_UNK \
(*_PREG) = NEXTOP((*_PREG), yx); \
UnifyCells(pt0, pt1); \
GONext();
#define GET_ATOM_INSTINIT \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0, d1; \
register CELL *pt0; \
d0 = XREG((*_PREG)->u.xc.x); \
d1 = (*_PREG)->u.xc.c;
#define GET_ATOM_GATOM_NONVAR \
BLOCK = (CELL)GET_ATOM_GATOM_NONVAR; \
FAILED = 0; \
if (d0 == d1) { \
(*_PREG) = NEXTOP((*_PREG), xc); \
GONext(); \
} \
else { \
YAAM_FAIL; \
}
#define GET_ATOM_GATOM_UNK \
(*_PREG) = NEXTOP((*_PREG), xc); \
Bind(pt0, d1); \
GONext();
#define GET_2ATOMS_INSTINIT \
register CELL d0, d1; \
register CELL *pt0; \
d0 = ARG1;
#define GET_2ATOMS_GATOM_2UNK \
Bind(pt0, (*_PREG)->u.cc.c1);
#define GET_2ATOMS_GATOM_2B \
d0 = ARG2; \
d1 = (*_PREG)->u.cc.c2;
#define GET_2ATOMS_GATOM_2BNONVAR \
BLOCK = (CELL)GET_2ATOMS_GATOM_2BNONVAR; \
FAILED = 0; \
if (d0 == d1) { \
(*_PREG) = NEXTOP((*_PREG), cc); \
GONext(); \
} \
else { \
YAAM_FAIL; \
}
#define GET_2ATOMS_GATOM_2BUNK \
(*_PREG) = NEXTOP((*_PREG), cc); \
Bind(pt0, d1); \
GONext();
#define GET_3ATOMS_INSTINIT \
register CELL d0, d1; \
register CELL *pt0; \
d0 = ARG1;
#define GET_3ATOMS_GATOM_3UNK \
Bind(pt0, (*_PREG)->u.ccc.c1);
#define GET_3ATOMS_GATOM_3B \
d0 = ARG2;
#define GET_3ATOMS_GATOM_3BUNK \
Bind(pt0, (*_PREG)->u.ccc.c2);
#define GET_3ATOMS_GATOM_3C \
d0 = ARG3; \
d1 = (*_PREG)->u.ccc.c3;
#define GET_3ATOMS_GATOM_3CNONVAR \
BLOCK = (CELL)GET_3ATOMS_GATOM_3CNONVAR; \
FAILED = 0; \
if (d0 == d1) { \
(*_PREG) = NEXTOP((*_PREG), ccc); \
GONext(); \
} \
else { \
YAAM_FAIL; \
}
#define GET_3ATOMS_GATOM_3CUNK \
(*_PREG) = NEXTOP((*_PREG), ccc); \
Bind(pt0, d1); \
GONext();
#define GET_4ATOMS_INSTINIT \
register CELL d0, d1; \
register CELL *pt0; \
d0 = ARG1;
#define GET_4ATOMS_GATOM_4UNK \
Bind(pt0, (*_PREG)->u.cccc.c1);
#define GET_4ATOMS_GATOM_4B \
d0 = ARG2;
#define GET_4ATOMS_GATOM_4BUNK \
Bind(pt0, (*_PREG)->u.cccc.c2);
#define GET_4ATOMS_GATOM_4C \
d0 = ARG3;
#define GET_4ATOMS_GATOM_4CUNK \
Bind(pt0, (*_PREG)->u.cccc.c3);
#define GET_4ATOMS_GATOM_4D \
d0 = ARG4; \
d1 = (*_PREG)->u.cccc.c4;
#define GET_4ATOMS_GATOM_4DNONVAR \
BLOCK = (CELL)GET_4ATOMS_GATOM_4DNONVAR; \
FAILED = 0; \
if (d0 == d1) { \
(*_PREG) = NEXTOP((*_PREG), cccc); \
GONext(); \
} \
else { \
YAAM_FAIL; \
}
#define GET_4ATOMS_GATOM_4DUNK \
(*_PREG) = NEXTOP((*_PREG), cccc); \
Bind(pt0, d1); \
GONext();
#define GET_5ATOMS_INSTINIT \
register CELL d0, d1; \
register CELL *pt0; \
d0 = ARG1;
#define GET_5ATOMS_GATOM_5UNK \
Bind(pt0, (*_PREG)->u.ccccc.c1);
#define GET_5ATOMS_GATOM_5B \
d0 = ARG2;
#define GET_5ATOMS_GATOM_5BUNK \
Bind(pt0, (*_PREG)->u.ccccc.c2);
#define GET_5ATOMS_GATOM_5C \
d0 = ARG3;
#define GET_5ATOMS_GATOM_5CUNK \
Bind(pt0, (*_PREG)->u.ccccc.c3);
#define GET_5ATOMS_GATOM_5D \
d0 = ARG4;
#define GET_5ATOMS_GATOM_5DUNK \
Bind(pt0, (*_PREG)->u.ccccc.c4);
#define GET_5ATOMS_GATOM_5E \
d0 = ARG5; \
d1 = (*_PREG)->u.ccccc.c5;
#define GET_5ATOMS_GATOM_5ENONVAR \
BLOCK = (CELL)GET_5ATOMS_GATOM_5ENONVAR; \
FAILED = 0; \
if (d0 == d1) { \
(*_PREG) = NEXTOP((*_PREG), ccccc); \
GONext(); \
} \
else { \
YAAM_FAIL; \
}
#define GET_5ATOMS_GATOM_5EUNK \
(*_PREG) = NEXTOP((*_PREG), ccccc); \
Bind(pt0, d1); \
GONext();
#define GET_6ATOMS_INSTINIT \
register CELL d0, d1; \
register CELL *pt0; \
d0 = ARG1;
#define GET_6ATOMS_GATOM_6UNK \
Bind(pt0, (*_PREG)->u.cccccc.c1);
#define GET_6ATOMS_GATOM_6B \
d0 = ARG2;
#define GET_6ATOMS_GATOM_6BUNK \
Bind(pt0, (*_PREG)->u.cccccc.c2);
#define GET_6ATOMS_GATOM_6C \
d0 = ARG3;
#define GET_6ATOMS_GATOM_6CUNK \
Bind(pt0, (*_PREG)->u.cccccc.c3);
#define GET_6ATOMS_GATOM_6D \
d0 = ARG4;
#define GET_6ATOMS_GATOM_6DUNK \
Bind(pt0, (*_PREG)->u.cccccc.c4);
#define GET_6ATOMS_GATOM_6E \
d0 = ARG5;
#define GET_6ATOMS_GATOM_6EUNK \
Bind(pt0, (*_PREG)->u.cccccc.c5);
#define GET_6ATOMS_GATOM_6F \
d0 = ARG6; \
d1 = (*_PREG)->u.cccccc.c6;
#define GET_6ATOMS_GATOM_6FNONVAR \
BLOCK = (CELL)GET_6ATOMS_GATOM_6FNONVAR; \
FAILED = 0; \
if (d0 == d1) { \
(*_PREG) = NEXTOP((*_PREG), cccccc); \
GONext(); \
} \
else { \
YAAM_FAIL; \
}
#define GET_6ATOMS_GATOM_6FUNK \
(*_PREG) = NEXTOP((*_PREG), cccccc); \
Bind(pt0, d1); \
GONext();
#define GET_LIST_INSTINIT \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0; \
register CELL *pt0; \
d0 = XREG((*_PREG)->u.x.x);
#define GET_LIST_GLIST_NONVAR \
BLOCK = (CELL)GET_LIST_GLIST_NONVAR; \
FAILED = 0; \
if (!IsPairTerm(d0)) { \
YAAM_FAIL; \
} \
else { \
(*_PREG) = NEXTOP((*_PREG), x); \
(*_SREG) = RepPair(d0); \
GONext(); \
}
#define GET_LIST_GLIST_UNK \
CACHE_S(); \
S_SREG = HR; \
START_PREFETCH_W(x); \
(*_PREG) = NEXTOP((*_PREG), x); \
d0 = AbsPair(S_SREG); \
Bind(pt0, d0); \
S_SREG = HR; \
HR = S_SREG + 2; \
WRITEBACK_S(S_SREG); \
GONextW(); \
END_PREFETCH_W(); \
ENDCACHE_S();
#define GET_STRUCT_INSTINIT \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0, d1; \
register CELL *pt0; \
d0 = XREG((*_PREG)->u.xfa.x);
#define GET_STRUCT_GSTRUCT_NONVAR \
BLOCK = (CELL)GET_STRUCT_GSTRUCT_NONVAR; \
FAILED = 0; \
if (!IsApplTerm(d0)) { \
YAAM_FAIL; \
} \
else { \
register CELL * S_SREG; \
S_SREG = RepAppl(d0); \
d0 = (CELL) ((*_PREG)->u.xfa.f); \
if (*S_SREG != d0) { \
YAAM_FAIL; \
} \
else { \
WRITEBACK_S(S_SREG+1); \
(*_PREG) = NEXTOP((*_PREG), xfa); \
GONext(); \
} \
}
#define GET_STRUCT_GSTRUCT_UNK \
START_PREFETCH_W(xfa); \
d1 = AbsAppl(HR); \
Bind(pt0, d1); \
pt0 = HR; \
d0 = (CELL) ((*_PREG)->u.xfa.f); \
*pt0++ = d0; \
HR = pt0 + (*_PREG)->u.xfa.a; \
(*_PREG) = NEXTOP((*_PREG), xfa); \
(*_SREG) = pt0; \
GONextW(); \
END_PREFETCH_W();
#define GET_FLOAT_INSTINIT \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0, d1; \
register CELL *pt0, *pt1; \
d0 = XREG((*_PREG)->u.xd.x);
#if SIZEOF_DOUBLE == 2*SIZEOF_INT_P
#define GET_FLOAT_GFLOAT_NONVAR \
BLOCK = (CELL)GET_FLOAT_GFLOAT_NONVAR; \
FAILED = 0; \
if (!IsApplTerm(d0)) { \
YAAM_FAIL; \
} \
else { \
pt0 = RepAppl(d0); \
if (*pt0 != (CELL)FunctorDouble) { \
YAAM_FAIL; \
} \
else { \
pt1 = (*_PREG)->u.xd.d; \
(*_PREG) = NEXTOP((*_PREG), xd); \
if ( \
pt1[1] != pt0[1] \
|| pt1[2] != pt0[2] \
) { \
YAAM_FAIL; \
} \
else { \
GONext(); \
} \
} \
}
#else /* SIZEOF_DOUBLE == 2*SIZEOF_INT_P */
#define GET_FLOAT_GFLOAT_NONVAR \
BLOCK = (CELL)GET_FLOAT_GFLOAT_NONVAR; \
FAILED = 0; \
if (!IsApplTerm(d0)) { \
YAAM_FAIL; \
} \
else { \
pt0 = RepAppl(d0); \
if (*pt0 != (CELL)FunctorDouble) { \
YAAM_FAIL; \
} \
else { \
pt1 = (*_PREG)->u.xd.d; \
(*_PREG) = NEXTOP((*_PREG), xd); \
if ( \
pt1[1] != pt0[1] \
) { \
YAAM_FAIL; \
} \
else { \
GONext(); \
} \
} \
}
#endif /* SIZEOF_DOUBLE == 2*SIZEOF_INT_P */
#define GET_FLOAT_GFLOAT_UNK \
START_PREFETCH(xc); \
d1 = AbsAppl((*_PREG)->u.xd.d); \
(*_PREG) = NEXTOP((*_PREG), xd); \
Bind(pt0, d1); \
GONext(); \
END_PREFETCH();
#define GET_LONGINT_INSTINIT \
register CELL d0, d1; \
register CELL *pt0; \
d0 = XREG((*_PREG)->u.xi.x);
#define GET_LONGINT_GLONGINT_NONVAR \
BLOCK = (CELL)GET_LONGINT_GLONGINT_NONVAR; \
FAILED = 0; \
if (!IsApplTerm(d0)) { \
YAAM_FAIL; \
} \
else { \
pt0 = RepAppl(d0); \
if (*pt0 != (CELL)FunctorLongInt) { \
YAAM_FAIL; \
} \
if ((*_PREG)->u.xi.i[1] != (CELL)pt0[1]) { \
YAAM_FAIL; \
} \
} \
if (!FAILED) { \
(*_PREG) = NEXTOP((*_PREG), xi); \
GONext(); \
}
#define GET_LONGINT_GLONGINT_UNK \
START_PREFETCH(xi); \
d1 = AbsAppl((*_PREG)->u.xi.i); \
(*_PREG) = NEXTOP((*_PREG), xi); \
Bind(pt0, d1); \
GONext(); \
END_PREFETCH();
#ifdef USE_GMP
#define GET_BIGINT_INSTINIT \
register CELL d0, d1; \
register CELL *pt0; \
d0 = XREG((*_PREG)->u.xN.x);
#define GET_BIGINT_GBIGINT_NONVAR \
BLOCK = (CELL)GET_BIGINT_GBIGINT_NONVAR; \
FAILED = 0; \
if (!IsApplTerm(d0)) { \
YAAM_FAIL; \
} \
else { \
pt0 = RepAppl(d0); \
if (*pt0 != (CELL)FunctorBigInt) { \
YAAM_FAIL; \
} \
if (Yap_gmp_tcmp_big_big(d0,(*_PREG)->u.xN.b)) { \
YAAM_FAIL; \
} \
} \
if (!FAILED) { \
(*_PREG) = NEXTOP((*_PREG), xN); \
GONext(); \
}
#define GET_BIGINT_GBIGINT_UNK \
START_PREFETCH(xN); \
d1 = (*_PREG)->u.xN.b; \
(*_PREG) = NEXTOP((*_PREG), xN); \
Bind(pt0, d1); \
GONext(); \
END_PREFETCH();
#endif
#define GET_DBTERM_INSTINIT \
register CELL d0, d1; \
register CELL *pt0; \
d0 = XREG((*_PREG)->u.xD.x);
#define GET_DBTERM_GDBTERM_NONVAR \
BLOCK = (CELL)GET_DBTERM_GDBTERM_NONVAR; \
d1 = (*_PREG)->u.xD.D; \
(*_PREG) = NEXTOP((*_PREG), xD); \
YAAM_UNIFYBOUND;
#define GET_DBTERM_GDBTERM_UNK \
START_PREFETCH(xD); \
d1 = (*_PREG)->u.xD.D; \
(*_PREG) = NEXTOP((*_PREG), xD); \
Bind(pt0, d1); \
GONext(); \
END_PREFETCH();
#define GLIST_VALX_INSTINIT \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0, d1; \
register CELL *pt0, *pt1; \
d0 = XREG((*_PREG)->u.xx.xl); \
if (!IsVarTerm(d0)) { \
printf("Oops!\n"); \
exit(1); \
}
#define GLIST_VALX_GLIST_VALX_READ \
BLOCK = (CELL)GLIST_VALX_GLIST_VALX_READ; \
FAILED = 0; \
if (!IsPairTerm(d0)) { \
YAAM_FAIL; \
} \
else { \
pt0 = RepPair(d0); \
(*_SREG) = pt0 + 1; \
d0 = *pt0; \
}
#define GLIST_VALX_GLIST_VALX_NONVAR \
d1 = XREG((*_PREG)->u.xx.xr);
#define GLIST_VALX_GLIST_VALX_NONVAR_NONVAR \
BLOCK = (CELL)GLIST_VALX_GLIST_VALX_NONVAR_NONVAR; \
(*_PREG) = NEXTOP((*_PREG), xx); \
YAAM_UNIFYBOUND;
#define GLIST_VALX_GLIST_VALX_NONVAR_UNK \
(*_PREG) = NEXTOP((*_PREG), xx); \
Bind(pt1, d0); \
GONext();
#define GLIST_VALX_GLIST_VALX_UNK \
d0 = XREG((*_PREG)->u.xx.xr);
#define GLIST_VALX_GLIST_VALX_VAR_NONVAR \
(*_PREG) = NEXTOP((*_PREG), xx); \
Bind_Global(pt0, d0); \
GONext();
#define GLIST_VALX_GLIST_VALX_VAR_UNK \
(*_PREG) = NEXTOP((*_PREG), xx); \
UnifyGlobalCellToCell(pt0, pt1); \
GONext(); \
#define GLIST_VALX_GLIST_VALX_WRITE \
CACHE_S(); \
S_SREG = HR; \
d1 = XREG((*_PREG)->u.xx.xr); \
d0 = AbsPair(S_SREG); \
S_SREG[0] = d1; \
ALWAYS_START_PREFETCH_W(xx); \
(*_PREG) = NEXTOP((*_PREG), xx); \
HR = S_SREG + 2; \
WRITEBACK_S(S_SREG+1); \
Bind(pt0, d0); \
ALWAYS_GONextW(); \
ALWAYS_END_PREFETCH_W(); \
ENDCACHE_S();
#define GLIST_VALY_INSTINIT \
register CELL d0, d1; \
register CELL *pt0, *pt1; \
d0 = XREG((*_PREG)->u.yx.x);
#define GLIST_VALY_GLIST_VALY_READ \
if (!IsPairTerm(d0)) { \
YAAM_FAIL; \
} \
START_PREFETCH(yx); \
pt0 = RepPair(d0); \
(*_SREG) = pt0 + 1; \
d0 = *pt0;
#define GLIST_VALY_GLIST_VALY_NONVAR \
pt1 = YREG + (*_PREG)->u.yx.y; \
d1 = *pt1; \
(*_PREG) = NEXTOP((*_PREG), yx);
#define GLIST_VALY_GLIST_VALY_NONVAR_NONVAR \
BLOCK = (CELL)GLIST_VALY_GLIST_VALY_NONVAR_NONVAR; \
(*_SREG) = pt0 + 1; \
YAAM_UNIFYBOUND;
#define GLIST_VALY_GLIST_VALY_NONVAR_UNK \
Bind(pt1, d0); \
GONext();
#define GLIST_VALY_GLIST_VALY_UNK \
pt1 = YREG+(*_PREG)->u.yx.y; \
d1 = *pt1;
#define GLIST_VALY_GLIST_VALY_VAR_NONVAR \
(*_PREG) = NEXTOP((*_PREG), yx); \
Bind_Global(pt0, d1); \
GONext();
#define GLIST_VALY_GLIST_VALY_VAR_UNK \
(*_PREG) = NEXTOP((*_PREG), yx); \
UnifyGlobalCellToCell(pt0, pt1); \
GONext(); \
END_PREFETCH();
#define GLIST_VALY_GLIST_VALY_WRITE \
START_PREFETCH_W(yx); \
pt1 = HR; \
d0 = AbsPair(pt1); \
Bind(pt0, d0); \
d0 = YREG[(*_PREG)->u.yx.y]; \
pt1[0] = d0; \
HR = pt1 + 2; \
(*_SREG) = pt1 + 1; \
(*_PREG) = NEXTOP((*_PREG), yx); \
GONextW(); \
END_PREFETCH_W();
#define GL_VOID_VARX_INSTINIT \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0; \
register CELL *pt0, *pt1; \
d0 = XREG((*_PREG)->u.xx.xl);
#define GL_VOID_VARX_GLIST_VOID_VARX_READ \
BLOCK = (CELL)GL_VOID_VARX_GLIST_VOID_VARX_READ; \
FAILED = 0; \
if (!IsPairTerm(d0)) { \
YAAM_FAIL; \
} \
else { \
pt0 = RepPair(d0); \
d0 = pt0[1]; \
XREG((*_PREG)->u.xx.xr) = d0; \
(*_PREG) = NEXTOP((*_PREG), xx); \
ALWAYS_GONext(); \
}
#define GL_VOID_VARX_GLIST_VOID_VAR_WRITE \
pt1 = HR; \
XREG((*_PREG)->u.xx.xr) = \
Unsigned(pt1 + 1); \
RESET_VARIABLE(pt1); \
RESET_VARIABLE(pt1+1); \
HR = pt1 + 2; \
d0 = AbsPair(pt1); \
Bind(pt0, d0); \
(*_PREG) = NEXTOP((*_PREG), xx); \
GONext();
#define GL_VOID_VARY_INSTINIT \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0; \
register CELL *pt0, *pt1; \
d0 = XREG((*_PREG)->u.yx.x);
#define GL_VOID_VARY_GLIST_VOID_VARY_READ \
BLOCK = (CELL)GL_VOID_VARY_GLIST_VOID_VARY_READ; \
FAILED = 0; \
if (!IsPairTerm(d0)) { \
YAAM_FAIL; \
} \
else { \
pt0 = RepPair(d0); \
d0 = pt0[1]; \
INITIALIZE_PERMVAR(YREG+(*_PREG)->u.yx.y,d0); \
(*_PREG) = NEXTOP((*_PREG), yx); \
GONext(); \
}
#define GL_VOID_VARY_GLIST_VOID_VARY_WRITE \
pt1 = HR; \
INITIALIZE_PERMVAR(YREG+(*_PREG)->u.yx.y,Unsigned(pt1 + 1)); \
(*_PREG) = NEXTOP((*_PREG), yx); \
RESET_VARIABLE(pt1); \
RESET_VARIABLE(pt1+1); \
d0 = AbsPair(pt1); \
HR = pt1 + 2; \
Bind(pt0, d0); \
GONext();
#define GL_VOID_VALX_INSTINIT \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0, d1; \
register CELL *pt0, *pt1; \
d0 = XREG((*_PREG)->u.xx.xl);
#define GL_VOID_VALX_GLIST_VOID_VALX_READ \
BLOCK = (CELL)GL_VOID_VALX_GLIST_VOID_VALX_READ; \
FAILED = 0; \
if (!IsPairTerm(d0)) { \
YAAM_FAIL; \
} \
else { \
pt0 = RepPair(d0)+1; \
d0 = *pt0; \
}
#define GL_VOID_VALX_GLIST_VOID_VALX_NONVAR \
d1 = XREG((*_PREG)->u.xx.xr);
#define GL_VOID_VALX_GLIST_VOID_VALX_NONVAR_NONVAR \
BLOCK = (CELL)GL_VOID_VALX_GLIST_VOID_VALX_NONVAR_NONVAR; \
(*_PREG) = NEXTOP((*_PREG), xx); \
YAAM_UNIFYBOUND;
#define GL_VOID_VALX_GLIST_VOID_VALX_NONVAR_UNK \
(*_PREG) = NEXTOP((*_PREG), xx); \
Bind(pt1, d0); \
GONext();
#define GL_VOID_VALX_GLIST_VOID_VALX_UNK \
d1 = XREG((*_PREG)->u.xx.xr);
#define GL_VOID_VALX_GLIST_VOID_VALX_VAR_NONVAR \
(*_PREG) = NEXTOP((*_PREG), xx); \
Bind_Global(pt0, d1); \
GONext();
#define GL_VOID_VALX_GLIST_VOID_VALX_VAR_UNK \
(*_PREG) = NEXTOP((*_PREG), xx); \
UnifyGlobalCellToCell(pt0, pt1); \
GONext();
#define GL_VOID_VALX_GLIST_VOID_VALX_WRITE \
pt1 = HR; \
d0 = AbsPair(pt1); \
Bind(pt0, d0); \
pt1 = HR; \
d0 = XREG((*_PREG)->u.xx.xr); \
RESET_VARIABLE(pt1); \
pt1[1] = d0; \
HR = pt1 + 2; \
(*_PREG) = NEXTOP((*_PREG), xx); \
GONext();
#define GL_VOID_VALY_INSTINIT \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0, d1; \
register CELL *pt0, *pt1; \
d0 = XREG((*_PREG)->u.yx.x);
#define GL_VOID_VALY_GLIST_VOID_VALY_READ \
BLOCK = (CELL)GL_VOID_VALY_GLIST_VOID_VALY_READ; \
FAILED = 0; \
if (!IsPairTerm(d0)) { \
YAAM_FAIL; \
} \
else { \
pt0 = RepPair(d0)+1; \
d0 = *pt0; \
}
#define GL_VOID_VALY_GLIST_VOID_VALY_NONVAR \
pt1 = YREG+(*_PREG)->u.yx.y; \
d1 = *pt1;
#define GL_VOID_VALY_GLIST_VOID_VALY_NONVAR_NONVAR \
BLOCK = (CELL)GL_VOID_VALY_GLIST_VOID_VALY_NONVAR_NONVAR; \
(*_PREG) = NEXTOP((*_PREG), yx); \
YAAM_UNIFYBOUND;
#define GL_VOID_VALY_GLIST_VOID_VALY_NONVAR_UNK \
(*_PREG) = NEXTOP((*_PREG), yx); \
Bind(pt1, d0); \
GONext();
#define GL_VOID_VALY_GLIST_VOID_VALY_UNK \
pt1 = YREG+(*_PREG)->u.yx.y; \
d1 = *pt1;
#define GL_VOID_VALY_GLIST_VOID_VALY_VAR_NONVAR \
(*_PREG) = NEXTOP((*_PREG), yx); \
Bind_Global(pt0, d1); \
GONext();
#define GL_VOID_VALY_GLIST_VOID_VALY_VAR_UNK \
(*_PREG) = NEXTOP((*_PREG), yx); \
UnifyGlobalCellToCell(pt0, pt1); \
GONext();
#define GL_VOID_VALY_GLIST_VOID_VALY_WRITE \
CACHE_S(); \
S_SREG = HR; \
d0 = AbsPair(S_SREG); \
Bind(pt0, d0); \
S_SREG = HR; \
d1 = YREG[(*_PREG)->u.yx.y]; \
RESET_VARIABLE(S_SREG); \
S_SREG[1] = d1; \
(*_PREG) = NEXTOP((*_PREG), yx); \
HR = S_SREG + 2; \
ENDCACHE_S(); \
GONext();

861
JIT/HPP/yaam_get_d.h Normal file
View File

@ -0,0 +1,861 @@
#define GET_X_VAR_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
register CELL d0; \
d0 = XREG((*_PREG)->u.xx.xr); \
XREG((*_PREG)->u.xx.xl) = d0; \
(*_PREG) = NEXTOP((*_PREG), xx); \
GONext();
#define GET_Y_VAR_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
register CELL d0; \
register CELL *pt0; \
pt0 = YREG + (*_PREG)->u.yx.y; \
d0 = XREG((*_PREG)->u.yx.x); \
(*_PREG) = NEXTOP((*_PREG), yx); \
INITIALIZE_PERMVAR(pt0,d0); \
GONext();
#define GET_YY_VAR_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
register CELL d0, d1; \
register CELL *pt0, *pt1; \
CACHE_Y(YREG); \
pt0 = S_YREG + (*_PREG)->u.yyxx.y1; \
d0 = XREG((*_PREG)->u.yyxx.x1); \
pt1 = S_YREG + (*_PREG)->u.yyx.y2; \
d1 = XREG((*_PREG)->u.yyxx.x2); \
(*_PREG) = NEXTOP((*_PREG), yyxx); \
INITIALIZE_PERMVAR(pt0,d0); \
INITIALIZE_PERMVAR(pt1,d1); \
ENDCACHE_Y(); \
GONext();
#define GET_X_VAL_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0, d1; \
register CELL *pt0, *pt1; \
d0 = XREG((*_PREG)->u.xx.xl);
#define GET_X_VAL_GVALX_NONVAR \
d1 = XREG((*_PREG)->u.xx.xr);
#define GET_X_VAL_GVALX_NONVAR_NONVAR \
BLOCK = (CELL)GET_X_VAL_GVALX_NONVAR_NONVAR; \
(*_PREG) = NEXTOP((*_PREG), xx); \
YAAM_UNIFYBOUND;
#define GET_X_VAL_GVALX_NONVAR_UNK \
(*_PREG) = NEXTOP((*_PREG), xx); \
Bind(pt0, d0); \
GONext();
#define GET_X_VAL_GVALX_UNK \
d1 = XREG((*_PREG)->u.xx.xr);
#define GET_X_VAL_GVALX_VAR_NONVAR \
(*_PREG) = NEXTOP((*_PREG), xx); \
Bind(pt0, d1); \
GONext();
#define GET_X_VAL_GVALX_VAR_UNK \
(*_PREG) = NEXTOP((*_PREG), xx); \
UnifyCells(pt0, pt1); \
GONext();
#define GET_Y_VAL_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
register CELL d0, d1; \
register CELL *pt0, *pt1; \
pt0 = YREG + (*_PREG)->u.yx.y; \
d0 = *pt0;
#define GET_Y_VAL_GVALY_NONVAR \
d1 = XREG((*_PREG)->u.yx.x);
#define GET_Y_VAL_GVALY_NONVAR_NONVAR \
BLOCK = (CELL)GET_Y_VAL_GVALY_NONVAR_NONVAR; \
(*_PREG) = NEXTOP((*_PREG), yx); \
YAAM_UNIFYBOUND;
#define GET_Y_VAL_GVALY_NONVAR_UNK \
(*_PREG) = NEXTOP((*_PREG), yx); \
Bind(pt1, d0); \
GONext();
#define GET_Y_VAL_GVALY_UNK \
d1 = XREG((*_PREG)->u.yx.x);
#define GET_Y_VAL_GVALY_VAR_NONVAR \
(*_PREG) = NEXTOP((*_PREG), yx); \
Bind(pt0, d1); \
GONext();
#define GET_Y_VAL_GVALY_VAR_UNK \
(*_PREG) = NEXTOP((*_PREG), yx); \
UnifyCells(pt0, pt1); \
GONext();
#define GET_ATOM_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0, d1; \
register CELL *pt0; \
d0 = XREG((*_PREG)->u.xc.x); \
d1 = (*_PREG)->u.xc.c;
#define GET_ATOM_GATOM_NONVAR \
BLOCK = (CELL)GET_ATOM_GATOM_NONVAR; \
FAILED = 0; \
if (d0 == d1) { \
(*_PREG) = NEXTOP((*_PREG), xc); \
GONext(); \
} \
else { \
YAAM_FAIL; \
}
#define GET_ATOM_GATOM_UNK \
(*_PREG) = NEXTOP((*_PREG), xc); \
Bind(pt0, d1); \
GONext();
#define GET_2ATOMS_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
register CELL d0, d1; \
register CELL *pt0; \
d0 = ARG1;
#define GET_2ATOMS_GATOM_2UNK \
Bind(pt0, (*_PREG)->u.cc.c1);
#define GET_2ATOMS_GATOM_2B \
d0 = ARG2; \
d1 = (*_PREG)->u.cc.c2;
#define GET_2ATOMS_GATOM_2BNONVAR \
BLOCK = (CELL)GET_2ATOMS_GATOM_2BNONVAR; \
FAILED = 0; \
if (d0 == d1) { \
(*_PREG) = NEXTOP((*_PREG), cc); \
GONext(); \
} \
else { \
YAAM_FAIL; \
}
#define GET_2ATOMS_GATOM_2BUNK \
(*_PREG) = NEXTOP((*_PREG), cc); \
Bind(pt0, d1); \
GONext();
#define GET_3ATOMS_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
register CELL d0, d1; \
register CELL *pt0; \
d0 = ARG1;
#define GET_3ATOMS_GATOM_3UNK \
Bind(pt0, (*_PREG)->u.ccc.c1);
#define GET_3ATOMS_GATOM_3B \
d0 = ARG2;
#define GET_3ATOMS_GATOM_3BUNK \
Bind(pt0, (*_PREG)->u.ccc.c2);
#define GET_3ATOMS_GATOM_3C \
d0 = ARG3; \
d1 = (*_PREG)->u.ccc.c3;
#define GET_3ATOMS_GATOM_3CNONVAR \
BLOCK = (CELL)GET_3ATOMS_GATOM_3CNONVAR; \
FAILED = 0; \
if (d0 == d1) { \
(*_PREG) = NEXTOP((*_PREG), ccc); \
GONext(); \
} \
else { \
YAAM_FAIL; \
}
#define GET_3ATOMS_GATOM_3CUNK \
(*_PREG) = NEXTOP((*_PREG), ccc); \
Bind(pt0, d1); \
GONext();
#define GET_4ATOMS_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
register CELL d0, d1; \
register CELL *pt0; \
d0 = ARG1;
#define GET_4ATOMS_GATOM_4UNK \
Bind(pt0, (*_PREG)->u.cccc.c1);
#define GET_4ATOMS_GATOM_4B \
d0 = ARG2;
#define GET_4ATOMS_GATOM_4BUNK \
Bind(pt0, (*_PREG)->u.cccc.c2);
#define GET_4ATOMS_GATOM_4C \
d0 = ARG3;
#define GET_4ATOMS_GATOM_4CUNK \
Bind(pt0, (*_PREG)->u.cccc.c3);
#define GET_4ATOMS_GATOM_4D \
d0 = ARG4; \
d1 = (*_PREG)->u.cccc.c4;
#define GET_4ATOMS_GATOM_4DNONVAR \
BLOCK = (CELL)GET_4ATOMS_GATOM_4DNONVAR; \
FAILED = 0; \
if (d0 == d1) { \
(*_PREG) = NEXTOP((*_PREG), cccc); \
GONext(); \
} \
else { \
YAAM_FAIL; \
}
#define GET_4ATOMS_GATOM_4DUNK \
(*_PREG) = NEXTOP((*_PREG), cccc); \
Bind(pt0, d1); \
GONext();
#define GET_5ATOMS_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
register CELL d0, d1; \
register CELL *pt0; \
d0 = ARG1;
#define GET_5ATOMS_GATOM_5UNK \
Bind(pt0, (*_PREG)->u.ccccc.c1);
#define GET_5ATOMS_GATOM_5B \
d0 = ARG2;
#define GET_5ATOMS_GATOM_5BUNK \
Bind(pt0, (*_PREG)->u.ccccc.c2);
#define GET_5ATOMS_GATOM_5C \
d0 = ARG3;
#define GET_5ATOMS_GATOM_5CUNK \
Bind(pt0, (*_PREG)->u.ccccc.c3);
#define GET_5ATOMS_GATOM_5D \
d0 = ARG4;
#define GET_5ATOMS_GATOM_5DUNK \
Bind(pt0, (*_PREG)->u.ccccc.c4);
#define GET_5ATOMS_GATOM_5E \
d0 = ARG5; \
d1 = (*_PREG)->u.ccccc.c5;
#define GET_5ATOMS_GATOM_5ENONVAR \
BLOCK = (CELL)GET_5ATOMS_GATOM_5ENONVAR; \
FAILED = 0; \
if (d0 == d1) { \
(*_PREG) = NEXTOP((*_PREG), ccccc); \
GONext(); \
} \
else { \
YAAM_FAIL; \
}
#define GET_5ATOMS_GATOM_5EUNK \
(*_PREG) = NEXTOP((*_PREG), ccccc); \
Bind(pt0, d1); \
GONext();
#define GET_6ATOMS_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
register CELL d0, d1; \
register CELL *pt0; \
d0 = ARG1;
#define GET_6ATOMS_GATOM_6UNK \
Bind(pt0, (*_PREG)->u.cccccc.c1);
#define GET_6ATOMS_GATOM_6B \
d0 = ARG2;
#define GET_6ATOMS_GATOM_6BUNK \
Bind(pt0, (*_PREG)->u.cccccc.c2);
#define GET_6ATOMS_GATOM_6C \
d0 = ARG3;
#define GET_6ATOMS_GATOM_6CUNK \
Bind(pt0, (*_PREG)->u.cccccc.c3);
#define GET_6ATOMS_GATOM_6D \
d0 = ARG4;
#define GET_6ATOMS_GATOM_6DUNK \
Bind(pt0, (*_PREG)->u.cccccc.c4);
#define GET_6ATOMS_GATOM_6E \
d0 = ARG5;
#define GET_6ATOMS_GATOM_6EUNK \
Bind(pt0, (*_PREG)->u.cccccc.c5);
#define GET_6ATOMS_GATOM_6F \
d0 = ARG6; \
d1 = (*_PREG)->u.cccccc.c6;
#define GET_6ATOMS_GATOM_6FNONVAR \
BLOCK = (CELL)GET_6ATOMS_GATOM_6FNONVAR; \
FAILED = 0; \
if (d0 == d1) { \
(*_PREG) = NEXTOP((*_PREG), cccccc); \
GONext(); \
} \
else { \
YAAM_FAIL; \
}
#define GET_6ATOMS_GATOM_6FUNK \
(*_PREG) = NEXTOP((*_PREG), cccccc); \
Bind(pt0, d1); \
GONext();
#define GET_LIST_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0; \
register CELL *pt0; \
d0 = XREG((*_PREG)->u.x.x);
#define GET_LIST_GLIST_NONVAR \
BLOCK = (CELL)GET_LIST_GLIST_NONVAR; \
FAILED = 0; \
if (!IsPairTerm(d0)) { \
YAAM_FAIL; \
} \
else { \
(*_PREG) = NEXTOP((*_PREG), x); \
(*_SREG) = RepPair(d0); \
GONext(); \
}
#define GET_LIST_GLIST_UNK \
CACHE_S(); \
S_SREG = HR; \
START_PREFETCH_W(x); \
(*_PREG) = NEXTOP((*_PREG), x); \
d0 = AbsPair(S_SREG); \
Bind(pt0, d0); \
S_SREG = HR; \
HR = S_SREG + 2; \
WRITEBACK_S(S_SREG); \
GONextW(); \
END_PREFETCH_W(); \
ENDCACHE_S();
#define GET_STRUCT_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0, d1; \
register CELL *pt0; \
d0 = XREG((*_PREG)->u.xfa.x);
#define GET_STRUCT_GSTRUCT_NONVAR \
BLOCK = (CELL)GET_STRUCT_GSTRUCT_NONVAR; \
FAILED = 0; \
if (!IsApplTerm(d0)) { \
YAAM_FAIL; \
} \
else { \
register CELL * S_SREG; \
S_SREG = RepAppl(d0); \
d0 = (CELL) ((*_PREG)->u.xfa.f); \
if (*S_SREG != d0) { \
YAAM_FAIL; \
} \
else { \
WRITEBACK_S(S_SREG+1); \
(*_PREG) = NEXTOP((*_PREG), xfa); \
GONext(); \
} \
}
#define GET_STRUCT_GSTRUCT_UNK \
START_PREFETCH_W(xfa); \
d1 = AbsAppl(HR); \
Bind(pt0, d1); \
pt0 = HR; \
d0 = (CELL) ((*_PREG)->u.xfa.f); \
*pt0++ = d0; \
HR = pt0 + (*_PREG)->u.xfa.a; \
(*_PREG) = NEXTOP((*_PREG), xfa); \
(*_SREG) = pt0; \
GONextW(); \
END_PREFETCH_W();
#define GET_FLOAT_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0, d1; \
register CELL *pt0, *pt1; \
d0 = XREG((*_PREG)->u.xd.x);
#if SIZEOF_DOUBLE == 2*SIZEOF_INT_P
#define GET_FLOAT_GFLOAT_NONVAR \
BLOCK = (CELL)GET_FLOAT_GFLOAT_NONVAR; \
FAILED = 0; \
if (!IsApplTerm(d0)) { \
YAAM_FAIL; \
} \
else { \
pt0 = RepAppl(d0); \
if (*pt0 != (CELL)FunctorDouble) { \
YAAM_FAIL; \
} \
else { \
pt1 = (*_PREG)->u.xd.d; \
(*_PREG) = NEXTOP((*_PREG), xd); \
if ( \
pt1[1] != pt0[1] \
|| pt1[2] != pt0[2] \
) { \
YAAM_FAIL; \
} \
else { \
GONext(); \
} \
} \
}
#else /* SIZEOF_DOUBLE == 2*SIZEOF_INT_P */
#define GET_FLOAT_GFLOAT_NONVAR \
BLOCK = (CELL)GET_FLOAT_GFLOAT_NONVAR; \
FAILED = 0; \
if (!IsApplTerm(d0)) { \
YAAM_FAIL; \
} \
else { \
pt0 = RepAppl(d0); \
if (*pt0 != (CELL)FunctorDouble) { \
YAAM_FAIL; \
} \
else { \
pt1 = (*_PREG)->u.xd.d; \
(*_PREG) = NEXTOP((*_PREG), xd); \
if ( \
pt1[1] != pt0[1] \
) { \
YAAM_FAIL; \
} \
else { \
GONext(); \
} \
} \
}
#endif /* SIZEOF_DOUBLE == 2*SIZEOF_INT_P */
#define GET_FLOAT_GFLOAT_UNK \
START_PREFETCH(xc); \
d1 = AbsAppl((*_PREG)->u.xd.d); \
(*_PREG) = NEXTOP((*_PREG), xd); \
Bind(pt0, d1); \
GONext(); \
END_PREFETCH();
#define GET_LONGINT_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
register CELL d0, d1; \
register CELL *pt0; \
d0 = XREG((*_PREG)->u.xi.x);
#define GET_LONGINT_GLONGINT_NONVAR \
BLOCK = (CELL)GET_LONGINT_GLONGINT_NONVAR; \
FAILED = 0; \
if (!IsApplTerm(d0)) { \
YAAM_FAIL; \
} \
else { \
pt0 = RepAppl(d0); \
if (*pt0 != (CELL)FunctorLongInt) { \
YAAM_FAIL; \
} \
if ((*_PREG)->u.xi.i[1] != (CELL)pt0[1]) { \
YAAM_FAIL; \
} \
} \
if (!FAILED) { \
(*_PREG) = NEXTOP((*_PREG), xi); \
GONext(); \
}
#define GET_LONGINT_GLONGINT_UNK \
START_PREFETCH(xi); \
d1 = AbsAppl((*_PREG)->u.xi.i); \
(*_PREG) = NEXTOP((*_PREG), xi); \
Bind(pt0, d1); \
GONext(); \
END_PREFETCH();
#ifdef USE_GMP
#define GET_BIGINT_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
register CELL d0, d1; \
register CELL *pt0; \
d0 = XREG((*_PREG)->u.xN.x);
#define GET_BIGINT_GBIGINT_NONVAR \
BLOCK = (CELL)GET_BIGINT_GBIGINT_NONVAR; \
FAILED = 0; \
if (!IsApplTerm(d0)) { \
YAAM_FAIL; \
} \
else { \
pt0 = RepAppl(d0); \
if (*pt0 != (CELL)FunctorBigInt) { \
YAAM_FAIL; \
} \
if (Yap_gmp_tcmp_big_big(d0,(*_PREG)->u.xN.b)) { \
YAAM_FAIL; \
} \
} \
if (!FAILED) { \
(*_PREG) = NEXTOP((*_PREG), xN); \
GONext(); \
}
#define GET_BIGINT_GBIGINT_UNK \
START_PREFETCH(xN); \
d1 = (*_PREG)->u.xN.b; \
(*_PREG) = NEXTOP((*_PREG), xN); \
Bind(pt0, d1); \
GONext(); \
END_PREFETCH();
#endif
#define GET_DBTERM_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
register CELL d0, d1; \
register CELL *pt0; \
d0 = XREG((*_PREG)->u.xD.x);
#define GET_DBTERM_GDBTERM_NONVAR \
BLOCK = (CELL)GET_DBTERM_GDBTERM_NONVAR; \
d1 = (*_PREG)->u.xD.D; \
(*_PREG) = NEXTOP((*_PREG), xD); \
YAAM_UNIFYBOUND;
#define GET_DBTERM_GDBTERM_UNK \
START_PREFETCH(xD); \
d1 = (*_PREG)->u.xD.D; \
(*_PREG) = NEXTOP((*_PREG), xD); \
Bind(pt0, d1); \
GONext(); \
END_PREFETCH();
#define GLIST_VALX_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0, d1; \
register CELL *pt0, *pt1; \
d0 = XREG((*_PREG)->u.xx.xl); \
if (!IsVarTerm(d0)) { \
printf("Oops!\n"); \
exit(1); \
}
#define GLIST_VALX_GLIST_VALX_READ \
BLOCK = (CELL)GLIST_VALX_GLIST_VALX_READ; \
FAILED = 0; \
if (!IsPairTerm(d0)) { \
YAAM_FAIL; \
} \
else { \
pt0 = RepPair(d0); \
(*_SREG) = pt0 + 1; \
d0 = *pt0; \
}
#define GLIST_VALX_GLIST_VALX_NONVAR \
d1 = XREG((*_PREG)->u.xx.xr);
#define GLIST_VALX_GLIST_VALX_NONVAR_NONVAR \
BLOCK = (CELL)GLIST_VALX_GLIST_VALX_NONVAR_NONVAR; \
(*_PREG) = NEXTOP((*_PREG), xx); \
YAAM_UNIFYBOUND;
#define GLIST_VALX_GLIST_VALX_NONVAR_UNK \
(*_PREG) = NEXTOP((*_PREG), xx); \
Bind(pt1, d0); \
GONext();
#define GLIST_VALX_GLIST_VALX_UNK \
d0 = XREG((*_PREG)->u.xx.xr);
#define GLIST_VALX_GLIST_VALX_VAR_NONVAR \
(*_PREG) = NEXTOP((*_PREG), xx); \
Bind_Global(pt0, d0); \
GONext();
#define GLIST_VALX_GLIST_VALX_VAR_UNK \
(*_PREG) = NEXTOP((*_PREG), xx); \
UnifyGlobalCellToCell(pt0, pt1); \
GONext(); \
#define GLIST_VALX_GLIST_VALX_WRITE \
CACHE_S(); \
S_SREG = HR; \
d1 = XREG((*_PREG)->u.xx.xr); \
d0 = AbsPair(S_SREG); \
S_SREG[0] = d1; \
ALWAYS_START_PREFETCH_W(xx); \
(*_PREG) = NEXTOP((*_PREG), xx); \
HR = S_SREG + 2; \
WRITEBACK_S(S_SREG+1); \
Bind(pt0, d0); \
ALWAYS_GONextW(); \
ALWAYS_END_PREFETCH_W(); \
ENDCACHE_S();
#define GLIST_VALY_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
register CELL d0, d1; \
register CELL *pt0, *pt1; \
d0 = XREG((*_PREG)->u.yx.x);
#define GLIST_VALY_GLIST_VALY_READ \
if (!IsPairTerm(d0)) { \
YAAM_FAIL; \
} \
START_PREFETCH(yx); \
pt0 = RepPair(d0); \
(*_SREG) = pt0 + 1; \
d0 = *pt0;
#define GLIST_VALY_GLIST_VALY_NONVAR \
pt1 = YREG + (*_PREG)->u.yx.y; \
d1 = *pt1; \
(*_PREG) = NEXTOP((*_PREG), yx);
#define GLIST_VALY_GLIST_VALY_NONVAR_NONVAR \
BLOCK = (CELL)GLIST_VALY_GLIST_VALY_NONVAR_NONVAR; \
(*_SREG) = pt0 + 1; \
YAAM_UNIFYBOUND;
#define GLIST_VALY_GLIST_VALY_NONVAR_UNK \
Bind(pt1, d0); \
GONext();
#define GLIST_VALY_GLIST_VALY_UNK \
pt1 = YREG+(*_PREG)->u.yx.y; \
d1 = *pt1;
#define GLIST_VALY_GLIST_VALY_VAR_NONVAR \
(*_PREG) = NEXTOP((*_PREG), yx); \
Bind_Global(pt0, d1); \
GONext();
#define GLIST_VALY_GLIST_VALY_VAR_UNK \
(*_PREG) = NEXTOP((*_PREG), yx); \
UnifyGlobalCellToCell(pt0, pt1); \
GONext(); \
END_PREFETCH();
#define GLIST_VALY_GLIST_VALY_WRITE \
START_PREFETCH_W(yx); \
pt1 = HR; \
d0 = AbsPair(pt1); \
Bind(pt0, d0); \
d0 = YREG[(*_PREG)->u.yx.y]; \
pt1[0] = d0; \
HR = pt1 + 2; \
(*_SREG) = pt1 + 1; \
(*_PREG) = NEXTOP((*_PREG), yx); \
GONextW(); \
END_PREFETCH_W();
#define GL_VOID_VARX_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0; \
register CELL *pt0, *pt1; \
d0 = XREG((*_PREG)->u.xx.xl);
#define GL_VOID_VARX_GLIST_VOID_VARX_READ \
BLOCK = (CELL)GL_VOID_VARX_GLIST_VOID_VARX_READ; \
FAILED = 0; \
if (!IsPairTerm(d0)) { \
YAAM_FAIL; \
} \
else { \
pt0 = RepPair(d0); \
d0 = pt0[1]; \
XREG((*_PREG)->u.xx.xr) = d0; \
(*_PREG) = NEXTOP((*_PREG), xx); \
ALWAYS_GONext(); \
}
#define GL_VOID_VARX_GLIST_VOID_VAR_WRITE \
pt1 = HR; \
XREG((*_PREG)->u.xx.xr) = \
Unsigned(pt1 + 1); \
RESET_VARIABLE(pt1); \
RESET_VARIABLE(pt1+1); \
HR = pt1 + 2; \
d0 = AbsPair(pt1); \
Bind(pt0, d0); \
(*_PREG) = NEXTOP((*_PREG), xx); \
GONext();
#define GL_VOID_VARY_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0; \
register CELL *pt0, *pt1; \
d0 = XREG((*_PREG)->u.yx.x);
#define GL_VOID_VARY_GLIST_VOID_VARY_READ \
BLOCK = (CELL)GL_VOID_VARY_GLIST_VOID_VARY_READ; \
FAILED = 0; \
if (!IsPairTerm(d0)) { \
YAAM_FAIL; \
} \
else { \
pt0 = RepPair(d0); \
d0 = pt0[1]; \
INITIALIZE_PERMVAR(YREG+(*_PREG)->u.yx.y,d0); \
(*_PREG) = NEXTOP((*_PREG), yx); \
GONext(); \
}
#define GL_VOID_VARY_GLIST_VOID_VARY_WRITE \
pt1 = HR; \
INITIALIZE_PERMVAR(YREG+(*_PREG)->u.yx.y,Unsigned(pt1 + 1)); \
(*_PREG) = NEXTOP((*_PREG), yx); \
RESET_VARIABLE(pt1); \
RESET_VARIABLE(pt1+1); \
d0 = AbsPair(pt1); \
HR = pt1 + 2; \
Bind(pt0, d0); \
GONext();
#define GL_VOID_VALX_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0, d1; \
register CELL *pt0, *pt1; \
d0 = XREG((*_PREG)->u.xx.xl);
#define GL_VOID_VALX_GLIST_VOID_VALX_READ \
BLOCK = (CELL)GL_VOID_VALX_GLIST_VOID_VALX_READ; \
FAILED = 0; \
if (!IsPairTerm(d0)) { \
YAAM_FAIL; \
} \
else { \
pt0 = RepPair(d0)+1; \
d0 = *pt0; \
}
#define GL_VOID_VALX_GLIST_VOID_VALX_NONVAR \
d1 = XREG((*_PREG)->u.xx.xr);
#define GL_VOID_VALX_GLIST_VOID_VALX_NONVAR_NONVAR \
BLOCK = (CELL)GL_VOID_VALX_GLIST_VOID_VALX_NONVAR_NONVAR; \
(*_PREG) = NEXTOP((*_PREG), xx); \
YAAM_UNIFYBOUND;
#define GL_VOID_VALX_GLIST_VOID_VALX_NONVAR_UNK \
(*_PREG) = NEXTOP((*_PREG), xx); \
Bind(pt1, d0); \
GONext();
#define GL_VOID_VALX_GLIST_VOID_VALX_UNK \
d1 = XREG((*_PREG)->u.xx.xr);
#define GL_VOID_VALX_GLIST_VOID_VALX_VAR_NONVAR \
(*_PREG) = NEXTOP((*_PREG), xx); \
Bind_Global(pt0, d1); \
GONext();
#define GL_VOID_VALX_GLIST_VOID_VALX_VAR_UNK \
(*_PREG) = NEXTOP((*_PREG), xx); \
UnifyGlobalCellToCell(pt0, pt1); \
GONext();
#define GL_VOID_VALX_GLIST_VOID_VALX_WRITE \
pt1 = HR; \
d0 = AbsPair(pt1); \
Bind(pt0, d0); \
pt1 = HR; \
d0 = XREG((*_PREG)->u.xx.xr); \
RESET_VARIABLE(pt1); \
pt1[1] = d0; \
HR = pt1 + 2; \
(*_PREG) = NEXTOP((*_PREG), xx); \
GONext();
#define GL_VOID_VALY_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0, d1; \
register CELL *pt0, *pt1; \
d0 = XREG((*_PREG)->u.yx.x);
#define GL_VOID_VALY_GLIST_VOID_VALY_READ \
BLOCK = (CELL)GL_VOID_VALY_GLIST_VOID_VALY_READ; \
FAILED = 0; \
if (!IsPairTerm(d0)) { \
YAAM_FAIL; \
} \
else { \
pt0 = RepPair(d0)+1; \
d0 = *pt0; \
}
#define GL_VOID_VALY_GLIST_VOID_VALY_NONVAR \
pt1 = YREG+(*_PREG)->u.yx.y; \
d1 = *pt1;
#define GL_VOID_VALY_GLIST_VOID_VALY_NONVAR_NONVAR \
BLOCK = (CELL)GL_VOID_VALY_GLIST_VOID_VALY_NONVAR_NONVAR; \
(*_PREG) = NEXTOP((*_PREG), yx); \
YAAM_UNIFYBOUND;
#define GL_VOID_VALY_GLIST_VOID_VALY_NONVAR_UNK \
(*_PREG) = NEXTOP((*_PREG), yx); \
Bind(pt1, d0); \
GONext();
#define GL_VOID_VALY_GLIST_VOID_VALY_UNK \
pt1 = YREG+(*_PREG)->u.yx.y; \
d1 = *pt1;
#define GL_VOID_VALY_GLIST_VOID_VALY_VAR_NONVAR \
(*_PREG) = NEXTOP((*_PREG), yx); \
Bind_Global(pt0, d1); \
GONext();
#define GL_VOID_VALY_GLIST_VOID_VALY_VAR_UNK \
(*_PREG) = NEXTOP((*_PREG), yx); \
UnifyGlobalCellToCell(pt0, pt1); \
GONext();
#define GL_VOID_VALY_GLIST_VOID_VALY_WRITE \
CACHE_S(); \
S_SREG = HR; \
d0 = AbsPair(S_SREG); \
Bind(pt0, d0); \
S_SREG = HR; \
d1 = YREG[(*_PREG)->u.yx.y]; \
RESET_VARIABLE(S_SREG); \
S_SREG[1] = d1; \
(*_PREG) = NEXTOP((*_PREG), yx); \
HR = S_SREG + 2; \
ENDCACHE_S(); \
GONext();

1309
JIT/HPP/yaam_macros.hh Normal file

File diff suppressed because it is too large Load Diff

1262
JIT/HPP/yaam_misc.h Normal file

File diff suppressed because it is too large Load Diff

1301
JIT/HPP/yaam_misc_d.h Normal file

File diff suppressed because it is too large Load Diff

39
JIT/HPP/yaam_pop.h Normal file
View File

@ -0,0 +1,39 @@
#define POP_N_INSTINIT \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0; \
d0 = (*_PREG)->u.os.s; \
SP = (CELL *) (((char *) SP) + d0); \
d0 = SP[0]; \
if (d0) { \
(*_SREG) = (CELL *) (SP[1]); \
SP += 2; \
(*_PREG) = NEXTOP((*_PREG), s); \
GONext(); \
} \
else { \
(*_SREG) = (CELL *) (SP[1]); \
SP += 2; \
(*_PREG) = NEXTOP((*_PREG), s); \
GONextW(); \
}
#define POP_N_END \
BLOCK = (CELL)POP_N_END;
#define POP_INSTINIT \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0; \
d0 = SP[0]; \
(*_SREG) = (CELL *) (SP[1]); \
SP += 2; \
if (d0) { \
(*_PREG) = NEXTOP((*_PREG), e); \
GONext(); \
} \
else { \
(*_PREG) = NEXTOP((*_PREG), e); \
GONextW(); \
}
#define POP_END \
BLOCK = (CELL)POP_END;

41
JIT/HPP/yaam_pop_d.h Normal file
View File

@ -0,0 +1,41 @@
#define POP_N_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0; \
d0 = (*_PREG)->u.os.s; \
SP = (CELL *) (((char *) SP) + d0); \
d0 = SP[0]; \
if (d0) { \
(*_SREG) = (CELL *) (SP[1]); \
SP += 2; \
(*_PREG) = NEXTOP((*_PREG), s); \
GONext(); \
} \
else { \
(*_SREG) = (CELL *) (SP[1]); \
SP += 2; \
(*_PREG) = NEXTOP((*_PREG), s); \
GONextW(); \
}
#define POP_N_END \
BLOCK = (CELL)POP_N_END;
#define POP_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
BLOCKADDRESS = (CELL)(*_PREG); \
register CELL d0; \
d0 = SP[0]; \
(*_SREG) = (CELL *) (SP[1]); \
SP += 2; \
if (d0) { \
(*_PREG) = NEXTOP((*_PREG), e); \
GONext(); \
} \
else { \
(*_PREG) = NEXTOP((*_PREG), e); \
GONextW(); \
}
#define POP_END \
BLOCK = (CELL)POP_END;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

182
JIT/HPP/yaam_put.h Normal file
View File

@ -0,0 +1,182 @@
#define PUT_X_VAR_INSTINIT \
register CELL *pt0; \
pt0 = HR; \
XREG((*_PREG)->u.xx.xl) = Unsigned(pt0); \
HR = pt0 + 1; \
XREG((*_PREG)->u.xx.xr) = Unsigned(pt0); \
(*_PREG) = NEXTOP((*_PREG), xx); \
RESET_VARIABLE(pt0); \
GONext();
#if defined(YAPOR_SBA) && defined(FROZEN_STACKS)
#define PUT_Y_VAR_INSTINIT \
register CELL *pt0; \
pt0 = YREG + (*_PREG)->u.yx.y; \
XREG((*_PREG)->u.yx.x) = (CELL) pt0; \
(*_PREG) = NEXTOP((*_PREG), yx); \
if (Unsigned((Int)(pt0)-(Int)(H_FZ)) > \
Unsigned((Int)(B_FZ)-(Int)(H_FZ))) { \
*pt0 = (CELL)STACK_TO_SBA(pt0); \
} else \
INITIALIZE_PERMVAR(pt0, (CELL)pt0); \
GONext();
#else /* defined(YAPOR_SBA) && defined(FROZEN_STACKS) */
#define PUT_Y_VAR_INSTINIT \
register CELL *pt0; \
pt0 = YREG + (*_PREG)->u.yx.y; \
XREG((*_PREG)->u.yx.x) = (CELL) pt0; \
(*_PREG) = NEXTOP((*_PREG), yx); \
INITIALIZE_PERMVAR(pt0, (CELL)pt0); \
GONext();
#endif /* defined(YAPOR_SBA) && defined(FROZEN_STACKS) */
#define PUT_X_VAL_INSTINIT \
register CELL d0; \
d0 = XREG((*_PREG)->u.xx.xl); \
XREG((*_PREG)->u.xx.xr) = d0; \
(*_PREG) = NEXTOP((*_PREG), xx); \
GONext();
#define PUT_XX_VAL_INSTINIT \
register CELL d0, d1; \
d0 = XREG((*_PREG)->u.xxxx.xl1); \
d1 = XREG((*_PREG)->u.xxxx.xl2); \
XREG((*_PREG)->u.xxxx.xr1) = d0; \
XREG((*_PREG)->u.xxxx.xr2) = d1; \
(*_PREG) = NEXTOP((*_PREG), xxxx); \
GONext();
#ifdef YAPOR_SBA
#define PUT_Y_VAL_INSTINIT \
register CELL d0; \
d0 = YREG[(*_PREG)->u.yx.y]; \
if (d0 == 0) { \
XREG((*_PREG)->u.yx.x) = (CELL)(YREG+(*_PREG)->u.yx.y); \
} else \
XREG((*_PREG)->u.yx.x) = d0; \
(*_PREG) = NEXTOP((*_PREG), yx); \
GONext();
#else /* YAPOR_SBA */
#define PUT_Y_VAL_INSTINIT \
register CELL d0; \
d0 = YREG[(*_PREG)->u.yx.y]; \
XREG((*_PREG)->u.yx.x) = d0; \
(*_PREG) = NEXTOP((*_PREG), yx); \
GONext();
#endif /* YAPOR_SBA */
#ifdef YAPOR_SBA
#define PUT_Y_VALS_INSTINIT \
register CELL d0, d1; \
ALWAYS_START_PREFETCH(yyxx); \
d0 = YREG[(*_PREG)->u.yyxx.y1]; \
if (d0 == 0) \
XREG((*_PREG)->u.yyxx.x1) = (CELL)(YREG+(*_PREG)->u.yyxx.y1); \
else \
XREG((*_PREG)->u.yyxx.x1) = d0; \
(*_PREG) = NEXTOP((*_PREG), yyxx); \
d1 = YREG[PREVOP((*_PREG),yyxx)->u.yyxx.y2]; \
if (d1 == 0) \
XREG(PREVOP((*_PREG)->u.yyxx,yyxx).x2) = (CELL)(YREG+(*_PREG)->u.yyxx.y2); \
else \
XREG(PREVOP((*_PREG),yyxx)->u.yyxx.x2) = d1; \
ALWAYS_GONext(); \
ALWAYS_END_PREFETCH();
#else /* YAPOR_SBA */
#define PUT_Y_VALS_INSTINIT \
register CELL d0, d1; \
ALWAYS_START_PREFETCH(yyxx); \
d0 = YREG[(*_PREG)->u.yyxx.y1]; \
XREG((*_PREG)->u.yyxx.x1) = d0; \
(*_PREG) = NEXTOP((*_PREG), yyxx); \
d1 = YREG[PREVOP((*_PREG),yyxx)->u.yyxx.y2]; \
XREG(PREVOP((*_PREG),yyxx)->u.yyxx.x2) = d1; \
ALWAYS_GONext(); \
ALWAYS_END_PREFETCH();
#endif /* YAPOR_SBA */
#define PUT_UNSAFE_INSTINIT \
register CELL d0; \
register CELL *pt0; \
pt0 = YREG+(*_PREG)->u.yx.y; \
d0 = *pt0;
#define PUT_UNSAFE_PUNSAFE_NONVAR \
XREG((*_PREG)->u.yx.x) = d0; \
(*_PREG) = NEXTOP((*_PREG), yx); \
GONext();
#define PUT_UNSAFE_PUNSAFE_UNK \
if (pt0 <= HR || pt0 >= YREG) { \
XREG((*_PREG)->u.yx.x) = Unsigned(pt0); \
(*_PREG) = NEXTOP((*_PREG), yx); \
GONext(); \
} \
else { \
Bind_Local(pt0, Unsigned(HR)); \
XREG((*_PREG)->u.yx.x) = (CELL) HR; \
RESET_VARIABLE(HR); \
H++; \
(*_PREG) = NEXTOP((*_PREG), yx); \
GONext(); \
}
#define PUT_ATOM_INSTINIT \
register CELL d0; \
d0 = (*_PREG)->u.xc.c; \
XREG((*_PREG)->u.xc.x) = d0; \
(*_PREG) = NEXTOP((*_PREG), xc); \
GONext();
#define PUT_DBTERM_INSTINIT \
register CELL d0; \
d0 = (*_PREG)->u.xD.D; \
XREG((*_PREG)->u.xD.x) = d0; \
(*_PREG) = NEXTOP((*_PREG), xD); \
GONext();
#define PUT_BIGINT_INSTINIT \
register CELL d0; \
d0 = (*_PREG)->u.xN.b; \
XREG((*_PREG)->u.xN.x) = d0; \
(*_PREG) = NEXTOP((*_PREG), xN); \
GONext();
#define PUT_FLOAT_INSTINIT \
register CELL d0; \
d0 = AbsAppl((*_PREG)->u.xd.d); \
XREG((*_PREG)->u.xd.x) = d0; \
(*_PREG) = NEXTOP((*_PREG), xd); \
GONext();
#define PUT_LONGINT_INSTINIT \
register CELL d0; \
d0 = AbsAppl((*_PREG)->u.xi.i); \
XREG((*_PREG)->u.xi.x) = d0; \
(*_PREG) = NEXTOP((*_PREG), xi); \
GONext();
#define PUT_LIST_INSTINIT \
register CELL d0; \
CACHE_S(); \
READ_IN_S(); \
S_SREG = HR; \
HR += 2; \
d0 = AbsPair(S_SREG); \
XREG((*_PREG)->u.x.x) = d0; \
(*_PREG) = NEXTOP((*_PREG), x); \
WRITEBACK_S(S_SREG); \
ENDCACHE_S(); \
GONext();
#define PUT_STRUCT_INSTINIT \
register CELL d0; \
d0 = AbsAppl(HR); \
XREG((*_PREG)->u.xfa.x) = d0; \
d0 = (CELL) ((*_PREG)->u.xfa.f); \
*H++ = d0; \
(*_SREG) = HR; \
HR += (*_PREG)->u.xfa.a; \
(*_PREG) = NEXTOP((*_PREG), xfa); \
GONext();

199
JIT/HPP/yaam_put_d.h Normal file
View File

@ -0,0 +1,199 @@
#define PUT_X_VAR_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
register CELL *pt0; \
pt0 = HR; \
XREG((*_PREG)->u.xx.xl) = Unsigned(pt0); \
HR = pt0 + 1; \
XREG((*_PREG)->u.xx.xr) = Unsigned(pt0); \
(*_PREG) = NEXTOP((*_PREG), xx); \
RESET_VARIABLE(pt0); \
GONext();
#if defined(YAPOR_SBA) && defined(FROZEN_STACKS)
#define PUT_Y_VAR_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
register CELL *pt0; \
pt0 = YREG + (*_PREG)->u.yx.y; \
XREG((*_PREG)->u.yx.x) = (CELL) pt0; \
(*_PREG) = NEXTOP((*_PREG), yx); \
if (Unsigned((Int)(pt0)-(Int)(H_FZ)) > \
Unsigned((Int)(B_FZ)-(Int)(H_FZ))) { \
*pt0 = (CELL)STACK_TO_SBA(pt0); \
} else \
INITIALIZE_PERMVAR(pt0, (CELL)pt0); \
GONext();
#else /* defined(YAPOR_SBA) && defined(FROZEN_STACKS) */
#define PUT_Y_VAR_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
register CELL *pt0; \
pt0 = YREG + (*_PREG)->u.yx.y; \
XREG((*_PREG)->u.yx.x) = (CELL) pt0; \
(*_PREG) = NEXTOP((*_PREG), yx); \
INITIALIZE_PERMVAR(pt0, (CELL)pt0); \
GONext();
#endif /* defined(YAPOR_SBA) && defined(FROZEN_STACKS) */
#define PUT_X_VAL_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
register CELL d0; \
d0 = XREG((*_PREG)->u.xx.xl); \
XREG((*_PREG)->u.xx.xr) = d0; \
(*_PREG) = NEXTOP((*_PREG), xx); \
GONext();
#define PUT_XX_VAL_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
register CELL d0, d1; \
d0 = XREG((*_PREG)->u.xxxx.xl1); \
d1 = XREG((*_PREG)->u.xxxx.xl2); \
XREG((*_PREG)->u.xxxx.xr1) = d0; \
XREG((*_PREG)->u.xxxx.xr2) = d1; \
(*_PREG) = NEXTOP((*_PREG), xxxx); \
GONext();
#ifdef YAPOR_SBA
#define PUT_Y_VAL_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
register CELL d0; \
d0 = YREG[(*_PREG)->u.yx.y]; \
if (d0 == 0) { \
XREG((*_PREG)->u.yx.x) = (CELL)(YREG+(*_PREG)->u.yx.y); \
} else \
XREG((*_PREG)->u.yx.x) = d0; \
(*_PREG) = NEXTOP((*_PREG), yx); \
GONext();
#else /* YAPOR_SBA */
#define PUT_Y_VAL_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
register CELL d0; \
d0 = YREG[(*_PREG)->u.yx.y]; \
XREG((*_PREG)->u.yx.x) = d0; \
(*_PREG) = NEXTOP((*_PREG), yx); \
GONext();
#endif /* YAPOR_SBA */
#ifdef YAPOR_SBA
#define PUT_Y_VALS_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
register CELL d0, d1; \
ALWAYS_START_PREFETCH(yyxx); \
d0 = YREG[(*_PREG)->u.yyxx.y1]; \
if (d0 == 0) \
XREG((*_PREG)->u.yyxx.x1) = (CELL)(YREG+(*_PREG)->u.yyxx.y1); \
else \
XREG((*_PREG)->u.yyxx.x1) = d0; \
(*_PREG) = NEXTOP((*_PREG), yyxx); \
d1 = YREG[PREVOP((*_PREG),yyxx)->u.yyxx.y2]; \
if (d1 == 0) \
XREG(PREVOP((*_PREG)->u.yyxx,yyxx).x2) = (CELL)(YREG+(*_PREG)->u.yyxx.y2); \
else \
XREG(PREVOP((*_PREG),yyxx)->u.yyxx.x2) = d1; \
ALWAYS_GONext(); \
ALWAYS_END_PREFETCH();
#else /* YAPOR_SBA */
#define PUT_Y_VALS_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
register CELL d0, d1; \
ALWAYS_START_PREFETCH(yyxx); \
d0 = YREG[(*_PREG)->u.yyxx.y1]; \
XREG((*_PREG)->u.yyxx.x1) = d0; \
(*_PREG) = NEXTOP((*_PREG), yyxx); \
d1 = YREG[PREVOP((*_PREG),yyxx)->u.yyxx.y2]; \
XREG(PREVOP((*_PREG),yyxx)->u.yyxx.x2) = d1; \
ALWAYS_GONext(); \
ALWAYS_END_PREFETCH();
#endif /* YAPOR_SBA */
#define PUT_UNSAFE_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
register CELL d0; \
register CELL *pt0; \
pt0 = YREG+(*_PREG)->u.yx.y; \
d0 = *pt0;
#define PUT_UNSAFE_PUNSAFE_NONVAR \
XREG((*_PREG)->u.yx.x) = d0; \
(*_PREG) = NEXTOP((*_PREG), yx); \
GONext();
#define PUT_UNSAFE_PUNSAFE_UNK \
if (pt0 <= HR || pt0 >= YREG) { \
XREG((*_PREG)->u.yx.x) = Unsigned(pt0); \
(*_PREG) = NEXTOP((*_PREG), yx); \
GONext(); \
} \
else { \
Bind_Local(pt0, Unsigned(HR)); \
XREG((*_PREG)->u.yx.x) = (CELL) HR; \
RESET_VARIABLE(HR); \
H++; \
(*_PREG) = NEXTOP((*_PREG), yx); \
GONext(); \
}
#define PUT_ATOM_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
register CELL d0; \
d0 = (*_PREG)->u.xc.c; \
XREG((*_PREG)->u.xc.x) = d0; \
(*_PREG) = NEXTOP((*_PREG), xc); \
GONext();
#define PUT_DBTERM_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
register CELL d0; \
d0 = (*_PREG)->u.xD.D; \
XREG((*_PREG)->u.xD.x) = d0; \
(*_PREG) = NEXTOP((*_PREG), xD); \
GONext();
#define PUT_BIGINT_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
register CELL d0; \
d0 = (*_PREG)->u.xN.b; \
XREG((*_PREG)->u.xN.x) = d0; \
(*_PREG) = NEXTOP((*_PREG), xN); \
GONext();
#define PUT_FLOAT_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
register CELL d0; \
d0 = AbsAppl((*_PREG)->u.xd.d); \
XREG((*_PREG)->u.xd.x) = d0; \
(*_PREG) = NEXTOP((*_PREG), xd); \
GONext();
#define PUT_LONGINT_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
register CELL d0; \
d0 = AbsAppl((*_PREG)->u.xi.i); \
XREG((*_PREG)->u.xi.x) = d0; \
(*_PREG) = NEXTOP((*_PREG), xi); \
GONext();
#define PUT_LIST_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
register CELL d0; \
CACHE_S(); \
READ_IN_S(); \
S_SREG = HR; \
HR += 2; \
d0 = AbsPair(S_SREG); \
XREG((*_PREG)->u.x.x) = d0; \
(*_PREG) = NEXTOP((*_PREG), x); \
WRITEBACK_S(S_SREG); \
ENDCACHE_S(); \
GONext();
#define PUT_STRUCT_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
register CELL d0; \
d0 = AbsAppl(HR); \
XREG((*_PREG)->u.xfa.x) = d0; \
d0 = (CELL) ((*_PREG)->u.xfa.f); \
*H++ = d0; \
(*_SREG) = HR; \
HR += (*_PREG)->u.xfa.a; \
(*_PREG) = NEXTOP((*_PREG), xfa); \
GONext();

1266
JIT/HPP/yaam_unify.h Normal file

File diff suppressed because it is too large Load Diff

1341
JIT/HPP/yaam_unify_d.h Normal file

File diff suppressed because it is too large Load Diff

297
JIT/HPP/yaam_write.h Normal file
View File

@ -0,0 +1,297 @@
#define WRITE_X_VAR_INSTINIT \
XREG((*_PREG)->u.x.x) = Unsigned((*_SREG)); \
(*_PREG) = NEXTOP((*_PREG), x); \
RESET_VARIABLE((*_SREG)); \
(*_SREG)++; \
GONext();
#define WRITE_VOID_INSTINIT \
(*_PREG) = NEXTOP((*_PREG), e); \
RESET_VARIABLE((*_SREG)); \
(*_SREG)++; \
GONext();
#define WRITE_N_VOIDS_INSTINIT \
register CELL d0; \
d0 = (*_PREG)->u.s.s; \
(*_PREG) = NEXTOP((*_PREG), s); \
for (; d0 > 0; d0--) { \
RESET_VARIABLE((*_SREG)); \
(*_SREG)++; \
} \
GONext();
#define WRITE_Y_VAR_INSTINIT \
INITIALIZE_PERMVAR(YREG+(*_PREG)->u.y.y,Unsigned((*_SREG))); \
(*_PREG) = NEXTOP((*_PREG), y); \
RESET_VARIABLE((*_SREG)); \
(*_SREG)++; \
GONext();
#define WRITE_X_VAL_INSTINIT \
register CELL d0; \
d0 = XREG((*_PREG)->u.x.x); \
*(*_SREG)++ = d0; \
(*_PREG) = NEXTOP((*_PREG), x); \
GONext();
#define WRITE_X_LOC_INSTINIT \
register CELL d0; \
register CELL *pt0; \
d0 = XREG((*_PREG)->u.x.x); \
(*_PREG) = NEXTOP((*_PREG), x);
#define WRITE_X_LOC_W_X_BOUND \
*(*_SREG)++ = d0; \
GONext();
#if defined(YAPOR_SBA) && defined(FROZEN_STACKS)
#ifdef FROZEN_STACKS
#define WRITE_X_LOC_W_X_UNK \
if (pt0 > HR && pt0<(CELL *)B_FZ) { \
Bind_Local(pt0, Unsigned((*_SREG))); \
RESET_VARIABLE((*_SREG)); \
(*_SREG)++; \
GONext(); \
} \
else { \
*(*_SREG)++ = Unsigned(pt0); \
GONext(); \
}
#else /* FROZEN_STACKS */
#define WRITE_X_LOC_W_X_UNK \
if (pt0 > HR && pt0<(CELL *)B_FZ) { \
TRAIL_LOCAL(pt0, Unsigned((*_SREG))); \
*pt0 = Unsigned((*_SREG)); \
RESET_VARIABLE((*_SREG)); \
(*_SREG)++; \
GONext(); \
} \
else { \
*(*_SREG)++ = Unsigned(pt0); \
GONext(); \
}
#endif /* FROZEN_STACKS */
#else /* defined(YAPOR_SBA) && defined(FROZEN_STACKS) */
#ifdef FROZEN_STACKS
#define WRITE_X_LOC_W_X_UNK \
if (pt0 > HR) { \
Bind_Local(pt0, Unsigned((*_SREG))); \
RESET_VARIABLE((*_SREG)); \
(*_SREG)++; \
GONext(); \
} \
else { \
*(*_SREG)++ = Unsigned(pt0); \
GONext(); \
}
#else /* FROZEN_STACKS */
#define WRITE_X_LOC_W_X_UNK \
if (pt0 > HR) { \
TRAIL_LOCAL(pt0, Unsigned((*_SREG))); \
*pt0 = Unsigned((*_SREG)); \
RESET_VARIABLE((*_SREG)); \
(*_SREG)++; \
GONext(); \
} \
else { \
*(*_SREG)++ = Unsigned(pt0); \
GONext(); \
}
#endif /* FROZEN_STACKS */
#endif /*defined(YAPOR_SBA) && defined(FROZEN_STACKS) */
#ifdef YAPOR_SBA
#define WRITE_Y_VAL_INSTINIT \
register CELL d0; \
d0 = YREG[(*_PREG)->u.y.y]; \
if (d0 == 0) \
*(*_SREG)++ = (CELL)(YREG+(*_PREG)->u.y.y); \
else \
*(*_SREG)++ = d0; \
(*_PREG) = NEXTOP((*_PREG), y); \
GONext();
#else /* YAPOR_SBA */
#define WRITE_Y_VAL_INSTINIT \
register CELL d0; \
d0 = YREG[(*_PREG)->u.y.y]; \
*(*_SREG)++ = d0; \
(*_PREG) = NEXTOP((*_PREG), y); \
GONext();
#endif /* YAPOR_SBA */
#define WRITE_Y_LOC_INSTINIT \
register CELL d0; \
register CELL *pt0; \
pt0 = YREG+(*_PREG)->u.y.y; \
d0 = *pt0;
#define WRITE_Y_LOC_W_Y_BOUND \
(*_PREG) = NEXTOP((*_PREG), y); \
*(*_SREG)++ = d0; \
GONext();
#if defined(YAPOR_SBA) && defined(FROZEN_STACKS)
#ifdef FROZEN_STACKS
#define WRITE_Y_LOC_W_Y_UNK \
if (pt0 > HR \
&& pt0<(CELL *)B_FZ \
) { \
(*_PREG) = NEXTOP((*_PREG), y); \
Bind_Local(pt0, Unsigned((*_SREG))); \
RESET_VARIABLE((*_SREG)); \
(*_SREG)++; \
GONext(); \
} else { \
(*_PREG) = NEXTOP((*_PREG), y); \
*(*_SREG)++ = Unsigned(pt0); \
GONext(); \
}
#else /* FROZEN_STACKS */
#define WRITE_Y_LOC_W_Y_UNK \
if (pt0 > HR \
&& pt0<(CELL *)B_FZ \
) { \
(*_PREG) = NEXTOP((*_PREG), y); \
*pt0 = Unsigned((*_SREG)); \
TRAIL_LOCAL(pt0, Unsigned((*_SREG))); \
RESET_VARIABLE((*_SREG)); \
(*_SREG)++; \
GONext(); \
} else { \
(*_PREG) = NEXTOP((*_PREG), y); \
*(*_SREG)++ = Unsigned(pt0); \
GONext(); \
}
#endif /* FROZEN_STACKS */
#else /* defined(YAPOR_SBA) && defined(FROZEN_STACKS) */
#ifdef FROZEN_STACKS
#define WRITE_Y_LOC_W_Y_UNK \
if (pt0 > HR \
) { \
(*_PREG) = NEXTOP((*_PREG), y); \
Bind_Local(pt0, Unsigned((*_SREG))); \
RESET_VARIABLE((*_SREG)); \
(*_SREG)++; \
GONext(); \
} else { \
(*_PREG) = NEXTOP((*_PREG), y); \
*(*_SREG)++ = Unsigned(pt0); \
GONext(); \
}
#else /* FROZEN_STACKS */
#define WRITE_Y_LOC_W_Y_UNK \
if (pt0 > HR \
) { \
(*_PREG) = NEXTOP((*_PREG), y); \
*pt0 = Unsigned((*_SREG)); \
TRAIL_LOCAL(pt0, Unsigned((*_SREG))); \
RESET_VARIABLE((*_SREG)); \
(*_SREG)++; \
GONext(); \
} else { \
(*_PREG) = NEXTOP((*_PREG), y); \
*(*_SREG)++ = Unsigned(pt0); \
GONext(); \
}
#endif /* FROZEN_STACKS */
#endif /* defined(YAPOR_SBA) && defined(FROZEN_STACKS) */
#define WRITE_ATOM_INSTINIT \
register CELL d0; \
d0 = (*_PREG)->u.c.c; \
*(*_SREG)++ = d0; \
(*_PREG) = NEXTOP((*_PREG), c); \
GONext();
#define WRITE_BIGINT_INSTINIT \
register CELL d0; \
d0 = (*_PREG)->u.N.b; \
*(*_SREG)++ = d0; \
(*_PREG) = NEXTOP((*_PREG), N); \
GONext();
#define WRITE_DBTERM_INSTINIT \
register CELL d0; \
d0 = (*_PREG)->u.D.D; \
*(*_SREG)++ = d0; \
(*_PREG) = NEXTOP((*_PREG), D); \
GONext();
#define WRITE_FLOAT_INSTINIT \
register CELL d0; \
d0 = AbsAppl((*_PREG)->u.d.d); \
*(*_SREG)++ = d0; \
(*_PREG) = NEXTOP((*_PREG), d); \
GONext();
#define WRITE_LONGIT_INSTINIT \
register CELL d0; \
d0 = AbsAppl((*_PREG)->u.i.i); \
*(*_SREG)++ = d0; \
(*_PREG) = NEXTOP((*_PREG), i); \
GONext();
#define WRITE_N_ATOMS_INSTINIT \
register CELL d0, d1; \
d0 = (*_PREG)->u.sc.s; \
d1 = (*_PREG)->u.sc.c; \
for (; d0 > 0; d0--) { \
*(*_SREG)++ = d1; \
} \
(*_PREG) = NEXTOP((*_PREG), sc); \
GONext();
#define WRITE_LIST_INSTINIT \
register CELL d0; \
d0 = AbsPair(HR); \
*(*_SREG)++ = d0; \
SP[-1] = Unsigned((*_SREG)); \
SP[-2] = 1; \
SP -= 2; \
(*_SREG) = HR; \
HR += 2; \
(*_PREG) = NEXTOP((*_PREG), e); \
GONext();
#define WRITE_L_LIST_INSTINIT \
register CELL d0; \
ALWAYS_START_PREFETCH(e); \
(*_PREG) = NEXTOP((*_PREG), e); \
CACHE_S(); \
READ_IN_S(); \
d0 = AbsPair(HR); \
*S_SREG = d0; \
WRITEBACK_S(HR); \
HR += 2; \
ENDCACHE_S(); \
ALWAYS_GONext(); \
ALWAYS_END_PREFETCH();
#define WRITE_STRUCT_INSTINIT \
register CELL d0; \
d0 = AbsAppl(HR); \
*(*_SREG)++ = d0; \
SP[-1] = Unsigned((*_SREG)); \
SP[-2] = 1; \
SP -= 2; \
d0 = (CELL) ((*_PREG)->u.fa.f); \
*H++ = d0; \
d0 = (*_PREG)->u.fa.a; \
(*_PREG) = NEXTOP((*_PREG), fa); \
(*_SREG) = HR; \
HR += d0; \
GONext();
#define WRITE_L_STRUC_INSTINIT \
register CELL d0; \
d0 = AbsAppl(HR); \
*(*_SREG) = d0; \
d0 = (CELL) ((*_PREG)->u.fa.f); \
*H++ = d0; \
(*_SREG) = HR; \
d0 = (*_PREG)->u.fa.a; \
(*_PREG) = NEXTOP((*_PREG), fa); \
HR += d0; \
GONext();

316
JIT/HPP/yaam_write_d.h Normal file
View File

@ -0,0 +1,316 @@
#define WRITE_X_VAR_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
XREG((*_PREG)->u.x.x) = Unsigned((*_SREG)); \
(*_PREG) = NEXTOP((*_PREG), x); \
RESET_VARIABLE((*_SREG)); \
(*_SREG)++; \
GONext();
#define WRITE_VOID_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
(*_PREG) = NEXTOP((*_PREG), e); \
RESET_VARIABLE((*_SREG)); \
(*_SREG)++; \
GONext();
#define WRITE_N_VOIDS_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
register CELL d0; \
d0 = (*_PREG)->u.s.s; \
(*_PREG) = NEXTOP((*_PREG), s); \
for (; d0 > 0; d0--) { \
RESET_VARIABLE((*_SREG)); \
(*_SREG)++; \
} \
GONext();
#define WRITE_Y_VAR_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
INITIALIZE_PERMVAR(YREG+(*_PREG)->u.y.y,Unsigned((*_SREG))); \
(*_PREG) = NEXTOP((*_PREG), y); \
RESET_VARIABLE((*_SREG)); \
(*_SREG)++; \
GONext();
#define WRITE_X_VAL_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
register CELL d0; \
d0 = XREG((*_PREG)->u.x.x); \
*(*_SREG)++ = d0; \
(*_PREG) = NEXTOP((*_PREG), x); \
GONext();
#define WRITE_X_LOC_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
register CELL d0; \
register CELL *pt0; \
d0 = XREG((*_PREG)->u.x.x); \
(*_PREG) = NEXTOP((*_PREG), x);
#define WRITE_X_LOC_W_X_BOUND \
*(*_SREG)++ = d0; \
GONext();
#if defined(YAPOR_SBA) && defined(FROZEN_STACKS)
#ifdef FROZEN_STACKS
#define WRITE_X_LOC_W_X_UNK \
if (pt0 > HR && pt0<(CELL *)B_FZ) { \
Bind_Local(pt0, Unsigned((*_SREG))); \
RESET_VARIABLE((*_SREG)); \
(*_SREG)++; \
GONext(); \
} \
else { \
*(*_SREG)++ = Unsigned(pt0); \
GONext(); \
}
#else /* FROZEN_STACKS */
#define WRITE_X_LOC_W_X_UNK \
if (pt0 > HR && pt0<(CELL *)B_FZ) { \
TRAIL_LOCAL(pt0, Unsigned((*_SREG))); \
*pt0 = Unsigned((*_SREG)); \
RESET_VARIABLE((*_SREG)); \
(*_SREG)++; \
GONext(); \
} \
else { \
*(*_SREG)++ = Unsigned(pt0); \
GONext(); \
}
#endif /* FROZEN_STACKS */
#else /* defined(YAPOR_SBA) && defined(FROZEN_STACKS) */
#ifdef FROZEN_STACKS
#define WRITE_X_LOC_W_X_UNK \
if (pt0 > HR) { \
Bind_Local(pt0, Unsigned((*_SREG))); \
RESET_VARIABLE((*_SREG)); \
(*_SREG)++; \
GONext(); \
} \
else { \
*(*_SREG)++ = Unsigned(pt0); \
GONext(); \
}
#else /* FROZEN_STACKS */
#define WRITE_X_LOC_W_X_UNK \
if (pt0 > HR) { \
TRAIL_LOCAL(pt0, Unsigned((*_SREG))); \
*pt0 = Unsigned((*_SREG)); \
RESET_VARIABLE((*_SREG)); \
(*_SREG)++; \
GONext(); \
} \
else { \
*(*_SREG)++ = Unsigned(pt0); \
GONext(); \
}
#endif /* FROZEN_STACKS */
#endif /*defined(YAPOR_SBA) && defined(FROZEN_STACKS) */
#ifdef YAPOR_SBA
#define WRITE_Y_VAL_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
register CELL d0; \
d0 = YREG[(*_PREG)->u.y.y]; \
if (d0 == 0) \
*(*_SREG)++ = (CELL)(YREG+(*_PREG)->u.y.y); \
else \
*(*_SREG)++ = d0; \
(*_PREG) = NEXTOP((*_PREG), y); \
GONext();
#else /* YAPOR_SBA */
#define WRITE_Y_VAL_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
register CELL d0; \
d0 = YREG[(*_PREG)->u.y.y]; \
*(*_SREG)++ = d0; \
(*_PREG) = NEXTOP((*_PREG), y); \
GONext();
#endif /* YAPOR_SBA */
#define WRITE_Y_LOC_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
register CELL d0; \
register CELL *pt0; \
pt0 = YREG+(*_PREG)->u.y.y; \
d0 = *pt0;
#define WRITE_Y_LOC_W_Y_BOUND \
(*_PREG) = NEXTOP((*_PREG), y); \
*(*_SREG)++ = d0; \
GONext();
#if defined(YAPOR_SBA) && defined(FROZEN_STACKS)
#ifdef FROZEN_STACKS
#define WRITE_Y_LOC_W_Y_UNK \
if (pt0 > HR \
&& pt0<(CELL *)B_FZ \
) { \
(*_PREG) = NEXTOP((*_PREG), y); \
Bind_Local(pt0, Unsigned((*_SREG))); \
RESET_VARIABLE((*_SREG)); \
(*_SREG)++; \
GONext(); \
} else { \
(*_PREG) = NEXTOP((*_PREG), y); \
*(*_SREG)++ = Unsigned(pt0); \
GONext(); \
}
#else /* FROZEN_STACKS */
#define WRITE_Y_LOC_W_Y_UNK \
if (pt0 > HR \
&& pt0<(CELL *)B_FZ \
) { \
(*_PREG) = NEXTOP((*_PREG), y); \
*pt0 = Unsigned((*_SREG)); \
TRAIL_LOCAL(pt0, Unsigned((*_SREG))); \
RESET_VARIABLE((*_SREG)); \
(*_SREG)++; \
GONext(); \
} else { \
(*_PREG) = NEXTOP((*_PREG), y); \
*(*_SREG)++ = Unsigned(pt0); \
GONext(); \
}
#endif /* FROZEN_STACKS */
#else /* defined(YAPOR_SBA) && defined(FROZEN_STACKS) */
#ifdef FROZEN_STACKS
#define WRITE_Y_LOC_W_Y_UNK \
if (pt0 > HR \
) { \
(*_PREG) = NEXTOP((*_PREG), y); \
Bind_Local(pt0, Unsigned((*_SREG))); \
RESET_VARIABLE((*_SREG)); \
(*_SREG)++; \
GONext(); \
} else { \
(*_PREG) = NEXTOP((*_PREG), y); \
*(*_SREG)++ = Unsigned(pt0); \
GONext(); \
}
#else /* FROZEN_STACKS */
#define WRITE_Y_LOC_W_Y_UNK \
if (pt0 > HR \
) { \
(*_PREG) = NEXTOP((*_PREG), y); \
*pt0 = Unsigned((*_SREG)); \
TRAIL_LOCAL(pt0, Unsigned((*_SREG))); \
RESET_VARIABLE((*_SREG)); \
(*_SREG)++; \
GONext(); \
} else { \
(*_PREG) = NEXTOP((*_PREG), y); \
*(*_SREG)++ = Unsigned(pt0); \
GONext(); \
}
#endif /* FROZEN_STACKS */
#endif /* defined(YAPOR_SBA) && defined(FROZEN_STACKS) */
#define WRITE_ATOM_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
register CELL d0; \
d0 = (*_PREG)->u.c.c; \
*(*_SREG)++ = d0; \
(*_PREG) = NEXTOP((*_PREG), c); \
GONext();
#define WRITE_BIGINT_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
register CELL d0; \
d0 = (*_PREG)->u.N.b; \
*(*_SREG)++ = d0; \
(*_PREG) = NEXTOP((*_PREG), N); \
GONext();
#define WRITE_DBTERM_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
register CELL d0; \
d0 = (*_PREG)->u.D.D; \
*(*_SREG)++ = d0; \
(*_PREG) = NEXTOP((*_PREG), D); \
GONext();
#define WRITE_FLOAT_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
register CELL d0; \
d0 = AbsAppl((*_PREG)->u.d.d); \
*(*_SREG)++ = d0; \
(*_PREG) = NEXTOP((*_PREG), d); \
GONext();
#define WRITE_LONGIT_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
register CELL d0; \
d0 = AbsAppl((*_PREG)->u.i.i); \
*(*_SREG)++ = d0; \
(*_PREG) = NEXTOP((*_PREG), i); \
GONext();
#define WRITE_N_ATOMS_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
register CELL d0, d1; \
d0 = (*_PREG)->u.sc.s; \
d1 = (*_PREG)->u.sc.c; \
for (; d0 > 0; d0--) { \
*(*_SREG)++ = d1; \
} \
(*_PREG) = NEXTOP((*_PREG), sc); \
GONext();
#define WRITE_LIST_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
register CELL d0; \
d0 = AbsPair(HR); \
*(*_SREG)++ = d0; \
SP[-1] = Unsigned((*_SREG)); \
SP[-2] = 1; \
SP -= 2; \
(*_SREG) = HR; \
HR += 2; \
(*_PREG) = NEXTOP((*_PREG), e); \
GONext();
#define WRITE_L_LIST_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
register CELL d0; \
ALWAYS_START_PREFETCH(e); \
(*_PREG) = NEXTOP((*_PREG), e); \
CACHE_S(); \
READ_IN_S(); \
d0 = AbsPair(HR); \
*S_SREG = d0; \
WRITEBACK_S(HR); \
HR += 2; \
ENDCACHE_S(); \
ALWAYS_GONext(); \
ALWAYS_END_PREFETCH();
#define WRITE_STRUCT_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
register CELL d0; \
d0 = AbsAppl(HR); \
*(*_SREG)++ = d0; \
SP[-1] = Unsigned((*_SREG)); \
SP[-2] = 1; \
SP -= 2; \
d0 = (CELL) ((*_PREG)->u.fa.f); \
*H++ = d0; \
d0 = (*_PREG)->u.fa.a; \
(*_PREG) = NEXTOP((*_PREG), fa); \
(*_SREG) = HR; \
HR += d0; \
GONext();
#define WRITE_L_STRUC_INSTINIT \
print_instruction((*_PREG), ON_NATIVE); \
register CELL d0; \
d0 = AbsAppl(HR); \
*(*_SREG) = d0; \
d0 = (CELL) ((*_PREG)->u.fa.f); \
*H++ = d0; \
(*_SREG) = HR; \
d0 = (*_PREG)->u.fa.a; \
(*_PREG) = NEXTOP((*_PREG), fa); \
HR += d0; \
GONext();

876
JIT/JIT_Compiler.cpp Normal file
View File

@ -0,0 +1,876 @@
#include "JIT_Compiler.hpp"
#include <unistd.h>
#include <sys/wait.h>
#include <fcntl.h>
using namespace std;
#define FREE_ALLOCATED() \
free(buffer); \
free(p->u.jhc.jh->cmd); \
free(outputfilename); \
free(optoutputfilename); \
free(cmd1); \
free(cmd2);
#define ADD_PASS_ACCORDING_TO_KIND() \
switch (Kind) { \
case PT_BasicBlock: \
fprintf(stderr, "Oops -- basicblock printer\n"); \
exit(1); \
case PT_Region: \
Pass.add(new RegionPassPrinter(PI)); \
break; \
case PT_Loop: \
Pass.add(new LoopPassPrinter(PI)); \
break; \
case PT_Function: \
Pass.add(new FunctionPassPrinter(PI)); \
break; \
case PT_CallGraphSCC: \
Pass.add(new CallGraphSCCPassPrinter(PI)); \
break; \
default: \
Pass.add(new ModulePassPrinter(PI)); \
break; \
}
#define TREAT_CASE_FOR(PASS) \
PI = PassRegistry::getPassRegistry()->getPassInfo(PASS->getPassID()); \
Kind = PASS->getPassKind(); \
ADD_PASS_ACCORDING_TO_KIND();
#include "PassPrinters.hpp"
void JIT_Compiler::analyze_module(llvm::Module* &M)
{
PassManager Pass; // 'Pass' stores analysis passes to be applied
TargetLibraryInfo *TLI = new TargetLibraryInfo(Triple(M->getTargetTriple()));
const PassInfo *PI;
PassKind Kind;
Pass.add(TLI); // First, I add on 'Pass' the Target Info of Module
Pass.add(new TargetData(M)); // Second, I must add Target Data on 'Pass'
for (int i = 0; i < ExpEnv.analysis_struc.n; i++) {
/*
* 'ExpEnv.analysis_struc.act_an' contains sorted analysis passes *
* 'ExpEnv.analysis_struc.act_an' is filled by analysis predicates *
* What must I do? *
* 1. Pass over 'ExpEnv.analysis_struc.act_an' (by previous 'for') *
* 2. For each unity within 'ExpEnv.analysis_struc.act_an' *
* 2.1. Check its type *
* 2.2. Add analysis pass on 'Pass' accordingly the type checked *
*/
switch (ExpEnv.analysis_struc.act_an[i]) {
case e_createAAEvalPass:
TREAT_CASE_FOR(createAAEvalPass());
break;
case e_createBasicAliasAnalysisPass:
TREAT_CASE_FOR(createBasicAliasAnalysisPass());
break;
case e_createAliasAnalysisCounterPass:
TREAT_CASE_FOR(createAliasAnalysisCounterPass());
break;
case e_createGlobalsModRefPass:
TREAT_CASE_FOR(createGlobalsModRefPass());
break;
case e_createInstCountPass:
TREAT_CASE_FOR(createInstCountPass());
break;
case e_createIVUsersPass:
TREAT_CASE_FOR(createIVUsersPass());
break;
case e_createLazyValueInfoPass:
TREAT_CASE_FOR(createLazyValueInfoPass());
break;
case e_createLoopDependenceAnalysisPass:
TREAT_CASE_FOR(createLoopDependenceAnalysisPass());
break;
case e_createLibCallAliasAnalysisPass:
TREAT_CASE_FOR(createLibCallAliasAnalysisPass(NULL));
break;
case e_createLintPass:
TREAT_CASE_FOR(createLintPass());
break;
case e_createMemDepPrinter:
TREAT_CASE_FOR(createMemDepPrinter());
break;
case e_createModuleDebugInfoPrinterPass:
TREAT_CASE_FOR(createModuleDebugInfoPrinterPass());
break;
case e_createNoAAPass:
TREAT_CASE_FOR(createNoAAPass());
break;
case e_createNoPathProfileInfoPass:
TREAT_CASE_FOR(createNoPathProfileInfoPass());
break;
case e_createNoProfileInfoPass:
TREAT_CASE_FOR(createNoProfileInfoPass());
break;
case e_createObjCARCAliasAnalysisPass:
TREAT_CASE_FOR(createObjCARCAliasAnalysisPass());
break;
case e_createProfileEstimatorPass:
TREAT_CASE_FOR(createProfileEstimatorPass());
break;
case e_createProfileLoaderPass:
TREAT_CASE_FOR(createProfileLoaderPass());
break;
case e_createProfileVerifierPass:
TREAT_CASE_FOR(createProfileVerifierPass());
break;
case e_createRegionInfoPass:
TREAT_CASE_FOR(createRegionInfoPass());
break;
case e_createScalarEvolutionAliasAnalysisPass:
TREAT_CASE_FOR(createScalarEvolutionAliasAnalysisPass());
break;
case e_createTypeBasedAliasAnalysisPass:
TREAT_CASE_FOR(createTypeBasedAliasAnalysisPass());
break;
case e_createDbgInfoPrinterPass:
TREAT_CASE_FOR(createDbgInfoPrinterPass());
break;
case e_createCFGPrinterPass:
TREAT_CASE_FOR(createCFGPrinterPass());
break;
case e_createCFGOnlyPrinterPass:
TREAT_CASE_FOR(createCFGOnlyPrinterPass());
break;
case e_createDomPrinterPass:
TREAT_CASE_FOR(createDomPrinterPass());
break;
case e_createDomOnlyPrinterPass:
TREAT_CASE_FOR(createDomOnlyPrinterPass());
break;
case e_createPostDomPrinterPass:
TREAT_CASE_FOR(createPostDomPrinterPass());
break;
case e_createPostDomOnlyPrinterPass:
TREAT_CASE_FOR(createPostDomOnlyPrinterPass());
break;
case e_createRegionPrinterPass:
TREAT_CASE_FOR(createRegionPrinterPass());
break;
case e_createRegionOnlyPrinterPass:
TREAT_CASE_FOR(createRegionOnlyPrinterPass());
break;
case e_createPathProfileLoaderPass:
TREAT_CASE_FOR(createPathProfileLoaderPass());
break;
case e_createPathProfileVerifierPass:
TREAT_CASE_FOR(createPathProfileVerifierPass());
break;
default:;
}
}
/* if 'llvm::TimePassesIsEnabled' is 'true', llvm time passes are printed on 'shutdown_llvm()' (p_halt -- stdpreds.c) */
llvm::TimePassesIsEnabled = ExpEnv.analysis_struc.time_pass_enabled;
/* Use 'llvm::EnableStatistics()' so that llvm stats are printed on 'shutdown_llvm()' (p_halt -- stdpreds.c) */
if (ExpEnv.analysis_struc.stats_enabled) llvm::EnableStatistics();
/*
* Here, I configure resulting analysis output -- default: stderr *
* Use analysis_output_file/1 to change *
*/
if (strcmp(((char*)ExpEnv.analysis_struc.outfile), "STDERR")) { // print to file that is not stderr
int stderrcopy = dup(2); // stderr backup
if (strcmp(((char*)ExpEnv.analysis_struc.outfile), "STDOUT") == 0) { // print to stdout
dup2(1, 2); // 2 is stderr; 1 is stdout -- dup2(1,2) redirects stderr output to stdout
Pass.run(*M); // Run passes (results will be printed on stdout)
dup2(stderrcopy, 2); // Recovers stderr
}
else {
int Outputfile = open(((char*)ExpEnv.analysis_struc.outfile), O_CREAT | O_TRUNC | O_WRONLY, 0777);
// Openning Output file, whose name is on 'ExpEnv.analysis_struc.outfile'
if (Outputfile < 0) {
fprintf(stderr, "Error:: I can not write analysis passes's output on %s...\n", ((char*)ExpEnv.analysis_struc.outfile));
fprintf(stderr, " %s...\n", strerror(errno));
errno = 0;
exit(1);
}
dup2(Outputfile, 2); // 2 is stderr; Outputfile is any other file -- dup2(Outputfile,2) redirects stderr output to Outputfile
Pass.run(*M); // Run passes (results will be printed on Outputfile)
close(Outputfile);
dup2(stderrcopy, 2); // Recovers stderr
}
close(stderrcopy);
}
else // print to stderr
Pass.run(*M); // Run passes (results will be printed on stderr)
}
void JIT_Compiler::optimize_module(llvm::Module* &M)
{
if (ExpEnv.transform_struc.optlevel > -1) { /* Do I need to apply transform level? */
/* Yes, I do, so... */
/* Initializes PassManager for Function */
OwningPtr<FunctionPassManager> FPM;
FPM.reset(new FunctionPassManager(M));
FPM->add(new TargetData(M));
PassManagerBuilder Builder; // aid to 'FPM' and 'MPM'
/* Initializes PassManager for Function */
PassManager MPM;
TargetLibraryInfo *TLI = new TargetLibraryInfo(Triple(M->getTargetTriple()));
MPM.add(TLI);
MPM.add(new TargetData(M));
/* Populates 'Builder' */
Builder.OptLevel = ExpEnv.transform_struc.optlevel;
Builder.DisableUnitAtATime = !ExpEnv.transform_struc.unit_at_time_enabled;
Builder.DisableSimplifyLibCalls = !ExpEnv.transform_struc.simplify_libcalls_enabled;
/* inline and unrool only be enabled if 'ExpEnv.transform_struc.optlevel' > 0 */
if (ExpEnv.transform_struc.optlevel) Builder.Inliner =
createFunctionInliningPass(ExpEnv.transform_struc.opt_args.inline_threshold);
Builder.DisableUnrollLoops = (ExpEnv.transform_struc.optlevel == 0);
/***/
/***/
/* Populates 'FPM' from 'Builder' */
Builder.populateFunctionPassManager(*FPM);
/* Populates 'MPM' from 'Builder' */
Builder.populateModulePassManager(MPM);
/*
* Enabling link-time optimizations -- default is no *
* Use 'link_time_opt/1', 'link_time_opt/3', 'enable_link_time_opt/0', or 'enable_link_time_opt/2' to change *
*/
if (ExpEnv.transform_struc.link_time_opt.enabled)
Builder.populateLTOPassManager(MPM,
(bool)ExpEnv.transform_struc.link_time_opt.internalize,
(bool)ExpEnv.transform_struc.link_time_opt.runinliner);
/***/
//set_regalloc_pass(MPM);
/* Pass over all functions within Module and run passes */
FPM->doInitialization();
for (Module::iterator F = M->begin(), E = M->end(); F != E; ++F)
FPM->run(*F);
FPM->doFinalization();
/***/
MPM.run(*M); // Run passes on module
}
else {
/* No, I need to apply transform passes accordingly transform predicates but transform_level/1 */
std::vector<GlobalValue*> GVvector; // 'createGVExtractionPass' argument
PassManager Pass; // 'Pass' stores transform passes to be applied
TargetLibraryInfo *TLI = new TargetLibraryInfo(Triple(M->getTargetTriple()));
Pass.add(TLI); // First, I add on 'Pass' the Target Info of Module
Pass.add(new TargetData(M)); // Second, I must add Target Data on 'Pass'
for (int i = 0; i < ExpEnv.transform_struc.n; i++) {
/*
* 'ExpEnv.transform_struc.act_tr' contains sorted transform passes *
* 'ExpEnv.transform_struc.act_tr' is filled by transform predicates *
* What must I do? *
* 1. Pass over 'ExpEnv.transform_struc.act_tr' (by previous 'for') *
* 2. For each unity within 'ExpEnv.analysis_struc.act_an', add transform pass on 'Pass' *
*/
switch (ExpEnv.transform_struc.act_tr[i]) {
case t_createAggressiveDCEPass:
Pass.add(createAggressiveDCEPass());
break;
case t_createArgumentPromotionPass:
Pass.add(createArgumentPromotionPass((Int)ExpEnv.transform_struc.opt_args.arg_promotion_max_elements));
break;
case t_createBBVectorizePass:
Pass.add(createBBVectorizePass());
break;
case t_createBlockExtractorPass:
Pass.add(createBlockExtractorPass());
break;
case t_createBlockPlacementPass:
Pass.add(createBlockPlacementPass());
break;
case t_createBreakCriticalEdgesPass:
Pass.add(createBreakCriticalEdgesPass());
break;
case t_createCFGSimplificationPass:
Pass.add(createCFGSimplificationPass());
break;
case t_createCodeGenPreparePass:
Pass.add(createCodeGenPreparePass());
break;
case t_createConstantMergePass:
Pass.add(createConstantMergePass());
break;
case t_createConstantPropagationPass:
Pass.add(createConstantPropagationPass());
break;
case t_createCorrelatedValuePropagationPass:
Pass.add(createCorrelatedValuePropagationPass());
break;
case t_createDeadArgEliminationPass:
Pass.add(createDeadArgEliminationPass());
break;
case t_createDeadArgHackingPass:
Pass.add(createDeadArgHackingPass());
break;
case t_createDeadCodeEliminationPass:
Pass.add(createDeadCodeEliminationPass());
break;
case t_createDeadInstEliminationPass:
Pass.add(createDeadInstEliminationPass());
break;
case t_createDeadStoreEliminationPass:
Pass.add(createDeadStoreEliminationPass());
break;
case t_createDemoteRegisterToMemoryPass:
Pass.add(createDemoteRegisterToMemoryPass());
break;
case t_createEarlyCSEPass:
Pass.add(createEarlyCSEPass());
break;
case t_createFunctionAttrsPass:
Pass.add(createFunctionAttrsPass());
break;
case t_createFunctionInliningPass:
Pass.add(createFunctionInliningPass(ExpEnv.transform_struc.opt_args.inline_threshold));
break;
case t_createGlobalDCEPass:
Pass.add(createGlobalDCEPass());
break;
case t_createGlobalOptimizerPass:
Pass.add(createGlobalOptimizerPass());
break;
case t_createGVExtractionPass:
Pass.add(createGVExtractionPass(GVvector));
break;
case t_createGVNPass:
Pass.add(createGVNPass());
break;
case t_createIndVarSimplifyPass:
Pass.add(createIndVarSimplifyPass());
break;
case t_createInstructionCombiningPass:
Pass.add(createInstructionCombiningPass());
break;
case t_createInstructionNamerPass:
Pass.add(createInstructionNamerPass());
break;
case t_createInstructionSimplifierPass:
Pass.add(createInstructionSimplifierPass());
break;
case t_createInternalizePass:
Pass.add(createInternalizePass(true));
break;
case t_createIPConstantPropagationPass:
Pass.add(createIPConstantPropagationPass());
break;
case t_createIPSCCPPass:
Pass.add(createIPSCCPPass());
break;
case t_createJumpThreadingPass:
Pass.add(createJumpThreadingPass());
break;
case t_createLCSSAPass:
Pass.add(createLCSSAPass());
break;
case t_createLICMPass:
Pass.add(createLICMPass());
break;
case t_createLoopDeletionPass:
Pass.add(createLoopDeletionPass());
break;
case t_createLoopExtractorPass:
Pass.add(createLoopExtractorPass());
break;
case t_createLoopIdiomPass:
Pass.add(createLoopIdiomPass());
break;
case t_createLoopInstSimplifyPass:
Pass.add(createLoopInstSimplifyPass());
break;
case t_createLoopRotatePass:
Pass.add(createLoopRotatePass());
break;
case t_createLoopSimplifyPass:
Pass.add(createLoopSimplifyPass());
break;
case t_createLoopStrengthReducePass:
Pass.add(createLoopStrengthReducePass());
break;
case t_createLoopUnrollPass:
Pass.add(createLoopUnrollPass((Int)ExpEnv.transform_struc.opt_args.loop_unroll_threshold));
break;
case t_createLoopUnswitchPass:
Pass.add(createLoopUnswitchPass((bool)ExpEnv.transform_struc.opt_args.loop_unswitch_optimize_for_size));
break;
case t_createLowerAtomicPass:
Pass.add(createLowerAtomicPass());
break;
case t_createLowerExpectIntrinsicPass:
Pass.add(createLowerExpectIntrinsicPass());
break;
case t_createLowerInvokePass:
Pass.add(createLowerInvokePass());
break;
case t_createLowerSwitchPass:
Pass.add(createLowerSwitchPass());
break;
case t_createMemCpyOptPass:
Pass.add(createMemCpyOptPass());
break;
case t_createMergeFunctionsPass:
Pass.add(createMergeFunctionsPass());
break;
case t_createObjCARCAPElimPass:
Pass.add(createObjCARCAPElimPass());
break;
case t_createObjCARCContractPass:
Pass.add(createObjCARCContractPass());
break;
case t_createObjCARCExpandPass:
Pass.add(createObjCARCExpandPass());
break;
case t_createObjCARCOptPass:
Pass.add(createObjCARCOptPass());
break;
case t_createPartialInliningPass:
Pass.add(createPartialInliningPass());
break;
case t_createPromoteMemoryToRegisterPass:
Pass.add(createPromoteMemoryToRegisterPass());
break;
case t_createPruneEHPass:
Pass.add(createPruneEHPass());
break;
case t_createReassociatePass:
Pass.add(createReassociatePass());
break;
case t_createScalarReplAggregatesPass:
Pass.add(createScalarReplAggregatesPass((Int)ExpEnv.transform_struc.opt_args.scalar_replace_aggregates_threshold));
break;
case t_createSCCPPass:
Pass.add(createSCCPPass());
break;
case t_createSimplifyLibCallsPass:
Pass.add(createSimplifyLibCallsPass());
break;
case t_createSingleLoopExtractorPass:
Pass.add(createSingleLoopExtractorPass());
break;
case t_createSinkingPass:
Pass.add(createSinkingPass());
break;
case t_createStripDeadDebugInfoPass:
Pass.add(createStripDeadDebugInfoPass());
break;
case t_createStripDeadPrototypesPass:
Pass.add(createStripDeadPrototypesPass());
break;
case t_createStripDebugDeclarePass:
Pass.add(createStripDebugDeclarePass());
break;
case t_createStripNonDebugSymbolsPass:
Pass.add(createStripNonDebugSymbolsPass());
break;
case t_createStripSymbolsPass:
Pass.add(createStripSymbolsPass((bool)ExpEnv.transform_struc.opt_args.strip_symbols_pass_type));
break;
case t_createTailCallEliminationPass:
Pass.add(createTailCallEliminationPass());
break;
default:;
}
}
//set_regalloc_pass(Pass);
Pass.run(*M); // Run passes
}
}
void JIT_Compiler::set_regalloc_pass(PassManager &PM) {
// 'ExpEnv.codegen_struc.struc_enginebuilder.regallocator' contains the active register allocator to be used
switch(ExpEnv.codegen_struc.struc_enginebuilder.regallocator) {
case REG_ALLOC_BASIC:
PM.add(createBasicRegisterAllocator());
break;
case REG_ALLOC_FAST:
PM.add(createFastRegisterAllocator());
break;
case REG_ALLOC_GREEDY:
PM.add(createGreedyRegisterAllocator());
break;
case REG_ALLOC_PBQP:
PM.add(createDefaultPBQPRegisterAllocator());
break;
}
}
void* JIT_Compiler::compile_all(LLVMContext* &Context, yamop* p)
{
/* Init llvm code generation, analysis and transform passes */
InitializeNativeTarget();
PassRegistry &Registry = *PassRegistry::getPassRegistry();
initializeCore(Registry);
initializeScalarOpts(Registry);
initializeVectorization(Registry);
initializeIPO(Registry);
initializeAnalysis(Registry);
initializeIPA(Registry);
initializeTransformUtils(Registry);
initializeInstCombine(Registry);
initializeInstrumentation(Registry);
initializeTarget(Registry);
sys::Process::PreventCoreFiles();
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wwrite-strings"
/* CLANG arguments */
char *clang_args[] =
{
"clang", "-fomit-frame-pointer", "-O0",
#if CUT_C
"-DCUT_C=1",
#endif
#if COROUTINING
"-DCOROUTINING=1",
#endif
#if RATIONAL_TREES
"-DRATIONAL_TREES=1",
#endif
#if DEBUG
"-DDEBUG=1",
#endif
#if DEPTH_LIMIT
"-DDEPTH_LIMIT=1",
#endif
#if YAP_DBG_PREDS
"-DYAP_DBG_PREDS=1",
#endif
#if YAP_STAT_PREDS
"-DYAP_STAT_PREDS=1",
#endif
#if TABLING
"-DTABLING=1",
#endif
#if _YAP_NOT_INSTALLED_
"-D_YAP_NOT_INSTALLED_=1",
#endif
#ifdef HAVE_CONFIG_H
"-DHAVE_CONFIG_H",
#endif
"-DYAP_JIT", "-D_NATIVE=1", "-I.", "-I./H", "-I./include", "-I./os", "-I./OPTYap", "-I./BEAM", "-I./MYDDAS", "-I./HPP", "-xc", "-c", "-", "-o", "-", "-emit-llvm", NULL
};
#pragma GCC diagnostic pop
std::string errStr;
llvm::error_code e;
OwningPtr<MemoryBuffer> bf;
/* Pipe to communicate 'echo' with 'clang' */
int pipe1[2];
int pid_echo, pid_clang ;
/* 'clang' out file */
char* outputfilename = (char*)malloc(33*sizeof(char));
sprintf(outputfilename, "%lx.bc", (CELL)p);
int Output = open(outputfilename, O_CREAT | O_RDWR, 0644);
/* Creating pipes */
if (pipe(pipe1)<0) {
perror(" ERROR!!\n ERROR") ;
exit(1);
}
/* Calls echo. */
pid_echo = fork() ;
if (pid_echo < 0) {
perror(" ERROR!!\n ERROR") ;
exit(1);
}
if (!pid_echo) {
/* Setting echo's output to 1st pipe */
dup2(pipe1[1], 1);
/* Closing pipes */
close(pipe1[0]);
close(pipe1[1]);
execlp("echo", "echo", p->u.jhc.jh->tcc.cmd, NULL);
}
else {
/* Calls clang. */
pid_clang = fork() ;
if (pid_clang < 0) {
perror(" ERROR!!\n ERROR") ;
exit(1);
}
if (!pid_clang) {
/* Setting clang's input from 1st pipe */
dup2(pipe1[0], 0) ;
/* Setting clang's output to Output */
dup2(Output, 1) ;
/* Closing pipes */
close(pipe1[0]);
close(pipe1[1]);
execvp(*clang_args, clang_args);
}
}
/* Closing pipes */
close(pipe1[0]);
close(pipe1[1]);
/* waiting for completion of processes */
int i;
int *status = NULL;
// 2 means two processes: 'echo' and 'clang'
for (i = 0; i < 2; i++) wait(status);
/***/
/*
* At this point, the compiled code (O0) is on 'Output' *
* I need to read it to main memory *
* for this, I'll use 'MemoryBuffer::getOpenFile' *
*/
lseek(Output, 0, SEEK_SET);
e = MemoryBuffer::getOpenFile(Output, outputfilename, bf);
if (e) {
errs() << "ERROR::Unable to MemoryBuffer from " << outputfilename << " -- " << e.message() << "\n";
exit(1);
}
/*
* At this point, the compiled code (O0) is on main memory *
* I need to read it to Module *
* for this, I'll use 'ParseBitcodeFile' *
*/
Module *Mod = ParseBitcodeFile(bf.get(), *Context);
/*
* verify module correctness *
* predicates: *
* enable_module_correctness/1 *
* verify_module_before/0 *
* verify_module_both/0 *
*/
if (ExpEnv.analysis_struc.pointtoverifymodule == BEFORE || ExpEnv.analysis_struc.pointtoverifymodule == BOTH) {
if (verifyModule(*Mod)) {
errs() << "ERROR:: Module not built correctly!\n";
exit(1);
}
}
/***/
#if YAP_DBG_PREDS
/* for debug... print module before optimizing it */
if (ExpEnv.debug_struc.pprint_llva.print_llva_before)
errs() << "Module before optimization::\n" << *Mod;
#endif
/* Analyze module -- analysis predicates */
analyze_module(Mod);
/* Optimize module -- transform predicates */
optimize_module(Mod);
/* Computing size of optimized module */
{
/* Open file 'tmp.bc' which will be filled by optimized Module */
OwningPtr<tool_output_file> Out;
std::string ErrorInfo;
Out.reset(new tool_output_file("tmp.bc", ErrorInfo, raw_fd_ostream::F_Binary));
if (!ErrorInfo.empty()) {
errs() << ErrorInfo << '\n';
exit(1);
}
/* 'createPrintModulePass(arg)' will print Module (now optimized) to on file represented by 'arg' */
PassManager Pass;
Pass.add(createPrintModulePass(&Out->os()));
Pass.run(*Mod);
/* 'Out->keep()' will keep printed module to file and will close file */
Out->keep();
/* Open file 'tmp.bc' */
int Outtmp = open("tmp.bc", O_CREAT | O_RDWR, 0644);
#if YAP_STAT_PREDS
/* for statistics... compute file size and store value on 'NativeArea->area.native_size_bytes' */
NativeArea->area.native_size_bytes[p->u.jhc.jh->caa.naddress][NativeArea->area.nrecomp[p->u.jhc.jh->caa.naddress]-1] = lseek(Outtmp, 0, SEEK_END);
#endif
close(Outtmp);
remove("tmp.bc");
}
/***/
#if YAP_DBG_PREDS
/* for debug... print module after optimizing it */
if (ExpEnv.debug_struc.pprint_llva.print_llva_after)
errs() << "Module after optimization::\n" << *Mod;
#endif
/*
* verify module correctness *
* predicates: *
* enable_module_correctness/0 *
* enable_module_correctness/1 *
* verify_module_after/0 *
* verify_module_both/0 *
*/
if (ExpEnv.analysis_struc.pointtoverifymodule == AFTER || ExpEnv.analysis_struc.pointtoverifymodule == BOTH) {
if (verifyModule(*Mod)) {
errs() << "ERROR:: Module not built correctly!\n";
exit(1);
}
}
/***/
// MaterializeAllPermanently -- Make sure all GlobalValues in this Module are fully read
if (Mod->MaterializeAllPermanently(&errStr)) {
errs() <<"Error:: bitcode didn't read correctly. -- " << errStr << "\n";
exit(1);
}
/* Creating EngineBuilder -- called 'builder' */
Function *EntryFn;
EngineBuilder builder(Mod);
builder.setErrorStr(&errStr);
builder.setJITMemoryManager(JITMemoryManager::CreateDefaultMemManager());
builder.setEngineKind(EngineKind::JIT);
// codegen predicate 'engine_opt_level/1'
switch(ExpEnv.codegen_struc.struc_enginebuilder.engineoptlevel) {
case 0:
builder.setOptLevel(CodeGenOpt::None);
break;
case 1:
builder.setOptLevel(CodeGenOpt::Less);
break;
case 2:
builder.setOptLevel(CodeGenOpt::Default);
break;
case 3:
builder.setOptLevel(CodeGenOpt::Aggressive);
break;
}
// codegen predicate 'relocmodel/1'
switch(ExpEnv.codegen_struc.struc_enginebuilder.relocmodel) {
case 0:
builder.setRelocationModel(Reloc::Default);
break;
case 1:
builder.setRelocationModel(Reloc::Static);
break;
case 2:
builder.setRelocationModel(Reloc::PIC_);
break;
case 3:
builder.setRelocationModel(Reloc::DynamicNoPIC);
break;
}
// codegen predicate 'codemodel/1'
switch(ExpEnv.codegen_struc.struc_enginebuilder.codemodel) {
case 0:
builder.setCodeModel(CodeModel::Default);
break;
case 1:
builder.setCodeModel(CodeModel::JITDefault);
break;
case 2:
builder.setCodeModel(CodeModel::Small);
break;
case 3:
builder.setCodeModel(CodeModel::Kernel);
break;
case 4:
builder.setCodeModel(CodeModel::Medium);
break;
case 5:
builder.setCodeModel(CodeModel::Large);
break;
}
// codegen predicates 'enable_mcjit/0' or 'disable_mcjit/0'
builder.setUseMCJIT((bool)ExpEnv.codegen_struc.struc_enginebuilder.usemcjit);
llvm::TargetOptions Options;
{
/* codegen predicates 'enable_framepointer_elimination/0' or 'disable_framepointer_elimination/0' */
Options.NoFramePointerElim = (bool)ExpEnv.codegen_struc.struc_targetopt.noframepointerelim;
Options.NoFramePointerElimNonLeaf = (bool)ExpEnv.codegen_struc.struc_targetopt.noframepointerelim;
/***/
// codegen predicates 'less_precise_fp_mad_option/0' or 'more_precise_fp_mad_option/0'
Options.LessPreciseFPMADOption = (bool)ExpEnv.codegen_struc.struc_targetopt.lessprecisefpmadoption;
// codegen predicates 'no_excess_fp_precision/0' or 'excess_fp_precision/0'
Options.NoExcessFPPrecision = (bool)ExpEnv.codegen_struc.struc_targetopt.noexcessfpprecision;
// codegen predicates 'unsafe_fp_math/0' or 'safe_fp_math/0'
Options.UnsafeFPMath = (bool)ExpEnv.codegen_struc.struc_targetopt.unsafefpmath;
// codegen predicates 'rounding_mode_dynamically_changed/0' or 'rounding_mode_not_changed/0'
Options.HonorSignDependentRoundingFPMathOption =
(bool)ExpEnv.codegen_struc.struc_targetopt.honorsigndependentroundingfpmathoption;
// codegen predicates 'no_use_soft_float/0' or 'use_soft_float/0'
Options.UseSoftFloat = (bool)ExpEnv.codegen_struc.struc_targetopt.usesoftfloat;
// codegen predicates 'enable_jit_exception_handling/0' or 'disable_jit_exception_handling/0'
Options.JITExceptionHandling = (bool)ExpEnv.codegen_struc.struc_targetopt.jitexceptionhandling;
// codegen predicates 'enable_jit_emit_debug_info/0' or 'disable_jit_emit_debug_info/0'
Options.JITEmitDebugInfo = (bool)ExpEnv.codegen_struc.struc_targetopt.jitemitdebuginfo;
// codegen predicates 'enable_jit_emit_debug_info_to_disk/0' or 'disable_jit_emit_debug_info_to_disk/0'
Options.JITEmitDebugInfoToDisk = (bool)ExpEnv.codegen_struc.struc_targetopt.jitemitdebuginfotodisk;
// codegen predicates 'guaranteed_tail_call_opt/0' or 'no_guaranteed_tail_call_opt/0'
Options.GuaranteedTailCallOpt = (bool)ExpEnv.codegen_struc.struc_targetopt.guaranteedtailcallopt;
// codegen predicates 'enable_tail_calls/0' or 'disable_tail_calls/0'
Options.DisableTailCalls = (bool)ExpEnv.codegen_struc.struc_targetopt.disabletailcalls;
// codegen predicates 'enable_fast_isel/0' or 'disable_fast_isel/0'
Options.EnableFastISel = (bool)ExpEnv.codegen_struc.struc_targetopt.fastisel;
}
// codegen predicates 'fp_abitype/1' or 'default_fp_abitype/0'
switch(ExpEnv.codegen_struc.struc_targetopt.floatabitype) {
case 0:
Options.FloatABIType = FloatABI::Default;
break;
case 1:
Options.FloatABIType = FloatABI::Soft;
break;
case 2:
Options.FloatABIType = FloatABI::Hard;
break;
}
builder.setTargetOptions(Options);
/***/
/* Creating ExecutionEngine from EngineBuilder (builder) */
ExecutionEngine *EE = builder.create();
if (!EE) {
if (!errStr.empty())
errs() << "Error creating Execution Engine: " << errStr << "\n";
else
errs() << "Unknown error creating Execution Engine!\n";
exit(1);
}
/***/
// 'clause' is our function -- getting it from Module
EntryFn = Mod->getFunction("clause");
if (!EntryFn) {
/*
* Theoretically, every Module is correct, but *
* for some reason, llvm can not compile some of them *
*/
close(Output);
remove(outputfilename);
free(p->u.jhc.jh->tcc.cmd);
free(outputfilename);
return NULL;
}
/* Here, we know that Module was be successfully compiled, so... */
// 1. execute all of the static constructors or destructors for program
EE->runStaticConstructorsDestructors(false);
global++;
close(Output);
remove(outputfilename);
free(p->u.jhc.jh->tcc.cmd);
free(outputfilename);
// 2. get native pointer from 'clause' (our function within Module) and return it
return EE->getPointerToFunction(EntryFn);
}
void* JIT_Compiler::compile(yamop* p) {
/* LLVMContext must be declared here, otherwise LLVM will crash on x86_64 machines */
LLVMContext *Context = new LLVMContext();
return compile_all(Context, p);
}

111
JIT/configure.in Normal file
View File

@ -0,0 +1,111 @@
dnl
dnl JIT CONFIGURATION
dnl
AC_SUBST(JITFLAGS)
AC_SUBST(JITLD)
AC_SUBST(JITLIBS)
AC_SUBST(JITDEBUGPREDS)
AC_SUBST(JITSTATISTICPREDS)
AC_SUBST(JITCOMPILER)
AC_SUBST(JITCONFIGPREDS)
AC_SUBST(JITANALYSISPREDS)
AC_SUBST(JITTRANSFORMPREDS)
AC_SUBST(JITCODEGENPREDS)
AC_SUBST(PAPILIB)
AC_ARG_ENABLE(jit,
[ --enable-jit support just-in-time (JIT) compilation],
yap_jit="$enableval", yap_jit=no)
AC_ARG_ENABLE(debug-predicates,
[ --enable-debug-predicates support debug predicates ],
dbg_preds="$enableval", dbg_preds=no)
AC_ARG_ENABLE(statistic-predicates,
[ --enable-statistic-predicates support statistic predicates ],
stat_preds="$enableval", stat_preds=no)
if test "$yap_jit" = "yes"
then
AC_CHECK_PROG(LLVM, llvm-config, [yes],[no])
if test "$LLVM" = "no" ;then
AC_MSG_ERROR([--enable-jit was given, but test for LLVM 3.1 failed])
else
LLVM_VERSION="`llvm-config --version`"
if test "$LLVM_VERSION" != "3.1";then
AC_MSG_ERROR([Test for LLVM 3.1 failed])
fi
fi
AC_CHECK_PROG(CLANG, clang, [yes],[no])
if test "$CLANG" = "no" ;then
AC_MSG_ERROR([--enable-jit was given, but test for clang faild])
fi
YAP_EXTRAS="$YAP_EXTRAS -DYAP_JIT=1"
JITCOMPILER="JIT_Compiler.o"
JITCONFIGPREDS="jit_configpreds.o"
JITANALYSISPREDS="jit_analysispreds.o"
JITTRANSFORMPREDS="jit_transformpreds.o"
JITCODEGENPREDS="jit_codegenpreds.o"
JITFLAGS="`llvm-config --cxxflags`"
JITLD="`llvm-config --ldflags`"
JITLIBS="`llvm-config --libs all`"
fi
if test "$dbg_preds" = "yes"
then
if test "$yap_jit" = "no"
then
AC_MSG_ERROR([--enable-debug-predicates was given, but --enable-jit was not given])
fi
YAP_EXTRAS="$YAP_EXTRAS -DYAP_DBG_PREDS=1"
JITDEBUGPREDS="jit_debugpreds.o"
fi
if test "$stat_preds" = "yes"
then
if test "$yap_jit" = "no"
then
AC_MSG_ERROR([--enable-statistic-predicates was given, but --enable-jit was not given])
fi
AC_CHECK_HEADER([papi.h],
[],
[if test "$stat_preds" != "no"; then
AC_MSG_ERROR(
[--enable-statistic-predicates was given, but papi.h not found])
fi
])
AC_CHECK_LIB([papi], [PAPI_start],
[if test "$stat_preds" != "no"; then
PAPILIB="-lpapi"
fi
],
[if test "$stat_preds" != "no"; then
AC_MSG_ERROR(
[--enable-statistic-predicates was given, but test for papi failed])
fi
])
YAP_EXTRAS="$YAP_EXTRAS -DYAP_STAT_PREDS=1"
JITSTATISTICPREDS="jit_statisticpreds.o"
PAPILIB="-lpapi"
fi

27
JIT/examples/append.pl Normal file
View File

@ -0,0 +1,27 @@
:- initialization(main).
:- use_module(library(random)).
generate(L, N) :-
generate(L, [], N).
generate(L, L, 0) :- !.
generate(L, X, N) :-
A is N - 1,
random(0, 1000000, B),
generate(L, [B|X], A).
append_([],L,L).
append_([X|L1],L2,[X|L3]) :-
append_(L1,L2,L3).
main :-
unix( argv([H|_]) ), number_atom(N,H),
generate(List, N),
append_(List, [], _),
statistics,
statistics_jit,
halt.

View File

@ -0,0 +1,89 @@
% ----------------------------------------------------------------------
% The Computer Language Benchmarks Game
% http://shootout.alioth.debian.org/
%
% Contributed by Anthony Borla
% Modified to run with YAP by Glendon Holst
% ----------------------------------------------------------------------
:- yap_flag(unknown,error).
:- initialization(main).
main :-
unix( argv([H|_]) ), number_atom(N,H),
MIN_DEPTH is 4, set_limits(N, MIN_DEPTH, MAX_DEPTH, STRETCH_DEPTH),
bottom_up_tree(0, STRETCH_DEPTH, ST),
check_tree(ST, ITS),
format('stretch tree of depth ~w\t check: ~w~n', [STRETCH_DEPTH, ITS]),
bottom_up_tree(0, MAX_DEPTH, LLT),
descend_trees(MIN_DEPTH, MIN_DEPTH, MAX_DEPTH),
check_tree(LLT, ITL),
format('long lived tree of depth ~w\t check: ~w~n', [MAX_DEPTH, ITL]),
statistics,
statistics_jit.
% ------------------------------- %
set_limits(N, MinDepth, MaxDepth, StretchDepth) :-
MinDepth1 is MinDepth + 2,
(MinDepth1 > N -> MaxDepth is MinDepth1 ; MaxDepth is N),
StretchDepth is MaxDepth + 1.
% ------------------------------- %
descend_trees(CurrentDepth, MinDepth, MaxDepth) :-
(
CurrentDepth =< MaxDepth ->
N is integer(2 ** (MaxDepth - CurrentDepth + MinDepth)), Iterations is 2 * N,
sum_trees(N, CurrentDepth, 0, Sum),
format('~w\t trees of depth ~w\t check: ~w~n', [Iterations, CurrentDepth, Sum]),
NewDepth is CurrentDepth + 2, !, descend_trees(NewDepth, MinDepth, MaxDepth)
;
true
).
% ------------- %
sum_trees(0, _, AccSum, AccSum) :- !.
sum_trees(N, CurrentDepth, AccSum, Sum) :-
bottom_up_tree(N, CurrentDepth, TreeLeft),
Nneg is -1 * N, bottom_up_tree(Nneg, CurrentDepth, TreeRight),
check_tree(TreeLeft, ItemLeft), check_tree(TreeRight, ItemRight),
AccSum1 is AccSum + ItemLeft + ItemRight,
N1 is N - 1, !, sum_trees(N1, CurrentDepth, AccSum1, Sum).
% ------------------------------- %
make_tree(Item, Left, Right, tree(Item, Left, Right)).
% ------------- %
bottom_up_tree(Item, 0, tree(Item, nil, nil)) :- !.
bottom_up_tree(Item, Depth, Tree) :-
ItemLeft is 2 * Item - 1, DepthLeft is Depth - 1,
bottom_up_tree(ItemLeft, DepthLeft, TreeLeft),
ItemRight is 2 * Item, DepthRight is Depth - 1,
bottom_up_tree(ItemRight, DepthRight, TreeRight),
make_tree(Item, TreeLeft, TreeRight, Tree).
% ------------- %
check_tree(tree(Item, nil, _), Item) :- !.
check_tree(tree(Item, _, nil), Item) :- !.
check_tree(tree(Item, Left, Right), ItemNew) :-
check_tree(Left, ItemLeft),
check_tree(Right, ItemRight),
ItemNew is Item + ItemLeft - ItemRight.
% ------------------------------- %

108
JIT/examples/fannkuch.pl Normal file
View File

@ -0,0 +1,108 @@
% ----------------------------------------------------------------------
% The Computer Language Benchmarks Game
% http://shootout.alioth.debian.org/
% Contributed by Anthony Borla
% Modified by Glendon Holst
% ----------------------------------------------------------------------
:- yap_flag(unknown,error).
:- use_module(library(lists)).
:- initialization(main).
main :-
unix( argv([H|_]) ), number_atom(N,H),
f_permutations(N, MaxFlips),
format('Pfannkuchen(~d) = ~d~n', [N, MaxFlips]),
statistics,
statistics_jit.
% ------------------------------- %
f_permutations(N, MaxFlips) :-
numlist(1, N, L),
f_permutations_(L, N, 0, 0, MaxFlips, 0, _).
% ------------- %
f_permutations_(L, N, I, MaxFlips0, MaxFlips, PermN0, PermN) :-
(I < N ->
(
N =:= 1 ->
!, processPerm(L, MaxFlips0, MaxFlips, PermN0, PermN)
;
N1 is N - 1,
f_permutations_(L, N1, 0, MaxFlips0, MaxFlips1, PermN0, PermN1),
split_list(L, N, Lt, Ld),
rotateLeft(Lt, LtRL), append(LtRL, Ld, La), Ii is I + 1,
!, f_permutations_(La, N, Ii, MaxFlips1, MaxFlips, PermN1, PermN)
)
;
!, MaxFlips = MaxFlips0, PermN = PermN0
).
% ------------------------------- %
flips(L, Flips) :- flips_(L, 0, Flips).
flips_([1|_], Fla, Fla) :- !.
flips_([N|T], Fla, Flips) :-
take_drop([N|T], N, Lt, Ld), append(Lt, Ld, La),
Fla1 is Fla + 1, !, flips_(La, Fla1, Flips).
% ------------------------------- %
rotateLeft([H|T], RL) :- append(T, [H], RL).
rotateLeft([], []).
% ------------------------------- %
numlist(N, M, [N|Ls]) :- N < M, !, N1 is N + 1, numlist(N1, M, Ls).
numlist(M, M, [M]).
% ------------------------------- %
printPerm([L|Ls]) :- write(L), printPerm(Ls).
printPerm([]) :- nl.
% ------------------------------- %
processPerm(L, MaxFlips0, MaxFlips, PermN0, PermN) :-
flips(L, Flips),
(
Flips > MaxFlips0 ->
MaxFlips = Flips
;
MaxFlips = MaxFlips0
),
(
PermN0 < 30 ->
printPerm(L),
PermN is PermN0 + 1
;
PermN = PermN0
).
% ------------------------------- %
split_list([L|Ls], N, [L|Hs], Ts) :-
N > 0, !, N1 is N - 1,
split_list(Ls, N1, Hs, Ts).
split_list(Ls, 0, [], Ls) :- !.
% ------------------------------- %
take_drop(L, N, Taken, Rest) :- take_drop_(L, N, 0, [], Taken, Rest).
take_drop_(L, N, N, Ta, Ta, L) :- !.
take_drop_([H|T], N, Nc, Ta, Taken, Rest) :-
Nc1 is Nc + 1, !, take_drop_(T, N, Nc1, [H|Ta], Taken, Rest).
% ------------------------------- %

130
JIT/examples/fasta.pl Normal file
View File

@ -0,0 +1,130 @@
% ----------------------------------------------------------------------
% The Computer Language Benchmarks Game
% http://shootout.alioth.debian.org/
% Contributed by Anthony Borla
% Modified to run with YAP by Glendon Holst
% ----------------------------------------------------------------------
:- yap_flag(unknown,error).
:- initialization(main).
main :-
unix( argv([H|_]) ), number_atom(N,H),
init_fasta(ALU, IUB, HOMOSAPIENS, RAND0),
N1 is N * 2,
N2 is N * 3,
N3 is N * 5,
repeat_fasta('ONE', 'Homo sapiens alu', N1, ALU),
make_cumulative(IUB, CVIUB),
random_fasta('TWO', 'IUB ambiguity codes', N2, CVIUB, RAND0, RAND1),
make_cumulative(HOMOSAPIENS, CVHOMOSAPIENS),
random_fasta('THREE', 'Homo sapiens frequency', N3, CVHOMOSAPIENS, RAND1, RAND),
statistics,
statistics_jit.
% ------------------------------- %
init_fasta(ALU, IUB, HOMOSAP, RAND) :-
ALU = 'GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAA',
IUB = [a:0.27, c:0.12, g:0.12, t:0.27,
'B':0.02, 'D':0.02, 'H':0.02, 'K':0.02, 'M':0.02,
'N':0.02, 'R':0.02, 'S':0.02, 'V':0.02, 'W':0.02, 'Y':0.02],
HOMOSAP = [a:0.3029549426680, c:0.1979883004921,
g:0.1975473066391, t:0.3015094502008],
init_gen_random(42, RAND).
% ------------------------------- %
repeat_fasta(Id, Desc, N, ALU) :-
LineLength = 60,
atom_length(ALU, ALULength),
write('>'), write(Id), tab(1), write(Desc), nl,
repeat_fasta_(N, 0, LineLength, ALU, ALULength).
% ------------- %
repeat_fasta_(N, _, _, _, _) :- N =< 0, !.
repeat_fasta_(N, Q, L, ALU, ALULength) :-
(N < L -> L1 = N ; L1 = L),
(L1 + Q < ALULength ->
sub_atom(ALU, Q, L1, Lineout), Q1 is L1 + Q,
write(Lineout), nl
;
Rest is ALULength - Q, sub_atom(ALU, Q, Rest, Prefix),
atom_length(Prefix, PrefixLength), Q1 is L1 - PrefixLength,
sub_atom(ALU, 0, Q1, Segment),
write(Prefix), write(Segment), nl),
N1 is N - L1, !, repeat_fasta_(N1, Q1, L1, ALU, ALULength).
% ------------------------------- %
random_fasta(Id, Desc, N, CumTbl, RAND0, RAND) :-
LineLength = 60,
write('>'), write(Id), tab(1), write(Desc), nl,
random_fasta_(N, LineLength, CumTbl, RAND0, RAND).
% ------------- %
random_fasta_(N, _, _, RAND, RAND) :- N =< 0, !.
random_fasta_(N, L, CumTbl, RAND0, RAND) :-
(N < L -> L1 = N ; L1 = L),
gen_line(L1, CumTbl, Codesout, RAND0, RAND1),
atom_chars(Lineout, Codesout), write(Lineout), nl,
N1 is N - L1, !, random_fasta_(N1, L1, CumTbl, RAND1, RAND).
% ------------- %
gen_line(0, _, [], RAND, RAND).
gen_line(N, CumTbl, K, RAND0, RAND) :-
select_random(CumTbl, C, RAND0, RAND1),
char_code(C, C1), K = [C1|T1], N1 is N - 1, !,
gen_line(N1, CumTbl, T1, RAND1, RAND).
% ------------------------------- %
make_cumulative(L, RL) :- make_cumulative_(L, RL, 0).
make_cumulative_([], [], _) :- !.
make_cumulative_([K:V|T], L, CV) :-
CV1 is CV + V, L = [K:CV1|T1], !, make_cumulative_(T, T1, CV1).
% ------------- %
select_random(L, RK, RAND0, RAND) :-
gen_random(1.0, R, RAND0, RAND),
select_random_(L, R, RK).
select_random_([], _, _) :- !.
select_random_([K:V|T], R, RK) :-
(R < V -> RK = K ; !, select_random_(T, R, RK)).
% ------------------------------- %
init_gen_random(Seed, [3877, 29573, 139968, Seed]).
% ------------- %
gen_random(UB, R, RAND0, RAND) :-
RAND0 = [IA, IC, IM, LAST],
LAST1 is (LAST * IA + IC) mod IM,
RAND = [IA, IC, IM, LAST1],
R is UB * LAST1 / IM.
% ------------------------------- %
% BUG FIX - sub_atom/5 errors out if Size = 0.
sub_atom(_,_,0,'') :- !.
sub_atom(A,Bef,Size,Aout) :- sub_atom(A,Bef,Size,_,Aout).

16
JIT/examples/hanoi.pl Normal file
View File

@ -0,0 +1,16 @@
:- initialization(main).
han(N,_,_,_) :- N =< 0.
han(N,A,B,C) :- N > 0,
N1 is N-1,
han(N1,A,C,B),
han(N1,C,B,A).
main :-
unix( argv([H|_]) ),
number_atom(N,H),
han(N,4,5,6),
statistics,
statistics_jit.

View File

@ -0,0 +1,172 @@
% ----------------------------------------------------------------------
% The Computer Language Benchmarks Game
% http://shootout.alioth.debian.org/
%
% contributed by Anthony Borla
% modified to run with YAP by Glendon Holst
% ----------------------------------------------------------------------
:- yap_flag(unknown,error).
:- use_module(library(readutil)).
:- use_module(library(lists)).
:- use_module(library(assoc)).
:- initialization(main).
main :-
current_input(Cin),
load_sequence(Cin, Seq),
FragmentLengths = [1, 2],
forall(member(E, FragmentLengths), (print_frequencies(Seq, E), nl)),
Fragments = ["GGT", "GGTA", "GGTATT", "GGTATTTTAATT", "GGTATTTTAATTTATAGT"],
forall(member(E, Fragments), print_count(Seq, E)),
statistics,
statistics_jit.
% ------------------------------- %
print_frequencies(Seq, KeyLen) :-
generate_counts(Seq, KeyLen, CountTable),
sum_counts_(CountTable, 0, SumCounts),
make_freq_table_(CountTable, SumCounts, [], FTable),
keysort(FTable, SFTable), reverse(SFTable, FreqTable),
print_freq_table_(FreqTable).
% ------------- %
sum_counts_([_-C|T], Acc, Sum) :- Acc1 is Acc + C, !, sum_counts_(T, Acc1, Sum).
sum_counts_([], Acc, Acc).
% ------------- %
make_freq_table_([K-C|T], SumCounts, FTA, FreqTable) :-
F is C / SumCounts * 100.0, append([F-K], FTA, FTA1),
!, make_freq_table_(T, SumCounts, FTA1, FreqTable).
make_freq_table_([], _, FTA, FTA).
% ------------- %
print_freq_table_([F-K|T]) :-
format('~w ~3f\n', [K, F]),
!, print_freq_table_(T).
print_freq_table_([]).
% ------------------------------- %
print_count(Seq, Fragment) :-
length(Fragment, FragLen),
generate_counts(Seq, FragLen, CountTable),
atom_codes(FragKey, Fragment),
(
select(FragKey-Count, CountTable, _)
;
Count = 0
), !,
format('~d\t~s\n', [Count, Fragment]).
% ------------- %
generate_counts(Seq, Length, CountTable) :-
length(Seq, SeqLen), Last is SeqLen - Length + 1,
make_count_table(Length, Last, Seq, CountTable).
% ------------------------------- %
make_count_table(Length, Last, Seq, CountTable) :-
empty_assoc(A),
mct_i_loop_(0, Length, Last, Seq, A, ACT),
assoc_to_list(ACT, CountTable).
% ------------- %
mct_i_loop_(I, Length, Last, Seq, CTA, CountTable) :-
I < Length, !,
mct_j_loop_(Last, Length, Seq, CTA, CTA1),
I1 is I + 1, !,
Seq = [_|Ss], Last1 is Last - 1,
mct_i_loop_(I1, Length, Last1, Ss, CTA1, CountTable).
mct_i_loop_(Length, Length, _, _, CTA, CTA).
% ------------- %
mct_j_loop_(Last, Length, Seq, CTA, CountTable) :-
Last > 0, !,
sub_list_(Seq, Length, KeyString, Rest), atom_codes(Key, KeyString),
(
get_assoc(Key, CTA, Value) ->
V1 is Value + 1, put_assoc(Key, CTA, V1, CTA1)
;
put_assoc(Key, CTA, 1, CTA1)
),
!, Last1 is Last - Length,
mct_j_loop_(Last1, Length, Rest, CTA1, CountTable).
mct_j_loop_(Last, _, _, CTA, CTA) :- Last =< 0, !.
% ------------------------------- %
load_sequence(S, Seq) :- load_sequence_(S, fail, "", Seq).
% ------------- %
load_sequence_(S, Loading, Seq, RetSeq) :-
catch(read_line_to_codes(S, L), _, fail), is_list(L), !,
(
Loading ->
process_sequence(L, S, Seq, RetSeq)
;
ignore_sequence(L, S, Seq, RetSeq)
).
load_sequence_(S, _, Seq, Seq).
% ------------- %
ignore_sequence([62,84,72,82,69,69|_], S, Seq, RetSeq) :- !,
load_sequence_(S, true, Seq, RetSeq).
ignore_sequence(_, S, Seq, RetSeq) :- !,
load_sequence_(S, fail, Seq, RetSeq).
process_sequence([62|_], _, Seq, Seq) :- !.
process_sequence([59|_], S, Seq, RetSeq) :- !,
load_sequence_(S, true, Seq, RetSeq).
process_sequence(L, S, Seq, RetSeq) :-
to_upper(L, UL),
append(Seq, UL, NewSeq),
!, load_sequence_(S, true, NewSeq, RetSeq).
% ------------------------------- %
to_upper(L, U) :- to_upper_(L, [], U).
% ------------- %
to_upper_([], UA, U) :- reverse(UA, U), !.
to_upper_([C|T], UA, U) :-
is_lower(C), C1 is C - 32,
!, to_upper_(T, [C1|UA], U).
to_upper_([C|T], UA, U) :-
!, to_upper_(T, [C|UA], U).
% ------------- %
is_lower(C) :- C >= 97, C =< 122.
% ------------------------------- %
forall(Gen, Proc) :- findall(_,(Gen, Proc), _).
% ------------- %
sub_list_([S|Seq], L, [S|Ks], Rs) :- L > 0, !,
L1 is L - 1,
sub_list_(Seq, L1, Ks, Rs).
sub_list_(Rs, 0, [], Rs).
% ------------------------------- %

107
JIT/examples/mandelbrot.pl Normal file
View File

@ -0,0 +1,107 @@
0% ----------------------------------------------------------------------
% The Computer Language Benchmarks Game
% http://shootout.alioth.debian.org/
% Modified to run with YAP by Glendon Holst
% ----------------------------------------------------------------------
:- yap_flag(unknown,error).
:- initialization(main).
main :-
unix( argv([H|_]) ), number_atom(Height,H), Width = Height,
format('P4~N~d ~d~N',[Height, Width]),
pointsY(Height, Width, 0, 0, 0, 0, 0),
statistics,
statistics_jit.
% ------------------------------- %
pointsY(Height, Width, Y, X,
OUTFLAG0,
BYTEOUT0,
BITN0) :-
Y1 is Y + 1, Height >= Y1, !,
pointsX(Height, Width, Y, 0,
OUTFLAG0, OUTFLAG,
BYTEOUT0, BYTEOUT,
BITN0, BITN),
pointsY(Height, Width, Y1, X,
OUTFLAG,
BYTEOUT,
BITN).
pointsY(_, _, _, _, _, _, _) :- !.
% ------------- %
pointsX(Height, Width, Y, X,
OUTFLAG0, OUTFLAG,
BYTEOUT0, BYTEOUT,
BITN0, BITN) :-
X1 is X + 1, Width >= X1, !,
(mandel(Height, Width, Y, X, 50) -> LimitAdj = 0 ; LimitAdj = 1),
BITN1 is BITN0 + 1,
(BITN1 == 8 -> OUTFLAG1 = 1 ; OUTFLAG1 = OUTFLAG0),
BYTEOUT1 is BYTEOUT0 * 2 + LimitAdj,
(
(Width == X1, BITN1 \== 8) ->
(BYTEOUT2 is BYTEOUT1 * integer(2 ** (8 - Width mod 8)), OUTFLAG2 = 1)
;
(BYTEOUT2 = BYTEOUT1, OUTFLAG2 = OUTFLAG1)
),
output(OUTFLAG2, OUTFLAG3, BYTEOUT2, BYTEOUT3, BITN1, BITN2),
pointsX(Height, Width, Y, X1,
OUTFLAG3, OUTFLAG,
BYTEOUT3, BYTEOUT,
BITN2, BITN).
pointsX(_, _, _, _, OUTFLAG, OUTFLAG, BYTEOUT, BYTEOUT, BITN, BITN) :- !.
% ------------- %
mandel(Height, Width, Y, X, Repetitions) :-
Cr is (2.0 * X / Width - 1.5), Ci is (2.0 * Y / Height - 1.0),
mandel_(Cr, Ci, 0.0, 0.0, Repetitions, 0).
mandel_(_, _, Zr, Zi, Repetitions, Repetitions) :- !,
Limit is Zr * Zr + Zi * Zi, Limit > 4.0.
mandel_(Cr, Ci, Zr, Zi, Repetitions, N) :-
Zr1 is Zr * Zr - Zi * Zi + Cr,
Zi1 is 2.0 * Zr * Zi + Ci,
Limit is Zr1 * Zr1 + Zi1 * Zi1,
Limit =< 4.0, N1 is N + 1, !,
mandel_(Cr, Ci, Zr1, Zi1, Repetitions, N1).
mandel_(_, _, _, _, _, _) :- !.
% ------------- %
output(OUTFLAG0, OUTFLAG, BYTEOUT0, BYTEOUT, BITN0, BITN) :-
(
OUTFLAG0 =:= 1 ->
(
put_byte(BYTEOUT0),
BITN = 0,
BYTEOUT = 0,
OUTFLAG = 0
)
;
(
BYTEOUT = BYTEOUT0,
BITN = BITN0,
OUTFLAG = OUTFLAG0
)
).
% ------------------------------- %

145
JIT/examples/n-body.pl Normal file
View File

@ -0,0 +1,145 @@
% ----------------------------------------------------------------------
% The Computer Language Benchmarks Game
% http://shootout.alioth.debian.org/
% Contributed by Anthony Borla
% Modified to run with YAP by Glendon Holst
% ----------------------------------------------------------------------
:- yap_flag(unknown,error).
:- initialization(main).
main :-
unix( argv([H|_]) ), number_atom(N,H),
make_bodies(Bodies0),
energy(Bodies0, EnergyStart),
loop_advance(N, 0.01, Bodies0, Bodies),
energy(Bodies, EnergyAfter),
format('~9f~N~9f~N', [EnergyStart, EnergyAfter]),
statistics,
statistics_jit.
% ------------------------------- %
energy(Bodies, Energy) :- energy_(Bodies, 0.0, Energy).
energy_([ _:B | Bs], Energy0, Energy) :-
!, B = [_X, _Y, _Z, VX, VY, VZ, Mass],
Energy1 is Energy0 + 0.5 * Mass * (VX * VX + VY * VY + VZ * VZ),
energy_diff_(B, Bs, Energy1, Energy2),
energy_(Bs, Energy2, Energy).
energy_([], Energy, Energy).
energy_diff_(Planet, [_:B | Bs], Energy0, Energy) :-
Planet = [X, Y, Z, _VX, _VY, _VZ, Mass],
B = [XT, YT, ZT, _VXT, _VYT, _VZT, MassT],
DX is X - XT, DY is Y - YT, DZ is Z - ZT,
DISTANCE is sqrt(DX * DX + DY * DY + DZ * DZ),
Energy1 is Energy0 - (Mass * MassT) / DISTANCE,
energy_diff_(Planet, Bs, Energy1, Energy).
energy_diff_(_, [], Energy, Energy).
% ------------------------------- %
loop_advance(N, Dt, Bodies0, Bodies) :-
N > 0, !,
advance(Dt, Bodies0, Bodies1),
N1 is N - 1,
loop_advance(N1, Dt, Bodies1, Bodies).
loop_advance(_, _, Bodies, Bodies).
advance(Dt, Bodies0, Bodies) :-
Bodies0 = [B0 | B0s], !,
advance_(Dt, B0, B1, B0s, B1s),
advance(Dt, B1s, Bs),
B1 = E:[X, Y, Z, VX, VY, VZ, Mass],
X1 is X + Dt * VX,
Y1 is Y + Dt * VY,
Z1 is Z + Dt * VZ,
B = E:[X1, Y1, Z1, VX, VY, VZ, Mass],
Bodies = [ B | Bs].
advance(_, Bodies, Bodies).
advance_(Dt, Planet0, Planet, Bodies0, Bodies) :-
Bodies0 = [B0 | B0s], !,
Planet0 = E:[X, Y, Z, VX, VY, VZ, Mass],
B0 = ET:[XT, YT, ZT, VXT, VYT, VZT, MassT],
DX is X - XT, DY is Y - YT, DZ is Z - ZT,
DISTANCE is sqrt(DX * DX + DY * DY + DZ * DZ),
Mag is Dt / (DISTANCE * DISTANCE * DISTANCE),
VX1 is VX - DX * MassT * Mag,
VY1 is VY - DY * MassT * Mag,
VZ1 is VZ - DZ * MassT * Mag,
VXT1 is VXT + DX * Mass * Mag,
VYT1 is VYT + DY * Mass * Mag,
VZT1 is VZT + DZ * Mass * Mag,
Planet3 = E:[X, Y, Z, VX1, VY1, VZ1, Mass],
advance_(Dt, Planet3, Planet, B0s, Bs),
B = ET:[XT, YT, ZT, VXT1, VYT1, VZT1, MassT],
Bodies = [B | Bs].
advance_(_, P, P, Bs, Bs).
% ------------------------------- %
make_bodies(Bodies) :-
SOLAR_MASS = 3.9478417604357432000e+01,
Bodies0 =
[
jupiter:[4.84143144246472090e+00, -1.16032004402742839e+00,
-1.03622044471123109e-01, 6.06326392995832020e-01,
2.811986844916260200e+00, -2.5218361659887636e-02,
3.7693674870389486e-02],
saturn:[8.34336671824457987e+00, 4.12479856412430479e+00,
-4.03523417114321381e-01, -1.010774346178792400e+00,
1.825662371230411900e+00, 8.415761376584154e-03,
1.1286326131968767e-02],
uranus:[1.28943695621391310e+01, -1.51111514016986312e+01,
-2.23307578892655734e-01, 1.082791006441535600e+00,
8.68713018169607890e-01, -1.0832637401363636e-02,
1.723724057059711e-03],
neptune:[1.53796971148509165e+01, -2.59193146099879641e+01,
1.79258772950371181e-01, 9.79090732243897980e-01,
5.94698998647676060e-01, -3.4755955504078104e-02,
2.033686869924631e-03]
],
Sun0 = sun:[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, SOLAR_MASS],
offset_momentum(Sun0, Sun, Bodies0, SOLAR_MASS),
Bodies = [Sun | Bodies0].
% ------------- %
offset_momentum(Sun0, Sun, Bodies, SOLAR_MASS) :-
offset_momentum_(Bodies, [0.0, 0.0, 0.0], [PX, PY, PZ]),
Sun0 = E:[X, Y, Z, VX, VY, VZ, Mass],
VX1 is -(PX / SOLAR_MASS),
VY1 is -(PY / SOLAR_MASS),
VZ1 is -(PZ / SOLAR_MASS),
Sun = E:[X, Y, Z, VX1, VY1, VZ1, Mass].
offset_momentum_([_:E|Bs], Pt0, Pt) :-
E = [_X, _Y, _Z, VX, VY, VZ, Mass],
Pt0 = [PX, PY, PZ],
PX1 is PX + VX * Mass,
PY1 is PY + VY * Mass,
PZ1 is PZ + VZ * Mass,
offset_momentum_(Bs, [PX1, PY1, PZ1], Pt).
offset_momentum_([], Pt, Pt).
% ------------------------------- %

4014
JIT/examples/nreverse.pl Normal file

File diff suppressed because it is too large Load Diff

89
JIT/examples/nsieve.pl Normal file
View File

@ -0,0 +1,89 @@
% ----------------------------------------------------------------------
% The Computer Language Benchmarks Game
% http://shootout.alioth.debian.org/
%
% This is a slightly-modified version of the exising nsieve implementation
% differing only in the mechanism used to mimic array creation and
% access. This version [when compared to existing version]:
%
% * Makes only modest demands of the global stack, so should execute using
% default values, at least up to a load of N = 9. However, its heap
% memory demands make it prone to thrashing [existing version is more
% stable as long as a sufficiently large stack size is specified]
%
% * Execution times are on par at up to N = 6, then diverge quite
% dramatically [e.g. at N = 8 this version is roughly twice as fast as
% existing version]
%
% Contributed by Anthony Borla
% Modified to run with YAP by Glendon Holst
% ----------------------------------------------------------------------
:- yap_flag(unknown,error).
:- initialization(main).
main :-
unix( argv([H|_]) ), number_atom(N,H),
N1 is 10000 << N,
N2 is 10000 << (N - 1),
N3 is 10000 << (N - 2),
calcAndshowSieve(N1),
calcAndshowSieve(N2),
calcAndshowSieve(N3),
statistics,
statistics_jit.
% ------------------------------- %
calcAndshowSieve(N) :-
make_array(N, 1),
nsieve(2, N, 0, R),
format('Primes up to~t~w~21|~t~w~30|~n', [N, R]).
% ------------------------------- %
nsieve(ASize, ASize, R, R) :- !.
nsieve(N, ASize, A, R) :-
(
is_slot(N) ->
clear_sieve(N, N, ASize), A1 is A + 1
;
A1 is A
),
N1 is N + 1, !,
nsieve(N1, ASize, A1, R).
% ------------- %
clear_sieve(N, M, ASize) :-
N1 is N + M, clear_sieve_(N1, M, ASize).
% ------------- %
clear_sieve_(N, _, ASize) :- ASize < N, !.
clear_sieve_(N, M, ASize) :-
clear_slot(N),
N1 is N + M, !, clear_sieve_(N1, M, ASize).
% ------------------------------- %
make_array(N, V) :- fill_array(N, V).
% ------------- %
fill_array(0, _) :- !.
fill_array(N, V) :- bb_put(N, V), N1 is N - 1, !, fill_array(N1, V).
% ------------- %
set_slot(N) :- bb_put(N, 1).
clear_slot(N) :- bb_put(N, 0).
is_slot(N) :- bb_get(N, 1).
% ------------------------------- %

109
JIT/examples/nsieve_bits.pl Normal file
View File

@ -0,0 +1,109 @@
% ----------------------------------------------------------------------
% The Computer Language Benchmarks Game
% http://shootout.alioth.debian.org/
%
% This is a modified version of the orignal 'nsieve.swiprolog'
% submission. Whilst that particular implementation made quite heavy
% demands of the global stack [owing to the creation of a very large
% array], the current version:
%
% * Requires an array approximately 1/32 the size since each array slot
% stores 32 encoded values [as opposed to a single value]
%
% * As expected, utilises bit twiddling for encoding / decoding values
%
% In short, while memory use is curbed, runtime suffers [a trading of
% speed for a saving in space as they say]. At a value of N = 9 runtime
% *should* be within the timeout period, but probably not by much
%
% Contributed by Anthony Borla
% Modified to run with YAP by Glendon Holst
% ----------------------------------------------------------------------
:- yap_flag(unknown,error).
:- initialization(main).
main :-
unix( argv([H|_]) ), number_atom(N,H),
N1 is 10000 << N,
N2 is 10000 << (N - 1),
N3 is 10000 << (N - 2),
calcAndshowSieve(N1),
calcAndshowSieve(N2),
calcAndshowSieve(N3),
statistics,
statistics_jit.
% ------------------------------- %
calcAndshowSieve(N) :-
make_array(ns, N, 0xffffffff, Array),
nsieve(2, Array, N, 0, R),
format('Primes up to~t~w~21|~t~w~30|~n', [N, R]).
% ------------------------------- %
nsieve(ASize, _, ASize, R, R) :- !.
nsieve(N, Array, ASize, A, R) :-
(
is_arg(N, Array) ->
clear_sieve(N, N, Array, ASize), A1 is A + 1
;
A1 is A
),
N1 is N + 1, !,
nsieve(N1, Array, ASize, A1, R).
% ------------- %
clear_sieve(N, M, Array, ASize) :-
N1 is N + M, clear_sieve_(N1, M, Array, ASize).
% ------------- %
clear_sieve_(N, _, _, ASize) :- ASize < N, !.
clear_sieve_(N, M, Array, ASize) :-
clear_arg(N, Array),
N1 is N + M, !, clear_sieve_(N1, M, Array, ASize).
% ------------------------------- %
array_slots(N, Slots) :- Slots is ((N + 15) >> 4) + 1.
% ------------- %
make_array(Name, N, V, Array) :-
array_slots(N, Slots),
functor(Array, Name, Slots),
fill_array(Slots, V, Array).
% ------------- %
fill_array(0, _, _) :- !.
fill_array(N, V, Array) :-
setarg(N, Array, V), N1 is N - 1, !,
fill_array(N1, V, Array).
% ------------- %
clear_arg(N, Array) :-
Idx is (N >> 4) + 1, Value is (1 << (N /\ 15)),
arg(Idx, Array, OldValue),
Complement is \ Value,
NewValue is OldValue /\ Complement,
setarg(Idx, Array, NewValue).
is_arg(N, Array) :-
Idx is (N >> 4) + 1, Value is 1 << (N /\ 15),
arg(Idx, Array, OldValue),
CurrentValue is OldValue /\ Value,
CurrentValue =\= 0.
% ------------------------------- %

View File

@ -0,0 +1,66 @@
% ----------------------------------------------------------------------
% The Computer Language Benchmarks Game
% http://shootout.alioth.debian.org/
%
% Based on D language implementation by David Fladebo
% Contributed by Anthony Borla
% Modified to run with YAP by Glendon Holst
% ----------------------------------------------------------------------
:- yap_flag(unknown,error).
:- initialization(main).
main :-
unix( argv([H|_]) ), number_atom(N,H),
compute_sums(N, SUMS),
print_sums(SUMS),
statistics,
statistics_jit.
% ------------------------------- %
compute_sums(N, SUMS) :-
SUMS0 = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
compute_sums_(1.0, N, 1.0, SUMS0, SUMS).
% ------------- %
compute_sums_(D, N, _, SUMS, SUMS) :- D > N, !.
compute_sums_(D, N, ALT, SUMS0, SUMS) :-
SUMS0 = [A1, A2, A3, A4, A5, A6, A7, A8, A9],
D2 is D * D, D3 is D2 * D, DS is sin(D), DC is cos(D),
A1N is A1 + (2 / 3.0) ** (D - 1.0),
A2N is A2 + 1 / sqrt(D),
A3N is A3 + 1 / (D * (D + 1)),
A4N is A4 + 1 / (D3 * DS * DS),
A5N is A5 + 1 / (D3 * DC * DC),
A6N is A6 + 1 / D,
A7N is A7 + 1 / (D2),
A8N is A8 + ALT / D,
A9N is A9 + ALT / (2 * D - 1),
SUMS1 = [A1N, A2N, A3N, A4N, A5N, A6N, A7N, A8N, A9N],
DN is D + 1.0, ALTN is -ALT, !,
compute_sums_(DN, N, ALTN, SUMS1, SUMS).
% ------------------------------- %
print_sums(SUMS) :-
SUMS = [A1, A2, A3, A4, A5, A6, A7, A8, A9],
format('~9f\t~w\n', [A1, '(2/3)^k']),
format('~9f\t~w\n', [A2, 'k^-0.5']),
format('~9f\t~w\n', [A3, '1/k(k+1)']),
format('~9f\t~w\n', [A4, 'Flint Hills']),
format('~9f\t~w\n', [A5, 'Cookson Hills']),
format('~9f\t~w\n', [A6, 'Harmonic']),
format('~9f\t~w\n', [A7, 'Riemann Zeta']),
format('~9f\t~w\n', [A8, 'Alternating Harmonic']),
format('~9f\t~w\n', [A9, 'Gregory']).
% ------------------------------- %

57
JIT/examples/pidigits.pl Normal file
View File

@ -0,0 +1,57 @@
% ----------------------------------------------------------------------
% The Computer Language Benchmarks Game
% http://shootout.alioth.debian.org/
% Contributed by Anthony Borla
% Modified to run with YAP by Glendon Holst
% ----------------------------------------------------------------------
:- yap_flag(unknown,error).
:- initialization(main).
main :-
transform_level(3),
unix( argv([H|_]) ), number_atom(N,H),
pidigits(N),
statistics,
statistics_jit.
% ------------------------------- %
pidigits(N) :- pidigits_(1, [1, 0, 0, 1], N, 0, 0).
% ------------- %
pidigits_(K, Z, N, Row, Col) :-
(N > 0 ->
next(Z, Y), safe(Z, Y, IsSafe),
(IsSafe ->
prod(Z, Y, RL), N1 is N - 1,
(Col =:= 10 ->
Cf is 1, Rf is 10 + Row, format('\t:~w\n~w', [Rf, Y])
;
Cf is 1 + Col, Rf is Row, format('~w', [Y])),
!, pidigits_(K, RL, N1, Rf, Cf)
;
cons(Z, K, RL), K1 is K + 1,
!, pidigits_(K1, RL, N, Row, Col))
;
NS is 10 - Col, tab(NS), RC is Row + Col, format('\t:~w\n', [RC])).
% ------------- %
next([Q, R, S, T], RV) :- RV is (3 * Q + R) // (3 * S + T).
safe([Q, R, S, T], N, RV) :-
V is ((4 * Q + R) // (4 * S + T)), (V =:= N -> RV = true ; RV = fail).
comp([Q1, R1, S1, T1], [Q2, R2, S2, T2], [QO, RO, SO, TO]) :-
QO is Q1 * Q2 + R1 * S2, RO is Q1 * R2 + R1 * T2,
SO is S1 * Q2 + T1 * S2, TO is S1 * R2 + T1 * T2.
prod(Z, N, RL) :- A2 is -10 * N, comp([10, A2, 0, 1], Z, RL).
cons(Z, K, RL) :- A2 is 4 * K + 2, A4 is 2 * K + 1, comp(Z, [K, A2, 0, A4], RL).
% ------------------------------- %

87
JIT/examples/query.pl Normal file
View File

@ -0,0 +1,87 @@
% generated: 17 November 1989
% option(s): SOURCE_TRANSFORM_1
%
% query
%
% David H. D. Warren
%
% query population and area database to find coun-
% tries of approximately equal population density
q:- statistics(runtime,[S|_]),
query,
statistics(runtime,[S1|_]), Y is S1-S,
write('time : '), write(Y), nl,
true.
test :- query.
query :- query(_), fail.
query.
query([C1,D1,C2,D2]) :-
density(C1,D1),
density(C2,D2),
D1 > D2,
T1 is 20*D1,
T2 is 21*D2,
T1 < T2.
density(C,D) :-
pop(C,P),
area(C,A),
D is (P*100)//A.
% populations in 100000's
pop(china, 8250).
pop(india, 5863).
pop(ussr, 2521).
pop(usa, 2119).
pop(indonesia, 1276).
pop(japan, 1097).
pop(brazil, 1042).
pop(bangladesh, 750).
pop(pakistan, 682).
pop(w_germany, 620).
pop(nigeria, 613).
pop(mexico, 581).
pop(uk, 559).
pop(italy, 554).
pop(france, 525).
pop(philippines, 415).
pop(thailand, 410).
pop(turkey, 383).
pop(egypt, 364).
pop(spain, 352).
pop(poland, 337).
pop(s_korea, 335).
pop(iran, 320).
pop(ethiopia, 272).
pop(argentina, 251).
% areas in 1000's of square miles
area(china, 3380).
area(india, 1139).
area(ussr, 8708).
area(usa, 3609).
area(indonesia, 570).
area(japan, 148).
area(brazil, 3288).
area(bangladesh, 55).
area(pakistan, 311).
area(w_germany, 96).
area(nigeria, 373).
area(mexico, 764).
area(uk, 86).
area(italy, 116).
area(france, 213).
area(philippines, 90).
area(thailand, 200).
area(turkey, 296).
area(egypt, 386).
area(spain, 190).
area(poland, 121).
area(s_korea, 37).
area(iran, 628).
area(ethiopia, 350).
area(argentina, 1080).

71
JIT/examples/recursive.pl Normal file
View File

@ -0,0 +1,71 @@
% The Computer Language Benchmarks Game
% http://shootout.alioth.debian.org/
% SWI-Prolog contributed by Anthony Borla, Christoph Bauer
% converted to YAP by Isaac Gouy
:- initialization(main).
ack(0, N, Val) :- Val is N + 1, !.
ack(M, 0, Val) :- M1 is M - 1, ack(M1, 1, Val), !.
ack(M, N, Val) :-
M1 is M - 1, N1 is N - 1,
ack(M, N1, Val1), ack(M1, Val1, Val).
fib(0, 1) :- !.
fib(1, 1) :- !.
fib(N, Val) :-
N > 1,
N1 is N-1,
N2 is N1-1,
fib(N2, Val2),
fib(N1, Val1),
Val is Val1 + Val2.
fib_float(1.0, 1.0) :- !.
fib_float(0.0, 1.0) :- !.
fib_float(N, Val) :-
N > 1,
N1 is N-1,
N2 is N1-1,
fib_float(N2, Val2),
fib_float(N1, Val1),
Val is Val1 + Val2.
tak(X, Y, Z, R) :-
Y < X,
X1 is X-1,
Y1 is Y-1,
Z1 is Z-1,
tak(X1, Y, Z, A),
tak(Y1, Z, X, B),
tak(Z1, X, Y, C),
tak(A, B, C, R), !.
tak(_, _, Z, Z).
main :-
unix( argv([H|_]) ), number_atom(A,H),
B is A-1,
C is 27.0 + A,
write('Ack(3,'), write(A), write('): '),
ack(3, A, Val),!,
write(Val), nl,
write('Fib('), write(C), write('): '), fib_float(C,V), format('~1f', V), nl, !,
X is 3*B,
Y is 2*B,
Z is B,
write('Tak('), write(X), write(','), write(Y), write(','), write(Z), write('): '),
tak(X,Y,Z,R),
write(R), nl,
write('Fib(3): '), fib(3,V1), write(V1), nl,
write('Tak(3.0,2.0,1.0): '),
tak(3.0,2.0,1.0,FR),
format('~1f', FR), nl,
statistics,
statistics_jit.

View File

@ -0,0 +1,126 @@
% ----------------------------------------------------------------------
% The Computer Language Benchmarks Game
% http://shootout.alioth.debian.org/
% Contributed by anon
% Modified to run with YAP by Glendon Holst
% ----------------------------------------------------------------------
:- yap_flag(unknown,error).
:- initialization(main).
main :-
unix( argv([H|_]) ), number_atom(N,H),
approximate(N, R),
format("~9f~n", [R]),
statistics,
statistics_jit.
% ------------------------------- %
approximate(N, R) :-
make_array(app_u, N, 1.0, U), make_array(app_v, N, 0.0, V),
approx_(10, N, U, V),
vbv_loop(N, U, V, VbV), vv_loop(N, V, V, Vv),
Vi is VbV / Vv, R is sqrt(Vi).
approx_(I, N, U, V) :-
I > 0,
mulAtAv(N, U, V),
mulAtAv(N, V, U),
I1 is I - 1, approx_(I1, N, U, V).
approx_(0, _, _, _).
% ------------- %
vbv_loop(N, U, V, VbV) :- vbv_loop_(N, U, V, 0.0, VbV).
vbv_loop_(0, _, _, VAcc, VAcc) :- !.
vbv_loop_(N, U, V, VAcc, VbV) :-
arg(N, U, UValue), arg(N, V, VValue),
VAcc1 is VAcc + UValue * VValue,
N1 is N - 1, !, vbv_loop_(N1, U, V, VAcc1, VbV).
% ------------- %
vv_loop(N, U, V, Vv) :- vv_loop_(N, U, V, 0.0, Vv).
vv_loop_(0, _, _, VAcc, VAcc) :- !.
vv_loop_(N, U, V, VAcc, Vv) :-
arg(N, V, VValue),
VAcc1 is VAcc + VValue * VValue,
N1 is N - 1, !, vv_loop_(N1, U, V, VAcc1, Vv).
% ------------------------------- %
a(I, J, AResult) :-
Ia is I - 1.0, Ja is J - 1.0,
AResult is 1.0 / ((Ia + Ja) * (Ia + Ja + 1.0) / 2.0 + Ia + 1.0).
% ------------------------------- %
mulAv(N, V, Av) :- mulAv_(N, N, N, V, Av).
% ------------- %
mulAv_(0, _, _, _, _) :- !.
mulAv_(I, J, N, V, Av) :-
setarg(I, Av, 0.0),
mulAvJ_(I, J, N, V, Av),
I1 is I - 1, !, mulAv_(I1, J, N, V, Av).
mulAvJ_(_, 0, _, _, _) :- !.
mulAvJ_(I, J, N, V, Av) :-
arg(I, Av, AvValue), arg(J, V, VValue), a(I, J, AResult),
AvNew is AvValue + AResult * VValue,
setarg(I, Av, AvNew),
J1 is J - 1, !, mulAvJ_(I, J1, N, V, Av).
% ------------------------------- %
mulAtV(N, V, Atv) :- mulAtV_(N, N, N, V, Atv).
% ------------- %
mulAtV_(0, _, _, _, _) :- !.
mulAtV_(I, J, N, V, Atv) :-
setarg(I, Atv, 0.0),
mulAtVJ_(I, J, N, V, Atv),
I1 is I - 1, !, mulAtV_(I1, J, N, V, Atv).
mulAtVJ_(_, 0, _, _, _) :- !.
mulAtVJ_(I, J, N, V, Atv) :-
arg(I, Atv, AtvValue), arg(J, V, VValue), a(J, I, AResult),
AtvNew is AtvValue + AResult * VValue,
setarg(I, Atv, AtvNew),
J1 is J - 1, !, mulAtVJ_(I, J1, N, V, Atv).
% ------------------------------- %
mulAtAv(N, V, AtAv) :-
make_array(mul_u, N, 0.0, U),
mulAv(N, V, U), mulAtV(N, U, AtAv).
% ------------------------------- %
make_array(Name, N, V, Array) :- functor(Array, Name, N), fill_array(N, V, Array).
% ------------- %
fill_array(0, _, _) :- !.
fill_array(N, V, Array) :-
setarg(N, Array, V), N1 is N - 1, !,
fill_array(N1, V, Array).
% ------------------------------- %

24
JIT/examples/tak.pl Normal file
View File

@ -0,0 +1,24 @@
:- initialization(main).
tak(X,Y,Z,A) :- X =< Y,
Z = A.
tak(X,Y,Z,A) :- X > Y,
X1 is X - 1,
tak(X1,Y,Z,A1),
Y1 is Y - 1,
tak(Y1,Z,X,A2),
Z1 is Z - 1,
tak(Z1,X,Y,A3),
tak(A1,A2,A3,A).
main :-
unix( argv([H|_]) ),
number_atom(N,H),
R1 is N >> 3,
R2 is N / 2,
N2 is R2 - R1,
N3 is N - N2,
tak(N,N2,N3,_),
statistics,
statistics_jit.

54
JIT/examples/zebra.pl Normal file
View File

@ -0,0 +1,54 @@
:- initialization(main).
houses([house(_, _, _, _, _),
house(_, _, _, _, _),
house(_, _, _, _, _),
house(_, _, _, _, _),
house(_, _, _, _, _)]).
right_of(A, B, [B, A | _]).
right_of(A, B, [_ | Y]) :-
right_of(A, B, Y).
next_to(A, B, [A, B | _]).
next_to(A, B, [B, A | _]).
next_to(A, B, [_ | Y]) :-
next_to(A, B, Y).
my_member(X, [X|_]).
my_member(X, [_|Y]) :-
my_member(X, Y).
print_houses([]).
print_houses([A|B]) :-
write(A), nl,
print_houses(B).
main:-
houses(Houses),
my_member(house(red, english, _, _, _), Houses),
my_member(house(_, spanish, dog, _, _), Houses),
my_member(house(green, _, _, coffee, _), Houses),
my_member(house(_, ukrainian, _, tea, _), Houses),
right_of(house(green,_,_,_,_), house(ivory,_,_,_,_), Houses),
my_member(house(_, _, snails, _, winstons), Houses),
my_member(house(yellow, _, _, _, kools), Houses),
Houses = [_, _, house(_, _, _, milk, _), _,_],
Houses = [house(_, norwegian, _, _, _)|_],
next_to(house(_,_,_,_,chesterfields), house(_,_,fox,_,_), Houses),
next_to(house(_,_,_,_,kools), house(_,_,horse,_,_), Houses),
my_member(house(_, _, _, orange_juice, lucky_strikes), Houses),
my_member(house(_, japanese, _, _, parliaments), Houses),
next_to(house(_,norwegian,_,_,_), house(blue,_,_,_,_), Houses),
my_member(house(_, _, zebra, _, _), Houses),
my_member(house(_, _, _, water, _), Houses),
statistics.

614
JIT/jit_analysispreds.c Normal file
View File

@ -0,0 +1,614 @@
/*************************************************************************
* *
* Extension for YAP Prolog *
* *
* Copyright G.S.Oliveira, A.F.Silva and Universidade Estadual de Maringá *
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: jit_analysispreds.c *
* comments: JIT Compiler Analysis predicates *
* *
* Last rev: 2013-10-18 *
*************************************************************************/
#include "jit_predicates.hh"
#include <string.h>
#define N_ANALYSIS_PASSES 33
// Disable one (passed by argument) LLVM analysis pass
static Int p_disable_analysis_pass(USES_REGS1 ) ;
// Enable one (passed by argument) LLVM analysis pass
static Int p_analysis_pass( USES_REGS1 );
// Enable one (passed by argument) LLVM analysis pass
static Int p_enable_analysis_pass( USES_REGS1 );
// Enable a list (passed by argument) of LLVM analysis passes
static Int p_analysis_passes( USES_REGS1 );
// Enable all available LLVM analysis passes
static Int p_enable_all_analysis_passes( USES_REGS1 );
// Disable all available LLVM analysis passes
static Int p_disable_all_analysis_passes( USES_REGS1 );
// Enable LLVM statistics
static Int p_enable_stats( USES_REGS1 );
// Enable elapsed time of each LLVM's task
static Int p_enable_time_passes( USES_REGS1 );
// Checks generated modules are correct (before optimize it). Use only if you suspect that any module has been generated incorrectly.
static Int p_enable_module_correctness( USES_REGS1 );
// Same as 'p_enable_module_correctness', but accepts one argument, which defines when modules are checked.
// Valid values are those defined by 'enumPointToVerifiy' on 'amidefs.h'
static Int p_enable_module_correctness1( USES_REGS1 );
// Same as 'p_enable_module_correctness' with ARG1 = NOPOINT
static Int p_verify_module_nopoint( USES_REGS1 );
// Same as 'p_enable_module_correctness' with ARG1 = BEFORE
static Int p_verify_module_before( USES_REGS1 );
// Same as 'p_enable_module_correctness' with ARG1 = AFTER
static Int p_verify_module_after( USES_REGS1 );
// Same as 'p_enable_module_correctness' with ARG1 = BOTH
static Int p_verify_module_both( USES_REGS1 );
// Disable LLVM statistics
static Int p_disable_stats( USES_REGS1 );
// Disable elapsed time of each LLVM's task
static Int p_disable_time_passes( USES_REGS1 ) );
// Don't check generated modules are correct
static Int p_disable_module_correctness( USES_REGS1 )
// Set output file where analysis results are emitted. 'stderr' and 'stdout' are valid values
static Int p_analysis_output_file( USES_REGS1 ) ;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wimplicit-function-declaration"
static Int
p_disable_analysis_pass( USES_REGS1 )
{
// First: stores what analysis pass should be disabled
Term t = Deref(ARG1);
enumAnalysisPasses f;
// valid values for ARG1 are 'integer' and 'atom'
if (IsIntTerm(t)) {
// ARG1 is integer
Int v = IntOfTerm(t);
if (v < 0 || v >= N_ANALYSIS_PASSES) {
// value passed by argument is out of known range
Yap_Error(OUT_OF_KNOWNRANGE_ERROR,t,"");
return FALSE;
}
f = (enumAnalysisPasses)v;
}
else if (IsAtomTerm(t)) {
// ARG1 is atom
int i = 0, j = 0;
char *tmp;
// gets string from atom and stores it on 'str'
char *str = (char*)malloc(YAP_AtomNameLength(AtomOfTerm(t))*sizeof(char)
strcpy(str, AtomName(AtomOfTerm(t)));
// Makes upper characters of 'str' (for comparison)
UPPER_ENTRY(str);
if (strcmp(str, "ALL") == 0) {
// atom is 'all' -- this will disable all passes
if (ExpEnv.analysis_struc.act_an) free(ExpEnv.analysis_struc.act_an);
ExpEnv.analysis_struc.act_an = NULL;
ExpEnv.analysis_struc.n = 0;
return TRUE;
}
// Detects one pass according to 'str' -- store it
if (strcmp(str, "AAEVAL") == 0) f = e_createAAEvalPass;
else if (strcmp(str, "ALIASANALYSISCOUNTER") == 0 || strcmp(str, "COUNTAA") == 0) f = e_createAliasAnalysisCounterPass;
else if (strcmp(str, "BASICALIASANALYSIS") == 0 || strcmp(str, "BASICAA") == 0) f = e_createBasicAliasAnalysisPass;
else if (strcmp(str, "CFGONLYPRINTER") == 0 || strcmp(str, "DOTCFGONLY") == 0) f = e_createCFGOnlyPrinterPass;
else if (strcmp(str, "CFGPRINTER") == 0 || strcmp(str, "DOTCFG") == 0) f = e_createCFGPrinterPass;
else if (strcmp(str, "DBGINFOPRINTER") == 0 || strcmp(str, "PRINTDBGINFO") == 0) f = e_createDbgInfoPrinterPass;
else if (strcmp(str, "DOMONLYPRINTER") == 0 || strcmp(str, "DOTDOMONLY") == 0) f = e_createDomOnlyPrinterPass;
else if (strcmp(str, "DOMPRINTER") == 0 || strcmp(str, "DOTDOM") == 0) f = e_createDomPrinterPass;
else if (strcmp(str, "GLOBALSMODREF") == 0 || strcmp(str, "GLOBALSMODREFAA") == 0) f = e_createGlobalsModRefPass;
else if (strcmp(str, "INSTCOUNT") == 0) f = e_createInstCountPass;
else if (strcmp(str, "IVUSERS") == 0) f = e_createIVUsersPass;
else if (strcmp(str, "LAZYVALUEINFO") == 0) f = e_createLazyValueInfoPass;
else if (strcmp(str, "LIBCALLALIASANALYSIS") == 0 || strcmp(str, "LIBCALLAA") == 0) f = e_createLibCallAliasAnalysisPass;
else if (strcmp(str, "LINT") == 0) f = e_createLintPass;
else if (strcmp(str, "LOOPDEPENDENCEANALYSIS") == 0 || strcmp(str, "LDA") == 0) f = e_createLoopDependenceAnalysisPass;
else if (strcmp(str, "MEMDEPPRINTER") == 0 || strcmp(str, "MEMDEP") == 0) f = e_createMemDepPrinter;
else if (strcmp(str, "MODULEDEBUGINFOPRINTER") == 0 || strcmp(str, "MODULEDEBUGINFO") == 0) f = e_createModuleDebugInfoPrinterPass;
else if (strcmp(str, "NOAA") == 0) f = e_createNoAAPass;
else if (strcmp(str, "NOPATHPROFILEINFO") == 0 || strcmp(str, "NOPATHPROFILE") == 0) f = e_createNoPathProfileInfoPass;
else if (strcmp(str, "NOPROFILEINFO") == 0 || strcmp(str, "NOPROFILE") == 0) f = e_createNoProfileInfoPass;
else if (strcmp(str, "OBJCARCALIASANALYSIS") == 0 || strcmp(str, "OBJCARCAA") == 0) f = e_createObjCARCAliasAnalysisPass;
else if (strcmp(str, "PATHPROFILELOADER") == 0) f = e_createPathProfileLoaderPass;
else if (strcmp(str, "PATHPROFILEVERIFIER") == 0) f = e_createPathProfileVerifierPass;
else if (strcmp(str, "POSTDOMONLYPRINTER") == 0 || strcmp(str, "DOTPOSTDOMONLY") == 0) f = e_createPostDomOnlyPrinterPass;
else if (strcmp(str, "POSTDOMPRINTER") == 0 || strcmp(str, "DOTPOSTDOM") == 0) f = e_createPostDomPrinterPass;
else if (strcmp(str, "PROFILEESTIMATOR") == 0) f = e_createProfileEstimatorPass;
else if (strcmp(str, "PROFILELOADER") == 0) f = e_createProfileLoaderPass;
else if (strcmp(str, "PROFILEVERIFIER") == 0) f = e_createProfileVerifierPass;
else if (strcmp(str, "REGIONINFO") == 0) f = e_createRegionInfoPass;
else if (strcmp(str, "REGIONONLYPRINTER") == 0 || strcmp(str, "DOTREGIONSONLY") == 0) f = e_createRegionOnlyPrinterPass;
else if (strcmp(str, "REGIONPRINTER") == 0 || strcmp(str, "DOTREGIONS") == 0) f = e_createRegionPrinterPass;
else if (strcmp(str, "SCALAREVOLUTIONALIASANALYSIS") == 0 || strcmp(str, "SCEVAA") == 0) f = e_createScalarEvolutionAliasAnalysisPass;
else if (strcmp(str, "TYPEBASEDALIASANALYSIS") == 0 || strcmp(str, "TBAA") == 0) f = e_createTypeBasedAliasAnalysisPass;
else {
// value passed by argument is out of known range
Yap_Error(OUT_OF_KNOWNRANGE_ERROR,t,"");
return FALSE;
}
}
else {
// ARG1 is not an integer or atom
Yap_NilError(INVALID_PARAMETER_TYPE_ERROR,"Analysis pass");
return FALSE;
}
// Second: creates a new list with all analysis on 'ExpEnv.analysis_struc.act_an' but that analysis stored on first step
enumAnalysisPasses *tmplist = NULL;
COUNT tmpn = 0;
int i = 0;
while (i < ExpEnv.analysis_struc.n) {
if (ExpEnv.analysis_struc.act_an[i] != f) {
tmpn += 1;
tmplist = (enumAnalysisPasses*)realloc(tmplist, tmpn*sizeof(enumAnalysisPasses));
tmplist[tmpn-1] = ExpEnv.analysis_struc.act_an[i];
}
i += 1;
}
// Third: makes 'ExpEnv.analysis_struc.act_an' to point to new list created on second step
free(ExpEnv.analysis_struc.act_an);
ExpEnv.analysis_struc.n = tmpn;
ExpEnv.analysis_struc.act_an = tmplist;
return TRUE;
}
static Int
p_analysis_pass( USES_REGS1 )
{
// First: disables analysis pass (if be active)
p_disable_analysis_pass();
// Second: valids argument and inserts new analysis pass
// valid values for ARG1 are 'integer' and 'atom'
Term t = Deref(ARG1);
Int v;
if (IsIntTerm(t)) {
// ARG1 is integer
v = IntOfTerm(t);
if (v < 0 || v >= N_ANALYSIS_PASSES) {
// value passed by argument is out of known range
Yap_Error(OUT_OF_KNOWNRANGE_ERROR,t,"");
return FALSE;
}
// creates a new slot in 'ExpEnv.analysis_struc.act_an' and appends the pass in it
ExpEnv.analysis_struc.n += 1;
ExpEnv.analysis_struc.act_an = (enumAnalysisPasses*)
realloc(ExpEnv.analysis_struc.act_an, ExpEnv.analysis_struc.n * sizeof(enumAnalysisPasses));
ExpEnv.analysis_struc.act_an[ExpEnv.analysis_struc.n-1] = (enumAnalysisPasses)v;
return TRUE;
}
else if (IsAtomTerm(t)) {
// ARG1 is atom
int i = 0, j = 0;
char *tmp;
// gets string from atom and stores it on 'str'
char *str = (char*)malloc(YAP_AtomNameLength(AtomOfTerm(t))*sizeof(char));
strcpy(str, AtomName(AtomOfTerm(t)));
// Makes upper characters of 'str' (for comparison)
UPPER_ENTRY(str);
// Detects one pass according to 'str'
if (strcmp(str, "AAEVAL") == 0) v = e_createAAEvalPass;
else if (strcmp(str, "ALIASANALYSISCOUNTER") == 0 || strcmp(str, "COUNTAA") == 0) v = e_createAliasAnalysisCounterPass;
else if (strcmp(str, "BASICALIASANALYSIS") == 0 || strcmp(str, "BASICAA") == 0) v = e_createBasicAliasAnalysisPass;
else if (strcmp(str, "CFGONLYPRINTER") == 0 || strcmp(str, "DOTCFGONLY") == 0) v = e_createCFGOnlyPrinterPass;
else if (strcmp(str, "CFGPRINTER") == 0 || strcmp(str, "DOTCFG") == 0) v = e_createCFGPrinterPass;
else if (strcmp(str, "DBGINFOPRINTER") == 0 || strcmp(str, "PRINTDBGINFO") == 0) v = e_createDbgInfoPrinterPass;
else if (strcmp(str, "DOMONLYPRINTER") == 0 || strcmp(str, "DOTDOMONLY") == 0) v = e_createDomOnlyPrinterPass;
else if (strcmp(str, "DOMPRINTER") == 0 || strcmp(str, "DOTDOM") == 0) v = e_createDomPrinterPass;
else if (strcmp(str, "GLOBALSMODREF") == 0 || strcmp(str, "GLOBALSMODREFAA") == 0) v = e_createGlobalsModRefPass;
else if (strcmp(str, "INSTCOUNT") == 0) v = e_createInstCountPass;
else if (strcmp(str, "IVUSERS") == 0) v = e_createIVUsersPass;
else if (strcmp(str, "LAZYVALUEINFO") == 0) v = e_createLazyValueInfoPass;
else if (strcmp(str, "LIBCALLALIASANALYSIS") == 0 || strcmp(str, "LIBCALLAA") == 0) v = e_createLibCallAliasAnalysisPass;
else if (strcmp(str, "LINT") == 0) v = e_createLintPass;
else if (strcmp(str, "LOOPDEPENDENCEANALYSIS") == 0 || strcmp(str, "LDA") == 0) v = e_createLoopDependenceAnalysisPass;
else if (strcmp(str, "MEMDEPPRINTER") == 0 || strcmp(str, "MEMDEP") == 0) v = e_createMemDepPrinter;
else if (strcmp(str, "MODULEDEBUGINFOPRINTER") == 0 || strcmp(str, "MODULEDEBUGINFO") == 0) v = e_createModuleDebugInfoPrinterPass;
else if (strcmp(str, "NOAA") == 0) v = e_createNoAAPass;
else if (strcmp(str, "NOPATHPROFILEINFO") == 0 || strcmp(str, "NOPATHPROFILE") == 0) v = e_createNoPathProfileInfoPass;
else if (strcmp(str, "NOPROFILEINFO") == 0 || strcmp(str, "NOPROFILE") == 0) v = e_createNoProfileInfoPass;
else if (strcmp(str, "OBJCARCALIASANALYSIS") == 0 || strcmp(str, "OBJCARCAA") == 0) v = e_createObjCARCAliasAnalysisPass;
else if (strcmp(str, "PATHPROFILELOADER") == 0) v = e_createPathProfileLoaderPass;
else if (strcmp(str, "PATHPROFILEVERIFIER") == 0) v = e_createPathProfileVerifierPass;
else if (strcmp(str, "POSTDOMONLYPRINTER") == 0 || strcmp(str, "DOTPOSTDOMONLY") == 0) v = e_createPostDomOnlyPrinterPass;
else if (strcmp(str, "POSTDOMPRINTER") == 0 || strcmp(str, "DOTPOSTDOM") == 0) v = e_createPostDomPrinterPass;
else if (strcmp(str, "PROFILEESTIMATOR") == 0) v = e_createProfileEstimatorPass;
else if (strcmp(str, "PROFILELOADER") == 0) v = e_createProfileLoaderPass;
else if (strcmp(str, "PROFILEVERIFIER") == 0) v = e_createProfileVerifierPass;
else if (strcmp(str, "REGIONINFO") == 0) v = e_createRegionInfoPass;
else if (strcmp(str, "REGIONONLYPRINTER") == 0 || strcmp(str, "DOTREGIONSONLY") == 0) v = e_createRegionOnlyPrinterPass;
else if (strcmp(str, "REGIONPRINTER") == 0 || strcmp(str, "DOTREGIONS") == 0) v = e_createRegionPrinterPass;
else if (strcmp(str, "SCALAREVOLUTIONALIASANALYSIS") == 0 || strcmp(str, "SCEVAA") == 0) v = e_createScalarEvolutionAliasAnalysisPass;
else if (strcmp(str, "TYPEBASEDALIASANALYSIS") == 0 || strcmp(str, "TBAA") == 0) v = e_createTypeBasedAliasAnalysisPass;
else {
// value passed by argument is out of known range
Yap_Error(OUT_OF_KNOWNRANGE_ERROR,t,"");
return FALSE;
}
// creates a new slot in 'ExpEnv.analysis_struc.act_an' and appends the pass in it
ExpEnv.analysis_struc.n += 1;
ExpEnv.analysis_struc.act_an = (enumAnalysisPasses*)
realloc(ExpEnv.analysis_struc.act_an, ExpEnv.analysis_struc.n * sizeof(enumAnalysisPasses));
ExpEnv.analysis_struc.act_an[ExpEnv.analysis_struc.n-1] = v;
return TRUE;
}
else {
// ARG1 is not an integer or atom
Yap_NilError(INVALID_PARAMETER_TYPE_ERROR,"Analysis pass");
return FALSE;
}
}
static Int
p_enable_analysis_pass( USES_REGS1 )
{
return p_analysis_pass();
}
static Int
p_analysis_passes( USES_REGS1 )
{
int i = 0, j = 0;
char *tmp;
// valid values for ARG1 are 'atom' and 'list (pair)'
Term t = Deref(ARG1);
if (IsAtomTerm(t)) {
// ARG1 is atom
// gets string from atom and stores it on 'str'
char *str = (char*)malloc(YAP_AtomNameLength(AtomOfTerm(t))*sizeof(char));
strcpy(str, AtomName(AtomOfTerm(t)));
// Makes upper characters of 'str' (for comparison)
UPPER_ENTRY(str);
// If ARG1 is atom, 'all' is the only valid value
if (strcmp(str, "ALL") == 0) {
// First: disables all analysis passes
free(ExpEnv.analysis_struc.act_an);
ExpEnv.analysis_struc.act_an = NULL;
ExpEnv.analysis_struc.n = 0;
// Second, insert all analysis passes on 'ExpEnv.analysis_struc.act_an'
int i;
for (i = 0; i < N_ANALYSIS_PASSES; i++) {
ExpEnv.analysis_struc.n += 1;
ExpEnv.analysis_struc.act_an = (enumAnalysisPasses*)realloc(ExpEnv.analysis_struc.act_an, ExpEnv.analysis_struc.n * sizeof(enumAnalysisPasses));
ExpEnv.analysis_struc.act_an[ExpEnv.analysis_struc.n-1] = i;
}
return TRUE;
}
// value passed by argument is out of known range (ARG1 differs of 'all')
Yap_Error(OUT_OF_KNOWNRANGE_ERROR,t,"");
return FALSE;
}
else if (IsPairTerm(t)) {
// ARG1 is list
// First: disables all analysis passes
if (ExpEnv.analysis_struc.act_an) free(ExpEnv.analysis_struc.act_an);
ExpEnv.analysis_struc.act_an = NULL;
ExpEnv.analysis_struc.n = 0;
// Second: scrolls over the list treating each element individually
Term u = HeadOfTermCell(t); // get head of list 't'
u = Deref(u);
while (1) {
Int v;
enumAnalysisPasses w;
// valid values for head are 'integer' and 'atom' (the list can contain both)
if (IsIntTerm(u)) {
// head is integer
v = IntOfTerm(u);
if (v < 0 || v >= N_ANALYSIS_PASSES) {
// head's value is out of known range
Yap_Error(OUT_OF_KNOWNRANGE_ERROR,u,"");
return FALSE;
}
// insert analysis pass defined by 'head' on 'ExpEnv.analysis_struc.act_an'
ExpEnv.analysis_struc.n += 1;
ExpEnv.analysis_struc.act_an = (enumAnalysisPasses*)realloc(ExpEnv.analysis_struc.act_an, ExpEnv.analysis_struc.n * sizeof(enumAnalysisPasses));
ExpEnv.analysis_struc.act_an[ExpEnv.analysis_struc.n-1] = (enumAnalysisPasses)v;
}
else if (IsAtomTerm(u)) {
// head is atom
int i = 0, j = 0;
// gets string from atom and stores it on 'str'
char *str = (char*)malloc(YAP_AtomNameLength(AtomOfTerm(u))*sizeof(char));
strcpy(str, AtomName(AtomOfTerm(u)));
// Makes upper characters of 'str' (for comparison)
UPPER_ENTRY(str);
// Detects one pass according to 'str'
if (strcmp(str, "AAEVAL") == 0) w = e_createAAEvalPass;
else if (strcmp(str, "ALIASANALYSISCOUNTER") == 0 || strcmp(str, "COUNTAA") == 0) w = e_createAliasAnalysisCounterPass;
else if (strcmp(str, "BASICALIASANALYSIS") == 0 || strcmp(str, "BASICAA") == 0) w = e_createBasicAliasAnalysisPass;
else if (strcmp(str, "CFGONLYPRINTER") == 0 || strcmp(str, "DOTCFGONLY") == 0) w = e_createCFGOnlyPrinterPass;
else if (strcmp(str, "CFGPRINTER") == 0 || strcmp(str, "DOTCFG") == 0) w = e_createCFGPrinterPass;
else if (strcmp(str, "DBGINFOPRINTER") == 0 || strcmp(str, "PRINTDBGINFO") == 0) w = e_createDbgInfoPrinterPass;
else if (strcmp(str, "DOMONLYPRINTER") == 0 || strcmp(str, "DOTDOMONLY") == 0) w = e_createDomOnlyPrinterPass;
else if (strcmp(str, "DOMPRINTER") == 0 || strcmp(str, "DOTDOM") == 0) w = e_createDomPrinterPass;
else if (strcmp(str, "GLOBALSMODREF") == 0 || strcmp(str, "GLOBALSMODREFAA") == 0) w = e_createGlobalsModRefPass;
else if (strcmp(str, "INSTCOUNT") == 0) w = e_createInstCountPass;
else if (strcmp(str, "IVUSERS") == 0) w = e_createIVUsersPass;
else if (strcmp(str, "LAZYVALUEINFO") == 0) w = e_createLazyValueInfoPass;
else if (strcmp(str, "LIBCALLALIASANALYSIS") == 0 || strcmp(str, "LIBCALLAA") == 0) w = e_createLibCallAliasAnalysisPass;
else if (strcmp(str, "LINT") == 0) w = e_createLintPass;
else if (strcmp(str, "LOOPDEPENDENCEANALYSIS") == 0 || strcmp(str, "LDA") == 0) w = e_createLoopDependenceAnalysisPass;
else if (strcmp(str, "MEMDEPPRINTER") == 0 || strcmp(str, "MEMDEP") == 0) w = e_createMemDepPrinter;
else if (strcmp(str, "MODULEDEBUGINFOPRINTER") == 0 || strcmp(str, "MODULEDEBUGINFO") == 0) w = e_createModuleDebugInfoPrinterPass;
else if (strcmp(str, "NOAA") == 0) w = e_createNoAAPass;
else if (strcmp(str, "NOPATHPROFILEINFO") == 0 || strcmp(str, "NOPATHPROFILE") == 0) w = e_createNoPathProfileInfoPass;
else if (strcmp(str, "NOPROFILEINFO") == 0 || strcmp(str, "NOPROFILE") == 0) w = e_createNoProfileInfoPass;
else if (strcmp(str, "OBJCARCALIASANALYSIS") == 0 || strcmp(str, "OBJCARCAA") == 0) w = e_createObjCARCAliasAnalysisPass;
else if (strcmp(str, "PATHPROFILELOADER") == 0) w = e_createPathProfileLoaderPass;
else if (strcmp(str, "PATHPROFILEVERIFIER") == 0) w = e_createPathProfileVerifierPass;
else if (strcmp(str, "POSTDOMONLYPRINTER") == 0 || strcmp(str, "DOTPOSTDOMONLY") == 0) w = e_createPostDomOnlyPrinterPass;
else if (strcmp(str, "POSTDOMPRINTER") == 0 || strcmp(str, "DOTPOSTDOM") == 0) w = e_createPostDomPrinterPass;
else if (strcmp(str, "PROFILEESTIMATOR") == 0) w = e_createProfileEstimatorPass;
else if (strcmp(str, "PROFILELOADER") == 0) w = e_createProfileLoaderPass;
else if (strcmp(str, "PROFILEVERIFIER") == 0) w = e_createProfileVerifierPass;
else if (strcmp(str, "REGIONINFO") == 0) w = e_createRegionInfoPass;
else if (strcmp(str, "REGIONONLYPRINTER") == 0 || strcmp(str, "DOTREGIONSONLY") == 0) w = e_createRegionOnlyPrinterPass;
else if (strcmp(str, "REGIONPRINTER") == 0 || strcmp(str, "DOTREGIONS") == 0) w = e_createRegionPrinterPass;
else if (strcmp(str, "SCALAREVOLUTIONALIASANALYSIS") == 0 || strcmp(str, "SCEVAA") == 0) w = e_createScalarEvolutionAliasAnalysisPass;
else if (strcmp(str, "TYPEBASEDALIASANALYSIS") == 0 || strcmp(str, "TBAA") == 0) w = e_createTypeBasedAliasAnalysisPass;
else {
// head's value is out of known range
Yap_Error(OUT_OF_KNOWNRANGE_ERROR,u,"");
return FALSE;
}
// insert analysis pass defined by 'head' on 'ExpEnv.analysis_struc.act_an'
ExpEnv.analysis_struc.n += 1;
ExpEnv.analysis_struc.act_an = (enumAnalysisPasses*)realloc(ExpEnv.analysis_struc.act_an, ExpEnv.analysis_struc.n * sizeof(enumAnalysisPasses));
ExpEnv.analysis_struc.act_an[ExpEnv.analysis_struc.n-1] = w;
}
else {
// head's value is not an integer or atom
Yap_NilError(INVALID_PARAMETER_TYPE_ERROR,"Analysis pass");
return FALSE;
}
// here, 'u' is the current head of list (just been treated) and 't' is our list itself
t = TailOfTermCell(t); // 't' is now our list without 'u' (tail of 't')
t = Deref(t);
if (IsAtomTerm(t)) break; // if 't' is an empty list (which is treated as atom by Prolog), we finish the loop
u = HeadOfTermCell(t); // else, 'u' is now next head which will be treated
u = Deref(u);
}
return TRUE;
}
else {
// ARG1 is not an integer or atom
Yap_NilError(INVALID_PARAMETER_TYPE_ERROR,"Analysis pass");
return FALSE;
}
}
static Int
p_enable_all_analysis_passes( USES_REGS1 )
{
// Same as 'analysis_passes(all)'
// First, disable all analysis passes
if (ExpEnv.analysis_struc.act_an) free(ExpEnv.analysis_struc.act_an);
ExpEnv.analysis_struc.act_an = NULL;
ExpEnv.analysis_struc.n = 0;
// Second, insert all analysis passes
int i;
for (i = 0; i < N_ANALYSIS_PASSES; i++) {
ExpEnv.analysis_struc.n += 1;
ExpEnv.analysis_struc.act_an = (enumAnalysisPasses*)
realloc(ExpEnv.analysis_struc.act_an, ExpEnv.analysis_struc.n * sizeof(enumAnalysisPasses));
ExpEnv.analysis_struc.act_an[ExpEnv.analysis_struc.n-1] = (enumAnalysisPasses)i;
}
return TRUE;
}
static Int
p_disable_all_analysis_passes( USES_REGS1 )
{
// Just empty 'ExpEnv.analysis_struc.act_an'
if (ExpEnv.analysis_struc.act_an) free(ExpEnv.analysis_struc.act_an);
ExpEnv.analysis_struc.act_an = NULL;
ExpEnv.analysis_struc.n = 0;
return TRUE;
}
static Int
p_enable_stats( USES_REGS1 )
{
ExpEnv.analysis_struc.stats_enabled = 1;
return TRUE;
}
static Int
p_enable_time_passes( USES_REGS1 )
{
ExpEnv.analysis_struc.time_pass_enabled = 1;
return TRUE;
}
static Int
p_enable_module_correctness( USES_REGS1 )
{
ExpEnv.analysis_struc.pointtoverifymodule = AFTER;
return TRUE;
}
static Int
p_enable_module_correctness1( USES_REGS1 )
{
Term t = Deref(ARG1);
char *tmp;
// valid value for ARG1 is just 'atom'
if (IsAtomTerm(t)) {
// 'ARG1' is atom
int i = 0, j = 0;
// gets string from atom and stores it on 'str'
char *str = (char*)malloc(YAP_AtomNameLength(AtomOfTerm(t))*sizeof(char));
strcpy(str, AtomName(AtomOfTerm(t)));
// Makes upper characters of 'str' (for comparison)
UPPER_ENTRY(str);
// Detects one pass according to 'str'
if (strcmp(str, "NOPOINT") == 0) ExpEnv.analysis_struc.pointtoverifymodule = NOPOINT;
else if (strcmp(str, "BEFORE") == 0) ExpEnv.analysis_struc.pointtoverifymodule = BEFORE;
else if (strcmp(str, "AFTER") == 0) ExpEnv.analysis_struc.pointtoverifymodule = AFTER;
else if (strcmp(str, "BOTH") == 0) ExpEnv.analysis_struc.pointtoverifymodule = BOTH;
else {
// value passed by argument is out of known range
Yap_Error(OUT_OF_KNOWNRANGE_ERROR,t,"");
return FALSE;
}
return TRUE;
}
else {
// ARG1 is not an atom
Yap_NilError(INVALID_PARAMETER_TYPE_ERROR,"Analysis pass");
return FALSE;
}
}
static Int
p_verify_module_nopoint( USES_REGS1 )
{
// Same as 'enable_module_correctness(nopoint)'
ExpEnv.analysis_struc.pointtoverifymodule = NOPOINT;
return TRUE;
}
static Int
p_verify_module_before( USES_REGS1 )
{
// Same as 'enable_module_correctness(before)'
ExpEnv.analysis_struc.pointtoverifymodule = BEFORE;
return TRUE;
}
static Int
p_verify_module_after( USES_REGS1 )
{
// Same as 'enable_module_correctness(after)'
ExpEnv.analysis_struc.pointtoverifymodule = AFTER;
return TRUE;
}
static Int
p_verify_module_both( USES_REGS1 )
{
// Same as 'enable_module_correctness(both)'
ExpEnv.analysis_struc.pointtoverifymodule = BOTH;
return TRUE;
}
static Int
p_disable_stats( USES_REGS1 )
{
ExpEnv.analysis_struc.stats_enabled = 0;
return TRUE;
}
static Int
p_disable_time_passes( USES_REGS1 )
{
ExpEnv.analysis_struc.time_pass_enabled = 0;
return TRUE;
}
static Int
p_disable_module_correctness( USES_REGS1 )
{
ExpEnv.analysis_struc.pointtoverifymodule = NOPOINT;
return TRUE;
}
static Int
p_analysis_output_file( USES_REGS1 )
{
Term t = Deref(ARG1);
char *tmp;
// valid value for ARG1 is just 'atom'
if (IsAtomTerm(t)) {
// 'ARG1' is atom
int i = 0, j = 0;
// allocates memory to 'ExpEnv.analysis_struc.outfile'
ExpEnv.analysis_struc.outfile = (CELL)malloc(YAP_AtomNameLength(AtomOfTerm(t))*sizeof(char));
// gets string from atom and stores it on 'str' and 'tmpstr'
char *str = (char*)malloc(YAP_AtomNameLength(AtomOfTerm(t))*sizeof(char));
char *tmpstr = (char*)malloc(YAP_AtomNameLength(AtomOfTerm(t))*sizeof(char));
strcpy(str, AtomName(AtomOfTerm(t)));
strcpy(tmpstr, str);
// here, both 'str' and 'tmpstr' contain the file name... I need to verify if this name is 'stdout' or 'stderr', so...
// makes upper characters of 'tmpstr' (for comparison) and...
UPPER_ENTRY(tmpstr);
// verify if tmpstr is 'stdout' or 'stderr'. Note here that 'tmpstr' is the same of 'str', but capitalized
if (strcmp(tmpstr, "STDOUT") == 0 || strcmp(tmpstr, "STDERR") == 0)
strcpy(((char*)ExpEnv.analysis_struc.outfile), tmpstr);
else
// if not 'stdout' or 'stderr', 'ExpEnv.analysis_struc.outfile' will be the real string of ARG1, ie., 'str'
strcpy(((char*)ExpEnv.analysis_struc.outfile), str);
return TRUE;
}
else {
// ARG1 is not an atom
Yap_NilError(INVALID_PARAMETER_TYPE_ERROR,"Analysis pass");
return FALSE;
}
}
#pragma GCC diagnostic pop
void
Yap_InitJitAnalysisPreds(void)
{
Yap_InitCPred("disable_analysis_pass", 1, p_disable_analysis_pass, SafePredFlag);
Yap_InitCPred("analysis_pass", 1, p_analysis_pass, SafePredFlag);
Yap_InitCPred("enable_analysis_pass", 1, p_enable_analysis_pass, SafePredFlag);
Yap_InitCPred("analysis_passes", 1, p_analysis_passes, SafePredFlag);
Yap_InitCPred("enable_all_analysis_passes", 0, p_enable_all_analysis_passes, SafePredFlag);
Yap_InitCPred("disable_all_analysis_passes", 0, p_disable_all_analysis_passes, SafePredFlag);
Yap_InitCPred("enable_stats", 0, p_enable_stats, SafePredFlag);
Yap_InitCPred("enable_time_passes", 0, p_enable_time_passes, SafePredFlag);
Yap_InitCPred("enable_module_correctness", 0, p_enable_module_correctness, SafePredFlag);
Yap_InitCPred("enable_module_correctness", 1, p_enable_module_correctness1, SafePredFlag);
Yap_InitCPred("verify_module_nopoint", 0, p_verify_module_nopoint, SafePredFlag);
Yap_InitCPred("verify_module_before", 0, p_verify_module_before, SafePredFlag);
Yap_InitCPred("verify_module_after", 0, p_verify_module_after, SafePredFlag);
Yap_InitCPred("verify_module_both", 0, p_verify_module_both, SafePredFlag);
Yap_InitCPred("disable_stats", 0, p_disable_stats, SafePredFlag);
Yap_InitCPred("disable_time_passes", 0, p_disable_time_passes, SafePredFlag);
Yap_InitCPred("disable_module_correctness", 0, p_disable_module_correctness, SafePredFlag);
Yap_InitCPred("analysis_output_file", 1, p_analysis_output_file, SafePredFlag);
}

567
JIT/jit_codegenpreds.c Normal file
View File

@ -0,0 +1,567 @@
/*************************************************************************
* *
* Extension for YAP Prolog *
* *
* Copyright G.S.Oliveira, A.F.Silva and Universidade Estadual de Maringá *
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: jit_codegenpreds.c *
* comments: JIT Compiler Codegen Options predicates *
* *
* Last rev: 2013-10-18 *
*************************************************************************/
#include "jit_predicates.hh"
/* Predicates for LLVM Target Options configuration */
static Int p_enable_framepointer_elimination( USES_REGS1 );
static Int p_more_precise_fp_mad_option( USES_REGS1 );
static Int p_excess_fp_precision( USES_REGS1 );
static Int p_safe_fp_math( USES_REGS1 );
static Int p_rounding_mode_not_changed( USES_REGS1 );
static Int p_no_use_soft_float( USES_REGS1 );
static Int p_disable_jit_exception_handling( USES_REGS1 );
static Int p_disable_jit_emit_debug_info( USES_REGS1 );
static Int p_disable_jit_emit_debug_info_to_disk( USES_REGS1 );
static Int p_no_guaranteed_tail_call_opt( USES_REGS1 );
static Int p_enable_tail_calls( USES_REGS1 );
static Int p_disable_fast_isel( USES_REGS1 );
static Int p_disable_framepointer_elimination( USES_REGS1 );
static Int p_less_precise_fp_mad_option( USES_REGS1 );
static Int p_no_excess_fp_precision( USES_REGS1 );
static Int p_unsafe_fp_math( USES_REGS1 );
static Int p_rounding_mode_dynamically_changed( USES_REGS1 );
static Int p_use_soft_float( USES_REGS1 );
static Int p_enable_jit_exception_handling( USES_REGS1 );
static Int p_enable_jit_emit_debug_info( USES_REGS1 );
static Int p_enable_jit_emit_debug_info_to_disk( USES_REGS1 );
static Int p_guaranteed_tail_call_opt( USES_REGS1 );
static Int p_disable_tail_calls( USES_REGS1 );
static Int p_enable_fast_isel( USES_REGS1 );
static Int p_fp_abitype( USES_REGS1 );
static Int p_default_fp_abitype( USES_REGS1 );
// LLVM Execution Engine level
static Int p_engine_opt_level( USES_REGS1 );
static Int p_reset_engine_opt_level( USES_REGS1 );
// LLVM Execution Engine reloc model
static Int p_relocmodel( USES_REGS1 );
static Int p_reset_relocmodel( USES_REGS1 );
// LLVM Execution Engine code model
static Int p_codemodel( USES_REGS1 );
static Int p_reset_codemodel( USES_REGS1 );
// Enable MC JIT (experimental)
static Int p_enable_mcjit( USES_REGS1 );
// Disable MC JIT (experimental)
static Int p_disable_mcjit( USES_REGS1 );
// LLVM Register Allocator (not implemented -- for some reason, LLVM crashes when I use it on 'JIT_Compiler.cpp')
static Int p_register_allocator( USES_REGS1 );
static Int p_reset_register_allocator( USES_REGS1 );
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wimplicit-function-declaration"
static Int
p_enable_framepointer_elimination( USES_REGS1 )
{
ExpEnv.codegen_struc.struc_targetopt.noframepointerelim = FALSE;
return TRUE;
}
static Int
p_more_precise_fp_mad_option( USES_REGS1 )
{
ExpEnv.codegen_struc.struc_targetopt.lessprecisefpmadoption = FALSE;
return TRUE;
}
static Int
p_excess_fp_precision( USES_REGS1 )
{
ExpEnv.codegen_struc.struc_targetopt.noexcessfpprecision = FALSE;
return TRUE;
}
static Int
p_safe_fp_math( USES_REGS1 )
{
ExpEnv.codegen_struc.struc_targetopt.unsafefpmath = FALSE;
return TRUE;
}
static Int
p_rounding_mode_not_changed( USES_REGS1 )
{
ExpEnv.codegen_struc.struc_targetopt.honorsigndependentroundingfpmathoption = FALSE;
return TRUE;
}
static Int
p_no_use_soft_float( USES_REGS1 )
{
ExpEnv.codegen_struc.struc_targetopt.usesoftfloat = FALSE;
return TRUE;
}
static Int
p_disable_jit_exception_handling( USES_REGS1 )
{
ExpEnv.codegen_struc.struc_targetopt.jitexceptionhandling = FALSE;
return TRUE;
}
static Int
p_disable_jit_emit_debug_info( USES_REGS1 )
{
ExpEnv.codegen_struc.struc_targetopt.jitemitdebuginfo = FALSE;
return TRUE;
}
static Int
p_disable_jit_emit_debug_info_to_disk( USES_REGS1 )
{
ExpEnv.codegen_struc.struc_targetopt.jitemitdebuginfotodisk = FALSE;
return TRUE;
}
static Int
p_no_guaranteed_tail_call_opt( USES_REGS1 )
{
ExpEnv.codegen_struc.struc_targetopt.guaranteedtailcallopt = FALSE;
return TRUE;
}
static Int
p_enable_tail_calls( USES_REGS1 )
{
ExpEnv.codegen_struc.struc_targetopt.disabletailcalls = FALSE;
return TRUE;
}
static Int
p_disable_fast_isel( USES_REGS1 )
{
ExpEnv.codegen_struc.struc_targetopt.fastisel = FALSE;
return TRUE;
}
static Int
p_disable_framepointer_elimination( USES_REGS1 )
{
ExpEnv.codegen_struc.struc_targetopt.noframepointerelim = TRUE;
return TRUE;
}
static Int
p_less_precise_fp_mad_option( USES_REGS1 )
{
ExpEnv.codegen_struc.struc_targetopt.lessprecisefpmadoption = TRUE;
return TRUE;
}
static Int
p_no_excess_fp_precision( USES_REGS1 )
{
ExpEnv.codegen_struc.struc_targetopt.noexcessfpprecision = TRUE;
return TRUE;
}
static Int
p_unsafe_fp_math( USES_REGS1 )
{
ExpEnv.codegen_struc.struc_targetopt.unsafefpmath = TRUE;
return TRUE;
}
static Int
p_rounding_mode_dynamically_changed( USES_REGS1 )
{
ExpEnv.codegen_struc.struc_targetopt.honorsigndependentroundingfpmathoption = TRUE;
return TRUE;
}
static Int
p_use_soft_float( USES_REGS1 )
{
ExpEnv.codegen_struc.struc_targetopt.usesoftfloat = TRUE;
return TRUE;
}
static Int
p_enable_jit_exception_handling( USES_REGS1 )
{
ExpEnv.codegen_struc.struc_targetopt.jitexceptionhandling = TRUE;
return TRUE;
}
static Int
p_enable_jit_emit_debug_info( USES_REGS1 )
{
ExpEnv.codegen_struc.struc_targetopt.jitemitdebuginfo = TRUE;
return TRUE;
}
static Int
p_enable_jit_emit_debug_info_to_disk( USES_REGS1 )
{
ExpEnv.codegen_struc.struc_targetopt.jitemitdebuginfotodisk = TRUE;
return TRUE;
}
static Int
p_guaranteed_tail_call_opt( USES_REGS1 )
{
ExpEnv.codegen_struc.struc_targetopt.guaranteedtailcallopt = TRUE;
return TRUE;
}
static Int
p_disable_tail_calls( USES_REGS1 )
{
ExpEnv.codegen_struc.struc_targetopt.disabletailcalls = TRUE;
return TRUE;
}
static Int
p_enable_fast_isel( USES_REGS1 )
{
ExpEnv.codegen_struc.struc_targetopt.fastisel = TRUE;
return TRUE;
}
static Int
p_fp_abitype( USES_REGS1 )
{
Term t = Deref(ARG1);
Int v;
// valid values for ARG1 are 'integer' and 'atom'
if (IsIntTerm(t)) {
// ARG1 is integer
v = IntOfTerm(t);
if (v < 0 || v > 2) {
// value passed by argument is out of known range (0 = default; 1 = soft; 2 = hard)
Yap_Error(OUT_OF_KNOWNRANGE_ERROR,t,"");
return FALSE;
}
ExpEnv.codegen_struc.struc_targetopt.floatabitype = v; // setting 'float abi type'
return TRUE;
}
else if (IsAtomTerm(t)) {
// ARG1 is atom
int i = 0, j = 0;
char *tmp;
// gets string from atom and stores it on 'str'
char *str = (char*)malloc(YAP_AtomNameLength(AtomOfTerm(t))*sizeof(char));
strcpy(str, AtomName(AtomOfTerm(t)));
// Makes upper characters of 'str' (for comparison)
UPPER_ENTRY(str);
// Detects float abi type chosen by user
if (strcmp(str, "DEFAULT") == 0) v = 0;
else if (strcmp(str, "SOFT") == 0) v = 1;
else if (strcmp(str, "HARD") == 0) v = 2;
else {
// value passed by argument is out of known range
Yap_Error(OUT_OF_KNOWNRANGE_ERROR,t,"");
return FALSE;
}
ExpEnv.codegen_struc.struc_targetopt.floatabitype = v; // setting 'float abi type'
return TRUE;
}
else {
// ARG1 is not an integer or atom
Yap_NilError(INVALID_PARAMETER_TYPE_ERROR,"fp_abitype");
return FALSE;
}
}
static Int
p_default_fp_abitype( USES_REGS1 )
{
ExpEnv.codegen_struc.struc_targetopt.floatabitype = 0;
return TRUE;
}
static Int
p_engine_opt_level( USES_REGS1 )
{
Term t = Deref(ARG1);
Int v;
// valid values for ARG1 are 'integer' and 'atom'
if (IsIntTerm(t)) {
// ARG1 is integer
v = IntOfTerm(t);
if (v < 0 || v > 3) {
// value passed by argument is out of known range (0 = none; 1 = less; 2 = default; 3 = aggressive)
Yap_Error(OUT_OF_KNOWNRANGE_ERROR,t,"");
return FALSE;
}
ExpEnv.codegen_struc.struc_enginebuilder.engineoptlevel = v; // setting 'engine opt level'
return TRUE;
}
else if (IsAtomTerm(t)) {
// ARG1 is atom
int i = 0, j = 0;
char *tmp;
// gets string from atom and stores it on 'str'
char *str = (char*)malloc(YAP_AtomNameLength(AtomOfTerm(t))*sizeof(char));
strcpy(str, AtomName(AtomOfTerm(t)));
// Makes upper characters of 'str' (for comparison)
UPPER_ENTRY(str);
// Detects engine opt level chosen by user
if (strcmp(str, "NONE") == 0) v = 0;
else if (strcmp(str, "LESS") == 0) v = 1;
else if (strcmp(str, "DEFAULT") == 0) v = 2;
else if (strcmp(str, "AGGRESSIVE") == 0) v = 3;
else {
// value passed by argument is out of known range
Yap_Error(OUT_OF_KNOWNRANGE_ERROR,t,"");
return FALSE;
}
ExpEnv.codegen_struc.struc_enginebuilder.engineoptlevel = v; // setting 'engine opt level'
return TRUE;
}
else {
// ARG1 is not an integer or atom
Yap_NilError(INVALID_PARAMETER_TYPE_ERROR,"engine_opt_level");
return FALSE;
}
}
static Int
p_reset_engine_opt_level( USES_REGS1 )
{
ExpEnv.codegen_struc.struc_enginebuilder.engineoptlevel = 3;
return TRUE;
}
static Int
p_relocmodel( USES_REGS1 )
{
Term t = Deref(ARG1);
Int v;
// valid values for ARG1 are 'integer' and 'atom'
if (IsIntTerm(t)) {
// ARG1 is integer
v = IntOfTerm(t);
if (v < 0 || v > 3) {
// value passed by argument is out of known range (0 = default; 1 = static; 2 = PIC; 3 = DynamicNoPIC)
Yap_Error(OUT_OF_KNOWNRANGE_ERROR,t,"");
return FALSE;
}
ExpEnv.codegen_struc.struc_enginebuilder.relocmodel = v; // setting 'reloc model'
return TRUE;
}
else if (IsAtomTerm(t)) {
// ARG1 is atom
int i = 0, j = 0;
char *tmp;
// gets string from atom and stores it on 'str'
char *str = (char*)malloc(YAP_AtomNameLength(AtomOfTerm(t))*sizeof(char));
strcpy(str, AtomName(AtomOfTerm(t)));
// Makes upper characters of 'str' (for comparison)
UPPER_ENTRY(str);
// Detects reloc model chosen by user
if (strcmp(str, "DEFAULT") == 0) v = 0;
else if (strcmp(str, "STATIC") == 0) v = 1;
else if (strcmp(str, "PIC") == 0) v = 2;
else if (strcmp(str, "DYNAMICNOPIC") == 0) v = 3;
else {
// value passed by argument is out of known range
Yap_Error(OUT_OF_KNOWNRANGE_ERROR,t,"");
return FALSE;
}
ExpEnv.codegen_struc.struc_enginebuilder.relocmodel = v; // setting 'reloc model'
return TRUE;
}
else {
// ARG1 is not an integer or atom
Yap_NilError(INVALID_PARAMETER_TYPE_ERROR,"relocmodel");
return FALSE;
}
}
static Int
p_reset_relocmodel( USES_REGS1 )
{
ExpEnv.codegen_struc.struc_enginebuilder.relocmodel = 0;
return TRUE;
}
static Int
p_codemodel( USES_REGS1 )
{
Term t = Deref(ARG1);
Int v;
// valid values for ARG1 are 'integer' and 'atom'
if (IsIntTerm(t)) {
// ARG1 is integer
v = IntOfTerm(t);
if (v < 0 || v > 5) {
// value passed by argument is out of known range (0 = default; 1 = JITDefault; 2 = small; 3 = kernel; 4 = medium; 5 = large)
Yap_Error(OUT_OF_KNOWNRANGE_ERROR,t,"");
return FALSE;
}
ExpEnv.codegen_struc.struc_enginebuilder.codemodel = v; // setting 'code model'
return TRUE;
}
else if (IsAtomTerm(t)) {
// ARG1 is atom
int i = 0, j = 0;
char *tmp;
// gets string from atom and stores it on 'str'
char *str = (char*)malloc(YAP_AtomNameLength(AtomOfTerm(t))*sizeof(char));
strcpy(str, AtomName(AtomOfTerm(t)));
// Makes upper characters of 'str' (for comparison)
UPPER_ENTRY(str);
// Detects code chosen by user
if (strcmp(str, "DEFAULT") == 0) v = 0;
else if (strcmp(str, "JITDEFAULT") == 0) v = 1;
else if (strcmp(str, "SMALL") == 0) v = 2;
else if (strcmp(str, "KERNEL") == 0) v = 3;
else if (strcmp(str, "MEDIUM") == 0) v = 4;
else if (strcmp(str, "LARGE") == 0) v = 5;
else {
// value passed by argument is out of known range
Yap_Error(OUT_OF_KNOWNRANGE_ERROR,t,"");
return FALSE;
}
ExpEnv.codegen_struc.struc_enginebuilder.codemodel = v; // setting 'code model'
return TRUE;
}
else {
// ARG1 is not an integer or atom
Yap_NilError(INVALID_PARAMETER_TYPE_ERROR,"codemodel");
return FALSE;
}
}
static Int
p_reset_codemodel( USES_REGS1 )
{
ExpEnv.codegen_struc.struc_enginebuilder.codemodel = 1;
return TRUE;
}
static Int
p_enable_mcjit( USES_REGS1 )
{
ExpEnv.codegen_struc.struc_enginebuilder.usemcjit = 1;
return TRUE;
}
static Int
p_disable_mcjit( USES_REGS1 )
{
ExpEnv.codegen_struc.struc_enginebuilder.usemcjit = 0;
return TRUE;
}
static Int
p_register_allocator( USES_REGS1 )
{
Term t = Deref(ARG1);
// valid values for ARG1 are 'integer' and 'atom'
if (IsIntTerm(t)) {
// ARG1 is integer
Int v = IntOfTerm(t);
if (v < 0 || v > 3) {
// value passed by argument is out of known range (0 = basic; 1 = fast; 2 = greedy; 3 = PBQP)
Yap_Error(OUT_OF_KNOWNRANGE_ERROR,t,"");
return FALSE;
}
ExpEnv.codegen_struc.struc_enginebuilder.regallocator = (enumRegAllocator)v; // setting 'register allocator'
return TRUE;
}
else if (IsAtomTerm(t)) {
// ARG1 is atom
enumRegAllocator v;
int i = 0, j = 0;
char *tmp;
// gets string from atom and stores it on 'str'
char *str = (char*)malloc(YAP_AtomNameLength(AtomOfTerm(t))*sizeof(char));
strcpy(str, AtomName(AtomOfTerm(t)));
// Makes upper characters of 'str' (for comparison)
UPPER_ENTRY(str);
// Detects register allocator chosen by user
if (strcmp(str, "BASIC") == 0) v = REG_ALLOC_BASIC;
else if (strcmp(str, "FAST") == 0) v = REG_ALLOC_FAST;
else if (strcmp(str, "GREEDY") == 0) v = REG_ALLOC_GREEDY;
else if (strcmp(str, "PBQP") == 0) v = REG_ALLOC_PBQP;
else {
// value passed by argument is out of known range
Yap_Error(OUT_OF_KNOWNRANGE_ERROR,t,"");
return FALSE;
}
ExpEnv.codegen_struc.struc_enginebuilder.regallocator = v; // setting 'register allocator'
return TRUE;
}
else {
// ARG1 is not an integer or atom
Yap_NilError(INVALID_PARAMETER_TYPE_ERROR,"register_allocator");
return FALSE;
}
}
static Int
p_reset_register_allocator( USES_REGS1 )
{
ExpEnv.codegen_struc.struc_enginebuilder.regallocator = REG_ALLOC_GREEDY;
return TRUE;
}
#pragma GCC diagnostic pop
void
Yap_InitJitCodegenPreds(void)
{
Yap_InitCPred("enable_framepointer_elimination", 0, p_enable_framepointer_elimination, SafePredFlag);
Yap_InitCPred("more_precise_fp_mad_option", 0, p_more_precise_fp_mad_option, SafePredFlag);
Yap_InitCPred("excess_fp_precision", 0, p_excess_fp_precision, SafePredFlag);
Yap_InitCPred("safe_fp_math", 0, p_safe_fp_math, SafePredFlag);
Yap_InitCPred("rounding_mode_not_changed", 0, p_rounding_mode_not_changed, SafePredFlag);
Yap_InitCPred("no_use_soft_float", 0, p_no_use_soft_float, SafePredFlag);
Yap_InitCPred("disable_jit_exception_handling", 0, p_disable_jit_exception_handling, SafePredFlag);
Yap_InitCPred("disable_jit_emit_debug_info", 0, p_disable_jit_emit_debug_info, SafePredFlag);
Yap_InitCPred("disable_jit_emit_debug_info_to_disk", 0, p_disable_jit_emit_debug_info_to_disk, SafePredFlag);
Yap_InitCPred("no_guaranteed_tail_call_opt", 0, p_no_guaranteed_tail_call_opt, SafePredFlag);
Yap_InitCPred("enable_tail_calls", 0, p_enable_tail_calls, SafePredFlag);
Yap_InitCPred("disable_fast_isel", 0, p_disable_fast_isel, SafePredFlag);
Yap_InitCPred("disable_framepointer_elimination", 0, p_disable_framepointer_elimination, SafePredFlag);
Yap_InitCPred("less_precise_fp_mad_option", 0, p_less_precise_fp_mad_option, SafePredFlag);
Yap_InitCPred("no_excess_fp_precision", 0, p_no_excess_fp_precision, SafePredFlag);
Yap_InitCPred("unsafe_fp_math", 0, p_unsafe_fp_math, SafePredFlag);
Yap_InitCPred("rounding_mode_dynamically_changed", 0, p_rounding_mode_dynamically_changed, SafePredFlag);
Yap_InitCPred("use_soft_float", 0, p_use_soft_float, SafePredFlag);
Yap_InitCPred("enable_jit_exception_handling", 0, p_enable_jit_exception_handling, SafePredFlag);
Yap_InitCPred("enable_jit_emit_debug_info", 0, p_enable_jit_emit_debug_info, SafePredFlag);
Yap_InitCPred("enable_jit_emit_debug_info_to_disk", 0, p_enable_jit_emit_debug_info_to_disk, SafePredFlag);
Yap_InitCPred("guaranteed_tail_call_opt", 0, p_guaranteed_tail_call_opt, SafePredFlag);
Yap_InitCPred("disable_tail_calls", 0, p_disable_tail_calls, SafePredFlag);
Yap_InitCPred("enable_fast_isel", 0, p_enable_fast_isel, SafePredFlag);
Yap_InitCPred("fp_abitype", 1, p_fp_abitype, SafePredFlag);
Yap_InitCPred("default_fp_abitype", 0, p_default_fp_abitype, SafePredFlag);
Yap_InitCPred("engine_opt_level", 1, p_engine_opt_level, SafePredFlag);
Yap_InitCPred("reset_engine_opt_level", 0, p_reset_engine_opt_level, SafePredFlag);
Yap_InitCPred("relocmodel", 1, p_relocmodel, SafePredFlag);
Yap_InitCPred("reset_relocmodel", 0, p_reset_relocmodel, SafePredFlag);
Yap_InitCPred("codemodel", 1, p_codemodel, SafePredFlag);
Yap_InitCPred("reset_codemodel", 0, p_reset_codemodel, SafePredFlag);
Yap_InitCPred("enable_mcjit", 0, p_enable_mcjit, SafePredFlag);
Yap_InitCPred("disable_mcjit", 0, p_disable_mcjit, SafePredFlag);
Yap_InitCPred("register_allocator", 1, p_register_allocator, SafePredFlag);
Yap_InitCPred("reset_register_allocator", 0, p_reset_register_allocator, SafePredFlag);
}

730
JIT/jit_configpreds.c Normal file
View File

@ -0,0 +1,730 @@
/*************************************************************************
* *
* Extension for YAP Prolog *
* *
* Copyright G.S.Oliveira, A.F.Silva and Universidade Estadual de Maringá *
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: jit_configpreds.c *
* comments: JIT Compiler Configuration predicates *
* *
* Last rev: 2013-10-18 *
*************************************************************************/
#include "jit_predicates.hh"
#include <math.h>
// Enable any (passed by argument) execution mode
static Int p_execution_mode( USES_REGS1 );
// Enable 'just interpreted' mode.
static Int p_interpreted_mode( USES_REGS1 );
// Enable 'smart jit' mode.
static Int p_smartjit_mode( USES_REGS1 );
// Enable 'continuous compilation' mode.
static Int p_continuouscompilation_mode( USES_REGS1 );
// Enable 'just compiled' mode.
static Int p_justcompiled_mode( USES_REGS1 );
// Enable one (passed by argument) of all available frequency types: counter or time. Frequency bound is default.
// Just for 'smart jit' or 'continuous compilation' mode
static Int p_frequencyty1( USES_REGS1 );
// Enable one (1st argument) of all available frequency types: counter and time. Frequency bound is 2nd argument
// Just for 'smart jit' or 'continuous compilation' mode
static Int p_frequencyty2( USES_REGS1 );
// Enable frequency bound
// Just for 'smart jit' or 'continuous compilation' mode
static Int p_frequency_bound( USES_REGS1 );
// Enable value for starting profiling
// Just for 'smart jit' or 'continuous compilation' mode
static Int p_profiling_start_point( USES_REGS1 );
// Choose type of clause that can be main on traces
// Just for 'smart jit' or 'continuous compilation' mode
static Int p_main_clause_ty( USES_REGS1 );
// Choose amount of compilation threads
// Just for 'smart jit' or 'continuous compilation' mode
static Int p_compilation_threads( USES_REGS1 );
// Enable recompilation
// Just for 'smart jit' or 'continuous compilation' mode
static Int p_enable_recompilation( USES_REGS1 );
// Disable recompilation
// Just for 'smart jit' or 'continuous compilation' mode
static Int p_disable_recompilation( USES_REGS1 );
// Just code interpretation. Don't compile
// Just for 'smart jit' or 'continuous compilation' mode
static Int p_only_profiled_interpreter( USES_REGS1 );
// Disable 'p_only_profiled_interpreter'
// Just for 'smart jit' or 'continuous compilation' mode
static Int p_noonly_profiled_interpreter( USES_REGS1 );
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wimplicit-function-declaration"
static Int
p_execution_mode( USES_REGS1 )
{
enumExecModes mode;
// valid values for ARG1 are 'integer' and 'atom'
Term t = Deref(ARG1);
if (IsIntTerm(t)) {
// ARG1 is integer
Int v = IntOfTerm(t);
if (v < 0 || v > 3) {
// value passed by argument is out of known range (valid values are: 0 -- interpreted; 1 -- smart jit; 2 -- continuous compilation; 3 -- just compiled)
Yap_Error(OUT_OF_KNOWNRANGE_ERROR,t,"");
return FALSE;
}
// storing mode
mode = (enumExecModes)v;
}
else if (IsAtomTerm(t)) {
// ARG1 is atom
int i = 0, j = 0;
char *tmp;
// gets string from atom and stores it on 'str'
char *str = (char*)malloc(YAP_AtomNameLength(AtomOfTerm(t))*sizeof(char));
strcpy(str, AtomName(AtomOfTerm(t)));
// Makes upper characters of 'str' (for comparison)
UPPER_ENTRY(str);
// Detecting mode according to 'str'
if (strcmp(str, "INTERPRETED") == 0) mode = JUST_INTERPRETED;
else if (strcmp(str, "SMARTJIT") == 0) mode = SMART_JIT;
else if (strcmp(str, "CONTINUOUSCOMPILATION") == 0) mode = CONTINUOUS_COMPILATION;
else if (strcmp(str, "JUSTCOMPILED") == 0) mode = JUST_COMPILED;
else {
// value passed by argument is out of known range
Yap_Error(OUT_OF_KNOWNRANGE_ERROR,t,"");
return FALSE;
}
}
else {
// ARG1 is not an integer or atom
Yap_NilError(INVALID_PARAMETER_TYPE_ERROR,"Execution mode");
return FALSE;
}
// setting execution mode
ExpEnv.config_struc.execution_mode = mode;
/* setting execution mode parameters */
switch (mode) {
case JUST_INTERPRETED:
{
if (Yap_ExecutionMode == INTERPRETED) {
// execution mode only can be 'JUST_INTERPRETED' if 'Yap_ExecutionMode == INTERPRETED' (passing -J0 on command line)
// 'JUST_INTERPRETED' does not use these parameters
ExpEnv.config_struc.frequency_type = NO_FREQ;
ExpEnv.config_struc.frequency_bound = 0.0;
ExpEnv.config_struc.profiling_startp = 0.0;
ExpEnv.config_struc.mainclause_ty = UNUSED;
ExpEnv.config_struc.compilation_threads = 0;
#if YAP_DBG_PREDS
if (ExpEnv.debug_struc.act_predicate_msgs.success_msgs)
fprintf(stderr," YAP Execution mode changed to INTERPRETED!!\n");
#endif
}
else {
// 'Yap_ExecutionMode' is not compatible
Yap_NilError(INCOMPATIBLE_CODEMODE_WARNING,"INTERPRETED");
return FALSE;
}
}
break;
case SMART_JIT:
{
if (Yap_ExecutionMode == MIXED_MODE) {
// execution mode only can be 'SMART_JIT' if 'Yap_ExecutionMode == MIXED_MODE' (passing -J1 on command line)
ExpEnv.config_struc.frequency_type = COUNTER;
ExpEnv.config_struc.frequency_bound = 1024.0;
ExpEnv.config_struc.profiling_startp = 0.72;
ExpEnv.config_struc.mainclause_ty = HOT_AND_CALLEE;
ExpEnv.config_struc.compilation_threads = 0;
#if YAP_DBG_PREDS
if (ExpEnv.debug_struc.act_predicate_msgs.success_msgs)
fprintf(stderr," YAP Execution mode changed to SMART JIT!!\n");
#endif
}
else {
// 'Yap_ExecutionMode' is not compatible
Yap_NilError(INCOMPATIBLE_CODEMODE_WARNING,"SMART JIT");
return FALSE;
}
}
break;
case CONTINUOUS_COMPILATION:
{
if (Yap_ExecutionMode == MIXED_MODE) {
// execution mode only can be 'CONTINUOUS_COMPILATION' if 'Yap_ExecutionMode == MIXED_MODE' (passing -J1 on command line)
ExpEnv.config_struc.frequency_type = COUNTER;
ExpEnv.config_struc.frequency_bound = 1024.0;
ExpEnv.config_struc.profiling_startp = 0.72;
ExpEnv.config_struc.mainclause_ty = HOT_AND_CALLEE;
ExpEnv.config_struc.compilation_threads = ExpEnv.config_struc.ncores-1;
#if YAP_DBG_PREDS
if (ExpEnv.debug_struc.act_predicate_msgs.success_msgs)
fprintf(stderr," YAP Execution mode changed to CONTINUOUS COMPILATION!!\n");
#endif
}
else {
// 'Yap_ExecutionMode' is not compatible
Yap_NilError(INCOMPATIBLE_CODEMODE_WARNING,"CONTINUOUS COMPILATION");
return FALSE;
}
}
break;
case JUST_COMPILED:
{
if (Yap_ExecutionMode == COMPILED) {
// execution mode only can be 'JUST_COMPILED' if 'Yap_ExecutionMode == COMPILED' (passing -J2 on command line)
// 'JUST_COMPILED' does not use these parameters
ExpEnv.config_struc.frequency_type = NO_FREQ;
ExpEnv.config_struc.frequency_bound = 0.0;
ExpEnv.config_struc.profiling_startp = 0.0;
ExpEnv.config_struc.mainclause_ty = UNUSED;
ExpEnv.config_struc.compilation_threads = 0;
#if YAP_DBG_PREDS
if (ExpEnv.debug_struc.act_predicate_msgs.success_msgs)
fprintf(stderr," YAP Execution mode changed to JUST COMPILED!!\n");
#endif
}
else {
// 'Yap_ExecutionMode' is not compatible
Yap_NilError(INCOMPATIBLE_CODEMODE_WARNING,"JUST COMPILED");
return FALSE;
}
}
break;
}
/***/
return TRUE;
}
static Int
p_interpreted_mode( USES_REGS1 )
{
// Same as 'execution_mode(0)' or 'execution_mode(interpreted)'
if (Yap_ExecutionMode == INTERPRETED) {
// execution mode only can be 'JUST_INTERPRETED' if 'Yap_ExecutionMode == INTERPRETED' (passing -J0 on command line)
ExpEnv.config_struc.execution_mode = JUST_INTERPRETED; // setting mode
ExpEnv.config_struc.frequency_type = NO_FREQ; // does not use frequency type
ExpEnv.config_struc.frequency_bound = 0.0; // does not use frequency bound
ExpEnv.config_struc.profiling_startp = 0.0; // does not use profiling startp
ExpEnv.config_struc.mainclause_ty = UNUSED; // does not use mainclause ty
ExpEnv.config_struc.compilation_threads = 0; // does not use compilation threads
#if YAP_DBG_PREDS
if (ExpEnv.debug_struc.act_predicate_msgs.success_msgs)
fprintf(stderr," YAP Execution mode changed to INTERPRETED!!\n");
#endif
return TRUE;
}
else {
// 'Yap_ExecutionMode' is not compatible
Yap_NilError(INCOMPATIBLE_CODEMODE_WARNING,"INTERPRETED");
return FALSE;
}
}
static Int
p_smartjit_mode( USES_REGS1 )
{
// Same as 'execution_mode(1)' or 'execution_mode(smartjit)'
if (Yap_ExecutionMode == MIXED_MODE) {
// execution mode only can be 'SMART_JIT' if 'Yap_ExecutionMode == MIXED_MODE' (passing -J1 on command line)
ExpEnv.config_struc.execution_mode = SMART_JIT; // setting mode
ExpEnv.config_struc.frequency_type = COUNTER; // default value
ExpEnv.config_struc.frequency_bound = 1024.0; // default value
ExpEnv.config_struc.profiling_startp = 0.72; // default value
ExpEnv.config_struc.mainclause_ty = HOT_AND_CALLEE; // default value
/* does not use compilation threads */
ExpEnv.config_struc.compilation_threads = 0;
ExpEnv.config_struc.threaded_compiler_threads = NULL;
ExpEnv.config_struc.posthreads = NULL;
/***/
#if YAP_DBG_PREDS
if (ExpEnv.debug_struc.act_predicate_msgs.success_msgs)
fprintf(stderr," YAP Execution mode changed to SMART JIT!!\n");
if (ExpEnv.debug_struc.pprint_intermediate.print_to_file)
strcpy(((char*)ExpEnv.debug_struc.pprint_intermediate.file_name), "trace");
#endif
return TRUE;
}
else {
// 'Yap_ExecutionMode' is not compatible
Yap_NilError(INCOMPATIBLE_CODEMODE_WARNING,"SMART JIT");
return FALSE;
}
}
static Int
p_continuouscompilation_mode( USES_REGS1 )
{
// Same as 'execution_mode(2)' or 'execution_mode(continuouscompilation)'
if (Yap_ExecutionMode == MIXED_MODE) {
// execution mode only can be 'CONTINUOUS_COMPILATION' if 'Yap_ExecutionMode == MIXED_MODE' (passing -J1 on command line)
ExpEnv.config_struc.execution_mode = CONTINUOUS_COMPILATION; // setting mode
ExpEnv.config_struc.frequency_type = COUNTER; // default value
ExpEnv.config_struc.frequency_bound = 1024.0; // default value
ExpEnv.config_struc.profiling_startp = 0.72; // default value
ExpEnv.config_struc.mainclause_ty = HOT_AND_CALLEE; // default value
ExpEnv.config_struc.compilation_threads = ExpEnv.config_struc.ncores-1; // default value for this mode
/* initializing structures which will handle compilation threads */
{
if (ExpEnv.config_struc.threaded_compiler_threads) free(ExpEnv.config_struc.threaded_compiler_threads);
if (ExpEnv.config_struc.posthreads) free(ExpEnv.config_struc.posthreads);
ExpEnv.config_struc.threaded_compiler_threads = (pthread_t*)malloc(ExpEnv.config_struc.compilation_threads*sizeof(pthread_t));
ExpEnv.config_struc.posthreads = (CELL*)malloc(ExpEnv.config_struc.compilation_threads*sizeof(CELL));
int i;
for (i = 0; i < ExpEnv.config_struc.compilation_threads; i++) ExpEnv.config_struc.posthreads[i] = 0;
}
/***/
#if YAP_DBG_PREDS
if (ExpEnv.debug_struc.act_predicate_msgs.success_msgs)
fprintf(stderr," YAP Execution mode changed to CONTINUOUS COMPILATION!!\n");
if (ExpEnv.debug_struc.pprint_intermediate.print_to_file)
strcpy(((char*)ExpEnv.debug_struc.pprint_intermediate.file_name), "trace");
#endif
return TRUE;
}
else {
// 'Yap_ExecutionMode' is not compatible
Yap_NilError(INCOMPATIBLE_CODEMODE_WARNING,"CONTINUOUS COMPILATION");
return FALSE;
}
}
static Int
p_justcompiled_mode( USES_REGS1 )
{
// Same as 'execution_mode(3)' or 'execution_mode(justcompiled)'
if (Yap_ExecutionMode == COMPILED) {
// execution mode only can be 'JUST_COMPILED' if 'Yap_ExecutionMode == COMPILED' (passing -J2 on command line)
ExpEnv.config_struc.execution_mode = JUST_COMPILED; // setting mode
ExpEnv.config_struc.frequency_type = NO_FREQ; // does not use frequency type
ExpEnv.config_struc.frequency_bound = 0.0; // does not use frequency bound
ExpEnv.config_struc.profiling_startp = 0.0; // does not use profiling startp
ExpEnv.config_struc.mainclause_ty = UNUSED; // does not use mainclause ty
ExpEnv.config_struc.compilation_threads = 0; // does not use compilation threads
#if YAP_DBG_PREDS
if (ExpEnv.debug_struc.act_predicate_msgs.success_msgs)
fprintf(stderr," YAP Execution mode changed to JUST COMPILED!!\n");
if (ExpEnv.debug_struc.pprint_intermediate.print_to_file)
strcpy(((char*)ExpEnv.debug_struc.pprint_intermediate.file_name), "clause");
#endif
return TRUE;
}
else {
// 'Yap_ExecutionMode' is not compatible
Yap_NilError(INCOMPATIBLE_CODEMODE_WARNING,"JUST COMPILED");
return FALSE;
}
}
static Int
p_frequencyty1( USES_REGS1 )
{
// this predicate works only 'SMART_JIT' and 'CONTINUOUS_COMPILATION' modes
if (ExpEnv.config_struc.execution_mode == SMART_JIT || ExpEnv.config_struc.execution_mode == CONTINUOUS_COMPILATION) {
Term t = Deref(ARG1);
// valid value for ARG1 is just 'atom'
if (IsAtomTerm(t)) {
// ARG1 is atom
int i = 0, j = 0;
char *tmp;
// gets string from atom and stores it on 'str'
char *str = (char*)malloc(YAP_AtomNameLength(AtomOfTerm(t))*sizeof(char));
strcpy(str, AtomName(AtomOfTerm(t)));
// Makes upper characters of 'str' (for comparison)
UPPER_ENTRY(str);
// Detectng frequency type according to 'str'
if (strcmp(str, "COUNTER") == 0 || strcmp(str, "COUNT") == 0) {
ExpEnv.config_struc.frequency_type = COUNTER; // setting frequency type to 'counter'
ExpEnv.config_struc.frequency_bound = 1024.0; // if 'counter', frequency bound is '1024.0'
return TRUE;
}
else if (strcmp(str, "TIME") == 0 || strcmp(str, "TIMING") == 0) {
ExpEnv.config_struc.frequency_type = TIME; // setting frequency type to 'time'
ExpEnv.config_struc.frequency_bound = 0.02; // if 'time', frequency bound is '0.02'
return TRUE;
}
else {
// value passed by argument is out of known range
Yap_Error(OUT_OF_KNOWNRANGE_ERROR,t,"");
return FALSE;
}
}
else {
// ARG1 is not an atom
Yap_NilError(INVALID_PARAMETER_TYPE_ERROR,"Frequency type");
return FALSE;
}
}
else {
// current execution mode differs of 'SMART_JIT' and 'CONTINUOUS_COMPILATION'
Yap_NilError(INCOMPATIBLEMODE_WARNING,"");
return FALSE;
}
}
static Int
p_frequencyty2( USES_REGS1 )
{
// this predicate works only 'SMART_JIT' and 'CONTINUOUS_COMPILATION' modes
if (ExpEnv.config_struc.execution_mode == SMART_JIT || ExpEnv.config_struc.execution_mode == CONTINUOUS_COMPILATION) {
Term t = Deref(ARG1);
// valid value for ARG1 is just 'atom'
if (IsAtomTerm(t)) {
Term u = Deref(ARG2);
// valid values for ARG2 are 'integer' and 'float'
if (IsIntTerm(u) || IsFloatTerm(u)) {
// ARG1 is atom and ARG2 is integer or float
int i = 0, j = 0;
char *tmp;
// getting string from atom and stores it on 'str'
char *str = (char*)malloc(YAP_AtomNameLength(AtomOfTerm(t))*sizeof(char));
strcpy(str, AtomName(AtomOfTerm(t)));
// Making upper characters of 'str' (for comparison)
UPPER_ENTRY(str);
// getting ARG2 value
Float v;
if (IsIntTerm(u)) v = (Float)IntOfTerm(u);
if (IsFloatTerm(u)) v = FloatOfTerm(u);
// setting 'frequency type' and 'frequency bound' if 'COUNTER'
if (strcmp(str, "COUNTER") == 0 || strcmp(str, "COUNT") == 0) {
if (v < 20.0) {
// Very low frequency bound to apply on 'COUNTER'
fprintf(stderr,"%.2f is a very low value for the active frequency type. Reconsider its value...\n", v);
return FALSE;
}
ExpEnv.config_struc.frequency_type = COUNTER;
ExpEnv.config_struc.frequency_bound = roundf(v);
return TRUE;
}
// setting 'frequency type' and 'frequency bound' if 'TIME'
else if (strcmp(str, "TIME") == 0 || strcmp(str, "TIMING") == 0) {
if (v <= 0.0 || v > 0.49) {
// Very low frequency bound to apply on 'COUNTER'
fprintf(stderr,"%.2f is an invalid or a very high value for the active frequency type. Reconsider its value...\n", v);
return FALSE;
}
ExpEnv.config_struc.frequency_type = TIME;
ExpEnv.config_struc.frequency_bound = v;
return TRUE;
}
else {
// value passed by argument (ARG1) is out of known range
Yap_Error(OUT_OF_KNOWNRANGE_ERROR,t,"");
return FALSE;
}
}
else {
// ARG2 is not an 'integer' or 'float'
Yap_NilError(INVALID_PARAMETER_TYPE_ERROR,"frequencyty/2 (2nd arg)");
return FALSE;
}
}
else {
// ARG1 is not an atom
Yap_NilError(INVALID_PARAMETER_TYPE_ERROR,"frequencyty/2 (1st arg)");
return FALSE;
}
}
else {
// current execution mode differs of 'SMART_JIT' and 'CONTINUOUS_COMPILATION'
Yap_NilError(INCOMPATIBLEMODE_WARNING,"");
return FALSE;
}
}
static Int
p_frequency_bound( USES_REGS1 )
{
// this predicate works only 'SMART_JIT' and 'CONTINUOUS_COMPILATION' modes
if (ExpEnv.config_struc.execution_mode == SMART_JIT || ExpEnv.config_struc.execution_mode == CONTINUOUS_COMPILATION) {
Term t = Deref(ARG1);
// valid values for ARG1 are 'integer' and 'float'
if (IsIntTerm(t) || IsFloatTerm(t)) {
// ARG1 is integer or float
// getting ARG1 value
Float v;
if (IsIntTerm(t)) v = (Float)IntOfTerm(t);
if (IsFloatTerm(t)) v = FloatOfTerm(t);
// setting 'frequency bound' if 'frequency type' is 'COUNTER'
if (ExpEnv.config_struc.frequency_type == COUNTER) {
if (v < 20.0) {
fprintf(stderr,"%.2f is a very low value for the active frequency type. Reconsider its value...\n", v);
return FALSE;
}
ExpEnv.config_struc.frequency_bound = roundf(v);
return TRUE;
}
// setting 'frequency bound' if 'frequency type' is 'TIME'
else {
if (v <= 0.0 || v > 0.49) {
fprintf(stderr,"%.2f is an invalid or a very high value for the active frequency type. Reconsider its value...\n", v);
return FALSE;
}
ExpEnv.config_struc.frequency_bound = v;
return TRUE;
}
}
else {
// ARG1 is not an 'integer' or 'float'
Yap_NilError(INVALID_PARAMETER_TYPE_ERROR,"frequency_bound/1 (1st arg)");
return FALSE;
}
}
else {
// current execution mode differs of 'SMART_JIT' and 'CONTINUOUS_COMPILATION'
Yap_NilError(INCOMPATIBLEMODE_WARNING,"");
return FALSE;
}
}
static Int
p_profiling_start_point( USES_REGS1 )
{
// this predicate works only 'SMART_JIT' and 'CONTINUOUS_COMPILATION' modes
if (ExpEnv.config_struc.execution_mode == SMART_JIT || ExpEnv.config_struc.execution_mode == CONTINUOUS_COMPILATION) {
Term t = Deref(ARG1);
Float v;
// valid value for ARG1 is just 'float'
if (IsFloatTerm(t)) {
v = FloatOfTerm(t);
if (v < 0.0 || v >= 1.0) {
// value passed by argument is out of known range
Yap_Error(OUT_OF_KNOWNRANGE_ERROR,t,"");
return FALSE;
}
ExpEnv.config_struc.profiling_startp = v;
return TRUE;
}
else {
// ARG1 is not float
Yap_NilError(INVALID_PARAMETER_TYPE_ERROR,"profiling_start_point/1 (1st arg)");
return FALSE;
}
}
else {
// current execution mode differs of 'SMART_JIT' and 'CONTINUOUS_COMPILATION'
Yap_NilError(INCOMPATIBLEMODE_WARNING,"");
return FALSE;
}
}
static Int
p_main_clause_ty( USES_REGS1 )
{
// this predicate works only 'SMART_JIT' and 'CONTINUOUS_COMPILATION' modes
if (ExpEnv.config_struc.execution_mode == SMART_JIT || ExpEnv.config_struc.execution_mode == CONTINUOUS_COMPILATION) {
Term t = Deref(ARG1);
// valid values for ARG1 are 'integer' and 'atom'
if (IsIntTerm(t)) {
// ARG1 is integer
Int v;
v = IntOfTerm(t);
if (v < 0 || v > 3) {
// value passed by argument is out of known range
Yap_Error(OUT_OF_KNOWNRANGE_ERROR,t,"");
return FALSE;
}
#if YAP_DBG_PREDS
if (ExpEnv.debug_struc.act_predicate_msgs.success_msgs) {
switch(v) {
case 0:
fprintf(stderr," Type of main clause was changed to JUST HOT!!\n");
break;
case 1:
fprintf(stderr," Type of main clause was changed to HOT AND CALLEE!!\n");
break;
case 2:
fprintf(stderr," Type of main clause was changed to HOT AND GREATER!!\n");
break;
case 3:
fprintf(stderr," Type of main clause was changed to HOT AND FEWER!!\n");
break;
}
}
#endif
// setting 'mainclause_ty' -- I should de add '1' because the first enum of 'enumMainClauseType' is 'UNUSED', used just for control
ExpEnv.config_struc.mainclause_ty = (enumMainClauseType)(v+1);
return TRUE;
}
else if (IsAtomTerm(t)) {
// ARG1 is atom
enumMainClauseType v;
int i = 0, j = 0;
char *tmp;
// gets string from atom and stores it on 'str'
char *str = (char*)malloc(YAP_AtomNameLength(AtomOfTerm(t))*sizeof(char));
strcpy(str, AtomName(AtomOfTerm(t)));
// Makes upper characters of 'str' (for comparison)
UPPER_ENTRY(str);
// Detecting mainclause type chosen by user according to 'str'
if (strcmp(str, "JUSTHOT") == 0) {
v = JUST_HOT;
#if YAP_DBG_PREDS
if (ExpEnv.debug_struc.act_predicate_msgs.success_msgs) fprintf(stderr," Type of main clause was changed to JUST HOT!!\n");
#endif
}
else if (strcmp(str, "HOTANDCALLEE") == 0) {
v = HOT_AND_CALLEE;
#if YAP_DBG_PREDS
if (ExpEnv.debug_struc.act_predicate_msgs.success_msgs) fprintf(stderr," Type of main clause was changed to HOT AND CALLEE!!\n");
#endif
}
else if (strcmp(str, "HOTANDGREATER") == 0) {
v = HOT_AND_GREATER;
#if YAP_DBG_PREDS
if (ExpEnv.debug_struc.act_predicate_msgs.success_msgs) fprintf(stderr," Type of main clause was changed to HOT AND GREATER!!\n");
#endif
}
else if (strcmp(str, "HOTANDFEWER") == 0) {
v = HOT_AND_FEWER;
#if YAP_DBG_PREDS
if (ExpEnv.debug_struc.act_predicate_msgs.success_msgs) fprintf(stderr," Type of main clause was changed to HOT AND FEWER!!\n");
#endif
}
else {
// value passed by argument is out of known range
Yap_Error(OUT_OF_KNOWNRANGE_ERROR,t,"");
return FALSE;
}
ExpEnv.config_struc.mainclause_ty = v;
return TRUE;
}
else {
// ARG1 is not an integer or atom
Yap_NilError(INVALID_PARAMETER_TYPE_ERROR,"main_clause_ty/1 (1st arg)");
return FALSE;
}
}
else {
// current execution mode differs of 'SMART_JIT' and 'CONTINUOUS_COMPILATION'
Yap_NilError(INCOMPATIBLEMODE_WARNING,"");
return FALSE;
}
}
static Int
p_compilation_threads( USES_REGS1 )
{
// this predicate works only 'CONTINUOUS_COMPILATION' mode
if (ExpEnv.config_struc.execution_mode == SMART_JIT || ExpEnv.config_struc.execution_mode == CONTINUOUS_COMPILATION) {
Term t = Deref(ARG1);
Int v;
// valid value for ARG1 is 'integer' (because it defines number of threads)
if (IsIntTerm(t)) {
// ARG1 is integer
v = IntOfTerm(t);
if (v < 1) {
// ERROR: number of threads is negative!!
Yap_Error(OUT_OF_KNOWNRANGE_ERROR,t,"");
return FALSE;
}
if (v >= ExpEnv.config_struc.ncores) {
// WARNING: number of threads is not ideal -- real parallelism won't occur!!
fprintf(stderr,
" It was detected %ld cores on this computer, therefore it is ideally to set just %ld compilation thread. Reconsider its value...\n",
ExpEnv.config_struc.ncores, ExpEnv.config_struc.ncores-1);
}
// setting compilation threads
ExpEnv.config_struc.compilation_threads = v;
/* initializing structures which will handle compilation threads */
{
if (ExpEnv.config_struc.threaded_compiler_threads) free(ExpEnv.config_struc.threaded_compiler_threads);
if (ExpEnv.config_struc.posthreads) free(ExpEnv.config_struc.posthreads);
ExpEnv.config_struc.threaded_compiler_threads = (pthread_t*)malloc(v*sizeof(pthread_t));
ExpEnv.config_struc.posthreads = (CELL*)malloc(v*sizeof(CELL));
int i;
for (i = 0; i < v; i++) ExpEnv.config_struc.posthreads[i] = 0;
}
/***/
#if YAP_DBG_PREDS
if (ExpEnv.debug_struc.act_predicate_msgs.success_msgs) fprintf(stderr," Type of main clause was changed to HOT AND FEWER!!\n");
#endif
return TRUE;
}
else {
// ARG1 is not an integer
Yap_NilError(INVALID_PARAMETER_TYPE_ERROR,"compilation_threads/1 (1st arg)");
return FALSE;
}
}
else {
// current execution mode differs of 'CONTINUOUS_COMPILATION'
Yap_NilError(INCOMPATIBLEMODE_WARNING,"");
return FALSE;
}
}
static Int
p_enable_recompilation( USES_REGS1 )
{
ExpEnv.config_struc.torecompile = 1;
return TRUE;
}
static Int
p_disable_recompilation( USES_REGS1 )
{
ExpEnv.config_struc.torecompile = 0;
return TRUE;
}
static Int
p_only_profiled_interpreter( USES_REGS1 )
{
ExpEnv.config_struc.useonlypi = 1;
return TRUE;
}
static Int
p_noonly_profiled_interpreter( USES_REGS1 )
{
ExpEnv.config_struc.useonlypi = 0;
return TRUE;
}
#pragma GCC diagnostic pop
void
Yap_InitJitConfigPreds(void)
{
Yap_InitCPred("execution_mode", 1, p_execution_mode, SafePredFlag);
Yap_InitCPred("interpreted_mode", 0, p_interpreted_mode, SafePredFlag);
Yap_InitCPred("smartjit_mode", 0, p_smartjit_mode, SafePredFlag);
Yap_InitCPred("continuouscompilation_mode", 0, p_continuouscompilation_mode, SafePredFlag);
Yap_InitCPred("justcompiled_mode", 0, p_justcompiled_mode, SafePredFlag);
Yap_InitCPred("frequencyty1", 1, p_frequencyty1, SafePredFlag);
Yap_InitCPred("frequencyty2", 2, p_frequencyty2, SafePredFlag);
Yap_InitCPred("frequency_bound", 1, p_frequency_bound, SafePredFlag);
Yap_InitCPred("profiling_start_point", 1, p_profiling_start_point, SafePredFlag);
Yap_InitCPred("main_clause_ty", 1, p_main_clause_ty, SafePredFlag);
Yap_InitCPred("compilation_threads", 1, p_compilation_threads, SafePredFlag);
Yap_InitCPred("enable_recompilation", 0, p_enable_recompilation, SafePredFlag);
Yap_InitCPred("disable_recompilation", 0, p_disable_recompilation, SafePredFlag);
Yap_InitCPred("only_profiled_interpreter", 0, p_only_profiled_interpreter, SafePredFlag);
Yap_InitCPred("noonly_profiled_interpreter", 0, p_noonly_profiled_interpreter, SafePredFlag);
}

2476
JIT/jit_debugpreds.c Normal file

File diff suppressed because it is too large Load Diff

838
JIT/jit_statisticpreds.c Normal file
View File

@ -0,0 +1,838 @@
/*************************************************************************
* *
* Extension for YAP Prolog *
* *
* Copyright G.S.Oliveira, A.F.Silva and Universidade Estadual de Maringá *
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: jit_statisticpreds.c *
* comments: JIT Compiler Statistics predicates *
* *
* Last rev: 2013-10-18 *
*************************************************************************/
#include "jit_predicates.hh"
#include <papi.h>
static Int p_init_low_level_stats( USES_REGS1 );
static Int p_statistics_jit( USES_REGS1 );
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wimplicit-function-declaration"
static Int
p_init_low_level_stats( USES_REGS1 )
{
int i = 0, j = 0;
char *tmp;
Term t = Deref(ARG1);
// valid value for ARG1 is just 'atom'
if (IsAtomTerm(t)) {
// ARG1 is atom
// gets string from atom and stores it on 'str'
char *str = (char*)malloc(YAP_AtomNameLength(AtomOfTerm(t))*sizeof(char));
strcpy(str, AtomName(AtomOfTerm(t)));
// Makes upper characters of 'str' (for comparison)
UPPER_ENTRY(str);
// Detects one papi event (each event is a set of several performance counters)
// Such events are: 'conditional_branching', 'cache_requests', 'conditional_store', 'floating_point_operations', 'instruction_counting', 'cache_access', 'data_access', and 'tlb_operations'
// Event chosen by user is stored on 'ExpEnv.stats_struc.papi_event_type'
// Only one event can be chosen at a time
if (strcmp(str, "CONDITIONALBRANCHING") == 0)
ExpEnv.stats_struc.papi_event_type = 0;
else if (strcmp(str, "CACHEREQUESTS") == 0)
ExpEnv.stats_struc.papi_event_type = 1;
else if (strcmp(str, "CONDITIONALSTORE") == 0)
ExpEnv.stats_struc.papi_event_type = 2;
else if (strcmp(str, "FLOATINGPOINTOPERATIONS") == 0)
ExpEnv.stats_struc.papi_event_type = 3;
else if (strcmp(str, "INSTRUCTIONCOUNTING") == 0)
ExpEnv.stats_struc.papi_event_type = 4;
else if (strcmp(str, "CACHEACCESS") == 0)
ExpEnv.stats_struc.papi_event_type = 5;
else if (strcmp(str, "DATAACCESS") == 0)
ExpEnv.stats_struc.papi_event_type = 6;
else if (strcmp(str, "TLBOPERATIONS") == 0)
ExpEnv.stats_struc.papi_event_type = 7;
else {
// value passed by argument is out of known range (unknown event)
Yap_Error(OUT_OF_KNOWNRANGE_ERROR,t,"");
return FALSE;
}
/* Initializing PAPI library */
if (PAPI_library_init(PAPI_VER_CURRENT) != PAPI_VER_CURRENT) {
fprintf(stderr, "PAPI library init error!\n");
exit(1);
}
/***/
/* Create one event set */
if (PAPI_create_eventset(&ExpEnv.stats_struc.papi_eventset) != PAPI_OK)
fprintf (stderr, "%s:%d\t ERROR\n", __FILE__, __LINE__);
/***/
/* Add counters to event set */
if (ExpEnv.stats_struc.papi_event_type == 0) {
// Event type is 'conditional_branching' -- contains 9 performance counters
ExpEnv.stats_struc.papi_valid_values = (short*)malloc(9*sizeof(short));
/* Initializing 'ExpEnv.stats_struc.papi_valid_values'. Not all performance counters of an event are available, because they are machine-dependent. 'ExpEnv.stats_struc.papi_valid_values[i]' will be set with '1' if event 'i' is available */
for (i = 0; i < 9; i++) {
ExpEnv.stats_struc.papi_valid_values[i] = 0;
}
/* Adding performance counters of event*/
// Conditional Branching -- Conditional branch instructions
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_BR_CN) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[0] = 1;
// Conditional Branching -- Branch instructions
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_BR_INS) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[1] = 1;
// Conditional Branching -- Conditional branch instructions mispredicted
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_BR_MSP) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[2] = 1;
// Conditional Branching -- Conditional branch instructions not taken
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_BR_NTK) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[3] = 1;
// Conditional Branching -- Conditional branch instructions correctly predicted
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_BR_PRC) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[4] = 1;
// Conditional Branching -- Conditional branch instructions taken
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_BR_TKN) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[5] = 1;
// Conditional Branching -- Unconditional branch instructions
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_BR_UCN) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[6] = 1;
// Conditional Branching -- Cycles branch units are idle
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_BRU_IDL) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[7] = 1;
// Conditional Branching -- Branch target address cache misses
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_BTAC_M) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[8] = 1;
}
else if (ExpEnv.stats_struc.papi_event_type == 1) {
// Event type is 'cache_requests' -- contains 5 performance counters
ExpEnv.stats_struc.papi_valid_values = (short*)malloc(5*sizeof(short));
/* Initializing 'ExpEnv.stats_struc.papi_valid_values'. Not all performance counters of an event are available, because they are machine-dependent. 'ExpEnv.stats_struc.papi_valid_values[i]' will be set with '1' if event 'i' is available */
for (i = 0; i < 5; i++) {
ExpEnv.stats_struc.papi_valid_values[i] = 0;
}
/* Adding performance counters of event*/
// Cache Requests -- Requests for exclusive access to clean cache line
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_CA_CLN) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[0] = 1;
// Cache Requests -- Requests for cache line invalidation
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_CA_INV) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[1] = 1;
// Cache Requests -- Requests for cache line intervention
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_CA_ITV) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[2] = 1;
// Cache Requests -- Requests for exclusive access to shared cache line
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_CA_SHR) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[3] = 1;
// Cache Requests -- Requests for a snoop
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_CA_SNP) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[4] = 1;
}
else if (ExpEnv.stats_struc.papi_event_type == 2) {
// Event type is 'conditional_store' -- contains 3 performance counters
ExpEnv.stats_struc.papi_valid_values = (short*)malloc(3*sizeof(short));
/* Initializing 'ExpEnv.stats_struc.papi_valid_values'. Not all performance counters of an event are available, because they are machine-dependent. 'ExpEnv.stats_struc.papi_valid_values[i]' will be set with '1' if event 'i' is available */
for (i = 0; i < 3; i++) {
ExpEnv.stats_struc.papi_valid_values[i] = 0;
}
/* Adding performance counters of event*/
// Conditional Store -- Failed store conditional instructions
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_CSR_FAL) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[0] = 1;
// Conditional Store -- Successful store conditional instructions
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_CSR_SUC) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[1] = 1;
// Conditional Store -- Total store conditional instructions
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_CSR_TOT) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[2] = 1;
}
else if (ExpEnv.stats_struc.papi_event_type == 3) {
// Event type is 'floating_point_operations' -- contains 14 performance counters
ExpEnv.stats_struc.papi_valid_values = (short*)malloc(14*sizeof(short));
/* Initializing 'ExpEnv.stats_struc.papi_valid_values'. Not all performance counters of an event are available, because they are machine-dependent. 'ExpEnv.stats_struc.papi_valid_values[i]' will be set with '1' if event 'i' is available */
for (i = 0; i < 14; i++) {
ExpEnv.stats_struc.papi_valid_values[i] = 0;
}
/* Adding performance counters of event*/
// Floating Point Operations -- Floating point add instructions
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_FAD_INS) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[0] = 1;
// Floating Point Operations -- Floating point divide instructions
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_FDV_INS) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[1] = 1;
// Floating Point Operations -- FMA instructions completed
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_FMA_INS) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[2] = 1;
// Floating Point Operations -- Floating point multiply instructions
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_FML_INS) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[3] = 1;
// Floating Point Operations -- Floating point inverse instructions
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_FNV_INS) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[4] = 1;
// Floating Point Operations -- Floating point instructions
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_FP_INS) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[5] = 1;
// Floating Point Operations -- Floating point operations
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_FP_OPS) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[6] = 1;
// Floating Point Operations -- Cycles the FP unit
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_FP_STAL) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[7] = 1;
// Floating Point Operations -- Cycles floating point units are idle
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_FPU_IDL) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[8] = 1;
// Floating Point Operations -- Floating point square root instructions
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_FSQ_INS) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[9] = 1;
// Floating Point Operations -- Floating point operations executed; optimized to count scaled single precision vector operations
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_SP_OPS) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[10] = 1;
// Floating Point Operations -- Floating point operations executed; optimized to count scaled double precision vector operations
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_DP_OPS) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[11] = 1;
// Floating Point Operations -- Single precision vector/SIMD instructions
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_VEC_SP) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[12] = 1;
// Floating Point Operations -- Double precision vector/SIMD instructions
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_VEC_DP) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[13] = 1;
}
else if (ExpEnv.stats_struc.papi_event_type == 4) {
// Event type is 'instruction_counting' -- contains 9 performance counters
ExpEnv.stats_struc.papi_valid_values = (short*)malloc(9*sizeof(short));
/* Initializing 'ExpEnv.stats_struc.papi_valid_values'. Not all performance counters of an event are available, because they are machine-dependent. 'ExpEnv.stats_struc.papi_valid_values[i]' will be set with '1' if event 'i' is available */
for (i = 0; i < 9; i++) {
ExpEnv.stats_struc.papi_valid_values[i] = 0;
}
/* Adding performance counters of event*/
// Instruction Counting -- Cycles with maximum instructions completed
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_FUL_CCY) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[0] = 1;
// Instruction Counting -- Cycles with maximum instruction issue
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_FUL_ICY) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[1] = 1;
// Instruction Counting -- Cycles integer units are idle
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_FXU_IDL) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[2] = 1;
// Instruction Counting -- Hardware interrupts
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_HW_INT) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[3] = 1;
// Instruction Counting -- Integer instructions
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_INT_INS) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[4] = 1;
// Instruction Counting -- Total cycles
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_TOT_CYC) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[5] = 1;
// Instruction Counting -- Instructions issued
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_TOT_IIS) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[6] = 1;
// Instruction Counting -- Instructions completed
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_TOT_INS) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[7] = 1;
// Instruction Counting -- Vector/SIMD instructions
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_VEC_INS) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[8] = 1;
}
else if (ExpEnv.stats_struc.papi_event_type == 5) {
// Event type is 'cache_access' -- contains 51 performance counters
ExpEnv.stats_struc.papi_valid_values = (short*)malloc(51*sizeof(short));
/* Initializing 'ExpEnv.stats_struc.papi_valid_values'. Not all performance counters of an event are available, because they are machine-dependent. 'ExpEnv.stats_struc.papi_valid_values[i]' will be set with '1' if event 'i' is available */
for (i = 0; i < 51; i++) {
ExpEnv.stats_struc.papi_valid_values[i] = 0;
}
/* Adding performance counters of event*/
// Cache Access -- L1 data cache accesses
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_L1_DCA) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[0] = 1;
// Cache Access -- L1 data cache hits
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_L1_DCH) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[1] = 1;
// Cache Access -- L1 data cache misses
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_L1_DCM) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[2] = 1;
// Cache Access -- L1 data cache reads
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_L1_DCR) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[3] = 1;
// Cache Access -- L1 data cache writes
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_L1_DCW) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[4] = 1;
// Cache Access -- L1 instruction cache accesses
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_L1_ICA) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[5] = 1;
// Cache Access -- L1 instruction cache hits
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_L1_ICH) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[6] = 1;
// Cache Access -- L1 instruction cache misses
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_L1_ICM) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[7] = 1;
// Cache Access -- L1 instruction cache reads
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_L1_ICR) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[8] = 1;
// Cache Access -- L1 instruction cache writes
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_L1_ICW) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[9] = 1;
// Cache Access -- L1 load misses
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_L1_LDM) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[10] = 1;
// Cache Access -- L1 store misses
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_L1_STM) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[11] = 1;
// Cache Access -- L1 total cache accesses
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_L1_TCA) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[12] = 1;
// Cache Access -- L1 total cache hits
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_L1_TCH) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[13] = 1;
// Cache Access -- L1 total cache misses
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_L1_TCM) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[14] = 1;
// Cache Access -- L1 total cache reads
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_L1_TCR) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[15] = 1;
// Cache Access -- L1 total cache writes
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_L1_TCW) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[16] = 1;
// Cache Access -- L2 data cache accesses
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_L2_DCA) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[17] = 1;
// Cache Access -- L2 data cache hits
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_L2_DCH) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[18] = 1;
// Cache Access -- L2 data cache misses
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_L2_DCM) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[19] = 1;
// Cache Access -- L2 data cache reads
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_L2_DCR) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[20] = 1;
// Cache Access -- L2 data cache writes
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_L2_DCW) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[21] = 1;
// Cache Access -- L2 instruction cache accesses
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_L2_ICA) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[22] = 1;
// Cache Access -- L2 instruction cache hits
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_L2_ICH) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[23] = 1;
// Cache Access -- L2 instruction cache misses
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_L2_ICM) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[24] = 1;
// Cache Access -- L2 instruction cache reads
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_L2_ICR) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[25] = 1;
// Cache Access -- L2 instruction cache writes
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_L2_ICW) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[26] = 1;
// Cache Access -- L2 load misses
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_L2_LDM) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[27] = 1;
// Cache Access -- L2 store misses
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_L2_STM) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[28] = 1;
// Cache Access -- L2 total cache accesses
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_L2_TCA) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[29] = 1;
// Cache Access -- L2 total cache hits
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_L2_TCH) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[30] = 1;
// Cache Access -- L2 total cache misses
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_L2_TCM) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[31] = 1;
// Cache Access -- L2 total cache reads
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_L2_TCR) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[32] = 1;
// Cache Access -- L2 total cache writes
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_L2_TCW) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[33] = 1;
// Cache Access -- L3 data cache accesses
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_L3_DCA) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[34] = 1;
// Cache Access -- L3 data cache hits
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_L3_DCH) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[35] = 1;
// Cache Access -- L3 data cache misses
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_L3_DCM) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[36] = 1;
// Cache Access -- L3 data cache reads
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_L3_DCR) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[37] = 1;
// Cache Access -- L3 data cache writes
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_L3_DCW) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[38] = 1;
// Cache Access -- L3 instruction cache accesses
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_L3_ICA) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[39] = 1;
// Cache Access -- L3 instruction cache hits
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_L3_ICH) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[40] = 1;
// Cache Access -- L3 instruction cache misses
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_L3_ICM) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[41] = 1;
// Cache Access -- L3 instruction cache reads
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_L3_ICR) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[42] = 1;
// Cache Access -- L3 instruction cache writes
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_L3_ICW) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[43] = 1;
// Cache Access -- L3 load misses
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_L3_LDM) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[44] = 1;
// Cache Access -- L3 store misses
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_L3_STM) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[45] = 1;
// Cache Access -- L3 total cache accesses
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_L3_TCA) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[46] = 1;
// Cache Access -- L3 total cache hits
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_L3_TCH) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[47] = 1;
// Cache Access -- L3 total cache misses
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_L3_TCM) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[48] = 1;
// Cache Access -- L3 total cache reads
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_L3_TCR) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[49] = 1;
// Cache Access -- L3 total cache writes
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_L3_TCW) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[50] = 1;
}
else if (ExpEnv.stats_struc.papi_event_type == 6) {
// Event type is 'data_access' -- contains 12 performance counters
ExpEnv.stats_struc.papi_valid_values = (short*)malloc(12*sizeof(short));
/* Initializing 'ExpEnv.stats_struc.papi_valid_values'. Not all performance counters of an event are available, because they are machine-dependent. 'ExpEnv.stats_struc.papi_valid_values[i]' will be set with '1' if event 'i' is available */
for (i = 0; i < 12; i++) {
ExpEnv.stats_struc.papi_valid_values[i] = 0;
}
/* Adding performance counters of event*/
// Data Access -- Load instructions
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_LD_INS) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[0] = 1;
// Data Access -- Load/store instructions completed
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_LST_INS) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[1] = 1;
// Data Access -- Cycles load/store units are idle
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_LSU_IDL) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[2] = 1;
// Data Access -- Cycles Stalled Waiting for memory reads
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_MEM_RCY) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[3] = 1;
// Data Access -- Cycles Stalled Waiting for memory accesses
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_MEM_SCY) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[4] = 1;
// Data Access -- Cycles Stalled Waiting for memory writes
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_MEM_WCY) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[5] = 1;
// Data Access -- Data prefetch cache misses
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_PRF_DM) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[6] = 1;
// Data Access -- Cycles stalled on any resource
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_RES_STL) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[7] = 1;
// Data Access -- Store instructions
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_SR_INS) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[8] = 1;
// Data Access -- Cycles with no instructions completed
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_STL_CCY) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[9] = 1;
// Data Access -- Cycles with no instruction issue
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_STL_ICY) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[10] = 1;
// Data Access -- Synchronization instructions completed
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_SYC_INS) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[11] = 1;
}
else if (ExpEnv.stats_struc.papi_event_type == 7) {
// Event type is 'tbl_operations' -- contains 4 performance counters
ExpEnv.stats_struc.papi_valid_values = (short*)malloc(4*sizeof(short));
/* Initializing 'ExpEnv.stats_struc.papi_valid_values'. Not all performance counters of an event are available, because they are machine-dependent. 'ExpEnv.stats_struc.papi_valid_values[i]' will be set with '1' if event 'i' is available */
for (i = 0; i < 4; i++) {
ExpEnv.stats_struc.papi_valid_values[i] = 0;
}
/* Adding performance counters of event*/
// TLB Operations -- Data translation lookaside buffer misses
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_TLB_DM) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[0] = 1;
// TLB Operations -- Instruction translation lookaside buffer misses
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_TLB_IM) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[1] = 1;
// TLB Operations -- Translation lookaside buffer shootdowns
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_TLB_SD) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[2] = 1;
// TLB Operations -- Total translation lookaside buffer misses
if (PAPI_add_event(ExpEnv.stats_struc.papi_eventset, PAPI_TLB_TL) == PAPI_OK)
ExpEnv.stats_struc.papi_valid_values[3] = 1;
}
// Setting 'ExpEnv.stats_struc.papi_initialized'. This flag will be tested on predicate 'statistics_jit/0' and event's results will be emitted if '1'
ExpEnv.stats_struc.papi_initialized = 1;
/* Start counting */
if (PAPI_start(ExpEnv.stats_struc.papi_eventset) != PAPI_OK)
ExpEnv.stats_struc.papi_initialized = 0;
/***/
return TRUE;
}
else {
// ARG1 is not an atom
Yap_NilError(INVALID_PARAMETER_TYPE_ERROR, "Low-level stats");
return FALSE;
}
}
static Int
p_statistics_jit( USES_REGS1 )
{
if (NativeArea && NativeArea->n) { // This exp will be true only if JIT Compiler was used
// printing...
int i, j;
fprintf(stderr, "------------------------------\n");
fprintf(stderr, "Statistics for JIT::\n");
fprintf(stderr, "------------------------------\n");
for (i = 0; i < NativeArea->n; i++) { // For each slot in NativeArea
if (NativeArea->area.ok[i] == 1) { // For each compiled code. Some slots in NativeArea may be empty because not all code is compiled (I still do not know why LLVM fails to compile some code)
fprintf(stderr, " Trace %d:\n", i+1);
/* print size of each intermediate code compiled on each (re)compilation */
for (j = 0; j < NativeArea->area.nrecomp[i]; j++) {
fprintf(stderr, "\tSize (%d): %ld bytes.\n", j+1, NativeArea->area.trace_size_bytes[i][j]);
}
/* print size of each native code on each (re)compilation */
for (j = 0; j < NativeArea->area.nrecomp[i]; j++) {
fprintf(stderr, "\tNative size (%d): %ld bytes.\n", j+1, NativeArea->area.native_size_bytes[i][j]);
}
/* print compile time of each native code on each (re)compilation */
for (j = 0; j < NativeArea->area.nrecomp[i]; j++) {
fprintf(stderr, "\tNative compile time (%d): %.3lf sec.\n", j+1, NativeArea->area.compilation_time[i][j]);
}
// get address on IntermediatecodeArea which is stored on first instruction of native code (this instruction is NativeArea->area.pc[i]')
int taddress = ((yamop*)NativeArea->area.pc[i])->u.jhc.jh->caa.taddress;
if (taddress != -1) {
fprintf(stderr, "\tProfiling time: %.3lf sec.\n", IntermediatecodeArea->area.profiling_time[taddress]);
fprintf(stderr, "\tRun time: %.3lf sec.\n", NativeArea->t_runs[i]);
fprintf(stderr, "\t%ld runs\n", NativeArea->runs[i]);
fprintf(stderr, "\t%ld success\n", NativeArea->success[i]);
}
}
}
fprintf(stderr, "------------------------------\n");
}
// From this point until the end we do:
// 1. We verify if PAPI was initialized (ExpEnv.stats_struc.papi_initialized). If yes, we do:
// 2. We verify what event type was used. Based on this, we alloc memory for 'ExpEnv.stats_struc.papi_values'
// 3. 'ExpEnv.stats_struc.papi_values' is a vector which will be contain performance counters' values
// 4. As previously mentioned, not all performance counters are available on target machine. For such, the position in 'ExpEnv.stats_struc.papi_values' will be '0'. Therefore not be considered
// 5. Values of each performance counter will be read by function 'PAPI_read'. Note that one of argument is that 'ExpEnv.stats_struc.papi_values'
// 6. Finally, values will be printed (stderr)
if (ExpEnv.stats_struc.papi_initialized) {
if (ExpEnv.stats_struc.papi_event_type == 0)
ExpEnv.stats_struc.papi_values = (long long*)malloc(9*sizeof(long long));
else if (ExpEnv.stats_struc.papi_event_type == 1)
ExpEnv.stats_struc.papi_values = (long long*)malloc(5*sizeof(long long));
else if (ExpEnv.stats_struc.papi_event_type == 2)
ExpEnv.stats_struc.papi_values = (long long*)malloc(3*sizeof(long long));
else if (ExpEnv.stats_struc.papi_event_type == 3)
ExpEnv.stats_struc.papi_values = (long long*)malloc(14*sizeof(long long));
else if (ExpEnv.stats_struc.papi_event_type == 4)
ExpEnv.stats_struc.papi_values = (long long*)malloc(9*sizeof(long long));
else if (ExpEnv.stats_struc.papi_event_type == 5)
ExpEnv.stats_struc.papi_values = (long long*)malloc(51*sizeof(long long));
else if (ExpEnv.stats_struc.papi_event_type == 6)
ExpEnv.stats_struc.papi_values = (long long*)malloc(12*sizeof(long long));
else if (ExpEnv.stats_struc.papi_event_type == 7)
ExpEnv.stats_struc.papi_values = (long long*)malloc(4*sizeof(long long));
if (PAPI_read(ExpEnv.stats_struc.papi_eventset, ExpEnv.stats_struc.papi_values) != PAPI_OK)
fprintf (stderr, "%s:%d\t ERROR\n", __FILE__, __LINE__);
int k = 0;
if (ExpEnv.stats_struc.papi_event_type == 0) {
if (ExpEnv.stats_struc.papi_valid_values[0])
fprintf(stderr, "\tConditional branch instructions:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[1])
fprintf(stderr, "\tBranch instructions:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[2])
fprintf(stderr, "\tConditional branch instructions mispredicted:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[3])
fprintf(stderr, "\tConditional branch instructions not taken:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[4])
fprintf(stderr, "\tConditional branch instructions correctly predicted:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[5])
fprintf(stderr, "\tConditional branch instructions taken:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[6])
fprintf(stderr, "\tUnconditional branch instructions:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[7])
fprintf(stderr, "\tCycles branch units are idle:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[8])
fprintf(stderr, "\tBranch target address cache misses:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
}
else if (ExpEnv.stats_struc.papi_event_type == 1) {
if (ExpEnv.stats_struc.papi_valid_values[0])
fprintf(stderr, "\tRequests for exclusive access to clean cache line:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[1])
fprintf(stderr, "\tRequests for cache line invalidation:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[2])
fprintf(stderr, " CCache Requests -- Requests for cache line intervention:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[3])
fprintf(stderr, "\tRequests for exclusive access to shared cache line:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[4])
fprintf(stderr, "\tRequests for a snoop:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
}
else if (ExpEnv.stats_struc.papi_event_type == 2) {
if (ExpEnv.stats_struc.papi_valid_values[0])
fprintf(stderr, "\tFailed store conditional instructions:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[1])
fprintf(stderr, "\tSuccessful store conditional instructions:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[2])
fprintf(stderr, "\tTotal store conditional instructions:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
}
else if (ExpEnv.stats_struc.papi_event_type == 3) {
if (ExpEnv.stats_struc.papi_valid_values[0])
fprintf(stderr, "\tFloating point add instructions:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[1])
fprintf(stderr, "\tFloating point divide instructions:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[2])
fprintf(stderr, "\tFMA instructions completed:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[3])
fprintf(stderr, "\tFloating point multiply instructions:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[4])
fprintf(stderr, "\tFloating point inverse instructions:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[5])
fprintf(stderr, "\tFloating point instructions:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[6])
fprintf(stderr, "\tFloating point operations:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[7])
fprintf(stderr, "\tCycles the FP unit:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[8])
fprintf(stderr, "\tCycles floating point units are idle:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[9])
fprintf(stderr, "\tFloating point square root instructions:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[10])
fprintf(stderr, "\tFloating point operations executed; optimized to count scaled single precision vector operations:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[11])
fprintf(stderr, "\tFloating point operations executed; optimized to count scaled double precision vector operations:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[12])
fprintf(stderr, "\tSingle precision vector/SIMD instructions:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[13])
fprintf(stderr, "\tDouble precision vector/SIMD instructions:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
}
else if (ExpEnv.stats_struc.papi_event_type == 4) {
if (ExpEnv.stats_struc.papi_valid_values[0])
fprintf(stderr, "\tCycles with maximum instructions completed:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[1])
fprintf(stderr, " FInstruction Counting -- Cycles with maximum instruction issue:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[2])
fprintf(stderr, "\tCycles integer units are idle:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[3])
fprintf(stderr, "\tHardware interrupts:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[4])
fprintf(stderr, "\tInteger instructions:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[5])
fprintf(stderr, "\tTotal cycles:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[6])
fprintf(stderr, "\tInstructions issued:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[7])
fprintf(stderr, "\tInstructions completed:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[8])
fprintf(stderr, "\tVector/SIMD instructions:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
}
else if (ExpEnv.stats_struc.papi_event_type == 5) {
if (ExpEnv.stats_struc.papi_valid_values[0])
fprintf(stderr, "\tL1 data cache accesses:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[1])
fprintf(stderr, "\tL1 data cache hits:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[2])
fprintf(stderr, "\tL1 data cache misses:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[3])
fprintf(stderr, "\tL1 data cache reads:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[4])
fprintf(stderr, "\tL1 data cache writes:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[5])
fprintf(stderr, "\tL1 instruction cache accesses:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[6])
fprintf(stderr, "\tL1 instruction cache hits:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[7])
fprintf(stderr, "\tL1 instruction cache misses:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[8])
fprintf(stderr, "\tL1 instruction cache reads:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[9])
fprintf(stderr, "\tL1 instruction cache writes:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[10])
fprintf(stderr, "\tL1 load misses:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[11])
fprintf(stderr, "\tL1 store misses:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[12])
fprintf(stderr, "\tL1 total cache accesses:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[13])
fprintf(stderr, "\tL1 total cache hits:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[14])
fprintf(stderr, "\tL1 total cache misses:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[15])
fprintf(stderr, "\tL1 total cache reads:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[16])
fprintf(stderr, "\tL1 total cache writes:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[17])
fprintf(stderr, "\tL2 data cache accesses:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[18])
fprintf(stderr, "\tL2 data cache hits:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[19])
fprintf(stderr, "\tL2 data cache misses:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[20])
fprintf(stderr, "\tL2 data cache reads:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[21])
fprintf(stderr, "\tL2 data cache writes:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[22])
fprintf(stderr, "\tL2 instruction cache accesses:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[23])
fprintf(stderr, "\tL2 instruction cache hits:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[24])
fprintf(stderr, "\tL2 instruction cache misses:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[25])
fprintf(stderr, "\tL2 instruction cache reads:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[26])
fprintf(stderr, "\tL2 instruction cache writes:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[27])
fprintf(stderr, "\tL2 load misses:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[28])
fprintf(stderr, "\tL2 store misses:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[29])
fprintf(stderr, "\tL2 total cache accesses:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[30])
fprintf(stderr, "\tL2 total cache hits:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[31])
fprintf(stderr, "\tL2 total cache misses:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[32])
fprintf(stderr, "\tL2 total cache reads:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[33])
fprintf(stderr, "\tL2 total cache writes:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[34])
fprintf(stderr, "\tL3 data cache accesses:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[35])
fprintf(stderr, "\tL3 data cache hits:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[36])
fprintf(stderr, "\tL3 data cache misses:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[37])
fprintf(stderr, "\tL3 data cache reads:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[38])
fprintf(stderr, "\tL3 data cache writes:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[39])
fprintf(stderr, "\tL3 instruction cache accesses:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[40])
fprintf(stderr, "\tL3 instruction cache hits:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[41])
fprintf(stderr, "\tL3 instruction cache misses:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[42])
fprintf(stderr, "\tL3 instruction cache reads:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[43])
fprintf(stderr, "\tL3 instruction cache writes:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[44])
fprintf(stderr, "\tL3 load misses:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[45])
fprintf(stderr, "\tL3 store misses:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[46])
fprintf(stderr, "\tL3 total cache accesses:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[47])
fprintf(stderr, "\tL3 total cache hits:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[48])
fprintf(stderr, "\tL3 total cache misses:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[49])
fprintf(stderr, "\tL3 total cache reads:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[50])
fprintf(stderr, "\tL3 total cache writes:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
}
else if (ExpEnv.stats_struc.papi_event_type == 6) {
if (ExpEnv.stats_struc.papi_valid_values[0])
fprintf(stderr, "\tLoad instructions:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[1])
fprintf(stderr, "\tLoad/store instructions completed:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[2])
fprintf(stderr, "\tCycles load/store units are idle:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[3])
fprintf(stderr, "\tCycles Stalled Waiting for memory reads:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[4])
fprintf(stderr, "\tCycles Stalled Waiting for memory accesses:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[5])
fprintf(stderr, "\tCycles Stalled Waiting for memory writes:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[6])
fprintf(stderr, "\tData prefetch cache misses:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[7])
fprintf(stderr, "\tCycles stalled on any resource:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[8])
fprintf(stderr, "\tStore instructions:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[9])
fprintf(stderr, "\tCycles with no instructions completed:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[10])
fprintf(stderr, "\tCycles with no instruction issue:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[11])
fprintf(stderr, "\tSynchronization instructions completed:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
}
else if (ExpEnv.stats_struc.papi_event_type == 7) {
if (ExpEnv.stats_struc.papi_valid_values[0])
fprintf(stderr, "\tData translation lookaside buffer misses:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[1])
fprintf(stderr, "\tInstruction translation lookaside buffer misses:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[2])
fprintf(stderr, "\tTranslation lookaside buffer shootdowns:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
if (ExpEnv.stats_struc.papi_valid_values[3])
fprintf(stderr, "\tTotal translation lookaside buffer misses:: %lld\n", ExpEnv.stats_struc.papi_values[k++]);
}
fprintf(stderr, "------------------------------\n");
}
return TRUE;
}
#pragma GCC diagnostic pop
void
Yap_InitJitStatisticPreds(void)
{
Yap_InitCPred("init_low_level_stats", 1, p_init_low_level_stats, SafePredFlag);
Yap_InitCPred("statistics_jit", 0, p_statistics_jit, SafePredFlag);
}

1213
JIT/jit_transformpreds.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -103,6 +103,11 @@ TEXI2HTML=texi2html
TEXI2PDF=texi2pdf
YAPLIB=@YAPLIB@
SONAMEFLAG=@SONAMEFLAG@
#---------------
JITFLAGS=@JITFLAGS@
JITLD=@JITLD@
JITLIBS=@JITLIBS@
PAPILIB=@PAPILIB@
VPATH=@srcdir@
CWD=$(PWD)
@ -211,7 +216,9 @@ HEADERS = \
OPTYap/locks_mips_funcs.h OPTYap/locks_alpha.h \
OPTYap/locks_alpha_funcs.h \
OPTYap/locks_pthread.h \
library/dialect/swi/fli/swi.h
library/dialect/swi/fli/swi.h \
JIT/HPP/JIT.hh JIT/HPP/JIT_Compiler.hh \
JIT/HPP/jit_predicates.hh
IOLIB_SOURCES=os/pl-buffer.c os/pl-ctype.c \
os/pl-codelist.c \
@ -277,7 +284,6 @@ C_SOURCES= \
C/utilpreds.c C/write.c console/yap.c \
C/yap-args.c \
C/ypstdio.c \
CXX/yapi.cpp \
BEAM/eam_am.c BEAM/eam_showcode.c \
BEAM/eamindex.c BEAM/eamamasm.c \
BEAM/eam_gc.c BEAM/eam_split.c \
@ -293,6 +299,11 @@ C_SOURCES= \
# library/mpi/mpi.c library/mpi/mpe.c \
# library/lammpi/yap_mpi.c library/lamm1pi/hash.c library/lammpi/prologterms2c.c
CXX_SOURCES = \
CXX/yapi.cpp \
JIT/JIT_Compiler.cpp
PLCONS_SOURCES = \
console/LGPL/pl-nt.c \
console/LGPL/pl-ntcon.c \
@ -388,6 +399,15 @@ ENGINE_OBJECTS = \
yap-args.o write.o \
blobs.o swi.o ypstdio.o $(IOLIB_OBJECTS)
JIT_OBJECTS = \
@JITCOMPILER@ \
@JITCONFIGPREDS@ \
@JITANALYSISPREDS@ \
@JITTRANSFORMPREDS@ \
@JITCODEGENPREDS@ \
@JITDEBUGPREDS@ \
@JITSTATISTICPREDS@
LIBTAI_OBJECTS = \
tai_add.o tai_now.o tai_pack.o \
tai_sub.o tai_unpack.o taia_add.o taia_approx.o \
@ -415,7 +435,7 @@ BEAM_OBJECTS = \
STATIC_OBJECTS = \
@STATIC_MODE@sys.o yap_random.o regexp.o @NO_BUILTIN_REGEXP@ regcomp.o regerror.o regfree.o regexec.o
LIB_OBJECTS = $(ENGINE_OBJECTS) $(C_INTERFACE_OBJECTS) $(OR_OBJECTS) $(BEAM_OBJECTS) $(STATIC_OBJECTS) $(LIBTAI_OBJECTS)
LIB_OBJECTS = $(ENGINE_OBJECTS) $(C_INTERFACE_OBJECTS) $(OR_OBJECTS) $(BEAM_OBJECTS) $(STATIC_OBJECTS) $(LIBTAI_OBJECTS) $(JIT_OBJECTS)
OBJECTS = yap.o yapi.o $(LIB_OBJECTS)
@ -482,6 +502,12 @@ yap_random.o: library/random/yap_random.c config.h
%.o: os/%.c config.h
$(CC) -c $(CFLAGS) -I$(srcdir)/include -I$(srcdir) -Ios @EXTRA_INCLUDES_FOR_WIN32@ $< -o $@
JIT_Compiler.o: IT/JIT_Compiler.cpp
$(CXX) -c $(CFLAGS) $(JITFLAGS) $< -o $@
%.o: $JIT/%.c
$(CC) -c $(CFLAGS) $< -o $@
pl-ntcon.o: console/LGPL/pl-ntcon.c config.h
$(CC) -c $(CFLAGS) -DPL_CONSOLE=1 -I$(srcdir)/include $< -o $@
@ -569,8 +595,8 @@ all: startup.yss
-rm -f startup.yss
echo "bootstrap('$(srcdir)/pl/init.yap'). module(user). qsave_program('startup.yss')." | @PRE_INSTALL_ENV@ ./yap@EXEC_SUFFIX@ -b $(srcdir)/pl/boot.yap
yap@EXEC_SUFFIX@: $(HEADERS) yap.o @YAPLIB@ libYap.a
$(MPI_CC) $(EXECUTABLE_CFLAGS) $(LDFLAGS) -o yap@EXEC_SUFFIX@ yap.o @YAPLIB@ $(LIBS)
yap@EXEC_SUFFIX@: $(HEADERS) yap.o @YAPLIB@ libYap.a
$(MPI_CC) $(EXECUTABLE_CFLAGS) $(LDFLAGS) -o yap@EXEC_SUFFIX@ yap.o @YAPLIB@ $(PAPILIB) $(JITLIBS) $(JITLD)
yap-win: yap-win@EXEC_SUFFIX@

268
configure vendored
View File

@ -701,6 +701,19 @@ RFC822_CFLAGS
RFC2045_CFLAGS
RFC2045CHARSET
rfc822includedir
CLANG
LLVM
PAPILIB
JITCODEGENPREDS
JITTRANSFORMPREDS
JITANALYSISPREDS
JITCONFIGPREDS
JITCOMPILER
JITSTATISTICPREDS
JITDEBUGPREDS
JITLIBS
JITLD
JITFLAGS
MYDDAS_LIBS
PKG_MYDDAS
EXTRA_LIBS_FOR_SWIDLLS
@ -883,6 +896,9 @@ with_max_threads
enable_myddas
enable_myddas_stats
enable_myddas_top_level
enable_jit
enable_debug_predicates
enable_statistic_predicates
with_rfc2045_package
with_rfc2045_version
enable_mimecharset
@ -1553,6 +1569,9 @@ Optional Features:
--enable-myddas[=DIR] enable the MYDDAS library
--enable-myddas-stats enable the MYDDAS library statistics support
--enable-myddas-top-level enable the MYDDAS top-level support to MySQL
--enable-jit support just-in-time (JIT) compilation
--enable-debug-predicates support debug predicates
--enable-statistic-predicates support statistic predicates
--enable-mimecharset=charset Default MIME charset to set on new messages
--enable-bddlib dynamic bdd library
--enable-cplint=DIR enable the cplint library using the CUDD library in DIR/lib
@ -10386,6 +10405,244 @@ fi
# Check whether --enable-jit was given.
if test "${enable_jit+set}" = set; then :
enableval=$enable_jit; yap_jit="$enableval"
else
yap_jit=no
fi
# Check whether --enable-debug-predicates was given.
if test "${enable_debug_predicates+set}" = set; then :
enableval=$enable_debug_predicates; dbg_preds="$enableval"
else
dbg_preds=no
fi
# Check whether --enable-statistic-predicates was given.
if test "${enable_statistic_predicates+set}" = set; then :
enableval=$enable_statistic_predicates; stat_preds="$enableval"
else
stat_preds=no
fi
if test "$yap_jit" = "yes"
then
# Extract the first word of "llvm-config", so it can be a program name with args.
set dummy llvm-config; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_LLVM+:} false; then :
$as_echo_n "(cached) " >&6
else
if test -n "$LLVM"; then
ac_cv_prog_LLVM="$LLVM" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_LLVM="yes"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
test -z "$ac_cv_prog_LLVM" && ac_cv_prog_LLVM="no"
fi
fi
LLVM=$ac_cv_prog_LLVM
if test -n "$LLVM"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $LLVM" >&5
$as_echo "$LLVM" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
if test "$LLVM" = "no" ;then
as_fn_error $? "--enable-jit was given, but test for LLVM 3.1 failed" "$LINENO" 5
else
LLVM_VERSION="`llvm-config --version`"
if test "$LLVM_VERSION" != "3.1";then
as_fn_error $? "Test for LLVM 3.1 failed" "$LINENO" 5
fi
fi
# Extract the first word of "clang", so it can be a program name with args.
set dummy clang; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_CLANG+:} false; then :
$as_echo_n "(cached) " >&6
else
if test -n "$CLANG"; then
ac_cv_prog_CLANG="$CLANG" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_CLANG="yes"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
test -z "$ac_cv_prog_CLANG" && ac_cv_prog_CLANG="no"
fi
fi
CLANG=$ac_cv_prog_CLANG
if test -n "$CLANG"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CLANG" >&5
$as_echo "$CLANG" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
if test "$CLANG" = "no" ;then
as_fn_error $? "--enable-jit was given, but test for clang faild" "$LINENO" 5
fi
YAP_EXTRAS="$YAP_EXTRAS -DYAP_JIT=1"
JITCOMPILER="JIT_Compiler.o"
JITCONFIGPREDS="jit_configpreds.o"
JITANALYSISPREDS="jit_analysispreds.o"
JITTRANSFORMPREDS="jit_transformpreds.o"
JITCODEGENPREDS="jit_codegenpreds.o"
JITFLAGS="`llvm-config --cxxflags`"
JITLD="`llvm-config --ldflags`"
JITLIBS="`llvm-config --libs all`"
fi
if test "$dbg_preds" = "yes"
then
if test "$yap_jit" = "no"
then
as_fn_error $? "--enable-debug-predicates was given, but --enable-jit was not given" "$LINENO" 5
fi
YAP_EXTRAS="$YAP_EXTRAS -DYAP_DBG_PREDS=1"
JITDEBUGPREDS="jit_debugpreds.o"
fi
if test "$stat_preds" = "yes"
then
if test "$yap_jit" = "no"
then
as_fn_error $? "--enable-statistic-predicates was given, but --enable-jit was not given" "$LINENO" 5
fi
ac_fn_c_check_header_mongrel "$LINENO" "papi.h" "ac_cv_header_papi_h" "$ac_includes_default"
if test "x$ac_cv_header_papi_h" = xyes; then :
else
if test "$stat_preds" != "no"; then
as_fn_error $? "--enable-statistic-predicates was given, but papi.h not found" "$LINENO" 5
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for PAPI_start in -lpapi" >&5
$as_echo_n "checking for PAPI_start in -lpapi... " >&6; }
if ${ac_cv_lib_papi_PAPI_start+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lpapi $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char PAPI_start ();
int
main ()
{
return PAPI_start ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_papi_PAPI_start=yes
else
ac_cv_lib_papi_PAPI_start=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_papi_PAPI_start" >&5
$as_echo "$ac_cv_lib_papi_PAPI_start" >&6; }
if test "x$ac_cv_lib_papi_PAPI_start" = xyes; then :
if test "$stat_preds" != "no"; then
PAPILIB="-lpapi"
fi
else
if test "$stat_preds" != "no"; then
as_fn_error $? "--enable-statistic-predicates was given, but test for papi failed" "$LINENO" 5
fi
fi
YAP_EXTRAS="$YAP_EXTRAS -DYAP_STAT_PREDS=1"
JITSTATISTICPREDS="jit_statisticpreds.o"
PAPILIB="-lpapi"
fi
if test "$PKG_CLIB" != ""
then
@ -13338,7 +13595,7 @@ else
JAVA_TEST=Test.java
CLASS_TEST=Test.class
cat << \EOF > $JAVA_TEST
/* #line 13341 "configure" */
/* #line 13598 "configure" */
public class Test {
}
EOF
@ -13514,7 +13771,7 @@ EOF
if uudecode$EXEEXT Test.uue; then
ac_cv_prog_uudecode_base64=yes
else
echo "configure: 13517: uudecode had trouble decoding base 64 file 'Test.uue'" >&5
echo "configure: 13774: uudecode had trouble decoding base 64 file 'Test.uue'" >&5
echo "configure: failed file was:" >&5
cat Test.uue >&5
ac_cv_prog_uudecode_base64=no
@ -13645,7 +13902,7 @@ else
JAVA_TEST=Test.java
CLASS_TEST=Test.class
cat << \EOF > $JAVA_TEST
/* #line 13648 "configure" */
/* #line 13905 "configure" */
public class Test {
}
EOF
@ -13680,7 +13937,7 @@ JAVA_TEST=Test.java
CLASS_TEST=Test.class
TEST=Test
cat << \EOF > $JAVA_TEST
/* [#]line 13683 "configure" */
/* [#]line 13940 "configure" */
public class Test {
public static void main (String args[]) {
System.exit (0);
@ -14348,8 +14605,7 @@ fi
if test -e "$srcdir"/packages/raptor/Makefile.in
then
PKG_RAPTOR="packages/raptor"
PKG_RAPTOR="packages/raptor"