-
-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
147 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// #target: macos-x64 | ||
module test; | ||
bitstruct Foo : int | ||
{ | ||
bool enable_help; | ||
bool enable_version; | ||
} | ||
|
||
bitstruct Foo2 : char[2] | ||
{ | ||
bool enable_help; | ||
bool enable_version; | ||
} | ||
|
||
fn void main() | ||
{ | ||
Foo a = { .enable_help }; | ||
Foo b = { .enable_version }; | ||
Foo $a = { .enable_help }; | ||
Foo $b = { .enable_version }; | ||
$assert(!($a & $b)); | ||
if (a & b) return; | ||
Foo2 a2 = { .enable_help }; | ||
Foo2 b2 = { .enable_version, .enable_help }; | ||
if (!(a2 & b2)) return; | ||
} | ||
|
||
/* #expect: test.ll | ||
|
||
%a = alloca i32, align 4 | ||
%b = alloca i32, align 4 | ||
%a2 = alloca [2 x i8], align 1 | ||
%b2 = alloca [2 x i8], align 1 | ||
%0 = alloca i16, align 1 | ||
store i32 1, ptr %a, align 4 | ||
store i32 2, ptr %b, align 4 | ||
%1 = load i32, ptr %a, align 4 | ||
%2 = load i32, ptr %b, align 4 | ||
%and = and i32 %1, %2 | ||
%neq = icmp ne i32 %and, 0 | ||
br i1 %neq, label %if.then, label %if.exit | ||
|
||
if.then: ; preds = %entry | ||
ret void | ||
|
||
if.exit: ; preds = %entry | ||
store [2 x i8] c"\01\00", ptr %a2, align 1 | ||
store [2 x i8] c"\03\00", ptr %b2, align 1 | ||
%3 = load i16, ptr %a2, align 1 | ||
%4 = load i16, ptr %b2, align 1 | ||
%and1 = and i16 %3, %4 | ||
store i16 %and1, ptr %0, align 1 | ||
%5 = load i8, ptr %0, align 1 | ||
%zext = zext i8 %5 to i32 | ||
%ptradd = getelementptr inbounds i8, ptr %0, i64 1 | ||
%6 = load i8, ptr %ptradd, align 1 | ||
%zext2 = zext i8 %6 to i32 | ||
%7 = add i32 %zext, %zext2 | ||
%8 = icmp eq i32 %7, 0 | ||
br i1 %8, label %if.then3, label %if.exit4 | ||
|
||
if.then3: ; preds = %if.exit | ||
ret void | ||
|
||
if.exit4: ; preds = %if.exit | ||
ret void | ||
} |