ROSE 0.11.145.192
SageBuilderAsm.h
1#ifndef ROSE_SageBuilderAsm_H
2#define ROSE_SageBuilderAsm_H
3#include <featureTests.h>
4#ifdef ROSE_ENABLE_BINARY_ANALYSIS
5
6#include <AssemblerX86Init.h> // for X86InstructionKind
7
8#include <SgAsmRiscOperation.h>
9#include <SgAsmOperandList.h>
10
11#include <Sawyer/BitVector.h>
12
13namespace Rose {
14
16namespace SageBuilderAsm {
17
19// Build files
20
38SgBinaryComposite* buildBinaryComposite(const std::string &fileName);
39
40
41
43// Build data types
44//
45// These data type builders always return the same IR node and are thread-safe.
46
47// Generic data types
67// Architecture-specific data types
80// Generic value builders
81SgAsmIntegerValueExpression* buildValueInteger(uint64_t value, SgAsmType*);
83SgAsmFloatValueExpression* buildValueFloat(double value, SgAsmType*);
85
87// Building integer or FP values.
88
89// Build integer or FP values generically (one of these per buildType function above)
90SgAsmIntegerValueExpression* buildValueU1(bool);
91SgAsmIntegerValueExpression* buildValueU8(uint8_t);
92SgAsmIntegerValueExpression* buildValueU16(uint16_t);
93SgAsmIntegerValueExpression* buildValueU32(uint32_t);
94SgAsmIntegerValueExpression* buildValueU64(uint64_t);
95SgAsmIntegerValueExpression* buildValueI8(int8_t);
96SgAsmIntegerValueExpression* buildValueI16(int16_t);
97SgAsmIntegerValueExpression* buildValueI32(int32_t);
98SgAsmIntegerValueExpression* buildValueI64(int64_t);
99SgAsmFloatValueExpression* buildValueIeee754Binary32(double);
100SgAsmFloatValueExpression* buildValueIeee754Binary64(double);
101
102// Template specializations for building integer values
103template <class T>
104SgAsmIntegerValueExpression* buildValue(T);
105
106// Building integer or FP values with x86-specific type names
107SgAsmIntegerValueExpression* buildValueX86Byte(uint8_t);
108SgAsmIntegerValueExpression* buildValueX86Word(uint16_t);
109SgAsmIntegerValueExpression* buildValueX86DWord(uint32_t);
110SgAsmIntegerValueExpression* buildValueX86QWord(uint64_t);
111SgAsmFloatValueExpression* buildValueX86Float32(double);
112SgAsmFloatValueExpression* buildValueX86Float64(double);
113SgAsmFloatValueExpression* buildValueX86Float80(double);
114
116// Operators
117SgAsmBinaryAdd* buildAddExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
118SgAsmBinarySubtract* buildSubtractExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
119SgAsmBinaryMultiply* buildMultiplyExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
120SgAsmBinaryPreupdate* buildPreupdateExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
121SgAsmBinaryPostupdate* buildPostupdateExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
122SgAsmBinaryMsl* buildMslExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
123SgAsmBinaryLsl* buildLslExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
124SgAsmBinaryLsr* buildLsrExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
125SgAsmBinaryAsr* buildAsrExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
126SgAsmBinaryRor* buildRorExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
127SgAsmUnaryRrx* buildRrxExpression(SgAsmExpression *lhs, SgAsmType *type=NULL);
128SgAsmUnaryTruncate* buildTruncateExpression(SgAsmExpression*, SgAsmType*);
129SgAsmBinaryConcat* buildConcatExpression(SgAsmExpression *moreSignificant, SgAsmExpression *lessSignificant);
130SgAsmUnarySignedExtend* buildSignedExtendExpression(SgAsmExpression*, SgAsmType*);
131SgAsmUnaryUnsignedExtend* buildUnsignedExtendExpression(SgAsmExpression*, SgAsmType*);
132SgAsmExprListExp* buildExprListExpression();
133void appendExpression(SgAsmExprListExp*, SgAsmExpression*);
134SgAsmMemoryReferenceExpression* buildMemoryReferenceExpression(SgAsmExpression *addr, SgAsmExpression *segment=NULL,
135 SgAsmType *type=NULL);
142
143
144template <typename Insn>
145inline Insn* appendOperand(Insn* insn, SgAsmExpression* op) {
146 SgAsmOperandList* operands = insn->get_operandList();
147 operands->get_operands().push_back(op);
148 op->set_parent(operands);
149 return insn; // For chaining this operation
150}
151
153// Build instruction
154SgAsmX86Instruction *buildX86MultibyteNopInstruction(size_t nBytes);
155
157// Build basic blocks
158SgAsmBlock* buildBasicBlock(const std::vector<SgAsmInstruction*>&);
159SgAsmFunction* buildFunction(rose_addr_t entryVa, const std::vector<SgAsmBlock*>&);
160
162// Build data blocks
163SgAsmStaticData* buildStaticData(rose_addr_t startVa, const SgUnsignedCharList &rawData);
164SgAsmBlock* buildDataBlock(SgAsmStaticData*);
165
166
167} // namespace
168} // namespace
169
170#endif
171#endif
Expression that adds two operands.
Expression that performs an arithmetic, sign-bit preserving right shift.
Expression that concatenates two values to form a wider value.
Expression that performs a logical left shift operation.
Expression that performs a logical, sign-bit non-preserving right shift.
Expression that performs a logical left shift operation filling low-order bits with one.
Expression that multiplies two operands.
Expression that represents an update to a storage location.
Expression that represents an update to a storage location.
Expression that performs a right rotate.
Expression that subtracts the second operand from the first.
Instruction basic block.
List of expression nodes.
Base class for expressions.
Floating point types.
Represents a synthesized function.
Base class for integer values.
Reference to memory locations.
List of operands for an instruction.
SgAsmExpressionPtrList const & get_operands() const
Property: Ordered list of instruction operands.
Static representation of instruction semantics.
RiscOperator
One enum per RISC operator.
Represents static data in an executable.
Base class for binary types.
Expression representing sign extending.
Expression representing truncation.
Expression representing unsigned extending.
Base class for vector types.
Represents one Intel x86 machine instruction.
void set_parent(SgNode *parent)
All nodes in the AST contain a reference to a parent node.
SgAsmFloatType * buildIeee754Binary16()
16-bit IEEE-754 floating-point.
SgAsmIntegerType * buildTypeX86DoubleWord()
32-bit unsigned.
SgAsmIntegerType * buildTypeX86Byte()
8-bit unsigned.
SgAsmFloatType * buildIeee754Binary32()
32-bit IEEE-754 floating-point.
SgAsmIntegerType * buildTypeU64()
64-bit unsigned.
SgAsmFloatType * buildTypeX86Float64()
64-bit IEEE-754 floating-point.
SgAsmVectorType * buildTypeVector(size_t, SgAsmType *)
Fixed-size, packed array.
SgAsmFloatType * buildIeee754Binary64()
64-bit IEEE-754 floating-point.
SgAsmIntegerType * buildTypeI16()
16-bit signed.
SgAsmIntegerType * buildTypeI(size_t nBits)
Signed type of specified size.
SgAsmVectorType * buildTypeX86DoubleQuadWord()
Vector of two 64-bit unsigned integers.
SgAsmFloatType * buildIeee754Binary80()
80-bit IEEE-754 floating-point (as in x86).
SgAsmIntegerType * buildTypeX86QuadWord()
64-bit unsigned.
SgAsmIntegerType * buildTypeU(size_t nBits)
Unsigned type of specified size.
SgAsmFloatType * buildIeee754Binary128()
128-bit IEEE-754 floating-point.
SgAsmIntegerType * buildTypeU32()
32-bit unsigned.
SgAsmIntegerType * buildTypeI8()
8-bit signed.
SgAsmIntegerType * buildTypeU8()
8-bit unsigned.
SgAsmIntegerType * buildTypeU4()
4-bit unsigned.
SgAsmIntegerType * buildTypeI64()
64-bit signed.
SgAsmIntegerType * buildTypeU16()
16-bit unsigned.
SgAsmFloatType * buildTypeM68kFloat80()
Motorola M68k 96-bit float w/out 16-bit constant zero field.
SgAsmFloatType * buildTypeM68kFloat96()
Motorola M68k 96-bit float (16-bits are always zero).
SgAsmIntegerType * buildTypeX86Word()
16-bit unsigned.
SgAsmFloatType * buildTypeX86Float80()
80-bit IEEE-754 floating-point.
SgAsmIntegerType * buildTypeU1()
1-bit unsigned (Boolean).
SgAsmFloatType * buildTypeX86Float32()
32-bit IEEE-754 floating-point.
SgAsmIntegerType * buildTypeI32()
32-bit signed.
SgBinaryComposite * buildBinaryComposite(const std::string &fileName)
Build a new binary composite object.
The ROSE library.