Plan for pattern graph

This commit is contained in:
York Jasper Niebuhr 2025-10-13 22:39:45 +02:00
parent 3620d4ffc1
commit ae1d962dff

View File

@ -2,8 +2,29 @@
#include <unordered_map> #include <unordered_map>
class LocationPattern { class PatternNode {
public:
enum OP { NOP /* just move */, ADD, SUB, NEG, CALL, MEMREF };
private:
OP m_op;
public:
// ...
};
class PatternEdge {
public:
enum DATATYPE { VAR, CONST, FIELDOFF /* field offset is specialization of CONST */ };
private:
DATATYPE m_datatype;
// std::size_t m_datasize;
public:
// ...
};
// TODO -> build pattern tree from output root to input leafs
class LocationPattern {
// ...
public: public:
LocationPattern() {} LocationPattern() {}
~LocationPattern() {} ~LocationPattern() {}
@ -28,35 +49,29 @@ int register_gimple_statement_pattern(gimple_stmt_iterator* gsi) {
LocationPattern& pattern = lp_it->second; LocationPattern& pattern = lp_it->second;
/* /*
scan_stmt_for_offsetof(funcname, &gsi); for (unsigned i = 0; i < gimple_num_ops(stmt); ++i) {
for (unsigned i = 0; i < gimple_num_ops(stmt); ++i) { tree op = gimple_op(stmt, i);
tree op = gimple_op(stmt, i); scan_tree_for_components(op, funcname, &gsi);
scan_tree_for_components(op, funcname, &gsi); }
} */
Build GimpleStatementPattern tree from individual gimple statement switch (stmt_code) {
Add GimpleStatementPattern to LocationPattern (attached at matching variable names (potentially unnamed ssa)) case GIMPLE_CALL:
Patterns include markers for member offsets (type, member, value) // check for offsetof, then fall through to operand scanning
Later load a set of RTLInstructionPattern to match the patterns case GIMPLE_ASSIGN:
*/ case GIMPLE_COND:
case GIMPLE_LABEL:
case GIMPLE_RETURN:
return 0;
default:
return 1;
}
switch (stmt_code) { return 0;
case GIMPLE_CALL:
// check for offsetof, then fall through to operand scanning
case GIMPLE_ASSIGN:
case GIMPLE_COND:
case GIMPLE_LABEL:
case GIMPLE_RETURN:
return 0;
default:
return 1;
}
return 0;
} }
void clean_unnecessary_patterns() { void clean_unnecessary_patterns() {
// TODO // TODO -> erase all that do not contain a single member offset
} }
int register_rtl_instruction_pattern(rtx_insn* i) { int register_rtl_instruction_pattern(rtx_insn* i) {