-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CIR] Data member pointer comparison and casts
This patch adds CIRGen and LLVM lowering support for the following language features related to pointers to data members: - Comparisons between pointers to data members. - Casting from pointers to data members to boolean. - Reinterpret casts between pointers to data members.
- Loading branch information
Showing
9 changed files
with
210 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++17 -fclangir -emit-cir %s -o %t.cir | ||
// RUN: FileCheck --input-file=%t.cir --check-prefix=CIR %s | ||
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++17 -fclangir -emit-llvm %s -o %t.ll | ||
// RUN: FileCheck --input-file=%t.ll --check-prefix=LLVM %s | ||
|
||
struct Foo { | ||
int a; | ||
}; | ||
|
||
struct Bar { | ||
int a; | ||
}; | ||
|
||
bool eq(int Foo::*x, int Foo::*y) { | ||
return x == y; | ||
} | ||
|
||
// CIR-LABEL: @_Z2eqM3FooiS0_ | ||
// CIR: %[[#x:]] = cir.load %{{.+}} : !cir.ptr<!cir.data_member<!s32i in !ty_Foo>>, !cir.data_member<!s32i in !ty_Foo> | ||
// CIR-NEXT: %[[#y:]] = cir.load %{{.+}} : !cir.ptr<!cir.data_member<!s32i in !ty_Foo>>, !cir.data_member<!s32i in !ty_Foo> | ||
// CIR-NEXT: %{{.+}} = cir.cmp(eq, %[[#x]], %[[#y]]) : !cir.data_member<!s32i in !ty_Foo>, !cir.bool | ||
// CIR: } | ||
|
||
// LLVM-LABEL: @_Z2eqM3FooiS0_ | ||
// LLVM: %[[#x:]] = load i64, ptr %{{.+}}, align 8 | ||
// LLVM-NEXT: %[[#y:]] = load i64, ptr %{{.+}}, align 8 | ||
// LLVM-NEXT: %{{.+}} = icmp eq i64 %[[#x]], %[[#y]] | ||
// LLVM: } | ||
|
||
bool ne(int Foo::*x, int Foo::*y) { | ||
return x != y; | ||
} | ||
|
||
// CIR-LABEL: @_Z2neM3FooiS0_ | ||
// CIR: %[[#x:]] = cir.load %{{.+}} : !cir.ptr<!cir.data_member<!s32i in !ty_Foo>>, !cir.data_member<!s32i in !ty_Foo> | ||
// CIR-NEXT: %[[#y:]] = cir.load %{{.+}} : !cir.ptr<!cir.data_member<!s32i in !ty_Foo>>, !cir.data_member<!s32i in !ty_Foo> | ||
// CIR-NEXT: %{{.+}} = cir.cmp(ne, %[[#x]], %[[#y]]) : !cir.data_member<!s32i in !ty_Foo>, !cir.bool | ||
// CIR: } | ||
|
||
// LLVM-LABEL: @_Z2neM3FooiS0_ | ||
// LLVM: %[[#x:]] = load i64, ptr %{{.+}}, align 8 | ||
// LLVM-NEXT: %[[#y:]] = load i64, ptr %{{.+}}, align 8 | ||
// LLVM-NEXT: %{{.+}} = icmp ne i64 %[[#x]], %[[#y]] | ||
// LLVM: } |