ROSE  0.9.10.95
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
54 // Architecture-specific data types
65 // x86-specific data types (deprecated [Robb P. Matzke 2014-07-21]; use the functions with X86 in their names)
66 SgAsmIntegerType* buildAsmTypeByte() ROSE_DEPRECATED("use buildTypeX86Byte");
67 SgAsmIntegerType* buildAsmTypeWord() ROSE_DEPRECATED("use buildTypeX86Word");
68 SgAsmIntegerType* buildAsmTypeDoubleWord() ROSE_DEPRECATED("use buildTypeX86DoubleWord");
69 SgAsmIntegerType* buildAsmTypeQuadWord() ROSE_DEPRECATED("use buildTypeX86QuadWord");
70 SgAsmFloatType* buildAsmTypeSingleFloat() ROSE_DEPRECATED("use buildTypeX86Float32");
71 SgAsmFloatType* buildAsmTypeDoubleFloat() ROSE_DEPRECATED("use buildTypeX86Float64");
72 SgAsmFloatType* buildAsmType128bitFloat() ROSE_DEPRECATED("use architecture specific type");
73 SgAsmFloatType* buildAsmType80bitFloat() ROSE_DEPRECATED("use buildTypeX86Float80");
74 SgAsmVectorType* buildAsmTypeDoubleQuadWord() ROSE_DEPRECATED("use buildTypeX86DoubleQuadWord");
75 
77 // Build registers. Deprecated because ROSE doesn't have architecture-specific registers anymore. [Robb P. Matzke 2014-07-21]
78 // Use the SgAsmDirectRegisterExpression constructor instead.
79 SgAsmDirectRegisterExpression* buildSgAsmx86RegisterReferenceExpression(RegisterDescriptor)
80  ROSE_DEPRECATED("use SgAsmDirectRegisterExpression constructor");
81 SgAsmDirectRegisterExpression* buildSgAsmArmRegisterReferenceExpression(RegisterDescriptor)
82  ROSE_DEPRECATED("use SgAsmDirectRegisterExpression constructor");
83 SgAsmDirectRegisterExpression* buildSgAsmMipsRegisterReferenceExpression(RegisterDescriptor)
84  ROSE_DEPRECATED("use SgAsmDirectRegisterExpression constructor");
85 SgAsmDirectRegisterExpression* buildSgAsmPowerpcRegisterReferenceExpression(RegisterDescriptor)
86  ROSE_DEPRECATED("use SgAsmDirectRegisterExpression constructor");
87 
89 // Generic value builders
90 SgAsmIntegerValueExpression* buildValueInteger(uint64_t value, SgAsmType*);
92 SgAsmFloatValueExpression* buildValueFloat(double value, SgAsmType*);
94 
96 // Building integer values.
97 
98 // Build integer values generically (one of these per buildType function above)
99 SgAsmIntegerValueExpression* buildValueU1(bool);
100 SgAsmIntegerValueExpression* buildValueU8(uint8_t);
101 SgAsmIntegerValueExpression* buildValueU16(uint16_t);
102 SgAsmIntegerValueExpression* buildValueU32(uint32_t);
103 SgAsmIntegerValueExpression* buildValueU64(uint64_t);
104 SgAsmIntegerValueExpression* buildValueI8(int8_t);
105 SgAsmIntegerValueExpression* buildValueI16(int16_t);
106 SgAsmIntegerValueExpression* buildValueI32(int32_t);
107 SgAsmIntegerValueExpression* buildValueI64(int64_t);
108 SgAsmFloatValueExpression* buildValueIeee754Binary32(double);
109 SgAsmFloatValueExpression* buildValueIeee754Binary64(double);
110 
111 // Building integer values with x86-specific type names
112 SgAsmIntegerValueExpression* buildValueX86Byte(uint8_t);
113 SgAsmIntegerValueExpression* buildValueX86Word(uint16_t);
114 SgAsmIntegerValueExpression* buildValueX86DWord(uint32_t);
115 SgAsmIntegerValueExpression* buildValueX86QWord(uint64_t);
116 SgAsmFloatValueExpression* buildValueX86Float32(double);
117 SgAsmFloatValueExpression* buildValueX86Float64(double);
118 SgAsmFloatValueExpression* buildValueX86Float80(double);
119 
120 // Building integer values with x86-specific type names.
121 // These are deprecated because they lack "X86" in their names [Robb P. Matzke 2014-07-21].
122 SgAsmIntegerValueExpression* buildAsmByteValue(uint8_t) ROSE_DEPRECATED("use buildValueX86Byte");
123 SgAsmIntegerValueExpression* buildAsmWordValue(uint16_t) ROSE_DEPRECATED("use buildValueX86Word");
124 SgAsmIntegerValueExpression* buildAsmDWordValue(uint32_t) ROSE_DEPRECATED("use buildValueX86DWord");
125 SgAsmIntegerValueExpression* buildAsmQWordValue(uint64_t) ROSE_DEPRECATED("use buildValueX86QWord");
126 
127 // Building integer values with x86-specific type names.
128 // These are deprecated because they should have been named "build" instead of "make"
129 SgAsmIntegerValueExpression* makeByteValue(uint8_t) ROSE_DEPRECATED("use buildValueX86Byte");
130 SgAsmIntegerValueExpression* makeWordValue(uint16_t) ROSE_DEPRECATED("use buildValueX86Word");
131 SgAsmIntegerValueExpression* makeDWordValue(uint32_t) ROSE_DEPRECATED("use buildValueX86DWord");
132 SgAsmIntegerValueExpression* makeQWordValue(uint64_t) ROSE_DEPRECATED("use buildValueX86QWord");
133 
135 // Operators
136 SgAsmBinaryAdd* buildAddExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
137 SgAsmBinarySubtract* buildSubtractExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
138 SgAsmBinaryAddPreupdate* buildAddPreupdateExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
139 SgAsmBinarySubtractPreupdate* buildSubtractPreupdateExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
140 SgAsmBinaryAddPostupdate* buildAddPostupdateExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
141 SgAsmBinarySubtractPostupdate* buildSubtractPostupdateExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
142 SgAsmBinaryMultiply* buildMultiplyExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
143 SgAsmBinaryLsl* buildLslExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
144 SgAsmBinaryLsr* buildLsrExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
145 SgAsmBinaryAsr* buildAsrExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
146 SgAsmBinaryRor* buildRorExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
147 SgAsmUnaryRrx* buildRrxExpression(SgAsmExpression *lhs, SgAsmType *type=NULL);
148 SgAsmUnaryArmSpecialRegisterList *buildArmSpecialRegisterList(SgAsmExpression *lhs);
149 SgAsmExprListExp* buildExprListExpression();
150 void appendExpression(SgAsmExprListExp*, SgAsmExpression*);
151 SgAsmMemoryReferenceExpression* buildMemoryReferenceExpression(SgAsmExpression *addr, SgAsmExpression *segment=NULL,
152  SgAsmType *type=NULL);
158  SgAsmExpression*);
159 
160 
161 // Operators (deprecated because they should have been named "build" rather than "make" [Robb P. Matzke 2014-07-21])
162 SgAsmBinaryAdd* makeAdd(SgAsmExpression *lhs, SgAsmExpression *rhs) ROSE_DEPRECATED("use buildAddExpression");
163 SgAsmBinarySubtract* makeSubtract(SgAsmExpression *lhs, SgAsmExpression *rhs) ROSE_DEPRECATED("use buildSubtractExpression");
164 SgAsmBinaryAddPreupdate* makeAddPreupdate(SgAsmExpression *lhs, SgAsmExpression *rhs)
165  ROSE_DEPRECATED("use buildAddPreupdateExpression");
166 SgAsmBinarySubtractPreupdate* makeSubtractPreupdate(SgAsmExpression *lhs, SgAsmExpression *rhs)
167  ROSE_DEPRECATED("use buildSubtractPreupdateExpression");
168 SgAsmBinaryAddPostupdate* makeAddPostupdate(SgAsmExpression *lhs, SgAsmExpression *rhs)
169  ROSE_DEPRECATED("use buildAddPostupdateExpression");
170 SgAsmBinarySubtractPostupdate* makeSubtractPostupdate(SgAsmExpression *lhs, SgAsmExpression *rhs)
171  ROSE_DEPRECATED("use buildSubtractPostupdateExpression");
172 SgAsmBinaryMultiply* makeMul(SgAsmExpression *lhs, SgAsmExpression *rhs) ROSE_DEPRECATED("use buildMultiplyExpression");
173 SgAsmBinaryLsl* makeLsl(SgAsmExpression *lhs, SgAsmExpression *rhs) ROSE_DEPRECATED("use buildLslExpression");
174 SgAsmBinaryLsr* makeLsr(SgAsmExpression *lhs, SgAsmExpression *rhs) ROSE_DEPRECATED("use buildLsrExpression");
175 SgAsmBinaryAsr* makeAsr(SgAsmExpression *lhs, SgAsmExpression *rhs) ROSE_DEPRECATED("use buildAsrExpression");
176 SgAsmBinaryRor* makeRor(SgAsmExpression *lhs, SgAsmExpression *rhs) ROSE_DEPRECATED("use buildRorExpression");
177 SgAsmUnaryRrx* makeRrx(SgAsmExpression *lhs) ROSE_DEPRECATED("use buildRrxExpression");
178 SgAsmUnaryArmSpecialRegisterList* makeArmSpecialRegisterList(SgAsmExpression *lhs)
179  ROSE_DEPRECATED("use buildArmSpecialRegisterList");
180 SgAsmExprListExp* makeExprListExp() ROSE_DEPRECATED("use buildExprListExpression");
181 SgAsmMemoryReferenceExpression* makeMemoryReference(SgAsmExpression *addr, SgAsmExpression *segment=NULL,
182  SgAsmType *type=NULL) ROSE_DEPRECATED("use buildMemoryReferenceExpression");
183 
184 template <typename Insn>
185 inline Insn* appendOperand(Insn* insn, SgAsmExpression* op) {
186  SgAsmOperandList* operands = insn->get_operandList();
187  operands->get_operands().push_back(op);
188  op->set_parent(operands);
189  return insn; // For chaining this operation
190 }
191 
193 // Build instruction; some deprecated because of incorrect capitalization [Robb P. Matzke 2014-07-21]
194 SgAsmX86Instruction* buildx86Instruction(X86InstructionKind)
195  ROSE_DEPRECATED("use buildX86Instruction");
196 SgAsmX86Instruction* buildX86Instruction(X86InstructionKind);
197 SgAsmX86Instruction* buildx86Instruction(X86InstructionKind, SgAsmExpression *operand)
198  ROSE_DEPRECATED("use buildX86Instruction");
199 SgAsmX86Instruction* buildX86Instruction(X86InstructionKind, SgAsmExpression *operand);
200 SgAsmX86Instruction* buildx86Instruction(X86InstructionKind, SgAsmExpression *lhs, SgAsmExpression *rhs)
201  ROSE_DEPRECATED("use buildX86Instruction");
202 SgAsmX86Instruction* buildX86Instruction(X86InstructionKind, SgAsmExpression *lhs, SgAsmExpression *rhs);
203 SgAsmX86Instruction* buildx86Instruction(X86InstructionKind, SgAsmOperandList *operands)
204  ROSE_DEPRECATED("use buildX86Instruction");
205 SgAsmInstruction* buildMultibyteNopInstruction(int n) ROSE_DEPRECATED("use buildX86MultibyteNopInstruction");
206 SgAsmX86Instruction *buildX86MultibyteNopInstruction(size_t nBytes);
207 
209 // Build basic blocks
210 SgAsmBlock* buildBasicBlock(const std::vector<SgAsmInstruction*>&);
211 SgAsmFunction* buildFunction(rose_addr_t entryVa, const std::vector<SgAsmBlock*>&);
212 
214 // Build data blocks
215 SgAsmStaticData* buildStaticData(rose_addr_t startVa, const SgUnsignedCharList &rawData);
216 SgAsmBlock* buildDataBlock(SgAsmStaticData*);
217 
218 
219 } // namespace
220 } // namespace
221 
222 #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
SgAsmIntegerType * buildTypeU4()
4-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.