public void Switch_Unconditional_ParseCheck() { LValueRef valueRef = new LValueRef(LType.Int32Type(), "%1"); LLabelType defaultLabel = new LLabelType("%default"); LSwitch @switch = new LSwitch(valueRef, defaultLabel); Assert.AreEqual("switch i32 %1, label %default [ ]", LHelper.Trim(@switch.ParseInstruction())); }
public LConditionalBr(LValueRef condition, LLabelType ifTrueLabel, LLabelType ifFalseLabel) { if (!condition.Type.IsPrimitiveType() || condition.Type.CheckedCast <LPrimitiveType>().Type != LPrimitiveTypes.@bool) { throw new Exception("Condition must be from type i1. Actual type: " + condition.ParseType()); } Condition = condition; IfTrueLabel = ifTrueLabel; IfFalseLabel = ifFalseLabel; }
public void AdvancedLabel_RegisterInstructionByLabelTest_LabelNotFound_Exception() { var func = LFunction.Create("foo_function", new LValueRef(LType.Int32Type(), "")); var label1 = func.Register(new LLabelType("entry")); var label2 = new LLabelType("label2"); Assert.Throws <Exception>(() => { var alloca = func.Register(new LAlloca(func, LType.F32Type())); var pointerRef = alloca.PointerRef; var load = func.Register(label2, new LLoad(func, pointerRef)); }); }
public void Switch_ParseCheck() { LValueRef valueRef = new LValueRef(LType.Int32Type(), "%1"); LLabelType defaultLabel = new LLabelType("%default"); LSwitch @switch = new LSwitch(valueRef, defaultLabel); @switch.JumpTableDestinations.Add((0, new LLabelType("%one"))); @switch.JumpTableDestinations.Add((1, new LLabelType("%two"))); @switch.JumpTableDestinations.Add((2, new LLabelType("%three"))); @switch.JumpTableDestinations.Add((3, new LLabelType("%four"))); Assert.AreEqual($"switch i32 %1, label %default [ i32 0, label %one{Environment.NewLine}i32 1, label %two{Environment.NewLine}i32 2, label %three{Environment.NewLine}i32 3, label %four ]", LHelper.Trim(@switch.ParseInstruction())); }
public LUnconditionalBr(LLabelType destinationLabel) { DestinationLabel = destinationLabel; }
internal LLabelEntry(LLabelType label) { Label = label; }