ROSE  0.9.10.220
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 // Generic value builders
67 SgAsmIntegerValueExpression* buildValueInteger(uint64_t value, SgAsmType*);
69 SgAsmFloatValueExpression* buildValueFloat(double value, SgAsmType*);
71 
73 // Building integer values.
74 
75 // Build integer values generically (one of these per buildType function above)
76 SgAsmIntegerValueExpression* buildValueU1(bool);
77 SgAsmIntegerValueExpression* buildValueU8(uint8_t);
78 SgAsmIntegerValueExpression* buildValueU16(uint16_t);
79 SgAsmIntegerValueExpression* buildValueU32(uint32_t);
80 SgAsmIntegerValueExpression* buildValueU64(uint64_t);
81 SgAsmIntegerValueExpression* buildValueI8(int8_t);
82 SgAsmIntegerValueExpression* buildValueI16(int16_t);
83 SgAsmIntegerValueExpression* buildValueI32(int32_t);
84 SgAsmIntegerValueExpression* buildValueI64(int64_t);
85 SgAsmFloatValueExpression* buildValueIeee754Binary32(double);
86 SgAsmFloatValueExpression* buildValueIeee754Binary64(double);
87 
88 // Building integer values with x86-specific type names
89 SgAsmIntegerValueExpression* buildValueX86Byte(uint8_t);
90 SgAsmIntegerValueExpression* buildValueX86Word(uint16_t);
91 SgAsmIntegerValueExpression* buildValueX86DWord(uint32_t);
92 SgAsmIntegerValueExpression* buildValueX86QWord(uint64_t);
93 SgAsmFloatValueExpression* buildValueX86Float32(double);
94 SgAsmFloatValueExpression* buildValueX86Float64(double);
95 SgAsmFloatValueExpression* buildValueX86Float80(double);
96 
98 // Operators
99 SgAsmBinaryAdd* buildAddExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
100 SgAsmBinarySubtract* buildSubtractExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
101 SgAsmBinaryAddPreupdate* buildAddPreupdateExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
102 SgAsmBinarySubtractPreupdate* buildSubtractPreupdateExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
103 SgAsmBinaryAddPostupdate* buildAddPostupdateExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
104 SgAsmBinarySubtractPostupdate* buildSubtractPostupdateExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
105 SgAsmBinaryMultiply* buildMultiplyExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
106 SgAsmBinaryLsl* buildLslExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
107 SgAsmBinaryLsr* buildLsrExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
108 SgAsmBinaryAsr* buildAsrExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
109 SgAsmBinaryRor* buildRorExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
110 SgAsmUnaryRrx* buildRrxExpression(SgAsmExpression *lhs, SgAsmType *type=NULL);
111 SgAsmUnaryArmSpecialRegisterList *buildArmSpecialRegisterList(SgAsmExpression *lhs);
112 SgAsmExprListExp* buildExprListExpression();
113 void appendExpression(SgAsmExprListExp*, SgAsmExpression*);
114 SgAsmMemoryReferenceExpression* buildMemoryReferenceExpression(SgAsmExpression *addr, SgAsmExpression *segment=NULL,
115  SgAsmType *type=NULL);
121  SgAsmExpression*);
122 
123 
124 template <typename Insn>
125 inline Insn* appendOperand(Insn* insn, SgAsmExpression* op) {
126  SgAsmOperandList* operands = insn->get_operandList();
127  operands->get_operands().push_back(op);
128  op->set_parent(operands);
129  return insn; // For chaining this operation
130 }
131 
133 // Build instruction
134 SgAsmX86Instruction* buildX86Instruction(X86InstructionKind);
135 SgAsmX86Instruction* buildX86Instruction(X86InstructionKind, SgAsmExpression *operand);
136 SgAsmX86Instruction* buildX86Instruction(X86InstructionKind, SgAsmExpression *lhs, SgAsmExpression *rhs);
137 SgAsmX86Instruction *buildX86MultibyteNopInstruction(size_t nBytes);
138 
140 // Build basic blocks
141 SgAsmBlock* buildBasicBlock(const std::vector<SgAsmInstruction*>&);
142 SgAsmFunction* buildFunction(rose_addr_t entryVa, const std::vector<SgAsmBlock*>&);
143 
145 // Build data blocks
146 SgAsmStaticData* buildStaticData(rose_addr_t startVa, const SgUnsignedCharList &rawData);
147 SgAsmBlock* buildDataBlock(SgAsmStaticData*);
148 
149 
150 } // namespace
151 } // namespace
152 
153 #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
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.
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.