ROSE  0.9.9.109
sageBuilderAsm.h
1 #ifndef ROSE_SageBuilderAsm_H
2 #define ROSE_SageBuilderAsm_H
3 
4 namespace Rose {
5 
7 namespace SageBuilderAsm {
8 
10 // Build files
11 
29 SgBinaryComposite* buildBinaryComposite(const std::string &fileName);
30 
31 
32 
34 // Build data types
35 //
36 // These data type builders always return the same IR node and are thread-safe.
37 
38 // Generic data types
53 // Architecture-specific data types
64 // x86-specific data types (deprecated [Robb P. Matzke 2014-07-21]; use the functions with X86 in their names)
65 SgAsmIntegerType* buildAsmTypeByte() ROSE_DEPRECATED("use buildTypeX86Byte");
66 SgAsmIntegerType* buildAsmTypeWord() ROSE_DEPRECATED("use buildTypeX86Word");
67 SgAsmIntegerType* buildAsmTypeDoubleWord() ROSE_DEPRECATED("use buildTypeX86DoubleWord");
68 SgAsmIntegerType* buildAsmTypeQuadWord() ROSE_DEPRECATED("use buildTypeX86QuadWord");
69 SgAsmFloatType* buildAsmTypeSingleFloat() ROSE_DEPRECATED("use buildTypeX86Float32");
70 SgAsmFloatType* buildAsmTypeDoubleFloat() ROSE_DEPRECATED("use buildTypeX86Float64");
71 SgAsmFloatType* buildAsmType128bitFloat() ROSE_DEPRECATED("use architecture specific type");
72 SgAsmFloatType* buildAsmType80bitFloat() ROSE_DEPRECATED("use buildTypeX86Float80");
73 SgAsmVectorType* buildAsmTypeDoubleQuadWord() ROSE_DEPRECATED("use buildTypeX86DoubleQuadWord");
74 
76 // Build registers. Deprecated because ROSE doesn't have architecture-specific registers anymore. [Robb P. Matzke 2014-07-21]
77 // Use the SgAsmDirectRegisterExpression constructor instead.
78 SgAsmDirectRegisterExpression* buildSgAsmx86RegisterReferenceExpression(RegisterDescriptor)
79  ROSE_DEPRECATED("use SgAsmDirectRegisterExpression constructor");
80 SgAsmDirectRegisterExpression* buildSgAsmArmRegisterReferenceExpression(RegisterDescriptor)
81  ROSE_DEPRECATED("use SgAsmDirectRegisterExpression constructor");
82 SgAsmDirectRegisterExpression* buildSgAsmMipsRegisterReferenceExpression(RegisterDescriptor)
83  ROSE_DEPRECATED("use SgAsmDirectRegisterExpression constructor");
84 SgAsmDirectRegisterExpression* buildSgAsmPowerpcRegisterReferenceExpression(RegisterDescriptor)
85  ROSE_DEPRECATED("use SgAsmDirectRegisterExpression constructor");
86 
88 // Generic value builders
89 SgAsmIntegerValueExpression* buildValueInteger(uint64_t value, SgAsmType*);
91 SgAsmFloatValueExpression* buildValueFloat(double value, SgAsmType*);
93 
95 // Building integer values.
96 
97 // Build integer values generically (one of these per buildType function above)
98 SgAsmIntegerValueExpression* buildValueU1(bool);
99 SgAsmIntegerValueExpression* buildValueU8(uint8_t);
100 SgAsmIntegerValueExpression* buildValueU16(uint16_t);
101 SgAsmIntegerValueExpression* buildValueU32(uint32_t);
102 SgAsmIntegerValueExpression* buildValueU64(uint64_t);
103 SgAsmIntegerValueExpression* buildValueI8(int8_t);
104 SgAsmIntegerValueExpression* buildValueI16(int16_t);
105 SgAsmIntegerValueExpression* buildValueI32(int32_t);
106 SgAsmIntegerValueExpression* buildValueI64(int64_t);
107 SgAsmFloatValueExpression* buildValueIeee754Binary32(double);
108 SgAsmFloatValueExpression* buildValueIeee754Binary64(double);
109 
110 // Building integer values with x86-specific type names
111 SgAsmIntegerValueExpression* buildValueX86Byte(uint8_t);
112 SgAsmIntegerValueExpression* buildValueX86Word(uint16_t);
113 SgAsmIntegerValueExpression* buildValueX86DWord(uint32_t);
114 SgAsmIntegerValueExpression* buildValueX86QWord(uint64_t);
115 SgAsmFloatValueExpression* buildValueX86Float32(double);
116 SgAsmFloatValueExpression* buildValueX86Float64(double);
117 SgAsmFloatValueExpression* buildValueX86Float80(double);
118 
119 // Building integer values with x86-specific type names.
120 // These are deprecated because they lack "X86" in their names [Robb P. Matzke 2014-07-21].
121 SgAsmIntegerValueExpression* buildAsmByteValue(uint8_t) ROSE_DEPRECATED("use buildValueX86Byte");
122 SgAsmIntegerValueExpression* buildAsmWordValue(uint16_t) ROSE_DEPRECATED("use buildValueX86Word");
123 SgAsmIntegerValueExpression* buildAsmDWordValue(uint32_t) ROSE_DEPRECATED("use buildValueX86DWord");
124 SgAsmIntegerValueExpression* buildAsmQWordValue(uint64_t) ROSE_DEPRECATED("use buildValueX86QWord");
125 
126 // Building integer values with x86-specific type names.
127 // These are deprecated because they should have been named "build" instead of "make"
128 SgAsmIntegerValueExpression* makeByteValue(uint8_t) ROSE_DEPRECATED("use buildValueX86Byte");
129 SgAsmIntegerValueExpression* makeWordValue(uint16_t) ROSE_DEPRECATED("use buildValueX86Word");
130 SgAsmIntegerValueExpression* makeDWordValue(uint32_t) ROSE_DEPRECATED("use buildValueX86DWord");
131 SgAsmIntegerValueExpression* makeQWordValue(uint64_t) ROSE_DEPRECATED("use buildValueX86QWord");
132 
134 // Operators
135 SgAsmBinaryAdd* buildAddExpression(SgAsmExpression *lhs, SgAsmExpression *rhs);
136 SgAsmBinarySubtract* buildSubtractExpression(SgAsmExpression *lhs, SgAsmExpression *rhs);
137 SgAsmBinaryAddPreupdate* buildAddPreupdateExpression(SgAsmExpression *lhs, SgAsmExpression *rhs);
138 SgAsmBinarySubtractPreupdate* buildSubtractPreupdateExpression(SgAsmExpression *lhs, SgAsmExpression *rhs);
139 SgAsmBinaryAddPostupdate* buildAddPostupdateExpression(SgAsmExpression *lhs, SgAsmExpression *rhs);
140 SgAsmBinarySubtractPostupdate* buildSubtractPostupdateExpression(SgAsmExpression *lhs, SgAsmExpression *rhs);
141 SgAsmBinaryMultiply* buildMultiplyExpression(SgAsmExpression *lhs, SgAsmExpression *rhs);
142 SgAsmBinaryLsl* buildLslExpression(SgAsmExpression *lhs, SgAsmExpression *rhs);
143 SgAsmBinaryLsr* buildLsrExpression(SgAsmExpression *lhs, SgAsmExpression *rhs);
144 SgAsmBinaryAsr* buildAsrExpression(SgAsmExpression *lhs, SgAsmExpression *rhs);
145 SgAsmBinaryRor* buildRorExpression(SgAsmExpression *lhs, SgAsmExpression *rhs);
146 SgAsmUnaryRrx* buildRrxExpression(SgAsmExpression *lhs);
147 SgAsmUnaryArmSpecialRegisterList *buildArmSpecialRegisterList(SgAsmExpression *lhs);
148 SgAsmExprListExp* buildExprListExpression();
149 void appendExpression(SgAsmExprListExp*, SgAsmExpression*);
150 SgAsmMemoryReferenceExpression* buildMemoryReferenceExpression(SgAsmExpression *addr, SgAsmExpression *segment=NULL,
151  SgAsmType *type=NULL);
157  SgAsmExpression*);
158 
159 
160 // Operators (deprecated because they should have been named "build" rather than "make" [Robb P. Matzke 2014-07-21])
161 SgAsmBinaryAdd* makeAdd(SgAsmExpression *lhs, SgAsmExpression *rhs) ROSE_DEPRECATED("use buildAddExpression");
162 SgAsmBinarySubtract* makeSubtract(SgAsmExpression *lhs, SgAsmExpression *rhs) ROSE_DEPRECATED("use buildSubtractExpression");
163 SgAsmBinaryAddPreupdate* makeAddPreupdate(SgAsmExpression *lhs, SgAsmExpression *rhs)
164  ROSE_DEPRECATED("use buildAddPreupdateExpression");
165 SgAsmBinarySubtractPreupdate* makeSubtractPreupdate(SgAsmExpression *lhs, SgAsmExpression *rhs)
166  ROSE_DEPRECATED("use buildSubtractPreupdateExpression");
167 SgAsmBinaryAddPostupdate* makeAddPostupdate(SgAsmExpression *lhs, SgAsmExpression *rhs)
168  ROSE_DEPRECATED("use buildAddPostupdateExpression");
169 SgAsmBinarySubtractPostupdate* makeSubtractPostupdate(SgAsmExpression *lhs, SgAsmExpression *rhs)
170  ROSE_DEPRECATED("use buildSubtractPostupdateExpression");
171 SgAsmBinaryMultiply* makeMul(SgAsmExpression *lhs, SgAsmExpression *rhs) ROSE_DEPRECATED("use buildMultiplyExpression");
172 SgAsmBinaryLsl* makeLsl(SgAsmExpression *lhs, SgAsmExpression *rhs) ROSE_DEPRECATED("use buildLslExpression");
173 SgAsmBinaryLsr* makeLsr(SgAsmExpression *lhs, SgAsmExpression *rhs) ROSE_DEPRECATED("use buildLsrExpression");
174 SgAsmBinaryAsr* makeAsr(SgAsmExpression *lhs, SgAsmExpression *rhs) ROSE_DEPRECATED("use buildAsrExpression");
175 SgAsmBinaryRor* makeRor(SgAsmExpression *lhs, SgAsmExpression *rhs) ROSE_DEPRECATED("use buildRorExpression");
176 SgAsmUnaryRrx* makeRrx(SgAsmExpression *lhs) ROSE_DEPRECATED("use buildRrxExpression");
177 SgAsmUnaryArmSpecialRegisterList* makeArmSpecialRegisterList(SgAsmExpression *lhs)
178  ROSE_DEPRECATED("use buildArmSpecialRegisterList");
179 SgAsmExprListExp* makeExprListExp() ROSE_DEPRECATED("use buildExprListExpression");
180 SgAsmMemoryReferenceExpression* makeMemoryReference(SgAsmExpression *addr, SgAsmExpression *segment=NULL,
181  SgAsmType *type=NULL) ROSE_DEPRECATED("use buildMemoryReferenceExpression");
182 
183 template <typename Insn>
184 inline Insn* appendOperand(Insn* insn, SgAsmExpression* op) {
185  SgAsmOperandList* operands = insn->get_operandList();
186  operands->get_operands().push_back(op);
187  op->set_parent(operands);
188  return insn; // For chaining this operation
189 }
190 
192 // Build instruction; some deprecated because of incorrect capitalization [Robb P. Matzke 2014-07-21]
193 SgAsmX86Instruction* buildx86Instruction(X86InstructionKind)
194  ROSE_DEPRECATED("use buildX86Instruction");
195 SgAsmX86Instruction* buildX86Instruction(X86InstructionKind);
196 SgAsmX86Instruction* buildx86Instruction(X86InstructionKind, SgAsmExpression *operand)
197  ROSE_DEPRECATED("use buildX86Instruction");
198 SgAsmX86Instruction* buildX86Instruction(X86InstructionKind, SgAsmExpression *operand);
199 SgAsmX86Instruction* buildx86Instruction(X86InstructionKind, SgAsmExpression *lhs, SgAsmExpression *rhs)
200  ROSE_DEPRECATED("use buildX86Instruction");
201 SgAsmX86Instruction* buildX86Instruction(X86InstructionKind, SgAsmExpression *lhs, SgAsmExpression *rhs);
202 SgAsmX86Instruction* buildx86Instruction(X86InstructionKind, SgAsmOperandList *operands)
203  ROSE_DEPRECATED("use buildX86Instruction");
204 SgAsmInstruction* buildMultibyteNopInstruction(int n) ROSE_DEPRECATED("use buildX86MultibyteNopInstruction");
205 SgAsmX86Instruction *buildX86MultibyteNopInstruction(size_t nBytes);
206 
208 // Build basic blocks
209 SgAsmBlock* buildBasicBlock(const std::vector<SgAsmInstruction*>&);
210 SgAsmFunction* buildFunction(rose_addr_t entryVa, const std::vector<SgAsmBlock*>&);
211 
213 // Build data blocks
214 SgAsmStaticData* buildStaticData(rose_addr_t startVa, const SgUnsignedCharList &rawData);
215 SgAsmBlock* buildDataBlock(SgAsmStaticData*);
216 
217 
218 } // namespace
219 } // namespace
220 
221 #endif
Expression that adds two operands.
Expression that performs a post-increment operation.
Expression that performs a right rotate.
Instruction basic block.
SgAsmIntegerType * buildTypeU16()
16-bit unsigned
SgAsmFloatType * buildIeee754Binary32()
32-bit IEEE-754 floating-point
Expression that performs a post-decrement operation.
Base class for machine instructions.
SgAsmIntegerType * buildTypeI64()
64-bit signed
RiscOperator
One enum per RISC operator.
SgAsmIntegerType * buildTypeU1()
1-bit unsigned (Boolean)
const SgAsmExpressionPtrList & get_operands() const
Property: Ordered list of instruction operands.
List of expression nodes.
SgAsmIntegerType * buildTypeU64()
64-bit unsigned
Expression that performs an arithmetic, sign-bit preserving right shift.
void set_parent(SgNode *parent)
All nodes in the AST contain a reference to a parent node.
Expression that performs a logical, sign-bit non-preserving right shift.
SgAsmFloatType * buildTypeM68kFloat96()
Motorola M68k 96-bit float (16-bits are always zero)
Represents a synthesized function.
SgAsmIntegerType * buildTypeU8()
8-bit unsigned
Main namespace for the ROSE library.
Describes (part of) a physical CPU register.
SgAsmIntegerType * buildTypeI32()
32-bit signed
SgAsmIntegerType * buildTypeX86Byte()
8-bit unsigned
SgAsmIntegerType * buildTypeI16()
16-bit signed
Reference to memory locations.
SgAsmFloatType * buildTypeX86Float32()
32-bit IEEE-754 floating-point
Expression representing a machine register.
Base class for integer values.
List of operands for an instruction.
SgBinaryComposite * buildBinaryComposite(const std::string &fileName)
Build a new binary composite object.
SgAsmIntegerType * buildTypeX86DoubleWord()
32-bit unsigned
SgAsmIntegerType * buildTypeU32()
32-bit unsigned
Expression that performs a pre-decrement operation.
Expression that performs a pre-increment operation.
SgAsmIntegerType * buildTypeX86QuadWord()
64-bit unsigned
Represents static data in an executable.
Represents one Intel x86 machine instruction.
Base class for expressions.
Expression that performs a logical left shift operation.
Expression that multiplies two operands.
Base class for binary types.
SgAsmIntegerType * buildTypeI8()
8-bit signed
Floating-point value.
Expression that subtracts the second operand from the first.
SgAsmIntegerType * buildTypeX86Word()
16-bit unsigned
SgAsmFloatType * buildIeee754Binary80()
80-bit IEEE-754 floating-point (as in x86)
SgAsmFloatType * buildIeee754Binary64()
64-bit IEEE-754 floating-point
Integer types.
SgAsmFloatType * buildTypeX86Float80()
80-bit IEEE-754 floating-point
Floating point types.
SgAsmVectorType * buildTypeVector(size_t, SgAsmType *)
Fixed-size, packed array.
Base class for vector types.
Static representation of instruction semantics.
SgAsmFloatType * buildTypeX86Float64()
64-bit IEEE-754 floating-point
SgAsmVectorType * buildTypeX86DoubleQuadWord()
Vector of two 64-bit unsigned integers.