-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HLS: Initial conversion of llvm intrinsics generated by Clang #483
base: master
Are you sure you want to change the base?
Conversation
Currently only llvm.smin.i32 is handled
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I stopped reviewing after I saw that this is extremely limited and would only cover cases for the intrinsic being in the lambda subregion (and not even in any gamma/theta node of the lambda).
The absolutely right way to go about this would be to:
- Introduce an smin operation similar like we did for the memcpy intrinsic
- Detect the smin intrinsic in the frontend when converting LLVM to RVSDG similarly like we do for memcpy.
- Add support for converting the smin operation/node back to an LLVM intrinsic in the backend.
- Add a pass in the HLS part that checks for the smin/node and converts it to a gamma.
If you want to restrict it to the HLS part of the compiler (and not touch the other parts of the compiler), then you should:
- Add an HLS pass that iterates through all the (sub-)regions of an RVSDG/lambda (you only have one lambda I guess). There is no need for a toplogical sorting, so taking the nodes directly should be enough. For every call node that you find, you :
- Compute the CallTypeClassifier
- If the call type classifier is an external call and the argument is a smin intrisinc, then replace this node with a gamma node.
{ | ||
auto arg = root->argument(i); | ||
auto imp = dynamic_cast<const llvm::impport *>(&arg->port()); | ||
std::cout << "impport " << imp->name() << ": " << imp->type().debug_string() << "\n"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not think that that it is intended to print stuff here, no?
std::cout << "impport " << imp->name() << ": " << imp->type().debug_string() << "\n"; | ||
if (imp->name().rfind("llvm.", 0) == 0) | ||
{ | ||
std::cout << "replacing intrinsic " << imp->name() << std::endl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
@@ -413,9 +414,81 @@ rvsdg2ref(llvm::RvsdgModule & rhls, std::string path) | |||
dump_ref(rhls, path); | |||
} | |||
|
|||
void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static void
} | ||
} | ||
|
||
void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static void
for (auto user : *out) | ||
{ | ||
if (auto ni = dynamic_cast<rvsdg::node_input *>(user)) | ||
{ | ||
if (dynamic_cast<const llvm::CallOperation *>(&ni->node()->operation())) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will fail to detect the smin if the call node is not in the lambda subregion (i.e., in a gamma or theta of any further nested region)
Currently only llvm.smin.i32 is handled