initial upload

This commit is contained in:
Ryan Fleury
2024-01-10 19:53:18 -08:00
commit a42ec6aeff
308 changed files with 162362 additions and 0 deletions
+8
View File
@@ -0,0 +1,8 @@
// Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
bias = (bias^x)&7;
x -= bias;
x *= 2;
x *= x;
x += bias;
+106
View File
@@ -0,0 +1,106 @@
// Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
/*
* Program to run in debugger organized to provide tests for
* single threaded stepping, breakpoints, evaluation.
*/
////////////////////////////////
// NOTE(allen): Complex Types
#include <complex.h>
void
c_type_coverage_eval_tests(void){
#if _WIN32
_Fcomplex x = _FCbuild(0.f, 1.f);
_Dcomplex y = _Cbuild(0.f, -1.f);
#else
float complex x = 0.f + 1.f*I;
double complex y = 0.0 - 1.0*I;
#endif
}
////////////////////////////////
// NOTE(allen): Reuse Type Names From Another Module
#include <stdint.h>
typedef struct Basics{
double a;
float b;
unsigned long long c;
long long d;
unsigned int e;
int f;
unsigned short g;
short h;
unsigned char i;
char j;
int z;
} Basics;
typedef struct Basics_Stdint{
double x1;
float x2;
uint64_t x3;
int64_t x4;
uint32_t x5;
int32_t x6;
uint16_t x7;
int16_t x8;
uint8_t x9;
int8_t x0;
} Basics_Stdint;
typedef struct Pair{
int i;
float f;
} Pair;
void
c_versions_of_same_types(void){
Basics basics = { 1.5f, 1.50000000000001, -1, 1, -2, 2, -4, 4, -8, 8, };
Basics_Stdint basics_stdint = { 1.5f, 1.50000000000001, -1, 1, -2, 2, -4, 4, -8, 8, };
Pair memory_[] = {
{100, 1.f},
{101, 2.f},
{102, 4.f},
{103, 8.f},
{104, 16.f},
{105, 32.f},
};
int x = memory_[3].i + basics.f;
}
////////////////////////////////
//~ NOTE(rjf): Bitfields
typedef struct TypeWithBitfield TypeWithBitfield;
struct TypeWithBitfield
{
int v : 14;
int w : 4;
int x : 32;
int y : 4;
int z : 10;
};
void
c_type_with_bitfield_usage(void)
{
TypeWithBitfield b = {0};
b.v = 100;
b.w = 6;
b.x = 434512;
b.y = 7;
b.z = 12;
int x = (b.v + b.x);
int y = (b.y - b.z);
int z = (b.w) + 5;
}
+10
View File
@@ -0,0 +1,10 @@
// Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
/*
* Program to run in debugger organized to provide tests for
* single threaded stepping, breakpoints, evaluation.
*/
void c_type_coverage_eval_tests(void);
void c_type_with_bitfield_usage(void);
+64
View File
@@ -0,0 +1,64 @@
// Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
/*
** Make sure we have an inlined function
*/
#if defined(_MSC_VER)
# define FORCE_INLINE __forceinline
#elif defined(__clang__)
# define FORCE_INLINE __attribute__((always_inline))
#else
# error need force inline for this compiler
#endif
////////////////////////////////
// NOTE(allen): Inline Stepping
extern unsigned int fixed_frac_bits = 5;
static unsigned int bias = 7;
static FORCE_INLINE unsigned int
fixed_mul(unsigned int a, unsigned int b){
unsigned int c = (((a - bias)*(b - bias)) >> fixed_frac_bits) + bias;
return(c);
}
static FORCE_INLINE unsigned int
multi_file_inlinesite(unsigned int x){
// force compiler to generate annotations for code that's inside another file
#include "inline_body.cpp"
return x >> fixed_frac_bits;
}
static unsigned int test_value = 0;
unsigned int
inline_stepping_tests(void){
bias = 15;
// NOTE(nick): Interesting that CL does not generate inline site symbols in order of apperance here unlike clang.
// CL:
// BinaryAnnotations: CodeLengthAndCodeOffset d 0
// BinaryAnnotation Length: 4 bytes (1 bytes padding)
//
// Clang:
// BinaryAnnotations: LineOffset 1 CodeLength d
// BinaryAnnotation Length: 4 bytes (0 bytes padding)
unsigned int x = fixed_mul(5001, 7121);
// CL:
// BinaryAnnotations: CodeOffsetAndLineOffset d File 0 CodeOffsetAndLineOffset 22 LineOffset 1e
// CodeLengthAndCodeOffset 2 3
// BinaryAnnotation Length: 12 bytes (1 bytes padding)
//
// Clang:
// BinaryAnnotations: File 18 LineOffset ffffffe6 CodeOffset d CodeOffsetAndLineOffset 22
// File 0 LineOffset 1e CodeOffset 3 CodeLength 2
// BinaryAnnotation Length: 16 bytes (0 bytes padding)
unsigned int z = multi_file_inlinesite(x);
return(z);
}
File diff suppressed because it is too large Load Diff
+38
View File
@@ -0,0 +1,38 @@
// Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
/*
** Program to run in debugger organized to provide tests for
** stepping, breakpoints, evaluation, cross-module calls.
*/
////////////////////////////////
// NOTE(allen): Setup
#if _WIN32
#define export_function extern "C" __declspec(dllexport)
#else
#define export_function extern "C"
#endif
////////////////////////////////
// NOTE(allen): TLS Eval
#if _WIN32
# define thread_var __declspec(thread)
#else
# define thread_var __thread
#endif
thread_var float tls_a = 1.015625f;
thread_var int tls_b = -100;
export_function void
dll_tls_eval_test(void){
tls_a *= 1.5f;
tls_b *= -2;
}
+119
View File
@@ -0,0 +1,119 @@
// Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
static int important_s32 = 0;
static float important_f32 = 0;
#if _WIN32
#include <Windows.h>
#endif
static void
do_something_with_intermediate_values(void)
{
static int another_important_s32 = 0;
static float another_important_f32 = 0;
another_important_s32 = (int)important_f32;
another_important_f32 = (float)important_s32;
#if _WIN32
char buffer[256] = "Hello, World!\n";
buffer[0] += important_s32 + another_important_s32;
buffer[1] += (int)another_important_f32 * important_f32;
OutputDebugStringA(buffer);
#endif
}
static void
store_important_s32(int *ptr)
{
important_s32 = *ptr;
}
static void
store_important_f32(float *ptr)
{
important_f32 = *ptr;
}
void
optimized_build_eval_tests(void)
{
int simple_sum = 0;
for(int i = 0; i < 10000; i += 1)
{
simple_sum += i;
}
store_important_s32(&simple_sum);
do_something_with_intermediate_values();
static struct {float x, y;} vec2s[] =
{
{ 10.f, 76.f },
{ 40.f, 50.f },
{ -230.f, 20.f },
{ 27.f, 27.f },
{ 57.f, -57.f },
{ -37.f, 97.f },
{ 99.f, 67.f },
{ 99.f, 37.f },
{ 99.f, 57.f },
};
{
struct{float x, y;}sum = {0};
int count = sizeof(vec2s)/sizeof(vec2s[0]);
for(int i = 0; i < count; i += 1)
{
sum.x += vec2s[i].x;
sum.y += vec2s[i].y;
}
struct{float x, y;}avg = {sum.x/count, sum.y/count};
float f32 = avg.x * avg.y;
store_important_f32(&f32);
}
do_something_with_intermediate_values();
int factorial = 1;
for(int i = 10; i > 0; i -= 1)
{
factorial *= i;
}
store_important_s32(&factorial);
do_something_with_intermediate_values();
}
////////////////////////////////
// NOTE(allen): Struct Parameters Eval
struct OptimizedBasics{
char a;
unsigned char b;
short c;
unsigned short d;
int e;
unsigned int f;
long long g;
unsigned long long h;
float i;
double j;
};
static void
optimized_struct_parameter_helper(int *ptr, OptimizedBasics basics)
{
basics.a += *ptr;
basics.a += 1;
basics.a += 1;
}
void
optimized_struct_parameters_eval_tests(void)
{
int x = 10;
OptimizedBasics basics = {-1, 1, -2, 2, -4, 4, -8, 8, 1.5f, 1.50000000000001};
optimized_struct_parameter_helper(&x, basics);
}