Add initial code for power 32 semantics and symbolic expansion for power 64
[dyninst.git] / dataflowAPI / rose / semantics / SymEvalSemantics.h
1 //
2 // Created by ssunny on 7/1/16.
3 //
4
5 #ifndef DYNINST_SYMEVALSEMANTICS_H
6 #define DYNINST_SYMEVALSEMANTICS_H
7
8 #include "external/rose/armv8InstructionEnum.h"
9 #include "BaseSemantics2.h"
10 #include "../../h/SymEval.h"
11
12 namespace rose {
13     namespace BinaryAnalysis {
14         namespace InstructionSemantics2 {
15             namespace SymEvalSemantics {
16
17                 /***************************************************************************************************/
18                 /*                                              SValue                                             */
19                 /***************************************************************************************************/
20
21                 typedef Sawyer::SharedPointer<class SValue> SValuePtr;
22
23                 class SValue : public BaseSemantics::SValue {
24                 protected:
25                     Dyninst::AST::Ptr expr;
26
27                     SValue(Dyninst::Absloc r, Dyninst::Address addr): BaseSemantics::SValue(64) {
28                         expr = Dyninst::DataflowAPI::VariableAST::create(Dyninst::DataflowAPI::Variable(Dyninst::AbsRegion(r), addr));
29                     }
30
31                     SValue(size_t nbits, uint64_t num): BaseSemantics::SValue(nbits) {
32                         expr = Dyninst::DataflowAPI::ConstantAST::create(Dyninst::DataflowAPI::Constant(num, nbits));
33                     }
34
35                     //TODO possibly set width differently for register types
36                     SValue(Dyninst::AST::Ptr expr): BaseSemantics::SValue(64) {
37                         this->expr = expr;
38                     }
39
40                 public:
41                     static SValuePtr instance(Dyninst::Absloc r, Dyninst::Address addr) {
42                         return SValuePtr(new SValue(r, addr));
43                     }
44
45                     static SValuePtr instance(size_t nbits, uint64_t num) {
46                         return SValuePtr(new SValue(nbits, num));
47                     }
48
49                     static SValuePtr instance(Dyninst::AST::Ptr expr) {
50                         return SValuePtr(new SValue(expr));
51                     }
52
53                 public:
54                     virtual BaseSemantics::SValuePtr undefined_(size_t nbits) const {
55                         return SValuePtr(new SValue(Dyninst::DataflowAPI::BottomAST::create(false)));
56                     }
57
58                     virtual BaseSemantics::SValuePtr unspecified_(size_t nbits) const {
59                         return SValuePtr(new SValue(Dyninst::DataflowAPI::BottomAST::create(false)));
60                     }
61
62                     //TODO
63                     virtual BaseSemantics::SValuePtr bottom_(size_t nbits) const {
64                         return SValuePtr(new SValue(Dyninst::DataflowAPI::BottomAST::create(true)));
65                     }
66
67                     virtual BaseSemantics::SValuePtr number_(size_t nbits, uint64_t num) const {
68                         return SValuePtr(new SValue(nbits, num));
69                     }
70
71                     virtual BaseSemantics::SValuePtr boolean_(bool value) const {
72                         return SValuePtr(new SValue(1, value?1:0));
73                     }
74
75                     virtual BaseSemantics::SValuePtr copy(size_t new_width = 0) const {
76                         SValuePtr retval(new SValue(get_expression()));
77                         if (new_width!=0 && new_width!=retval->get_width())
78                             retval->set_width(new_width);
79                         return retval;
80                     }
81
82                     virtual Sawyer::Optional<BaseSemantics::SValuePtr>
83                             createOptionalMerge(const BaseSemantics::SValuePtr &other, const BaseSemantics::MergerPtr&, SMTSolver*) const {
84                         ASSERT_not_implemented("SValue::createOptionalMerge not implemented for use in dyninst");
85                     }
86
87                 public:
88                     static SValuePtr promote(const BaseSemantics::SValuePtr &v) {
89                         SValuePtr retval = v.dynamicCast<SValue>();
90                         ASSERT_not_null(retval);
91                         return retval;
92                     }
93
94                 public:
95                     virtual Dyninst::AST::Ptr get_expression() const {
96                         return expr;
97                     }
98
99                     virtual bool isBottom() const {
100                         return expr->getID() == Dyninst::AST::V_BottomAST;
101                     }
102
103                     virtual bool is_number() const {
104                         return expr->getID() == Dyninst::AST::V_ConstantAST;
105                     }
106
107                     virtual uint64_t get_number() const {
108                         assert(expr->getID() == Dyninst::AST::V_ConstantAST);
109                         //TODO
110                         Dyninst::DataflowAPI::Constant constant = boost::dynamic_pointer_cast<Dyninst::DataflowAPI::ConstantAST>(expr)->val();
111                         return constant.val;
112                     }
113
114                     virtual void print(std::ostream &, BaseSemantics::Formatter &) const { }
115
116                 };
117
118
119                 /***************************************************************************************************/
120                 /*                                          Register State                                         */
121                 /***************************************************************************************************/
122
123                 typedef boost::shared_ptr<class RegisterStateAST> RegisterStateASTPtr;
124                 typedef boost::shared_ptr<class RegisterStateASTARM64> RegisterStateASTARM64Ptr;
125                 typedef boost::shared_ptr<class RegisterStateASTPPC32> RegisterStateASTPPC32Ptr;
126
127                 class RegisterStateAST : public BaseSemantics::RegisterState {
128                 public:
129                     RegisterStateAST(const BaseSemantics::SValuePtr &protoval,
130                                      const RegisterDictionary *regdict) : RegisterState(protoval, regdict) { }
131
132                 public:
133                     static RegisterStateASTPtr instance(const BaseSemantics::SValuePtr &protoval,
134                                                           const RegisterDictionary *regdict) {
135                         return RegisterStateASTPtr(new RegisterStateAST(protoval, regdict));
136                     }
137
138                     virtual BaseSemantics::RegisterStatePtr create(const BaseSemantics::SValuePtr &protoval,
139                                                                    const RegisterDictionary *regdict) const {
140                         return instance(protoval, regdict);
141                     }
142
143                     virtual BaseSemantics::RegisterStatePtr clone() const {
144                         ASSERT_not_implemented("RegisterState::clone() should not be called with Dyninst's SymEval policy");
145                     }
146
147                     static RegisterStateASTPtr promote(const BaseSemantics::RegisterStatePtr &from) {
148                         RegisterStateASTPtr retval = boost::dynamic_pointer_cast<RegisterStateAST>(from);
149                         ASSERT_not_null(retval);
150                         return retval;
151                     }
152
153                 public:
154                     virtual void clear() {
155                         ASSERT_not_implemented("RegisterState::clear() should not be called with Dyninst's SymEval policy");
156                     }
157
158                     virtual void zero() {
159                         ASSERT_not_implemented("RegisterState::zero() should not be called with Dyninst's SymEval policy");
160                     }
161
162                     virtual BaseSemantics::SValuePtr readRegister(const RegisterDescriptor &reg, const BaseSemantics::SValuePtr &dflt, BaseSemantics::RiscOperators *ops);
163                     virtual void writeRegister(const RegisterDescriptor &reg, const BaseSemantics::SValuePtr &value, BaseSemantics::RiscOperators *ops);
164
165                     virtual void print(std::ostream &, BaseSemantics::Formatter &) const {}
166
167                     virtual bool merge(const BaseSemantics::RegisterStatePtr &other, BaseSemantics::RiscOperators *ops) {
168                         return true;
169                     }
170
171                     BaseSemantics::SValuePtr readRegister(const RegisterDescriptor &reg, Dyninst::Address addr);
172                     void writeRegister(const RegisterDescriptor &reg, const BaseSemantics::SValuePtr &value,
173                                        Dyninst::DataflowAPI::Result_t &res, std::map<Dyninst::Absloc, Dyninst::Assignment::Ptr> &aaMap);
174
175                     Dyninst::AST::Ptr wrap(Dyninst::Absloc r, Dyninst::Address addr) {
176                         return Dyninst::DataflowAPI::VariableAST::create(Dyninst::DataflowAPI::Variable(Dyninst::AbsRegion(r), addr));
177                     }
178
179                 private:
180
181                     virtual Dyninst::Absloc convert(const RegisterDescriptor &reg);
182                 };
183
184                 class RegisterStateASTARM64 : public RegisterStateAST {
185                 public:
186                     RegisterStateASTARM64(const BaseSemantics::SValuePtr &protoval,
187                                           const RegisterDictionary *regdict) : RegisterStateAST(protoval, regdict) { }
188
189                     static RegisterStateASTARM64Ptr instance(const BaseSemantics::SValuePtr &protoval,
190                                                              const RegisterDictionary *regdict) {
191                         return RegisterStateASTARM64Ptr(new RegisterStateASTARM64(protoval, regdict));
192                     }
193
194                     static RegisterStateASTARM64Ptr promote(const BaseSemantics::RegisterStatePtr &from) {
195                         RegisterStateASTARM64Ptr retval = boost::dynamic_pointer_cast<RegisterStateASTARM64>(from);
196                         ASSERT_not_null(retval);
197                         return retval;
198                     }
199
200                 private:
201                     virtual Dyninst::Absloc convert(const RegisterDescriptor &reg);
202                 };
203                 
204                 class RegisterStateASTPPC32 : public RegisterStateAST {
205                 public:
206                     RegisterStateASTPPC32(const BaseSemantics::SValuePtr &protoval,
207                                           const RegisterDictionary *regdict) : RegisterStateAST(protoval, regdict) { }
208
209                     static RegisterStateASTPPC32Ptr instance(const BaseSemantics::SValuePtr &protoval,
210                                                              const RegisterDictionary *regdict) {
211                         return RegisterStateASTPPC32Ptr(new RegisterStateASTPPC32(protoval, regdict));
212                     }
213
214                     static RegisterStateASTPPC32Ptr promote(const BaseSemantics::RegisterStatePtr &from) {
215                         RegisterStateASTPPC32Ptr retval = boost::dynamic_pointer_cast<RegisterStateASTPPC32>(from);
216                         ASSERT_not_null(retval);
217                         return retval;
218                     }
219
220
221                 private:
222                     virtual Dyninst::Absloc convert(const RegisterDescriptor &reg);
223                 };
224
225
226                 /***************************************************************************************************/
227                 /*                                           Memory State                                          */
228                 /***************************************************************************************************/
229
230                 typedef boost::shared_ptr<class MemoryStateAST> MemoryStateASTPtr;
231
232                 class MemoryStateAST : public BaseSemantics::MemoryState {
233                 protected:
234                     MemoryStateAST(const BaseSemantics::SValuePtr &addrProtoval, const BaseSemantics::SValuePtr &valProtoval):
235                             BaseSemantics::MemoryState(addrProtoval, valProtoval) { }
236
237                 public:
238                     static MemoryStateASTPtr instance(const BaseSemantics::SValuePtr &addrProtoval, const BaseSemantics::SValuePtr &valProtoval) {
239                         return MemoryStateASTPtr(new MemoryStateAST(addrProtoval, valProtoval));
240                     }
241
242                     virtual BaseSemantics::MemoryStatePtr create(const BaseSemantics::SValuePtr &addrProtoval, const BaseSemantics::SValuePtr &valProtoval) const {
243                         return instance(addrProtoval, valProtoval);
244                     }
245
246                     static MemoryStateASTPtr promote(const BaseSemantics::MemoryStatePtr &from) {
247                         MemoryStateASTPtr retval = boost::dynamic_pointer_cast<MemoryStateAST>(from);
248                         ASSERT_not_null(retval);
249                         return retval;
250                     }
251
252                 public:
253                     virtual BaseSemantics::MemoryStatePtr clone() const {
254                         ASSERT_not_implemented("MemoryState::clone() should not be called with Dyninst's SymEval policy");
255                     }
256
257                     virtual void clear() {
258                         ASSERT_not_implemented("MemoryState::clear() should not be called with Dyninst's SymEval policy");
259                     }
260
261                     virtual void print(std::ostream&, BaseSemantics::Formatter&) const {
262                         //
263                     }
264
265                     virtual bool merge(const BaseSemantics::MemoryStatePtr &other, BaseSemantics::RiscOperators *addrOps, BaseSemantics::RiscOperators *valOps) {
266                         return true;
267                     }
268
269                 public:
270                     virtual BaseSemantics::SValuePtr readMemory(const BaseSemantics::SValuePtr &address, const BaseSemantics::SValuePtr &dflt,
271                                                                 BaseSemantics::RiscOperators *addrOps, BaseSemantics::RiscOperators *valOps);
272
273                     BaseSemantics::SValuePtr readMemory(const BaseSemantics::SValuePtr &address, size_t readSize);
274
275                     virtual void writeMemory(const BaseSemantics::SValuePtr &addr, const BaseSemantics::SValuePtr &value,
276                                              BaseSemantics::RiscOperators *addrOps, BaseSemantics::RiscOperators *valOps);
277
278                     void writeMemory(const BaseSemantics::SValuePtr &addr, const BaseSemantics::SValuePtr &value,
279                                        Dyninst::DataflowAPI::Result_t &res, std::map<Dyninst::Absloc, Dyninst::Assignment::Ptr> &aaMap, size_t writeSize);
280                 };
281
282
283                 /***************************************************************************************************/
284                 /*                                                State                                            */
285                 /***************************************************************************************************/
286
287                 typedef boost::shared_ptr<class StateAST> StateASTPtr;
288
289                 class StateAST : public BaseSemantics::State {
290                 public:
291                     StateAST(Dyninst::DataflowAPI::Result_t &r,
292                                Dyninst::Address a,
293                                Dyninst::Architecture ac,
294                                Dyninst::InstructionAPI::Instruction::Ptr insn_,
295                                const BaseSemantics::RegisterStatePtr &registers,
296                                const BaseSemantics::MemoryStatePtr &memory): BaseSemantics::State(registers, memory), res(r), addr(a), arch(ac), insn(insn_) {
297                         for (Dyninst::DataflowAPI::Result_t::iterator iter = r.begin();
298                              iter != r.end(); ++iter) {
299                             Dyninst::Assignment::Ptr a = iter->first;
300                             // For a different instruction...
301                             if (a->addr() != addr)
302                                 continue;
303                             Dyninst::AbsRegion &o = a->out();
304
305                             if (o.containsOfType(Dyninst::Absloc::Register)) {
306                                 // We're assuming this is a single register...
307                                 //std::cerr << "Marking register " << a << std::endl;
308                                 aaMap[o.absloc()] = a;
309                             }
310                             else {
311                                 // Use sufficiently-unique (Heap,0) Absloc
312                                 // to represent a definition to a memory absloc
313                                 aaMap[Dyninst::Absloc(0)] = a;
314                             }
315                         }
316                     }
317
318                 public:
319                     static StateASTPtr instance(Dyninst::DataflowAPI::Result_t &r,
320                                                   Dyninst::Address a,
321                                                   Dyninst::Architecture ac,
322                                                   Dyninst::InstructionAPI::Instruction::Ptr insn_,
323                                                   const BaseSemantics::RegisterStatePtr &registers,
324                                                   const BaseSemantics::MemoryStatePtr &memory) {
325                         return StateASTPtr(new StateAST(r, a, ac, insn_, registers, memory));
326                     }
327
328                     virtual BaseSemantics::StatePtr create(Dyninst::DataflowAPI::Result_t &r,
329                                                  Dyninst::Address a,
330                                                  Dyninst::Architecture ac,
331                                                  Dyninst::InstructionAPI::Instruction::Ptr insn_,
332                                                  const BaseSemantics::RegisterStatePtr &registers,
333                                                  const BaseSemantics::MemoryStatePtr &memory) const {
334                         return instance(r, a, ac, insn_, registers, memory);
335                     }
336
337                     static StateASTPtr promote(const BaseSemantics::StatePtr &from) {
338                         StateASTPtr retval = boost::dynamic_pointer_cast<StateAST>(from);
339                         ASSERT_not_null(retval);
340                         return retval;
341                     }
342
343                 public:
344                     virtual BaseSemantics::SValuePtr readRegister(const RegisterDescriptor &reg, const BaseSemantics::SValuePtr &dflt, BaseSemantics::RiscOperators *ops);
345                     virtual void writeRegister(const RegisterDescriptor &reg, const BaseSemantics::SValuePtr &value, BaseSemantics::RiscOperators *ops);
346                     virtual BaseSemantics::SValuePtr readMemory(const BaseSemantics::SValuePtr &address, const BaseSemantics::SValuePtr &dflt,
347                                                                 BaseSemantics::RiscOperators *addrOps, BaseSemantics::RiscOperators *valOps, size_t readSize = 0);
348                     virtual void writeMemory(const BaseSemantics::SValuePtr &addr, const BaseSemantics::SValuePtr &value, BaseSemantics::RiscOperators *addrOps,
349                                              BaseSemantics::RiscOperators *valOps, size_t writeSize = 0);
350
351                 protected:
352                     Dyninst::DataflowAPI::Result_t &res;
353                     Dyninst::Architecture arch;
354                     Dyninst::Address addr;
355                     Dyninst::InstructionAPI::Instruction::Ptr insn;
356
357                     std::map<Dyninst::Absloc, Dyninst::Assignment::Ptr> aaMap;
358                 };
359
360
361                 /***************************************************************************************************/
362                 /*                                          RiscOperators                                          */
363                 /***************************************************************************************************/
364                 typedef boost::shared_ptr<class RiscOperatorsAST> RiscOperatorsASTPtr;
365
366                 /** RISC operators for use by the Symbolic Semantics Domain of Dyninst.
367                  *
368                  */
369                 class RiscOperatorsAST : public BaseSemantics::RiscOperators {
370                 protected:
371                     RiscOperatorsAST(const BaseSemantics::SValuePtr &protoval, SMTSolver *solver = NULL)
372                             : BaseSemantics::RiscOperators(protoval, solver) {
373                         (void)SValue::promote(protoval);
374                     }
375
376                     RiscOperatorsAST(const BaseSemantics::StatePtr &state, SMTSolver *solver = NULL)
377                             : BaseSemantics::RiscOperators(state, solver) {
378                         (void)SValue::promote(state->protoval());
379                     }
380
381                 public:
382                     static RiscOperatorsASTPtr instance(const BaseSemantics::SValuePtr &protoval,
383                                                      SMTSolver *solver = NULL) {
384                         return RiscOperatorsASTPtr(new RiscOperatorsAST(protoval, solver));
385                     }
386
387                     static RiscOperatorsASTPtr instance(const BaseSemantics::StatePtr &state, SMTSolver *solver = NULL) {
388                         return RiscOperatorsASTPtr(new RiscOperatorsAST(state, solver));
389                     }
390
391                 public:
392                     virtual BaseSemantics::RiscOperatorsPtr create(const BaseSemantics::SValuePtr &protoval,
393                                                                    SMTSolver *solver = NULL) const {
394                         return instance(protoval, solver);
395                     }
396
397                     virtual BaseSemantics::RiscOperatorsPtr create(const BaseSemantics::StatePtr &state,
398                                                                    SMTSolver *solver = NULL) const {
399                         return instance(state, solver);
400                     }
401
402                 public:
403                     /** Run-time promotion of a base RiscOperators pointer to symbolic operators. This is a checked conversion--it
404                     *  will fail if @p x does not point to a SymbolicSemantics::RiscOperators object. */
405                     static RiscOperatorsASTPtr promote(const BaseSemantics::RiscOperatorsPtr &x) {
406                         RiscOperatorsASTPtr retval = boost::dynamic_pointer_cast<RiscOperatorsAST>(x);
407                         ASSERT_not_null(retval);
408                         return retval;
409                     }
410
411                 public:
412                     virtual BaseSemantics::SValuePtr boolean_(bool b) {
413                         SValuePtr retval = SValue::promote(BaseSemantics::RiscOperators::boolean_(b));
414                         return retval;
415                     }
416
417                     virtual BaseSemantics::SValuePtr number_(size_t nbits, uint64_t value) {
418                         SValuePtr retval = SValue::promote(BaseSemantics::RiscOperators::number_(nbits, value));
419                         return retval;
420                     }
421
422                 public:
423                     virtual BaseSemantics::SValuePtr and_(const BaseSemantics::SValuePtr &a_,
424                                                           const BaseSemantics::SValuePtr &b_);
425                     virtual BaseSemantics::SValuePtr or_(const BaseSemantics::SValuePtr &a_,
426                                                           const BaseSemantics::SValuePtr &b_);
427                     virtual BaseSemantics::SValuePtr xor_(const BaseSemantics::SValuePtr &a_,
428                                                           const BaseSemantics::SValuePtr &b_);
429                     virtual BaseSemantics::SValuePtr invert(const BaseSemantics::SValuePtr &a_);
430                     virtual BaseSemantics::SValuePtr extract(const BaseSemantics::SValuePtr &a_,
431                                                              uint64_t begin, uint64_t end);
432                     virtual BaseSemantics::SValuePtr ite(const BaseSemantics::SValuePtr &sel_,
433                                                          const BaseSemantics::SValuePtr &a_,
434                                                          const BaseSemantics::SValuePtr &b_);
435                     virtual BaseSemantics::SValuePtr concat(const BaseSemantics::SValuePtr &a_,
436                                                             const BaseSemantics::SValuePtr &b_);
437                     virtual BaseSemantics::SValuePtr leastSignificantSetBit(const BaseSemantics::SValuePtr &a_);
438                     virtual BaseSemantics::SValuePtr mostSignificantSetBit(const BaseSemantics::SValuePtr &a_);
439                     virtual BaseSemantics::SValuePtr rotateLeft(const BaseSemantics::SValuePtr &a_,
440                                                                 const BaseSemantics::SValuePtr &b_);
441                     virtual BaseSemantics::SValuePtr rotateRight(const BaseSemantics::SValuePtr &a_,
442                                                                 const BaseSemantics::SValuePtr &b_);
443                     virtual BaseSemantics::SValuePtr shiftLeft(const BaseSemantics::SValuePtr &a_,
444                                                                 const BaseSemantics::SValuePtr &b_);
445                     virtual BaseSemantics::SValuePtr shiftRight(const BaseSemantics::SValuePtr &a_,
446                                                                 const BaseSemantics::SValuePtr &b_);
447                     virtual BaseSemantics::SValuePtr shiftRightArithmetic(const BaseSemantics::SValuePtr &a_,
448                                                                 const BaseSemantics::SValuePtr &b_);
449                     virtual BaseSemantics::SValuePtr equalToZero(const BaseSemantics::SValuePtr &a_);
450                     virtual BaseSemantics::SValuePtr signExtend(const BaseSemantics::SValuePtr &a_,
451                                                                 uint64_t newwidth = 0);
452                     virtual BaseSemantics::SValuePtr add(const BaseSemantics::SValuePtr &a_,
453                                                          const BaseSemantics::SValuePtr &b_);
454                     virtual BaseSemantics::SValuePtr addWithCarries(const BaseSemantics::SValuePtr &a_,
455                                                                     const BaseSemantics::SValuePtr &b_,
456                                                                     const BaseSemantics::SValuePtr &c_,
457                                                                     BaseSemantics::SValuePtr &carry_out);
458                     virtual BaseSemantics::SValuePtr negate(const BaseSemantics::SValuePtr &a_);
459                     virtual BaseSemantics::SValuePtr signedDivide(const BaseSemantics::SValuePtr &a_,
460                                                                   const BaseSemantics::SValuePtr &b_);
461                     virtual BaseSemantics::SValuePtr signedModulo(const BaseSemantics::SValuePtr &a_,
462                                                                   const BaseSemantics::SValuePtr &b_);
463                     virtual BaseSemantics::SValuePtr signedMultiply(const BaseSemantics::SValuePtr &a_,
464                                                                   const BaseSemantics::SValuePtr &b_);
465                     virtual BaseSemantics::SValuePtr unsignedDivide(const BaseSemantics::SValuePtr &a_,
466                                                                   const BaseSemantics::SValuePtr &b_);
467                     virtual BaseSemantics::SValuePtr unsignedModulo(const BaseSemantics::SValuePtr &a_,
468                                                                   const BaseSemantics::SValuePtr &b_);
469                     virtual BaseSemantics::SValuePtr unsignedMultiply(const BaseSemantics::SValuePtr &a_,
470                                                                     const BaseSemantics::SValuePtr &b_);
471
472                 public:
473                     virtual BaseSemantics::SValuePtr readMemory(const RegisterDescriptor &segreg, const BaseSemantics::SValuePtr &addr, const BaseSemantics::SValuePtr &dflt,
474                                                  const BaseSemantics::SValuePtr &cond);
475                     virtual void writeMemory(const RegisterDescriptor &segreg, const BaseSemantics::SValuePtr &addr, const BaseSemantics::SValuePtr &data,
476                                              const BaseSemantics::SValuePtr &cond);
477
478                 private:
479                     Dyninst::AST::Ptr getUnaryAST(Dyninst::DataflowAPI::ROSEOperation::Op op,
480                                          Dyninst::AST::Ptr a,
481                                          size_t s = 0) {
482                         return Dyninst::DataflowAPI::RoseAST::create(Dyninst::DataflowAPI::ROSEOperation(op, s), a);
483                     }
484
485                     Dyninst::AST::Ptr getBinaryAST(Dyninst::DataflowAPI::ROSEOperation::Op op,
486                                                    Dyninst::AST::Ptr a,
487                                                    Dyninst::AST::Ptr b,
488                                           size_t s = 0) {
489                         return Dyninst::DataflowAPI::RoseAST::create(Dyninst::DataflowAPI::ROSEOperation(op, s), a, b);
490                     }
491
492                     Dyninst::AST::Ptr getTernaryAST(Dyninst::DataflowAPI::ROSEOperation::Op op,
493                                                     Dyninst::AST::Ptr a,
494                                                     Dyninst::AST::Ptr b,
495                                                     Dyninst::AST::Ptr c,
496                                            size_t s = 0) {
497                         return Dyninst::DataflowAPI::RoseAST::create(Dyninst::DataflowAPI::ROSEOperation(op, s), a, b, c);
498                     }
499
500                     SValuePtr createUnaryAST(Dyninst::DataflowAPI::ROSEOperation::Op op, const BaseSemantics::SValuePtr &a_) {
501                         Dyninst::AST::Ptr a = SValue::promote(a_)->get_expression();
502                         Dyninst::AST::Ptr ast = getUnaryAST(op, a);
503                         return SValue::instance(ast);
504                     }
505
506                     SValuePtr createBinaryAST(Dyninst::DataflowAPI::ROSEOperation::Op op, const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &b_) {
507                         Dyninst::AST::Ptr a = SValue::promote(a_)->get_expression();
508                         Dyninst::AST::Ptr b = SValue::promote(b_)->get_expression();
509                         Dyninst::AST::Ptr ast = getBinaryAST(op, a, b);
510                         return SValue::instance(ast);
511                     }
512
513                     SValuePtr createTernaryAST(Dyninst::DataflowAPI::ROSEOperation::Op op, const BaseSemantics::SValuePtr &a_,
514                                                const BaseSemantics::SValuePtr &b_, const BaseSemantics::SValuePtr &c_, size_t s = 0) {
515                         Dyninst::AST::Ptr a = SValue::promote(a_)->get_expression();
516                         Dyninst::AST::Ptr b = SValue::promote(b_)->get_expression();
517                         Dyninst::AST::Ptr c = SValue::promote(c_)->get_expression();
518                         Dyninst::AST::Ptr ast = getTernaryAST(op, a, b, c, s);
519                         return SValue::instance(ast);
520                     }
521
522                 };
523             }
524         }
525     }
526 }
527
528 #endif //DYNINST_SYMEVALSEMANTICS_H