Skip to content

Commit e79dfd1

Browse files
committed
Update Cast matchers function signatures
1 parent 37dca87 commit e79dfd1

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,18 @@ LLQL is a tool that allow you to run SQL-like query with Pattern matching functi
2626

2727
### Sample
2828

29+
You can search for missing optimizaitons patterns for example
30+
31+
```SQL
32+
-- trunc (binop (Y, (ext X))) --> binop ((trunc Y), X)
33+
SELECT instruction AS "Missing Optimization: trunc (binop (Y, (ext X))) --> binop ((trunc Y), X)"
34+
FROM instructions WHERE m_inst(instruction, m_trunc(m_binop(m_any_inst(), m_zext() || m_sext())));
35+
36+
-- trunc (binop (ext X), Y) --> binop X, (trunc Y)
37+
SELECT instruction AS "Missing Optimization: trunc (binop (ext X), Y) --> binop X, (trunc Y)"
38+
FROM instructions WHERE m_inst(instruction, m_trunc(m_binop(m_zext() || m_sext())));
39+
```
40+
2941
If we have LLVM IR function like this, and we want to match `add` instruction that has result of sub instruction as Left hand side and result of mul instruction as Right hand side.
3042

3143
```ir
@@ -122,7 +134,7 @@ Options:
122134
```
123135
MIT License
124136
125-
Copyright (c) 2024 Amr Hesham
137+
Copyright (c) 2024 - 2025 Amr Hesham
126138
127139
Permission is hereby granted, free of charge, to any person obtaining a copy
128140
of this software and associated documentation files (the "Software"), to deal

src/functions/matchers/cast.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use std::collections::HashMap;
22

3+
use gitql_ast::types::optional::OptionType;
34
use gitql_core::signature::Signature;
45
use gitql_core::signature::StandardFunction;
56
use gitql_core::values::base::Value;
@@ -37,8 +38,10 @@ pub fn register_cast_matchers_function_signatures(map: &mut HashMap<&'static str
3738
map.insert("m_addr_space_cast", cast_function_signature());
3839
}
3940

41+
#[inline(always)]
4042
fn cast_function_signature() -> Signature {
4143
Signature::with_return(Box::new(InstMatcherType))
44+
.add_parameter(Box::new(OptionType::new(Some(Box::new(InstMatcherType)))))
4245
}
4346

4447
fn match_trunc(values: &[Box<dyn Value>]) -> Box<dyn Value> {

0 commit comments

Comments
 (0)