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 or FP values.
82 // Build integer or FP 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 // Template specializations for building integer values
96 template <class T>
97 SgAsmIntegerValueExpression* buildValue(T);
99 // Building integer or FP values with x86-specific type names
100 SgAsmIntegerValueExpression* buildValueX86Byte(uint8_t);
101 SgAsmIntegerValueExpression* buildValueX86Word(uint16_t);
102 SgAsmIntegerValueExpression* buildValueX86DWord(uint32_t);
103 SgAsmIntegerValueExpression* buildValueX86QWord(uint64_t);
104 SgAsmFloatValueExpression* buildValueX86Float32(double);
105 SgAsmFloatValueExpression* buildValueX86Float64(double);
106 SgAsmFloatValueExpression* buildValueX86Float80(double);
109 // Operators
110 SgAsmBinaryAdd* buildAddExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
111 SgAsmBinarySubtract* buildSubtractExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
112 SgAsmBinaryMultiply* buildMultiplyExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
113 SgAsmBinaryPreupdate* buildPreupdateExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
114 SgAsmBinaryPostupdate* buildPostupdateExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
115 SgAsmBinaryMsl* buildMslExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
116 SgAsmBinaryLsl* buildLslExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
117 SgAsmBinaryLsr* buildLsrExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
118 SgAsmBinaryAsr* buildAsrExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
119 SgAsmBinaryRor* buildRorExpression(SgAsmExpression *lhs, SgAsmExpression *rhs, SgAsmType *type=NULL);
120 SgAsmUnaryRrx* buildRrxExpression(SgAsmExpression *lhs, SgAsmType *type=NULL);
121 SgAsmUnaryTruncate* buildTruncateExpression(SgAsmExpression*, SgAsmType*);
122 SgAsmBinaryConcat* buildConcatExpression(SgAsmExpression *moreSignificant, SgAsmExpression *lessSignificant);
123 SgAsmUnarySignedExtend* buildSignedExtendExpression(SgAsmExpression*, SgAsmType*);
124 SgAsmUnaryUnsignedExtend* buildUnsignedExtendExpression(SgAsmExpression*, SgAsmType*);
125 SgAsmExprListExp* buildExprListExpression();
126 void appendExpression(SgAsmExprListExp*, SgAsmExpression*);
127 SgAsmMemoryReferenceExpression* buildMemoryReferenceExpression(SgAsmExpression *addr, SgAsmExpression *segment=NULL,
128  SgAsmType *type=NULL);
134  SgAsmExpression*);
137 template <typename Insn>
138 inline Insn* appendOperand(Insn* insn, SgAsmExpression* op) {
139  SgAsmOperandList* operands = insn->get_operandList();
140  operands->get_operands().push_back(op);
141  op->set_parent(operands);
142  return insn; // For chaining this operation
143 }
146 // Build instruction
150 SgAsmX86Instruction *buildX86MultibyteNopInstruction(size_t nBytes);
153 // Build basic blocks
154 SgAsmBlock* buildBasicBlock(const std::vector<SgAsmInstruction*>&);
155 SgAsmFunction* buildFunction(rose_addr_t entryVa, const std::vector<SgAsmBlock*>&);
158 // Build data blocks
159 SgAsmStaticData* buildStaticData(rose_addr_t startVa, const SgUnsignedCharList &rawData);
160 SgAsmBlock* buildDataBlock(SgAsmStaticData*);
163 } // namespace
164 } // namespace
166 #endif
167 #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.