mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 03:28:20 +02:00
More SIMD work
This commit is contained in:
parent
b57cbe2d69
commit
ca4b383339
19 changed files with 695 additions and 76 deletions
12
BeefLibs/corlib/src/Numerics/Bool2.bf
Normal file
12
BeefLibs/corlib/src/Numerics/Bool2.bf
Normal file
|
@ -0,0 +1,12 @@
|
|||
namespace System.Numerics
|
||||
{
|
||||
[UnderlyingArray(typeof(bool), 2, true)]
|
||||
struct bool2
|
||||
{
|
||||
public bool x;
|
||||
public bool y;
|
||||
|
||||
[Intrinsic("and")]
|
||||
public static extern bool2 operator&(bool2 lhs, bool2 rhs);
|
||||
}
|
||||
}
|
89
BeefLibs/corlib/src/Numerics/Float2.bf
Normal file
89
BeefLibs/corlib/src/Numerics/Float2.bf
Normal file
|
@ -0,0 +1,89 @@
|
|||
namespace System.Numerics
|
||||
{
|
||||
[UnderlyingArray(typeof(float), 2, true)]
|
||||
struct float2
|
||||
{
|
||||
public float x;
|
||||
public float y;
|
||||
|
||||
[Inline]
|
||||
public this()
|
||||
{
|
||||
this = default;
|
||||
}
|
||||
|
||||
[Inline]
|
||||
public this(float x, float y)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public extern float this[int idx] { [Intrinsic("index")] get; [Intrinsic("index")] set; }
|
||||
|
||||
public extern float2 yx { [Intrinsic("shuffle10")] get; [Intrinsic("shuffle10")] set; }
|
||||
|
||||
[Intrinsic("add")]
|
||||
public static extern float2 operator+(float2 lhs, float2 rhs);
|
||||
[Intrinsic("add"), Commutable]
|
||||
public static extern float2 operator+(float2 lhs, float rhs);
|
||||
[Intrinsic("add")]
|
||||
public static extern float2 operator++(float2 lhs);
|
||||
|
||||
[Intrinsic("sub")]
|
||||
public static extern float2 operator-(float2 lhs, float2 rhs);
|
||||
[Intrinsic("sub"), Commutable]
|
||||
public static extern float2 operator-(float2 lhs, float rhs);
|
||||
[Intrinsic("sub")]
|
||||
public static extern float2 operator--(float2 lhs);
|
||||
|
||||
[Intrinsic("mul")]
|
||||
public static extern float2 operator*(float2 lhs, float2 rhs);
|
||||
[Intrinsic("mul"), Commutable]
|
||||
public static extern float2 operator*(float2 lhs, float rhs);
|
||||
|
||||
[Intrinsic("div")]
|
||||
public static extern float2 operator/(float2 lhs, float2 rhs);
|
||||
[Intrinsic("div")]
|
||||
public static extern float2 operator/(float2 lhs, float rhs);
|
||||
[Intrinsic("div")]
|
||||
public static extern float2 operator/(float lhs, float2 rhs);
|
||||
|
||||
[Intrinsic("mod")]
|
||||
public static extern float2 operator%(float2 lhs, float2 rhs);
|
||||
[Intrinsic("mod")]
|
||||
public static extern float2 operator%(float2 lhs, float rhs);
|
||||
[Intrinsic("mod")]
|
||||
public static extern float2 operator%(float lhs, float2 rhs);
|
||||
|
||||
[Intrinsic("eq")]
|
||||
public static extern bool2 operator==(float2 lhs, float2 rhs);
|
||||
[Intrinsic("eq"), Commutable]
|
||||
public static extern bool2 operator==(float2 lhs, float rhs);
|
||||
|
||||
[Intrinsic("neq")]
|
||||
public static extern bool2 operator!=(float2 lhs, float2 rhs);
|
||||
[Intrinsic("neq"), Commutable]
|
||||
public static extern bool2 operator!=(float2 lhs, float rhs);
|
||||
|
||||
[Intrinsic("lt")]
|
||||
public static extern bool2 operator<(float2 lhs, float2 rhs);
|
||||
[Intrinsic("lt")]
|
||||
public static extern bool2 operator<(float2 lhs, float rhs);
|
||||
|
||||
[Intrinsic("lte")]
|
||||
public static extern bool2 operator<=(float2 lhs, float2 rhs);
|
||||
[Intrinsic("lte")]
|
||||
public static extern bool2 operator<=(float2 lhs, float rhs);
|
||||
|
||||
[Intrinsic("gt")]
|
||||
public static extern bool2 operator>(float2 lhs, float2 rhs);
|
||||
[Intrinsic("gt")]
|
||||
public static extern bool2 operator>(float2 lhs, float rhs);
|
||||
|
||||
[Intrinsic("gte")]
|
||||
public static extern bool2 operator>=(float2 lhs, float2 rhs);
|
||||
[Intrinsic("gte")]
|
||||
public static extern bool2 operator>=(float2 lhs, float rhs);
|
||||
}
|
||||
}
|
|
@ -8,11 +8,13 @@ namespace System.Numerics
|
|||
public float z;
|
||||
public float w;
|
||||
|
||||
[Inline]
|
||||
public this()
|
||||
{
|
||||
this = default;
|
||||
}
|
||||
|
||||
[Inline]
|
||||
public this(float x, float y, float z, float w)
|
||||
{
|
||||
this.x = x;
|
||||
|
@ -21,6 +23,8 @@ namespace System.Numerics
|
|||
this.w = w;
|
||||
}
|
||||
|
||||
public extern float this[int idx] { [Intrinsic("index")] get; [Intrinsic("index")] set; }
|
||||
|
||||
public extern float4 wzyx { [Intrinsic("shuffle3210")] get; [Intrinsic("shuffle3210")] set; }
|
||||
|
||||
[Intrinsic("add")]
|
||||
|
|
137
BeefLibs/corlib/src/Numerics/V128.bf
Normal file
137
BeefLibs/corlib/src/Numerics/V128.bf
Normal file
|
@ -0,0 +1,137 @@
|
|||
namespace System.Numerics
|
||||
{
|
||||
[UnderlyingArray(typeof(uint8), 16, true), Align(16), Union]
|
||||
struct v128
|
||||
{
|
||||
public int8[16] int8;
|
||||
public uint8[16] uint8;
|
||||
public int16[8] int16;
|
||||
public uint16[8] uint16;
|
||||
public int32[4] int32;
|
||||
public uint32[4] uint32;
|
||||
public int64[2] int64;
|
||||
public uint64[2] uint64;
|
||||
public float[4] float;
|
||||
public double[2] double;
|
||||
|
||||
[Inline]
|
||||
public this(int8 v0)
|
||||
{
|
||||
this.int8 = .(v0, v0, v0, v0, v0, v0, v0, v0, v0, v0, v0, v0, v0, v0, v0, v0);
|
||||
}
|
||||
|
||||
[Inline]
|
||||
public this(uint8 v0)
|
||||
{
|
||||
this.uint8 = .(v0, v0, v0, v0, v0, v0, v0, v0, v0, v0, v0, v0, v0, v0, v0, v0);
|
||||
}
|
||||
|
||||
[Inline]
|
||||
public this(int16 v0)
|
||||
{
|
||||
this.int16 = .(v0, v0, v0, v0, v0, v0, v0, v0);
|
||||
}
|
||||
|
||||
[Inline]
|
||||
public this(uint16 v0)
|
||||
{
|
||||
this.uint16 = .(v0, v0, v0, v0, v0, v0, v0, v0);
|
||||
}
|
||||
|
||||
[Inline]
|
||||
public this(int32 v0)
|
||||
{
|
||||
this.int32 = .(v0, v0, v0, v0);
|
||||
}
|
||||
|
||||
[Inline]
|
||||
public this(uint32 v0)
|
||||
{
|
||||
this.uint32 = .(v0, v0, v0, v0);
|
||||
}
|
||||
|
||||
[Inline]
|
||||
public this(int64 v0)
|
||||
{
|
||||
this.int64 = .(v0, v0);
|
||||
}
|
||||
|
||||
[Inline]
|
||||
public this(uint64 v0)
|
||||
{
|
||||
this.uint64 = .(v0, v0);
|
||||
}
|
||||
|
||||
[Inline]
|
||||
public this(float v0)
|
||||
{
|
||||
this.float = .(v0, v0, v0, v0);
|
||||
}
|
||||
|
||||
[Inline]
|
||||
public this(double v0)
|
||||
{
|
||||
this.double = .(v0, v0);
|
||||
}
|
||||
|
||||
[Inline]
|
||||
public this(int8 v0, int8 v1, int8 v2, int8 v3, int8 v4, int8 v5, int8 v6, int8 v7, int8 v8, int8 v9, int8 v10, int8 v11, int8 v12, int8 v13, int8 v14, int8 v15)
|
||||
{
|
||||
this.int8 = .(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15);
|
||||
}
|
||||
|
||||
[Inline]
|
||||
public this(uint8 v0, uint8 v1, uint8 v2, uint8 v3, uint8 v4, uint8 v5, uint8 v6, uint8 v7, uint8 v8, uint8 v9, uint8 v10, uint8 v11, uint8 v12, uint8 v13, uint8 v14, uint8 v15)
|
||||
{
|
||||
this.uint8 = .(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15);
|
||||
}
|
||||
|
||||
[Inline]
|
||||
public this(int16 v0, int16 v1, int16 v2, int16 v3, int16 v4, int16 v5, int16 v6, int16 v7)
|
||||
{
|
||||
this.int16 = .(v0, v1, v2, v3, v4, v5, v6, v7);
|
||||
}
|
||||
|
||||
[Inline]
|
||||
public this(uint16 v0, uint16 v1, uint16 v2, uint16 v3, uint16 v4, uint16 v5, uint16 v6, uint16 v7)
|
||||
{
|
||||
this.uint16 = .(v0, v1, v2, v3, v4, v5, v6, v7);
|
||||
}
|
||||
|
||||
[Inline]
|
||||
public this(int32 v0, int32 v1, int32 v2, int32 v3)
|
||||
{
|
||||
this.int32 = .(v0, v1, v2, v3);
|
||||
}
|
||||
|
||||
[Inline]
|
||||
public this(uint32 v0, uint32 v1, uint32 v2, uint32 v3)
|
||||
{
|
||||
this.uint32 = .(v0, v1, v2, v3);
|
||||
}
|
||||
|
||||
[Inline]
|
||||
public this(int64 v0, int64 v1)
|
||||
{
|
||||
this.int64 = .(v0, v1);
|
||||
}
|
||||
|
||||
[Inline]
|
||||
public this(uint64 v0, uint64 v1)
|
||||
{
|
||||
this.uint64 = .(v0, v1);
|
||||
}
|
||||
|
||||
[Inline]
|
||||
public this(float v0, float v1, float v2, float v3)
|
||||
{
|
||||
this.float = .(v0, v1, v2, v3);
|
||||
}
|
||||
|
||||
[Inline]
|
||||
public this(double v0, double v1)
|
||||
{
|
||||
this.double = .(v0, v1);
|
||||
}
|
||||
}
|
||||
}
|
193
BeefLibs/corlib/src/Numerics/X86/SSE.bf
Normal file
193
BeefLibs/corlib/src/Numerics/X86/SSE.bf
Normal file
|
@ -0,0 +1,193 @@
|
|||
namespace System.Numerics.X86
|
||||
{
|
||||
static class SSE
|
||||
{
|
||||
[Intrinsic(":add_ps")]
|
||||
public static extern v128 add_ps(v128 a, v128 b);
|
||||
|
||||
[Inline]
|
||||
public static v128 add_ss(v128 a, v128 b)
|
||||
{
|
||||
var res = a;
|
||||
res.float[0] += b.float[0];
|
||||
return res;
|
||||
}
|
||||
|
||||
public static extern v128 andnot_ps(v128 a, v128 b);
|
||||
|
||||
public static extern v128 and_ps(v128 a, v128 b);
|
||||
|
||||
public static extern v128 cmpeq_ps(v128 a, v128 b);
|
||||
|
||||
public static extern v128 cmpeq_ss(v128 a, v128 b);
|
||||
|
||||
public static extern v128 cmpge_ps(v128 a, v128 b);
|
||||
|
||||
public static extern v128 cmpge_ss(v128 a, v128 b);
|
||||
|
||||
public static extern v128 cmpgt_ps(v128 a, v128 b);
|
||||
|
||||
public static extern v128 cmpgt_ss(v128 a, v128 b);
|
||||
|
||||
public static extern v128 cmple_ps(v128 a, v128 b);
|
||||
|
||||
public static extern v128 cmple_ss(v128 a, v128 b);
|
||||
|
||||
public static extern v128 cmplt_ps(v128 a, v128 b);
|
||||
|
||||
public static extern v128 cmplt_ss(v128 a, v128 b);
|
||||
|
||||
public static extern v128 cmpneq_ps(v128 a, v128 b);
|
||||
|
||||
public static extern v128 cmpneq_ss(v128 a, v128 b);
|
||||
|
||||
public static extern v128 cmpnge_ps(v128 a, v128 b);
|
||||
|
||||
public static extern v128 cmpnge_ss(v128 a, v128 b);
|
||||
|
||||
public static extern v128 cmpngt_ps(v128 a, v128 b);
|
||||
|
||||
public static extern v128 cmpngt_ss(v128 a, v128 b);
|
||||
|
||||
public static extern v128 cmpnle_ps(v128 a, v128 b);
|
||||
|
||||
public static extern v128 cmpnle_ss(v128 a, v128 b);
|
||||
|
||||
public static extern v128 cmpnlt_ps(v128 a, v128 b);
|
||||
|
||||
public static extern v128 cmpnlt_ss(v128 a, v128 b);
|
||||
|
||||
public static extern v128 cmpord_ps(v128 a, v128 b);
|
||||
|
||||
public static extern v128 cmpord_ss(v128 a, v128 b);
|
||||
|
||||
public static extern v128 cmpunord_ps(v128 a, v128 b);
|
||||
|
||||
public static extern v128 cmpunord_ss(v128 a, v128 b);
|
||||
|
||||
public static extern int32 comieq_ss(v128 a, v128 b);
|
||||
|
||||
public static extern int32 comige_ss(v128 a, v128 b);
|
||||
|
||||
public static extern int32 comigt_ss(v128 a, v128 b);
|
||||
|
||||
public static extern int32 comile_ss(v128 a, v128 b);
|
||||
|
||||
public static extern int32 comilt_ss(v128 a, v128 b);
|
||||
|
||||
public static extern int32 comineq_ss(v128 a, v128 b);
|
||||
|
||||
public static extern v128 cvtsi32_ss(v128 a, int32 b);
|
||||
|
||||
public static extern v128 cvtsi64_ss(v128 a, int64 b);
|
||||
|
||||
public static extern float cvtss_f32(v128 a);
|
||||
|
||||
public static extern int32 cvtss_si32(v128 a);
|
||||
|
||||
public static extern int64 cvtss_si64(v128 a);
|
||||
|
||||
public static extern int32 cvttss_si32(v128 a);
|
||||
|
||||
public static extern int64 cvttss_si64(v128 a);
|
||||
|
||||
public static extern int32 cvtt_ss2si(v128 a);
|
||||
|
||||
public static extern int32 cvt_ss2si(v128 a);
|
||||
|
||||
public static extern v128 div_ps(v128 a, v128 b);
|
||||
|
||||
public static extern v128 div_ss(v128 a, v128 b);
|
||||
|
||||
public static extern v128 loadu_ps(void* ptr);
|
||||
|
||||
public static extern v128 loadu_si16(void* mem_addr);
|
||||
|
||||
public static extern v128 loadu_si64(void* mem_addr);
|
||||
|
||||
public static extern v128 load_ps(void* ptr);
|
||||
|
||||
public static extern v128 max_ps(v128 a, v128 b);
|
||||
|
||||
public static extern v128 max_ss(v128 a, v128 b);
|
||||
|
||||
public static extern v128 min_ps(v128 a, v128 b);
|
||||
|
||||
public static extern v128 min_ss(v128 a, v128 b);
|
||||
|
||||
public static extern v128 movehl_ps(v128 a, v128 b);
|
||||
|
||||
public static extern v128 movelh_ps(v128 a, v128 b);
|
||||
|
||||
public static extern int32 movemask_ps(v128 a);
|
||||
|
||||
public static extern v128 move_ss(v128 a, v128 b);
|
||||
|
||||
public static extern v128 mul_ps(v128 a, v128 b);
|
||||
|
||||
public static extern v128 mul_ss(v128 a, v128 b);
|
||||
|
||||
public static extern v128 or_ps(v128 a, v128 b);
|
||||
|
||||
public static extern v128 rcp_ps(v128 a);
|
||||
|
||||
public static extern v128 rcp_ss(v128 a);
|
||||
|
||||
public static extern v128 rsqrt_ps(v128 a);
|
||||
|
||||
public static extern v128 rsqrt_ss(v128 a);
|
||||
|
||||
public static extern v128 set1_ps(float a);
|
||||
|
||||
public static extern v128 setr_ps(float e3, float e2, float e1, float e0);
|
||||
|
||||
public static extern v128 setzero_ps();
|
||||
|
||||
public static extern v128 set_ps(float e3, float e2, float e1, float e0);
|
||||
|
||||
public static extern v128 set_ps1(float a);
|
||||
|
||||
public static extern v128 set_ss(float a);
|
||||
public static extern int32 SHUFFLE(int32 d, int32 c, int32 b, int32 a);
|
||||
|
||||
public static extern v128 shuffle_ps(v128 a, v128 b, int32 imm8);
|
||||
|
||||
public static extern v128 sqrt_ps(v128 a);
|
||||
|
||||
public static extern v128 sqrt_ss(v128 a);
|
||||
|
||||
public static extern void storeu_ps(void* ptr, v128 val);
|
||||
public static extern void storeu_si16(void* mem_addr, v128 a);
|
||||
|
||||
public static extern void storeu_si64(void* mem_addr, v128 a);
|
||||
|
||||
public static extern void store_ps(void* ptr, v128 val);
|
||||
|
||||
public static extern void stream_ps(void* mem_addr, v128 a);
|
||||
|
||||
public static extern v128 sub_ps(v128 a, v128 b);
|
||||
|
||||
public static extern v128 sub_ss(v128 a, v128 b);
|
||||
|
||||
public static extern void TRANSPOSE4_PS(ref v128 row0, ref v128 row1, ref v128 row2, ref v128 row3);
|
||||
|
||||
public static extern int32 ucomieq_ss(v128 a, v128 b);
|
||||
|
||||
public static extern int32 ucomige_ss(v128 a, v128 b);
|
||||
|
||||
public static extern int32 ucomigt_ss(v128 a, v128 b);
|
||||
|
||||
public static extern int32 ucomile_ss(v128 a, v128 b);
|
||||
|
||||
public static extern int32 ucomilt_ss(v128 a, v128 b);
|
||||
|
||||
public static extern int32 ucomineq_ss(v128 a, v128 b);
|
||||
|
||||
public static extern v128 unpackhi_ps(v128 a, v128 b);
|
||||
|
||||
public static extern v128 unpacklo_ps(v128 a, v128 b);
|
||||
|
||||
//[Intrinsic("x86:x86_sse_cmp_ss")]
|
||||
public static extern v128 xor_ps(v128 a, v128 b);
|
||||
}
|
||||
}
|
6
BeefLibs/corlib/src/Numerics/X86/SSE2.bf
Normal file
6
BeefLibs/corlib/src/Numerics/X86/SSE2.bf
Normal file
|
@ -0,0 +1,6 @@
|
|||
namespace System.Numerics.X86
|
||||
{
|
||||
static class SSE2
|
||||
{
|
||||
}
|
||||
}
|
|
@ -4943,7 +4943,7 @@ BfTypedValue BfExprEvaluator::CreateCall(BfMethodInstance* methodInstance, BfIRV
|
|||
mModule->mBfIRBuilder->Call_AddAttribute(callInst, argIdx + 1, BfIRAttribute_NoCapture);
|
||||
addDeref = paramType->mSize;
|
||||
}
|
||||
else if (methodInstance->WantsIRStructsByVal())
|
||||
else if (methodInstance->WantsStructsAttribByVal())
|
||||
{
|
||||
mModule->mBfIRBuilder->Call_AddAttribute(callInst, argIdx + 1, BfIRAttribute_ByVal, mModule->mSystem->mPtrSize);
|
||||
}
|
||||
|
@ -5210,7 +5210,7 @@ void BfExprEvaluator::SplatArgs(BfTypedValue value, SizedArrayImpl<BfIRValue>& i
|
|||
checkTypeLambda(value);
|
||||
}
|
||||
|
||||
void BfExprEvaluator::PushArg(BfTypedValue argVal, SizedArrayImpl<BfIRValue>& irArgs, bool disableSplat, bool disableLowering)
|
||||
void BfExprEvaluator::PushArg(BfTypedValue argVal, SizedArrayImpl<BfIRValue>& irArgs, bool disableSplat, bool disableLowering, bool isIntrinsic)
|
||||
{
|
||||
MakeBaseConcrete(argVal);
|
||||
|
||||
|
@ -5231,12 +5231,17 @@ void BfExprEvaluator::PushArg(BfTypedValue argVal, SizedArrayImpl<BfIRValue>& ir
|
|||
SplatArgs(argVal, irArgs);
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
if (argVal.mType->IsComposite())
|
||||
{
|
||||
argVal = mModule->MakeAddressable(argVal);
|
||||
if (isIntrinsic)
|
||||
{
|
||||
// We can handle composites either by value or not
|
||||
}
|
||||
else
|
||||
argVal = mModule->MakeAddressable(argVal);
|
||||
|
||||
if (!disableLowering)
|
||||
if ((!disableLowering) && (!isIntrinsic))
|
||||
{
|
||||
BfTypeCode loweredTypeCode = BfTypeCode_None;
|
||||
BfTypeCode loweredTypeCode2 = BfTypeCode_None;
|
||||
|
@ -5922,10 +5927,17 @@ BfTypedValue BfExprEvaluator::CreateCall(BfAstNode* targetSrc, const BfTypedValu
|
|||
}
|
||||
else if ((wantType->IsComposite()) && (!expandedParamsArray))
|
||||
{
|
||||
// We need to make a temp and get the addr of that
|
||||
if ((!wantsSplat) && (!argValue.IsValuelessType()) && (!argValue.IsAddr()))
|
||||
{
|
||||
argValue = mModule->MakeAddressable(argValue);
|
||||
if (methodInstance->mIsIntrinsic)
|
||||
{
|
||||
// Intrinsics can handle structs either by value or address
|
||||
}
|
||||
else
|
||||
{
|
||||
// We need to make a temp and get the addr of that
|
||||
if ((!wantsSplat) && (!argValue.IsValuelessType()) && (!argValue.IsAddr()))
|
||||
{
|
||||
argValue = mModule->MakeAddressable(argValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!wantType->IsRef())
|
||||
|
@ -5982,7 +5994,7 @@ BfTypedValue BfExprEvaluator::CreateCall(BfAstNode* targetSrc, const BfTypedValu
|
|||
else if (wantsSplat)
|
||||
SplatArgs(argValue, irArgs);
|
||||
else
|
||||
PushArg(argValue, irArgs, true, false);
|
||||
PushArg(argValue, irArgs, true, false, methodInstance->mIsIntrinsic);
|
||||
}
|
||||
paramIdx++;
|
||||
}
|
||||
|
|
|
@ -382,7 +382,7 @@ public:
|
|||
BfTypedValue CreateCall(BfMethodMatcher* methodMatcher, BfTypedValue target);
|
||||
void MakeBaseConcrete(BfTypedValue& typedValue);
|
||||
void SplatArgs(BfTypedValue value, SizedArrayImpl<BfIRValue>& irArgs);
|
||||
void PushArg(BfTypedValue argVal, SizedArrayImpl<BfIRValue>& irArgs, bool disableSplat = false, bool disableLowering = false);
|
||||
void PushArg(BfTypedValue argVal, SizedArrayImpl<BfIRValue>& irArgs, bool disableSplat = false, bool disableLowering = false, bool isIntrinsic = false);
|
||||
void PushThis(BfAstNode* targetSrc, BfTypedValue callTarget, BfMethodInstance* methodInstance, SizedArrayImpl<BfIRValue>& irArgs, bool skipMutCheck = false);
|
||||
BfTypedValue MatchConstructor(BfAstNode* targetSrc, BfMethodBoundExpression* methodBoundExpr, BfTypedValue target, BfTypeInstance* targetType,
|
||||
BfResolvedArgs& argValues, bool callCtorBodyOnly, bool allowAppendAlloc, BfTypedValue* appendIndexValue = NULL);
|
||||
|
|
|
@ -2288,19 +2288,6 @@ void BfIRBuilder::CreateTypeDeclaration(BfType* type, bool forceDbgDefine)
|
|||
irType = CreateStructType(name);
|
||||
StructSetBody(irType, members, false);
|
||||
}
|
||||
else if (underlyingArraySize != -1)
|
||||
{
|
||||
if (underlyingArrayIsVector)
|
||||
{
|
||||
if (underlyingArrayType == mModule->GetPrimitiveType(BfTypeCode_Boolean))
|
||||
underlyingArrayType = mModule->GetPrimitiveType(BfTypeCode_UInt8);
|
||||
irType = GetVectorType(MapType(underlyingArrayType), underlyingArraySize);
|
||||
}
|
||||
else
|
||||
irType = GetSizedArrayType(MapType(underlyingArrayType), underlyingArraySize);
|
||||
if (wantDIData)
|
||||
diType = DbgCreateArrayType((int64)type->mSize * 8, type->mAlign * 8, DbgGetType(underlyingArrayType), underlyingArraySize);
|
||||
}
|
||||
else if (type->IsSizedArray())
|
||||
{
|
||||
BfSizedArrayType* arrayType = (BfSizedArrayType*)type;
|
||||
|
@ -2400,7 +2387,7 @@ void BfIRBuilder::CreateTypeDeclaration(BfType* type, bool forceDbgDefine)
|
|||
|
||||
BfIRMDNode diForwardDecl;
|
||||
if (wantDIData)
|
||||
{
|
||||
{
|
||||
BfFileInstance* bfFileInstance;
|
||||
|
||||
// Why did we bother setting the actual type declaration location?
|
||||
|
@ -2475,7 +2462,19 @@ void BfIRBuilder::CreateTypeDeclaration(BfType* type, bool forceDbgDefine)
|
|||
DbgSetType(type, diType);
|
||||
}
|
||||
|
||||
if (type->IsTypedPrimitive())
|
||||
if (underlyingArraySize != -1)
|
||||
{
|
||||
if (underlyingArrayIsVector)
|
||||
{
|
||||
if (underlyingArrayType == mModule->GetPrimitiveType(BfTypeCode_Boolean))
|
||||
underlyingArrayType = mModule->GetPrimitiveType(BfTypeCode_UInt8);
|
||||
irType = GetVectorType(MapType(underlyingArrayType), underlyingArraySize);
|
||||
}
|
||||
else
|
||||
irType = GetSizedArrayType(MapType(underlyingArrayType), underlyingArraySize);
|
||||
SetType(type, irType);
|
||||
}
|
||||
else if (type->IsTypedPrimitive())
|
||||
{
|
||||
mModule->PopulateType(type);
|
||||
auto underlyingType = type->GetUnderlyingType();
|
||||
|
@ -2565,8 +2564,8 @@ void BfIRBuilder::CreateDbgTypeDefinition(BfType* type)
|
|||
isPacked = typeInstance->mIsPacked;
|
||||
isUnion = typeInstance->mIsUnion;
|
||||
typeInstance->GetUnderlyingArray(underlyingArrayType, underlyingArraySize, underlyingArrayIsVector);
|
||||
if (underlyingArrayType != NULL)
|
||||
return; // Done
|
||||
// if (underlyingArrayType != NULL)
|
||||
// return; // Done
|
||||
}
|
||||
|
||||
String typeName = GetDebugTypeName(typeInstance, false);
|
||||
|
@ -2584,7 +2583,7 @@ void BfIRBuilder::CreateDbgTypeDefinition(BfType* type)
|
|||
int flags = llvm::DINode::FlagPublic;
|
||||
auto fieldType = typeInstance->GetUnionInnerType();
|
||||
auto resolvedFieldDIType = DbgGetType(fieldType);
|
||||
String fieldName = "__bfunion";
|
||||
String fieldName = "$bfunion";
|
||||
auto memberType = DbgCreateMemberType(diForwardDecl, fieldName, fileDIScope, lineNum,
|
||||
fieldType->mSize * 8, fieldType->mAlign * 8, 0,
|
||||
flags, resolvedFieldDIType);
|
||||
|
|
|
@ -406,6 +406,7 @@ enum BfIRConfigConst : uint8
|
|||
|
||||
enum BfIRIntrinsic : uint8
|
||||
{
|
||||
BfIRIntrinsic__PLATFORM,
|
||||
BfIRIntrinsic_Abs,
|
||||
BfIRIntrinsic_Add,
|
||||
BfIRIntrinsic_And,
|
||||
|
@ -435,6 +436,7 @@ enum BfIRIntrinsic : uint8
|
|||
BfIRIntrinsic_Free,
|
||||
BfIRIntrinsic_Gt,
|
||||
BfIRIntrinsic_GtE,
|
||||
BfIRIntrinsic_Index,
|
||||
BfIRIntrinsic_Log,
|
||||
BfIRIntrinsic_Log10,
|
||||
BfIRIntrinsic_Log2,
|
||||
|
|
|
@ -133,6 +133,7 @@ struct BuiltinEntry
|
|||
|
||||
static const BuiltinEntry gIntrinEntries[] =
|
||||
{
|
||||
{":PLATFORM"},
|
||||
{"abs"},
|
||||
{"add"},
|
||||
{"and"},
|
||||
|
@ -161,7 +162,8 @@ static const BuiltinEntry gIntrinEntries[] =
|
|||
{"floor"},
|
||||
{"free"},
|
||||
{"gt"},
|
||||
{"gte"},
|
||||
{"gte"},
|
||||
("index"),
|
||||
{"log"},
|
||||
{"log10"},
|
||||
{"log2"},
|
||||
|
@ -1094,6 +1096,71 @@ llvm::Value* BfIRCodeGen::TryToVector(llvm::Value* value)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
llvm::Value* BfIRCodeGen::TryToVector(llvm::Value* value, llvm::Type* elemType)
|
||||
{
|
||||
auto valueType = value->getType();
|
||||
if (auto vecType = llvm::dyn_cast<llvm::VectorType>(valueType))
|
||||
{
|
||||
if (vecType->getVectorElementType() == elemType)
|
||||
return value;
|
||||
|
||||
//TODO: We need an alloca....
|
||||
FatalError("Failed to get vector");
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
if (auto ptrType = llvm::dyn_cast<llvm::PointerType>(valueType))
|
||||
{
|
||||
auto ptrElemType = ptrType->getElementType();
|
||||
if (auto arrType = llvm::dyn_cast<llvm::ArrayType>(ptrElemType))
|
||||
{
|
||||
auto vecType = llvm::VectorType::get(arrType->getArrayElementType(), (uint)arrType->getArrayNumElements());
|
||||
auto vecPtrType = vecType->getPointerTo();
|
||||
|
||||
auto ptrVal0 = mIRBuilder->CreateBitCast(value, vecPtrType);
|
||||
return mIRBuilder->CreateAlignedLoad(ptrVal0, 1);
|
||||
}
|
||||
|
||||
if (auto vecType = llvm::dyn_cast<llvm::VectorType>(ptrElemType))
|
||||
{
|
||||
if (vecType->getVectorElementType() == elemType)
|
||||
return mIRBuilder->CreateAlignedLoad(value, 1);
|
||||
|
||||
auto dataLayout = llvm::DataLayout(mLLVMModule);
|
||||
int wantNumElements = (int)vecType->getVectorNumElements() * (int)dataLayout.getTypeSizeInBits(vecType->getVectorElementType()) / (int)dataLayout.getTypeSizeInBits(elemType);
|
||||
|
||||
auto newVecType = llvm::VectorType::get(elemType, wantNumElements);
|
||||
auto vecPtrType = newVecType->getPointerTo();
|
||||
|
||||
auto ptrVal0 = mIRBuilder->CreateBitCast(value, vecPtrType);
|
||||
return mIRBuilder->CreateAlignedLoad(ptrVal0, 1);
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
llvm::Type* BfIRCodeGen::GetElemType(llvm::Value* value)
|
||||
{
|
||||
auto valueType = value->getType();
|
||||
if (auto vecType = llvm::dyn_cast<llvm::VectorType>(valueType))
|
||||
return vecType->getVectorElementType();;
|
||||
|
||||
if (auto ptrType = llvm::dyn_cast<llvm::PointerType>(valueType))
|
||||
{
|
||||
auto ptrElemType = ptrType->getElementType();
|
||||
if (auto arrType = llvm::dyn_cast<llvm::ArrayType>(ptrElemType))
|
||||
return arrType->getArrayElementType();
|
||||
|
||||
if (auto vecType = llvm::dyn_cast<llvm::VectorType>(ptrElemType))
|
||||
return vecType->getVectorElementType();
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
bool BfIRCodeGen::TryMemCpy(llvm::Value* ptr, llvm::Value* val)
|
||||
{
|
||||
auto valType = val->getType();
|
||||
|
@ -1160,23 +1227,31 @@ bool BfIRCodeGen::TryVectorCpy(llvm::Value* ptr, llvm::Value* val)
|
|||
if (ptr->getType()->getPointerElementType() == val->getType())
|
||||
return false;
|
||||
|
||||
auto valType = val->getType();
|
||||
auto vecType = llvm::dyn_cast<llvm::VectorType>(valType);
|
||||
if (vecType == NULL)
|
||||
if (!llvm::isa<llvm::VectorType>(val->getType()))
|
||||
{
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < (int)vecType->getVectorNumElements(); i++)
|
||||
{
|
||||
auto extract = mIRBuilder->CreateExtractElement(val, i);
|
||||
|
||||
llvm::Value* gepArgs[] = {
|
||||
llvm::ConstantInt::get(llvm::Type::getInt32Ty(*mLLVMContext), 0),
|
||||
llvm::ConstantInt::get(llvm::Type::getInt32Ty(*mLLVMContext), i) };
|
||||
auto gep = mIRBuilder->CreateInBoundsGEP(ptr, llvm::makeArrayRef(gepArgs));
|
||||
|
||||
mIRBuilder->CreateStore(extract, gep);
|
||||
}
|
||||
|
||||
auto usePtr = mIRBuilder->CreateBitCast(ptr, val->getType()->getPointerTo());
|
||||
mIRBuilder->CreateAlignedStore(val, usePtr, 1);
|
||||
|
||||
// auto valType = val->getType();
|
||||
// auto vecType = llvm::dyn_cast<llvm::VectorType>(valType);
|
||||
// if (vecType == NULL)
|
||||
// return false;
|
||||
//
|
||||
// for (int i = 0; i < (int)vecType->getVectorNumElements(); i++)
|
||||
// {
|
||||
// auto extract = mIRBuilder->CreateExtractElement(val, i);
|
||||
//
|
||||
// llvm::Value* gepArgs[] = {
|
||||
// llvm::ConstantInt::get(llvm::Type::getInt32Ty(*mLLVMContext), 0),
|
||||
// llvm::ConstantInt::get(llvm::Type::getInt32Ty(*mLLVMContext), i) };
|
||||
// auto gep = mIRBuilder->CreateInBoundsGEP(ptr, llvm::makeArrayRef(gepArgs));
|
||||
//
|
||||
// mIRBuilder->CreateStore(extract, gep);
|
||||
// }
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2215,6 +2290,7 @@ void BfIRCodeGen::HandleNextCmd()
|
|||
|
||||
static _Intrinsics intrinsics[] =
|
||||
{
|
||||
{ (llvm::Intrinsic::ID)-1, -1}, // PLATFORM,
|
||||
{ llvm::Intrinsic::fabs, 0, -1},
|
||||
{ (llvm::Intrinsic::ID)-2, -1}, // add,
|
||||
{ (llvm::Intrinsic::ID)-2, -1}, // and,
|
||||
|
@ -2243,7 +2319,8 @@ void BfIRCodeGen::HandleNextCmd()
|
|||
{ llvm::Intrinsic::floor, 0, -1},
|
||||
{ (llvm::Intrinsic::ID)-2, -1}, // free
|
||||
{ (llvm::Intrinsic::ID)-2, -1}, // gt
|
||||
{ (llvm::Intrinsic::ID)-2, -1}, // gte
|
||||
{ (llvm::Intrinsic::ID)-2, -1}, // gte
|
||||
{ (llvm::Intrinsic::ID)-2, -1}, // index
|
||||
{ llvm::Intrinsic::log, 0, -1},
|
||||
{ llvm::Intrinsic::log10, 0, -1},
|
||||
{ llvm::Intrinsic::log2, 0, -1},
|
||||
|
@ -2269,21 +2346,6 @@ void BfIRCodeGen::HandleNextCmd()
|
|||
};
|
||||
BF_STATIC_ASSERT(BF_ARRAY_COUNT(intrinsics) == BfIRIntrinsic_COUNT);
|
||||
|
||||
bool isFakeIntrinsic = (int)intrinsics[intrinId].mID == -2;
|
||||
if (isFakeIntrinsic)
|
||||
{
|
||||
auto intrinsicData = mAlloc.Alloc<BfIRIntrinsicData>();
|
||||
intrinsicData->mName = intrinName;
|
||||
intrinsicData->mIntrinsic = (BfIRIntrinsic)intrinId;
|
||||
intrinsicData->mReturnType = returnType;
|
||||
|
||||
BfIRCodeGenEntry entry;
|
||||
entry.mKind = BfIRCodeGenEntryKind_IntrinsicData;
|
||||
entry.mIntrinsicData = intrinsicData;
|
||||
mResults.TryAdd(curId, entry);
|
||||
break;
|
||||
}
|
||||
|
||||
CmdParamVec<llvm::Type*> useParams;
|
||||
if (intrinsics[intrinId].mArg0 != -1)
|
||||
{
|
||||
|
@ -2298,11 +2360,55 @@ void BfIRCodeGen::HandleNextCmd()
|
|||
}
|
||||
}
|
||||
|
||||
BF_ASSERT(intrinsics[intrinId].mID != (llvm::Intrinsic::ID) - 1);
|
||||
func = llvm::Intrinsic::getDeclaration(mLLVMModule, intrinsics[intrinId].mID, useParams);
|
||||
bool isFakeIntrinsic = (int)intrinsics[intrinId].mID == -2;
|
||||
if (isFakeIntrinsic)
|
||||
{
|
||||
auto intrinsicData = mAlloc.Alloc<BfIRIntrinsicData>();
|
||||
intrinsicData->mName = intrinName;
|
||||
intrinsicData->mIntrinsic = (BfIRIntrinsic)intrinId;
|
||||
intrinsicData->mReturnType = returnType;
|
||||
|
||||
BfIRCodeGenEntry entry;
|
||||
entry.mKind = BfIRCodeGenEntryKind_IntrinsicData;
|
||||
entry.mIntrinsicData = intrinsicData;
|
||||
mResults.TryAdd(curId, entry);
|
||||
break;
|
||||
}
|
||||
|
||||
if (intrinId == BfIRIntrinsic__PLATFORM)
|
||||
{
|
||||
int colonPos = (int)intrinName.IndexOf(':');
|
||||
String platName = intrinName.Substring(0, colonPos);
|
||||
String platIntrinName = intrinName.Substring(colonPos + 1);
|
||||
|
||||
if (platName.IsEmpty())
|
||||
{
|
||||
auto intrinsicData = mAlloc.Alloc<BfIRIntrinsicData>();
|
||||
intrinsicData->mName = platIntrinName;
|
||||
intrinsicData->mIntrinsic = BfIRIntrinsic__PLATFORM;
|
||||
intrinsicData->mReturnType = returnType;
|
||||
|
||||
BfIRCodeGenEntry entry;
|
||||
entry.mKind = BfIRCodeGenEntryKind_IntrinsicData;
|
||||
entry.mIntrinsicData = intrinsicData;
|
||||
mResults.TryAdd(curId, entry);
|
||||
break;
|
||||
}
|
||||
|
||||
llvm::Intrinsic::ID intrin = llvm::Intrinsic::getIntrinsicForGCCBuiltin(platName.c_str(), platIntrinName.c_str());
|
||||
if ((int)intrin <= 0)
|
||||
FatalError(StrFormat("Unable to find intrinsic '%s'", intrinName.c_str()));
|
||||
else
|
||||
func = llvm::Intrinsic::getDeclaration(mLLVMModule, intrinsics[intrinId].mID, useParams);
|
||||
}
|
||||
else
|
||||
{
|
||||
BF_ASSERT(intrinsics[intrinId].mID != (llvm::Intrinsic::ID)-1);
|
||||
func = llvm::Intrinsic::getDeclaration(mLLVMModule, intrinsics[intrinId].mID, useParams);
|
||||
}
|
||||
mIntrinsicReverseMap[func] = intrinId;
|
||||
|
||||
SetResult(curId, func);
|
||||
SetResult(curId, func);
|
||||
}
|
||||
break;
|
||||
case BfIRCmd_CreateFunctionType:
|
||||
|
@ -2414,6 +2520,23 @@ void BfIRCodeGen::HandleNextCmd()
|
|||
|
||||
switch (intrinsicData->mIntrinsic)
|
||||
{
|
||||
case BfIRIntrinsic__PLATFORM:
|
||||
{
|
||||
if (intrinsicData->mName == "add_ps")
|
||||
{
|
||||
auto val0 = TryToVector(args[0], llvm::Type::getFloatTy(*mLLVMContext));
|
||||
auto val1 = TryToVector(args[0], llvm::Type::getFloatTy(*mLLVMContext));
|
||||
//SetResult(curId, TryToVector(mIRBuilder->CreateFAdd(val0, val1), GetElemType(args[0])));
|
||||
|
||||
SetResult(curId, mIRBuilder->CreateFAdd(val0, val1));
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalError(StrFormat("Unable to find intrinsic '%s'", intrinsicData->mName.c_str()));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case BfIRIntrinsic_Add:
|
||||
case BfIRIntrinsic_And:
|
||||
case BfIRIntrinsic_Div:
|
||||
|
@ -2453,7 +2576,11 @@ void BfIRCodeGen::HandleNextCmd()
|
|||
{
|
||||
auto ptrVal1 = mIRBuilder->CreateBitCast(args[1], vecType->getPointerTo());
|
||||
val1 = mIRBuilder->CreateAlignedLoad(ptrVal1, 1);
|
||||
}
|
||||
}
|
||||
else if (args[1]->getType()->isVectorTy())
|
||||
{
|
||||
val1 = args[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
val1 = mIRBuilder->CreateInsertElement(llvm::UndefValue::get(vecType), args[1], (uint64)0);
|
||||
|
@ -2644,6 +2771,19 @@ void BfIRCodeGen::HandleNextCmd()
|
|||
}
|
||||
}
|
||||
break;
|
||||
case BfIRIntrinsic_Index:
|
||||
{
|
||||
llvm::Value* gepArgs[] = {
|
||||
llvm::ConstantInt::get(llvm::Type::getInt32Ty(*mLLVMContext), 0),
|
||||
args[1] };
|
||||
auto gep = mIRBuilder->CreateInBoundsGEP(args[0], llvm::makeArrayRef(gepArgs));
|
||||
if (args.size() >= 3)
|
||||
mIRBuilder->CreateStore(args[2], gep);
|
||||
else
|
||||
SetResult(curId, mIRBuilder->CreateLoad(gep));
|
||||
}
|
||||
break;
|
||||
|
||||
case BfIRIntrinsic_AtomicCmpStore:
|
||||
case BfIRIntrinsic_AtomicCmpStore_Weak:
|
||||
case BfIRIntrinsic_AtomicCmpXChg:
|
||||
|
@ -3016,6 +3156,11 @@ void BfIRCodeGen::HandleNextCmd()
|
|||
int intrinId = -1;
|
||||
if (mIntrinsicReverseMap.TryGetValue(funcPtr, &intrinId))
|
||||
{
|
||||
if (intrinId == BfIRIntrinsic__PLATFORM)
|
||||
{
|
||||
NOP;
|
||||
}
|
||||
|
||||
if (intrinId == BfIRIntrinsic_MemSet)
|
||||
{
|
||||
int align = 1;
|
||||
|
@ -4876,6 +5021,9 @@ int BfIRCodeGen::GetIntrinsicId(const StringImpl& name)
|
|||
if (name.StartsWith("shuffle"))
|
||||
return BfIRIntrinsic_Shuffle;
|
||||
|
||||
if (name.Contains(':'))
|
||||
return BfIRIntrinsic__PLATFORM;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ class BfIRIntrinsicData
|
|||
public:
|
||||
String mName;
|
||||
BfIRIntrinsic mIntrinsic;
|
||||
llvm::Type* mReturnType;
|
||||
llvm::Type* mReturnType;
|
||||
};
|
||||
|
||||
struct BfIRCodeGenEntry
|
||||
|
@ -100,6 +100,8 @@ public:
|
|||
void CreateMemSet(llvm::Value* addr, llvm::Value* val, llvm::Value* size, int alignment, bool isVolatile = false);
|
||||
void AddNop();
|
||||
llvm::Value* TryToVector(llvm::Value* value);
|
||||
llvm::Value* TryToVector(llvm::Value* value, llvm::Type* elemType);
|
||||
llvm::Type* GetElemType(llvm::Value* value);
|
||||
bool TryMemCpy(llvm::Value* ptr, llvm::Value* val);
|
||||
bool TryVectorCpy(llvm::Value* ptr, llvm::Value* val);
|
||||
|
||||
|
|
|
@ -10572,7 +10572,7 @@ void BfModule::FinishAttributeState(BfAttributeState* attributeState)
|
|||
Warn(0, "Unused attributes", attributeState->mSrc);
|
||||
}
|
||||
|
||||
void BfModule::ProcessTypeInstCustomAttributes(bool& isPacked, bool& isUnion, bool& isCRepr, bool& isOrdered, BfType*& underlyingArrayType, int& underlyingArraySize)
|
||||
void BfModule::ProcessTypeInstCustomAttributes(bool& isPacked, bool& isUnion, bool& isCRepr, bool& isOrdered, int& alignOverride, BfType*& underlyingArrayType, int& underlyingArraySize)
|
||||
{
|
||||
if (mCurTypeInstance->mCustomAttributes != NULL)
|
||||
{
|
||||
|
@ -10615,6 +10615,14 @@ void BfModule::ProcessTypeInstCustomAttributes(bool& isPacked, bool& isUnion, bo
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (typeName == "System.AlignAttribute")
|
||||
{
|
||||
if (customAttribute.mCtorArgs.size() >= 1)
|
||||
{
|
||||
auto alignConstant = mCurTypeInstance->mConstHolder->GetConstant(customAttribute.mCtorArgs[0]);
|
||||
alignOverride = alignConstant->mInt32;
|
||||
}
|
||||
}
|
||||
else if (typeName == "System.UnderlyingArrayAttribute")
|
||||
{
|
||||
if (customAttribute.mCtorArgs.size() >= 2)
|
||||
|
@ -14856,7 +14864,7 @@ void BfModule::SetupIRMethod(BfMethodInstance* methodInstance, BfIRFunction func
|
|||
PopulateType(resolvedTypeRef, BfPopulateType_Data);
|
||||
addDeref = resolvedTypeRef->mSize;
|
||||
}
|
||||
else if (methodInstance->WantsIRStructsByVal())
|
||||
else if (methodInstance->WantsStructsAttribByVal())
|
||||
{
|
||||
mBfIRBuilder->PopulateType(resolvedTypeRef);
|
||||
mBfIRBuilder->Func_AddAttribute(func, argIdx + 1, BfIRAttribute_ByVal, mSystem->mPtrSize);
|
||||
|
|
|
@ -1467,7 +1467,7 @@ public:
|
|||
void GetCustomAttributes(BfCustomAttributes* customAttributes, BfAttributeDirective* attributesDirective, BfAttributeTargets attrType, bool allowNonConstArgs = false, BfCaptureInfo* captureInfo = NULL);
|
||||
BfCustomAttributes* GetCustomAttributes(BfAttributeDirective* attributesDirective, BfAttributeTargets attrType, bool allowNonConstArgs = false, BfCaptureInfo* captureInfo = NULL);
|
||||
void FinishAttributeState(BfAttributeState* attributeState);
|
||||
void ProcessTypeInstCustomAttributes(bool& isPacked, bool& isUnion, bool& isCRepr, bool& isOrdered, BfType*& underlyingArrayType, int& underlyingArraySize);
|
||||
void ProcessTypeInstCustomAttributes(bool& isPacked, bool& isUnion, bool& isCRepr, bool& isOrdered, int& alignOverride, BfType*& underlyingArrayType, int& underlyingArraySize);
|
||||
void ProcessCustomAttributeData();
|
||||
bool TryGetConstString(BfIRConstHolder* constHolder, BfIRValue irValue, StringImpl& str);
|
||||
BfVariant TypedValueToVariant(BfAstNode* refNode, const BfTypedValue& value, bool allowUndef = false);
|
||||
|
|
|
@ -2594,9 +2594,10 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
|
|||
bool isUnion = false;
|
||||
bool isCRepr = false;
|
||||
bool isOrdered = false;
|
||||
int alignOverride = 0;
|
||||
BfType* underlyingArrayType = NULL;
|
||||
int underlyingArraySize = -1;
|
||||
ProcessTypeInstCustomAttributes(isPacked, isUnion, isCRepr, isOrdered, underlyingArrayType, underlyingArraySize);
|
||||
ProcessTypeInstCustomAttributes(isPacked, isUnion, isCRepr, isOrdered, alignOverride, underlyingArrayType, underlyingArraySize);
|
||||
if (underlyingArraySize > 0)
|
||||
{
|
||||
typeInstance->mHasUnderlyingArray = true;
|
||||
|
@ -3289,7 +3290,9 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
|
|||
|
||||
CheckMemberNames(typeInstance);
|
||||
|
||||
if (isPacked)
|
||||
if (alignOverride > 0)
|
||||
typeInstance->mInstAlign = alignOverride;
|
||||
else if (isPacked)
|
||||
typeInstance->mInstAlign = 1;
|
||||
else
|
||||
typeInstance->mInstAlign = std::max(1, typeInstance->mInstAlign);
|
||||
|
|
|
@ -696,7 +696,7 @@ bool BfMethodInstance::GetLoweredReturnType(BfTypeCode* loweredTypeCode, BfTypeC
|
|||
return mReturnType->GetLoweredType(mMethodDef->mIsStatic ? BfTypeUsage_Return_Static : BfTypeUsage_Return_NonStatic, loweredTypeCode, loweredTypeCode2);
|
||||
}
|
||||
|
||||
bool BfMethodInstance::WantsIRStructsByVal()
|
||||
bool BfMethodInstance::WantsStructsAttribByVal()
|
||||
{
|
||||
auto owner = GetOwner();
|
||||
if ((owner->mModule->mCompiler->mOptions.mPlatformType == BfPlatformType_Windows) &&
|
||||
|
|
|
@ -872,8 +872,8 @@ public:
|
|||
bool HasParamsArray();
|
||||
int GetStructRetIdx();
|
||||
bool HasSelf();
|
||||
bool GetLoweredReturnType(BfTypeCode* loweredTypeCode = NULL, BfTypeCode* loweredTypeCode2 = NULL);
|
||||
bool WantsIRStructsByVal();
|
||||
bool GetLoweredReturnType(BfTypeCode* loweredTypeCode = NULL, BfTypeCode* loweredTypeCode2 = NULL);
|
||||
bool WantsStructsAttribByVal();
|
||||
bool IsAutocompleteMethod() { /*return mIdHash == -1;*/ return mIsAutocompleteMethod; }
|
||||
bool IsSkipCall(bool bypassVirtual = false);
|
||||
bool IsVarArgs();
|
||||
|
@ -1003,7 +1003,7 @@ public:
|
|||
virtual bool IsUnspecializedTypeVariation() override { return mElementType->IsUnspecializedType(); }
|
||||
virtual bool IsReified() override { return mElementType->IsReified(); }
|
||||
virtual bool IsDependentOnUnderlyingType() override { return true; }
|
||||
virtual bool IsAllocType() { return mModifiedKind == BfToken_AllocType; }
|
||||
virtual bool IsAllocType() override { return mModifiedKind == BfToken_AllocType; }
|
||||
virtual BfType* GetUnderlyingType() override { return mElementType; }
|
||||
};
|
||||
|
||||
|
|
|
@ -1182,7 +1182,7 @@ DbgExtType DbgType::CalcExtType()
|
|||
{
|
||||
for (auto member : mMemberList)
|
||||
{
|
||||
if (strcmp(member->mName, "__bfunion") == 0)
|
||||
if (strcmp(member->mName, "$bfunion") == 0)
|
||||
return DbgExtType_BfUnion;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5394,6 +5394,7 @@ String WinDebugger::GetMemberList(DbgType* dbgType, const StringImpl& expr, bool
|
|||
if (member->mName != NULL)
|
||||
{
|
||||
if ((member->mName[0] == '?') ||
|
||||
(member->mName[0] == '$') ||
|
||||
(strncmp(member->mName, "_vptr$", 6) == 0))
|
||||
ignoreMember = true;
|
||||
}
|
||||
|
@ -7980,7 +7981,10 @@ String WinDebugger::DbgTypedValueToString(const DbgTypedValue& origTypedValue, c
|
|||
}
|
||||
|
||||
if (member->mName != NULL)
|
||||
{
|
||||
{
|
||||
if (member->mName[0] == '$')
|
||||
continue;
|
||||
|
||||
if (!isdigit(*member->mName))
|
||||
{
|
||||
if (memberIdx != 0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue