Comments (5)
Hello @bcardosolopes ,
I'm moving all discussion to here. About your comment: "It might also be worth checking out how polygeist does some of that lowering, could provide interesting insights.". Unfortunately I haven't found absolutely anything about bitfields in Polygeist. I looked online and shallowly in the source code. I'll take a deeper look soon, but it may very well be that we are the first, specially because bitfields are not very well seen and hardly does what people expect it to do (standard-wise), but it still useful where implementation defined behavior is OK (which is my case).
from clangir.
Ok, looks like we have some interesting land to explore, thanks for taking a look @felipealmeida - we much very want to see support for bitfields too.
from clangir.
Hello, I'm using this example:
struct field {
char c;
unsigned i0 : 8;
unsigned i1 : 8;
unsigned i2 : 8;
unsigned i3 : 8;
char d;
};
void foo (struct field* f, char a) {
}
Generating this (as a test):
#loc2 = loc(fused["test.c":12:11, "test.c":12:25])
#loc3 = loc(fused["test.c":12:28, "test.c":12:33])
module {
cir.func @foo(%arg0: !cir.ptr<!cir.struct<"struct.field", i8, !cir.bitfield<i32, "offsets"<0, 8, 16, 24>, "sizes"<8, 8, 8, 8> >, i8>> loc(fused["test.c":12:11, "test.c":12:25]), %arg1: i8 loc(fused["test.c":12:28, "test.c":12:33])) {
%0 = cir.alloca !cir.ptr<!cir.struct<"struct.field", i8, !cir.bitfield<i32, "offsets"<0, 8, 16, 24>, "sizes"<8, 8, 8, 8> >, i8>>, cir.ptr <!cir.ptr<!cir.struct<"struct.field", i8, !cir.bitfield<i32, "offsets"<0, 8, 16, 24>, "sizes"<8, 8, 8, 8> >, i8>>>, ["f", paraminit] {alignment = 8 : i64} loc(#loc2)
%1 = cir.alloca i8, cir.ptr <i8>, ["a", paraminit] {alignment = 1 : i64} loc(#loc3)
cir.store %arg0, %0 : !cir.ptr<!cir.struct<"struct.field", i8, !cir.bitfield<i32, "offsets"<0, 8, 16, 24>, "sizes"<8, 8, 8, 8> >, i8>>, cir.ptr <!cir.ptr<!cir.struct<"struct.field", i8, !cir.bitfield<i32, "offsets"<0, 8, 16, 24>, "sizes"<8, 8, 8, 8> >, i8>>> loc(#loc4)
cir.store %arg1, %1 : i8, cir.ptr <i8> loc(#loc4)
cir.return loc(#loc5)
} loc(#loc1)
} loc(#loc0)
#loc0 = loc(unknown)
#loc1 = loc(fused["test.c":12:1, "test.c":14:1])
#loc4 = loc("test.c":12:36)
#loc5 = loc("test.c":14:1)
I don't think the current bitfield definition is good, probably not even legal, maybe cir.bitfield<i32, [0, 8], [8, 8], [16, 8], [24, 8]>. Let me know if anyone has any criticism.
Kind regards,
from clangir.
Hey,
as far as I understand there is no progress on this issue, so can you give an advice on implementation? The part I think about is mlir::LValue
that is similar to clang::LValue
, but lack the union with BitFieldInfo
, and looks like it's not easy to implement it, since the value is not stored by pointer. So... Any ideas? Thank you!
from clangir.
Is it a right place to discuss CIR design questions?
from clangir.
Related Issues (20)
- Fix XFAIL in clang/test/CIR/CodeGen/vbase.cpp HOT 1
- Fix windows builds to unblock test infra
- Re-introduce tablegen constraint for "is-this-a-CIR-type" and use it here
- Add support for clang-format-action after next rebase
- Destructors are not called when jumping out of a scope
- Statement expression dtor issue
- Invalid LLVM for constant array reference HOT 3
- Make most CIRGenTypeCache types to be MLIR type aliases
- Fix XFAILs on Lowering/globals.cir and CodeGen/fun-ptr.c HOT 2
- Use dedicated string attribute for string literals
- How should cir.base_class_addr work
- Make `cir.array` types mutable to allow forward declarations
- Should arrays be promoted to globals for LLVM on par codegen?
- How to use ClangIR downstream? HOT 4
- Initial support for OpenCL HOT 3
- ABI-aware calling conventions
- Teach CIR pointers about address space
- Adding ClangIR testing to debian-fast buildbot
- Remove "cir" from ENABLE_LLVM_PROJECTS
- MLIRCIR and MLIRCIRInterfaces depend upon one another
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.