[clang] [CIR] Add initial support for bitfields in structs (PR #142041)

2025-06-04 Thread Bruno Cardoso Lopes via cfe-commits
bcardosolopes wrote: > Why are we representing each member of a union individually but packing > bitfields away in integer fields? As you noticed, we went higher level for unions (kept the other types around) but didn't for bitfields. I don't see it as inconsistent because in my point of view

[clang] [CIR] Add initial support for bitfields in structs (PR #142041)

2025-06-03 Thread via cfe-commits
@@ -223,21 +272,114 @@ void CIRRecordLowering::fillOutputFields() { fieldTypes.size() - 1; // A field without storage must be a bitfield. assert(!cir::MissingFeatures::bitfields()); + if (!member.data) +setBitFieldInfo(member.fieldDecl, memb

[clang] [CIR] Add initial support for bitfields in structs (PR #142041)

2025-06-03 Thread via cfe-commits
https://github.com/Andres-Salamanca updated https://github.com/llvm/llvm-project/pull/142041 >From 8fd6f99f59d1bbde98696559141bcfe15920d175 Mon Sep 17 00:00:00 2001 From: Andres Salamanca Date: Thu, 29 May 2025 16:17:09 -0500 Subject: [PATCH 1/4] Add initial support for bitfields in structs and

[clang] [CIR] Add initial support for bitfields in structs (PR #142041)

2025-06-01 Thread via cfe-commits
@@ -14,6 +14,105 @@ namespace clang::CIRGen { +/// Record with information about how a bitfield should be accessed. This is +/// very similar to what LLVM codegen does, once CIR evolves it's possible we +/// can use a more higher level representation. +/// +/// Often we lay o

[clang] [CIR] Add initial support for bitfields in structs (PR #142041)

2025-05-30 Thread Andy Kaylor via cfe-commits
@@ -14,6 +14,105 @@ namespace clang::CIRGen { +/// Record with information about how a bitfield should be accessed. This is +/// very similar to what LLVM codegen does, once CIR evolves it's possible we +/// can use a more higher level representation. +/// +/// Often we lay o

[clang] [CIR] Add initial support for bitfields in structs (PR #142041)

2025-05-30 Thread Andy Kaylor via cfe-commits
andykaylor wrote: @bcardosolopes, I have some general concerns about the way that we're representing bitfields and bitfield accesses. It seems fundamentally inconsistent with the way we represent unions. For example: ``` union U { char a; int b; long c; }; ``` becomes `!cir.record -> !c

[clang] [CIR] Add initial support for bitfields in structs (PR #142041)

2025-05-30 Thread Andy Kaylor via cfe-commits
@@ -223,21 +272,114 @@ void CIRRecordLowering::fillOutputFields() { fieldTypes.size() - 1; // A field without storage must be a bitfield. assert(!cir::MissingFeatures::bitfields()); + if (!member.data) +setBitFieldInfo(member.fieldDecl, memb

[clang] [CIR] Add initial support for bitfields in structs (PR #142041)

2025-05-30 Thread Andy Kaylor via cfe-commits
@@ -223,21 +272,114 @@ void CIRRecordLowering::fillOutputFields() { fieldTypes.size() - 1; // A field without storage must be a bitfield. assert(!cir::MissingFeatures::bitfields()); + if (!member.data) +setBitFieldInfo(member.fieldDecl, memb

[clang] [CIR] Add initial support for bitfields in structs (PR #142041)

2025-05-30 Thread Andy Kaylor via cfe-commits
@@ -172,6 +195,32 @@ CIRRecordLowering::CIRRecordLowering(CIRGenTypes &cirGenTypes, zeroInitializable(true), zeroInitializableAsBase(true), packed(packed), padded(false) {} +void CIRRecordLowering::setBitFieldInfo(const FieldDecl *fd, +

[clang] [CIR] Add initial support for bitfields in structs (PR #142041)

2025-05-30 Thread Andy Kaylor via cfe-commits
@@ -14,6 +14,105 @@ namespace clang::CIRGen { +/// Record with information about how a bitfield should be accessed. This is +/// very similar to what LLVM codegen does, once CIR evolves it's possible we +/// can use a more higher level representation. +/// +/// Often we lay o

[clang] [CIR] Add initial support for bitfields in structs (PR #142041)

2025-05-30 Thread Andy Kaylor via cfe-commits
@@ -0,0 +1,79 @@ +// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir +// RUN: FileCheck --input-file=%t.cir %s --check-prefix=CIR +// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o %t-cir.ll +//

[clang] [CIR] Add initial support for bitfields in structs (PR #142041)

2025-05-30 Thread Andy Kaylor via cfe-commits
@@ -14,6 +14,105 @@ namespace clang::CIRGen { +/// Record with information about how a bitfield should be accessed. This is +/// very similar to what LLVM codegen does, once CIR evolves it's possible we +/// can use a more higher level representation. +/// +/// Often we lay o

[clang] [CIR] Add initial support for bitfields in structs (PR #142041)

2025-05-30 Thread Andy Kaylor via cfe-commits
@@ -223,21 +272,114 @@ void CIRRecordLowering::fillOutputFields() { fieldTypes.size() - 1; // A field without storage must be a bitfield. assert(!cir::MissingFeatures::bitfields()); + if (!member.data) +setBitFieldInfo(member.fieldDecl, memb

[clang] [CIR] Add initial support for bitfields in structs (PR #142041)

2025-05-30 Thread Andy Kaylor via cfe-commits
@@ -223,21 +272,114 @@ void CIRRecordLowering::fillOutputFields() { fieldTypes.size() - 1; // A field without storage must be a bitfield. assert(!cir::MissingFeatures::bitfields()); + if (!member.data) +setBitFieldInfo(member.fieldDecl, memb

[clang] [CIR] Add initial support for bitfields in structs (PR #142041)

2025-05-30 Thread Andy Kaylor via cfe-commits
@@ -223,21 +272,114 @@ void CIRRecordLowering::fillOutputFields() { fieldTypes.size() - 1; // A field without storage must be a bitfield. assert(!cir::MissingFeatures::bitfields()); + if (!member.data) +setBitFieldInfo(member.fieldDecl, memb

[clang] [CIR] Add initial support for bitfields in structs (PR #142041)

2025-05-30 Thread Andy Kaylor via cfe-commits
@@ -223,21 +272,114 @@ void CIRRecordLowering::fillOutputFields() { fieldTypes.size() - 1; // A field without storage must be a bitfield. assert(!cir::MissingFeatures::bitfields()); + if (!member.data) +setBitFieldInfo(member.fieldDecl, memb

[clang] [CIR] Add initial support for bitfields in structs (PR #142041)

2025-05-30 Thread Andy Kaylor via cfe-commits
@@ -223,21 +272,114 @@ void CIRRecordLowering::fillOutputFields() { fieldTypes.size() - 1; // A field without storage must be a bitfield. assert(!cir::MissingFeatures::bitfields()); + if (!member.data) +setBitFieldInfo(member.fieldDecl, memb

[clang] [CIR] Add initial support for bitfields in structs (PR #142041)

2025-05-30 Thread Andy Kaylor via cfe-commits
@@ -223,21 +272,114 @@ void CIRRecordLowering::fillOutputFields() { fieldTypes.size() - 1; // A field without storage must be a bitfield. assert(!cir::MissingFeatures::bitfields()); + if (!member.data) +setBitFieldInfo(member.fieldDecl, memb