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 SgAsmBinaryMultiply* buildMultiplyExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
109 SgAsmBinaryPreupdate* buildPreupdateExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
110 SgAsmBinaryPostupdate* buildPostupdateExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
111 SgAsmBinaryMsl* buildMslExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
112 SgAsmBinaryLsl* buildLslExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
113 SgAsmBinaryLsr* buildLsrExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
114 SgAsmBinaryAsr* buildAsrExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
115 SgAsmBinaryRor* buildRorExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
116 SgAsmUnaryRrx* buildRrxExpression(SgAsmExpression *lhs, SgAsmType *type=NULL);
117 SgAsmUnaryTruncate* buildTruncateExpression(SgAsmExpression*, SgAsmType*);
118 SgAsmBinaryConcat* buildConcatExpression(SgAsmExpression *moreSignificant, SgAsmExpression *lessSignificant);
119 SgAsmUnarySignedExtend* buildSignedExtendExpression(SgAsmExpression*, SgAsmType*);
120 SgAsmUnaryUnsignedExtend* buildUnsignedExtendExpression(SgAsmExpression*, SgAsmType*);
121 SgAsmExprListExp* buildExprListExpression();
122 void appendExpression(SgAsmExprListExp*, SgAsmExpression*);
123 SgAsmMemoryReferenceExpression* buildMemoryReferenceExpression(SgAsmExpression *addr, SgAsmExpression *segment=NULL,
124  SgAsmType *type=NULL);
130  SgAsmExpression*);
133 template <typename Insn>
134 inline Insn* appendOperand(Insn* insn, SgAsmExpression* op) {
135  SgAsmOperandList* operands = insn->get_operandList();
136  operands->get_operands().push_back(op);
137  op->set_parent(operands);
138  return insn; // For chaining this operation
139 }
142 // Build instruction
146 SgAsmX86Instruction *buildX86MultibyteNopInstruction(size_t nBytes);
149 // Build basic blocks
150 SgAsmBlock* buildBasicBlock(const std::vector<SgAsmInstruction*>&);
151 SgAsmFunction* buildFunction(rose_addr_t entryVa, const std::vector<SgAsmBlock*>&);
154 // Build data blocks
155 SgAsmStaticData* buildStaticData(rose_addr_t startVa, const SgUnsignedCharList &rawData);
156 SgAsmBlock* buildDataBlock(SgAsmStaticData*);
159 } // namespace
160 } // namespace
162 #endif
163 #endif
Expression that adds two operands.
Expression that performs a right rotate.
Instruction basic block.
SgAsmIntegerType * buildTypeU16()
16-bit unsigned.
Expression that represents an update to a storage location.
SgAsmFloatType * buildIeee754Binary32()
32-bit IEEE-754 floating-point.
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.
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.
Expression that represents an update to a storage location.
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.