From ad54a288a4d3fa48fd23f042e6d09f34780c5b5e Mon Sep 17 00:00:00 2001 From: Aiden Grossman Date: Sat, 6 Apr 2024 00:37:50 -0700 Subject: [PATCH] Add option to remove div instructions --- gematria/datasets/process_and_filter_bbs.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/gematria/datasets/process_and_filter_bbs.cc b/gematria/datasets/process_and_filter_bbs.cc index 1b2314a8..ff356573 100644 --- a/gematria/datasets/process_and_filter_bbs.cc +++ b/gematria/datasets/process_and_filter_bbs.cc @@ -52,6 +52,11 @@ static cl::opt ReportProgressEvery( cl::desc("The interval at which to report progress in blocks"), cl::init(std::numeric_limits::max()), cl::cat(ProcessFilterCat)); +static cl::opt FilterVariableLatencyInstructions( + "filter-variable-latency-instructions", + cl::desc("Whether or not to filter variable latency instructions"), + cl::init(false), cl::cat(ProcessFilterCat)); + Expected processBasicBlock( const std::string &BasicBlock, const gematria::LlvmArchitectureSupport &LLVMSupport, @@ -91,6 +96,15 @@ Expected processBasicBlock( if (FilterMemoryAccessingBlocks && (InstDesc.mayLoad() || InstDesc.mayStore())) continue; + + if (FilterVariableLatencyInstructions) { + // Kind of a hacky solution, but can't figure out a better way to get a + // list of all the variable latency instructions, and div seems like the + // main one currently. + if (Instruction.assembly.find("DIV") != std::string::npos) + continue; + } + OutputBlock += toHex(Instruction.machine_code); }