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