1 #ifndef ROSE_SageBuilderAsm_H
2 #define ROSE_SageBuilderAsm_H
3 #include <featureTests.h>
6 namespace Rose {
9 namespace SageBuilderAsm {
12 // Build files
31 SgBinaryComposite* buildBinaryComposite(const std::string &fileName);
36 // Build data types
37 //
38 // These data type builders always return the same IR node and are thread-safe.
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*);
80 // Building integer values.
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);
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);
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 SgAsmBinaryConcat* buildConcatExpression(SgAsmExpression *moreSignificant, SgAsmExpression *lessSignificant);
121 SgAsmUnarySignedExtend* buildSignedExtendExpression(SgAsmExpression*, SgAsmType*);
122 SgAsmUnaryUnsignedExtend* buildUnsignedExtendExpression(SgAsmExpression*, SgAsmType*);
123 SgAsmExprListExp* buildExprListExpression();
124 void appendExpression(SgAsmExprListExp*, SgAsmExpression*);
125 SgAsmMemoryReferenceExpression* buildMemoryReferenceExpression(SgAsmExpression *addr, SgAsmExpression *segment=NULL,
126  SgAsmType *type=NULL);
132  SgAsmExpression*);
135 template <typename Insn>
136 inline Insn* appendOperand(Insn* insn, SgAsmExpression* op) {
137  SgAsmOperandList* operands = insn->get_operandList();
138  operands->get_operands().push_back(op);
139  op->set_parent(operands);
140  return insn; // For chaining this operation
141 }
144 // Build instruction
148 SgAsmX86Instruction *buildX86MultibyteNopInstruction(size_t nBytes);
151 // Build basic blocks
152 SgAsmBlock* buildBasicBlock(const std::vector<SgAsmInstruction*>&);
153 SgAsmFunction* buildFunction(rose_addr_t entryVa, const std::vector<SgAsmBlock*>&);
156 // Build data blocks
157 SgAsmStaticData* buildStaticData(rose_addr_t startVa, const SgUnsignedCharList &rawData);
158 SgAsmBlock* buildDataBlock(SgAsmStaticData*);
161 } // namespace
162 } // namespace
164 #endif
165 #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.
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).
Expression representing truncation.
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).
Expression that concatenates two values to form a wider value.
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.