Skip to content
Permalink
Browse files

Fixing ref parameters, as in Swap(ref int a, ref int b).

  • Loading branch information...
kaby76 committed Mar 10, 2018
1 parent d2296fd commit bb4062f9371ece95058dac9bb5e86b58974e163d
Showing with 24 additions and 24 deletions.
  1. +3 −7 Campy.Compiler/inst.cs
  2. +13 −2 Campy.Compiler/jiter.cs
  3. +8 −15 ConsoleApp4/Program.cs
@@ -2589,14 +2589,10 @@ public override INST Convert(JITER converter, STATE state)
TypeRef tr = LLVM.TypeOf(v.V);
TypeKind kind = LLVM.GetTypeKind(tr);

ValueRef[] indexes = new ValueRef[0];
ValueRef gep = LLVM.BuildInBoundsGEP(Builder, v.V, indexes, "i" + instruction_id++);
if (Campy.Utils.Options.IsOn("jit_trace"))
System.Console.WriteLine(new VALUE(gep).ToString());

var load = LLVM.BuildLoad(Builder, gep, "i" + instruction_id++);
var load = v.V;
load = LLVM.BuildLoad(Builder, load, "i" + instruction_id++);
if (Campy.Utils.Options.IsOn("jit_trace"))
System.Console.WriteLine("load = " + new VALUE(load).ToString());
System.Console.WriteLine(new VALUE(load));

if (_dst != null && _dst.IntermediateType != LLVM.TypeOf(load))
{
@@ -63,17 +63,28 @@ public static class JIT_HELPER
// about! I cannot rail enough with this half-baked type system in Mono. It has caused so many
// problems!!!!!!!

TypeDefinition td = tr.Resolve();

var is_pointer = tr.IsPointer;
var is_reference = tr.IsByReference;
var is_array = tr.IsArray;
var is_value_type = tr.IsValueType;


if (is_pointer)
{

}

TypeDefinition td = tr.Resolve();

if (is_reference)
{
// Convert the base type first.
var base_type = ToTypeRef(td, generic_type_rewrite_rules, level + 1);
// Add in pointer to type.
TypeRef p = LLVM.PointerType(base_type, 0);
return p;
}

GenericInstanceType git = tr as GenericInstanceType;
TypeDefinition gtd = tr as TypeDefinition;

@@ -69,21 +69,14 @@ static void Main(string[] args)
{
StartDebugging();

int n = 4;
int[] x = new int[n];
Campy.Parallel.For(n, i => x[i] = i);
for (int i = 0; i < n; ++i) if (x[i] != i)
throw new Exception();


//var b = new BitonicSorter();
//Random rnd = new Random();
//int N = Bithacks.Power2(20);
//var a = Enumerable.Range(0, N).ToArray().OrderBy(x => rnd.Next()).ToArray();
//BitonicSorter.BitonicSortParallel1(a);
//for (int i = 0; i < N; ++i)
// if (a[i] != i)
// throw new Exception();
var b = new BitonicSorter();
Random rnd = new Random();
int N = Bithacks.Power2(20);
var a = Enumerable.Range(0, N).ToArray().OrderBy(x => rnd.Next()).ToArray();
BitonicSorter.BitonicSortParallel1(a);
for (int i = 0; i < N; ++i)
if (a[i] != i)
throw new Exception();
}
}
}

0 comments on commit bb4062f

Please sign in to comment.
You can’t perform that action at this time.