Ghidra Decompiler Analysis Engine
prefersplit.hh
1 /* ###
2  * IP: GHIDRA
3  * REVIEWED: YES
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 #ifndef __PREFERSPLIT__
18 #define __PREFERSPLIT__
19 
20 #include "varnode.hh"
21 class Funcdata; // Forward declaration
22 
24  VarnodeData storage;
25  int4 splitoffset; // Number of initial bytes (in address order) to split into first piece
26  bool operator<(const PreferSplitRecord &op2) const;
27 };
28 
30  class SplitInstance {
31  friend class PreferSplitManager;
32  int4 splitoffset;
33  Varnode *vn;
34  Varnode *hi; // Most significant piece
35  Varnode *lo; // Least significant piece
36  public:
37  SplitInstance(Varnode *v,int4 off) { vn = v; splitoffset = off; hi = (Varnode *)0; lo = (Varnode *)0; }
38  };
39  Funcdata *data;
40  const vector<PreferSplitRecord> *records;
41  vector<PcodeOp *> tempsplits; // Copies of temporaries that need additional splitting
42  void fillinInstance(SplitInstance *inst,bool bigendian,bool sethi,bool setlo);
43  void createCopyOps(SplitInstance *ininst,SplitInstance *outinst,PcodeOp *op,bool istemp);
44  bool testDefiningCopy(SplitInstance *inst,PcodeOp *def,bool &istemp);
45  void splitDefiningCopy(SplitInstance *inst,PcodeOp *def,bool istemp);
46  bool testReadingCopy(SplitInstance *inst,PcodeOp *readop,bool &istemp);
47  void splitReadingCopy(SplitInstance *inst,PcodeOp *readop,bool istemp);
48  bool testZext(SplitInstance *inst,PcodeOp *op);
49  void splitZext(SplitInstance *inst,PcodeOp *op);
50  bool testPiece(SplitInstance *inst,PcodeOp *op);
51  void splitPiece(SplitInstance *inst,PcodeOp *op);
52  bool testSubpiece(SplitInstance *inst,PcodeOp *op);
53  void splitSubpiece(SplitInstance *inst,PcodeOp *op);
54  bool testLoad(SplitInstance *inst,PcodeOp *op);
55  void splitLoad(SplitInstance *inst,PcodeOp *op);
56  bool testStore(SplitInstance *inst,PcodeOp *op);
57  void splitStore(SplitInstance *inst,PcodeOp *op);
58  bool splitVarnode(SplitInstance *inst);
59  void splitRecord(const PreferSplitRecord &rec);
60  bool testTemporary(SplitInstance *inst);
61  void splitTemporary(SplitInstance *inst);
62 public:
63  void init(Funcdata *fd,const vector<PreferSplitRecord> *rec);
64  const PreferSplitRecord *findRecord(Varnode *vn) const;
65  static void initialize(vector<PreferSplitRecord> &records);
66  void split(void);
67  void splitAdditional(void);
68 };
69 
70 #endif
PreferSplitRecord
Definition: prefersplit.hh:23
PcodeOp
Lowest level operation of the p-code language.
Definition: op.hh:58
PreferSplitManager
Definition: prefersplit.hh:29
Varnode
A low-level variable or contiguous set of bytes described by an Address and a size.
Definition: varnode.hh:65
Funcdata
Container for data structures associated with a single function.
Definition: funcdata.hh:45
VarnodeData
Data defining a specific memory location.
Definition: pcoderaw.hh:33
varnode.hh
The Varnode and VarnodeBank classes.