1 /* Copyright (c) 2015 Regents of the University of California
3 * Author: Brian Demsky <bdemsky@uci.edu>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * version 2 as published by the Free Software Foundation.
13 #include "stl-model.h"
16 #include "modeltypes.h"
17 #include <libinterface.h>
20 typedef ModelVector<EPValue *> ValueVector;
21 const char * eventToStr(EventType event);
27 inline unsigned int RIDP_hash_function(struct RecordIDPair * pair) {
28 return (unsigned int)(((uintptr_t)pair->record) >> 4) ^ ((uintptr_t)pair->idrecord);
31 inline bool RIDP_equals(struct RecordIDPair * key1, struct RecordIDPair * key2) {
34 return key1->record == key2->record && key1->idrecord == key2->idrecord;
37 typedef HashSet<struct RecordIDPair *, uintptr_t, 0, model_malloc, model_calloc, model_free, RIDP_hash_function, RIDP_equals> EPRecordIDSet;
39 typedef HSIterator<struct RecordIDPair *, uintptr_t, 0, model_malloc, model_calloc, model_free, RIDP_hash_function, RIDP_equals> EPRecordIDIterator;
43 EPRecord(EventType event, ExecPoint *execpoint, EPValue *branch, uintptr_t _offset, unsigned int numinputs,uint len, bool anyvalue = false);
45 ExecPoint * getEP() {return execpoint;}
46 void addEPValue(EPValue *v) {valuevector->push_back(v);}
47 bool hasAddr(const void *addr);
48 bool hasValue(uint64_t val);
49 unsigned int numValues() {return valuevector->size();}
50 EPValue * getValue(unsigned int i) {return (*valuevector)[i];}
51 EPValue * getBranch() {return branch;}
52 int getIndex(EPValue *v);
53 int getIndex(uint64_t val);
54 EventType getType() {return event;}
55 CGoalSet *completedGoalSet() {return completed;}
56 IntHashSet * getSet(unsigned int i) {return setarray[i];}
57 IntHashSet * getReturnValueSet();
58 IntHashSet * getStoreSet() { if (event==RMW) return setarray[VC_RMWOUTINDEX]; else return setarray[VC_BASEINDEX];}
59 uint getNumInputs() {return numinputs;}
60 uint getNumFuncInputs() {return numinputs-VC_BASEINDEX;}
61 bool getBranchAnyValue() {return anyvalue;}
64 EPRecord *getNextRecord() {return nextRecord;}
65 EPRecord *getChildRecord() {return childRecord;}
66 void setNextRecord(EPRecord * n) {nextRecord=n;}
67 void setChildRecord(EPRecord *n) {childRecord=n;}
68 bool getPhi() {return phi;}
69 void setPhi() {phi=true;}
70 bool getLoopPhi() {return loopphi;}
71 void setLoopPhi() {if (philooptable==NULL) philooptable=new EPRecordIDSet(); phi=true; loopphi=true;}
72 void setRMW(enum atomicop _op) {op=_op;}
73 enum atomicop getOp() {return op;}
74 uint getLen() {return len;}
75 void setJoinThread(thread_id_t _j) {jointhread=_j;}
76 thread_id_t getJoinThread() {return jointhread;}
77 EPRecordIDSet * getPhiLoopTable() {return philooptable;}
78 void setSize(size_t s) {size=s;}
79 size_t getSize() {return size;}
80 void setPtr(void *p) {ptr=p;}
81 void * getPtr() {return ptr;}
82 void setCompletedGoal(CGoalSet *c, bool shared) {completed=c;func_shares_goalset=shared;}
83 bool isSharedGoals() {return func_shares_goalset;}
84 uintptr_t getOffset() {return offset;}
88 ValueVector * valuevector;
89 ExecPoint * execpoint;
92 IntHashSet **setarray;
94 EPRecord *childRecord;
95 EPRecordIDSet * philooptable;
98 thread_id_t jointhread;
99 unsigned int numinputs;
106 bool func_shares_goalset;