ROSE  0.10.5.0
SageBuilderAsm.h
1 #ifndef ROSE_SageBuilderAsm_H
2 #define ROSE_SageBuilderAsm_H
3 #include <rosePublicConfig.h>
4 #ifdef ROSE_BUILD_BINARY_ANALYSIS_SUPPORT
5 
6 namespace Rose {
7 
9 namespace SageBuilderAsm {
10 
12 // Build files
13 
31 SgBinaryComposite* buildBinaryComposite(const std::string &fileName);
32 
33 
34 
36 // Build data types
37 //
38 // These data type builders always return the same IR node and are thread-safe.
39 
40 // Generic data types
41 SgAsmIntegerType* buildTypeU(size_t nBits);
42 SgAsmIntegerType* buildTypeI(size_t nBits);
60 // Architecture-specific data types
72 // Generic value builders
74 SgAsmIntegerValueExpression* buildValueInteger(uint64_t value, SgAsmType*);
76 SgAsmFloatValueExpression* buildValueFloat(double value, SgAsmType*);
78 
80 // Building integer values.
81 
82 // Build integer values generically (one of these per buildType function above)
83 SgAsmIntegerValueExpression* buildValueU1(bool);
84 SgAsmIntegerValueExpression* buildValueU8(uint8_t);
85 SgAsmIntegerValueExpression* buildValueU16(uint16_t);
86 SgAsmIntegerValueExpression* buildValueU32(uint32_t);
87 SgAsmIntegerValueExpression* buildValueU64(uint64_t);
88 SgAsmIntegerValueExpression* buildValueI8(int8_t);
89 SgAsmIntegerValueExpression* buildValueI16(int16_t);
90 SgAsmIntegerValueExpression* buildValueI32(int32_t);
91 SgAsmIntegerValueExpression* buildValueI64(int64_t);
92 SgAsmFloatValueExpression* buildValueIeee754Binary32(double);
93 SgAsmFloatValueExpression* buildValueIeee754Binary64(double);
94 
95 // Building integer values with x86-specific type names
96 SgAsmIntegerValueExpression* buildValueX86Byte(uint8_t);
97 SgAsmIntegerValueExpression* buildValueX86Word(uint16_t);
98 SgAsmIntegerValueExpression* buildValueX86DWord(uint32_t);
99 SgAsmIntegerValueExpression* buildValueX86QWord(uint64_t);
100 SgAsmFloatValueExpression* buildValueX86Float32(double);
101 SgAsmFloatValueExpression* buildValueX86Float64(double);
102 SgAsmFloatValueExpression* buildValueX86Float80(double);
103 
105 // Operators
106 SgAsmBinaryAdd* buildAddExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
107 SgAsmBinarySubtract* buildSubtractExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
108 SgAsmBinaryAddPreupdate* buildAddPreupdateExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
109 SgAsmBinarySubtractPreupdate* buildSubtractPreupdateExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
110 SgAsmBinaryAddPostupdate* buildAddPostupdateExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
111 SgAsmBinarySubtractPostupdate* buildSubtractPostupdateExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
112 SgAsmBinaryMultiply* buildMultiplyExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
113 SgAsmBinaryMsl* buildMslExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
114 SgAsmBinaryLsl* buildLslExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
115 SgAsmBinaryLsr* buildLsrExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
116 SgAsmBinaryAsr* buildAsrExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
117 SgAsmBinaryRor* buildRorExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
118 SgAsmUnaryRrx* buildRrxExpression(SgAsmExpression *lhs, SgAsmType *type=NULL);
119 SgAsmUnaryTruncate* buildTruncateExpression(SgAsmExpression*, SgAsmType*);
120 SgAsmUnarySignedExtend* buildSignedExtendExpression(SgAsmExpression*, SgAsmType*);
121 SgAsmUnaryUnsignedExtend* buildUnsignedExtendExpression(SgAsmExpression*, SgAsmType*);
122 SgAsmExprListExp* buildExprListExpression();
123 void appendExpression(SgAsmExprListExp*, SgAsmExpression*);
124 SgAsmMemoryReferenceExpression* buildMemoryReferenceExpression(SgAsmExpression *addr, SgAsmExpression *segment=NULL,
125  SgAsmType *type=NULL);
131  SgAsmExpression*);
132 
133 
134 template <typename Insn>
135 inline Insn* appendOperand(Insn* insn, SgAsmExpression* op) {
136  SgAsmOperandList* operands = insn->get_operandList();
137  operands->get_operands().push_back(op);
138  op->set_parent(operands);
139  return insn; // For chaining this operation
140 }
141 
143 // Build instruction
147 SgAsmX86Instruction *buildX86MultibyteNopInstruction(size_t nBytes);
148 
150 // Build basic blocks
151 SgAsmBlock* buildBasicBlock(const std::vector<SgAsmInstruction*>&);
152 SgAsmFunction* buildFunction(rose_addr_t entryVa, const std::vector<SgAsmBlock*>&);
153 
155 // Build data blocks
156 SgAsmStaticData* buildStaticData(rose_addr_t startVa, const SgUnsignedCharList &rawData);
157 SgAsmBlock* buildDataBlock(SgAsmStaticData*);
158 
159 
160 } // namespace
161 } // namespace
162 
163 #endif
164 #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.
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.
SgAsmIntegerType * buildTypeI32()
32-bit signed.
SgAsmIntegerType * buildTypeX86Byte()
8-bit unsigned.
SgAsmIntegerType * buildTypeI16()
16-bit signed.
SgAsmFloatType * buildIeee754Binary128()
128-bit IEEE-754 floating-point.
Reference to memory locations.
SgAsmFloatType * buildTypeX86Float32()
32-bit IEEE-754 floating-point.
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.
SgAsmFloatType * buildIeee754Binary16()
16-bit IEEE-754 floating-point.
Expression representing sign extending.
Base class for expressions.
Expression that performs a logical left shift operation.
Expression that multiplies two operands.
Expression that performs a logical left shift operation filling low-order bits with one...
Expression representing unsigned extending.
Base class for binary types.
SgAsmIntegerType * buildTypeI8()
8-bit signed.
SgAsmFloatType * buildTypeM68kFloat80()
Motorola M68k 96-bit float w/out 16-bit constant zero field.
Floating-point value.
SgAsmIntegerType * buildTypeU(size_t nBits)
Unsigned type of specified size.
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).
X86InstructionKind
List of all x86 instructions known to the ROSE disassembler/assembler.
SgAsmFloatType * buildIeee754Binary64()
64-bit IEEE-754 floating-point.
Integer types.
SgAsmFloatType * buildTypeX86Float80()
80-bit IEEE-754 floating-point.
SgAsmIntegerType * buildTypeI(size_t nBits)
Signed type of specified size.
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.