Comments (9)
Hello @bcardosolopes ,
I started hacking ClangIR to test adding bitfields support for ClangIR. I work with specific proprietary instructions that can be very useful with bitfields, however, premature lowering of bitfields accesses to arithmetic/logical instructions makes optimizations very hard to the backend.
However, I looked in other MLIR projects to see how bitfields have been handled and I did not find anything.
Does anyone in the project already have a possible path on how to solve this for ClangIR?
Kind regards,
from clangir.
How much problematic it'd be for you to drop it when lowering to CIR for now until a concrete use?
I don't mind dropping the qualifiers for now. My main goal at the moment is to see whether VAST -> CIR -> LLVM is a viable path. As we discussed, if there is some common part I am happy to add it to CIR. And this seemed to me as one of them :)
Do you have plans to build an ASTContext from VAST? This could also be necessary in AST-free-CIR, if generating, for instance, LLVM load/store's out of it.
I would need to investigate whether we can reconstruct ASTContext, I don't have answer for that now.
Oh, what kind of problems on high-level-types+attributes you've been running into?
Maybe with newer MLIR version and TypedAttrInterface
it is resolved. But the problem we had was with attributes that has vast
high-level types, e.g., constants, these can be arbitrarily nested in some non-typed attribute.
And when we tried to lower them from vast
types to std
types it was not clear if whether and where the attributes contains types that need to be converted.
from clangir.
@felipealmeida great to hear you played a bit with bitfields.
Does anyone in the project already have a possible path on how to solve this for ClangIR?
Nothing set in stone from our discussions but we surely don't wanna lower them in terms of logical operations right away, but instead proxy it out (and hide the details) over an operation cir.get_bitfield
or similar. We can iterate on a design (or a PR) if you already have ideas on how to implement that.
from clangir.
@felipealmeida Created #13 to track bitfields!
from clangir.
It might also be worth checking out how polygeist does some of that lowering, could provide interesting insights.
from clangir.
@bcardosolopes as I am now lowering vast to cir, I might add something similar to vast high-level types to cir:
https://github.com/trailofbits/vast/blob/master/include/vast/Dialect/HighLevel/HighLevelTypes.td
Do you want to retain type qualifiers in cir? Also a tricky part is to define constants with high-level types, they do not cooperate nicely with attributes, and our lowering of their attribute types is a bit hackish at the moment :(
from clangir.
@bcardosolopes as I am now lowering vast to cir
This is great to hear!
I might add something similar to vast high-level types to cir:
https://github.com/trailofbits/vast/blob/master/include/vast/Dialect/HighLevel/HighLevelTypes.td
Do you want to retain type qualifiers in cir?
This information will be good to have, for sure. The way I was planning to get type qualifiers would be through ASTContext queries on types (which should do the right thing on top of its CanQual
s). Type information would come from attached AST nodes, of course that requires AST-capable-CIR to be used. Do you have plans to build an ASTContext from VAST? This could also be necessary in AST-free-CIR, if generating, for instance, LLVM load/store's out of it.
Something like HighLevelTypes.td in CIR would be helpful, specially cause we also want to add something like your CharType, ShortType, etc (purpose of this github issue). How about adding these first and qualifiers as a second step?
Regarding qualifiers, since we don't usually add things without use cases, I'm curious about some pieces:
- Are you planning to (1) write a CIR pass that uses some of this in the shorter term? or (2) something that can concretely provide helpful insight info to codegen? A simple pass that exercises some of this potential would certainly be nice (e.g. produce statistics between number of volatile loads / normals loads, or volatile load/store LLVM codegen pieces).
- How much problematic it'd be for you to drop it when lowering to CIR for now until a concrete use?
Also a tricky part is to define constants with high-level types, they do not cooperate nicely with attributes, and our lowering of their attribute types is a bit hackish at the moment :(
Oh, what kind of problems on high-level-types+attributes you've been running into?
from clangir.
I don't mind dropping the qualifiers for now. My main goal at the moment is to see whether VAST -> CIR -> LLVM is a viable path.
Sweet, @lanza just started to work on CIR -> LLVM, so I guess we are all going towards the same goal, and adding qualifiers is a big step on that too!
As we discussed, if there is some common part I am happy to add it to CIR. And this seemed to me as one of them :)
Perfect.
Maybe with newer MLIR version and
TypedAttrInterface
it is resolved. But the problem we had was with attributes that hasvast
high-level types, e.g., constants, these can be arbitrarily nested in some non-typed attribute. And when we tried to lower them fromvast
types tostd
types it was not clear if whether and where the attributes contains types that need to be converted.
Yea, I remember he had to change a lot because of a change past few months ago that decoupled types and attributes, but I'm not sure how much it addresses the problem you are describing :(
from clangir.
The main parts of this are done, other issues will track further improvements.
from clangir.
Related Issues (20)
- Both `cir.const_struct` and `cir.const_array` should support `#cir.zero`
- Create a common interface/trait for CIR global values
- LLVM install failure `clang/CIR/Dialect/IR/CIROpsEnums.h.inc: No such file or directory` HOT 3
- Move struct field name from callsite to type
- Verification failure for recursive struct HOT 3
- Invalid lowering of for-loops HOT 2
- Lowering of nested break/continue in loops HOT 4
- Crash when lowering endless for loop HOT 4
- Revise usage of `const_struct` and `const_array` to enhance codegen parity
- Invalid order of global variables lowering HOT 4
- Invalid IR when accessing union HOT 2
- CIR Dialect Struct Type Recursive Reference HOT 13
- Support of symbol references in CIRGenExprConst HOT 2
- Support for `Decl::PragmaComment` HOT 1
- Create custom CIR floating point types. HOT 5
- Create a custom CIR void type HOT 1
- Patch remaining undesired usages of MLIR's built-in integer type HOT 1
- Use readable representation for char types
- Harden operation constraints from AnyType to CIRType HOT 2
- Consider change cir.br block targets to have operands. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from clangir.