-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[clang][Interp] Add basic support for _BitInt #68069
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -564,7 +564,7 @@ def FromCastTypeClass : TypeClass { | |
} | ||
|
||
def ToCastTypeClass : TypeClass { | ||
let Types = [Uint8, Sint8, Uint16, Sint16, Uint32, Sint32, Uint64, Sint64, Bool, IntAP, IntAPS]; | ||
let Types = [Uint8, Sint8, Uint16, Sint16, Uint32, Sint32, Uint64, Sint64, Bool]; | ||
} | ||
|
||
def Cast: Opcode { | ||
|
@@ -577,6 +577,22 @@ def CastFP : Opcode { | |
let Args = [ArgFltSemantics, ArgRoundingMode]; | ||
} | ||
|
||
def FixedSizeIntegralTypes : TypeClass { | ||
let Types = [Uint8, Sint8, Uint16, Sint16, Uint32, Sint32, Uint64, Sint64, Bool]; | ||
} | ||
|
||
def CastAP : Opcode { | ||
let Types = [AluTypeClass]; | ||
let Args = [ArgUint32]; | ||
let HasGroup = 1; | ||
} | ||
|
||
def CastAPS : Opcode { | ||
let Types = [AluTypeClass]; | ||
let Args = [ArgUint32]; | ||
let HasGroup = 1; | ||
} | ||
|
||
// Cast an integer to a floating type | ||
def CastIntegralFloating : Opcode { | ||
let Types = [AluTypeClass]; | ||
|
@@ -586,11 +602,21 @@ def CastIntegralFloating : Opcode { | |
|
||
// Cast a floating to an integer type | ||
def CastFloatingIntegral : Opcode { | ||
let Types = [AluTypeClass]; | ||
let Types = [FixedSizeIntegralTypes]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The type classes for these get kinda confusing... but I just can't come up with the correct syntax to define them inline. |
||
let Args = []; | ||
let HasGroup = 1; | ||
} | ||
|
||
def CastFloatingIntegralAP : Opcode { | ||
let Types = []; | ||
let Args = [ArgUint32]; | ||
} | ||
|
||
def CastFloatingIntegralAPS : Opcode { | ||
let Types = []; | ||
let Args = [ArgUint32]; | ||
} | ||
|
||
def CastPointerIntegral : Opcode { | ||
let Types = [AluTypeClass]; | ||
let Args = []; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,21 @@ | |
// RUN: %clang_cc1 -std=c++11 -fms-extensions -verify=ref %s | ||
// RUN: %clang_cc1 -std=c++20 -fms-extensions -verify=ref %s | ||
|
||
|
||
using MaxBitInt = _BitInt(8388608); | ||
|
||
constexpr _BitInt(2) A = 0; | ||
constexpr _BitInt(2) B = A + 1; | ||
constexpr _BitInt(2) C = B + 1; // expected-warning {{from 2 to -2}} \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since |
||
// ref-warning {{from 2 to -2}} | ||
static_assert(C == -2, ""); | ||
|
||
|
||
constexpr MaxBitInt A_ = 0; | ||
constexpr MaxBitInt B_ = A_ + 1; | ||
static_assert(B_ == 1, ""); | ||
|
||
|
||
#ifdef __SIZEOF_INT128__ | ||
namespace i128 { | ||
typedef __int128 int128_t; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CastFloatingIntegralAP(S)
needs a helper function to get rid of the code duplication.