Giter Club home page Giter Club logo

Comments (5)

felipealmeida avatar felipealmeida commented on July 20, 2024 1

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.

bcardosolopes avatar bcardosolopes commented on July 20, 2024

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.

felipealmeida avatar felipealmeida commented on July 20, 2024

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.

gitoleg avatar gitoleg commented on July 20, 2024

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.

gitoleg avatar gitoleg commented on July 20, 2024

Is it a right place to discuss CIR design questions?

from clangir.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.